LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/notify - ipc_remote_notify.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 16.0 % 25 4
Test Date: 2026-07-28 12:11:00 Functions: 50.0 % 4 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : #include "ipc_remote_notify.h"
      11              : #include "exchange_ipc_notify_dto.h"
      12              : #include "dev_capability.h"
      13              : namespace Hccl {
      14              : 
      15            2 : IpcRemoteNotify::IpcRemoteNotify() : BaseRemoteNotify(RmaType::IPC)
      16              : {
      17            2 : }
      18              : 
      19            0 : IpcRemoteNotify::IpcRemoteNotify(const Serializable &rmtDto) : BaseRemoteNotify(RmaType::IPC)
      20              : {
      21            0 :     auto dto   = dynamic_cast<const ExchangeIpcNotifyDto &>(rmtDto);
      22            0 :     rmtPid     = dto.pid;
      23            0 :     handleAddr = dto.handleAddr;
      24            0 :     id         = dto.id;
      25            0 :     devUsed    = dto.devUsed;
      26            0 :     rmtDevPhyId = dto.devPhyId;
      27            0 :     (void)memcpy_s(name, RTS_IPC_MEM_NAME_LEN, dto.name, RTS_IPC_MEM_NAME_LEN);
      28              : 
      29              :     // OpenIpc
      30            0 :     u32 myPid = HrtDeviceGetBareTgid();
      31            0 :     if (rmtPid == myPid) {
      32            0 :         handle = reinterpret_cast<void *>(handleAddr);
      33              :     } else {
      34            0 :         if (devUsed) {
      35            0 :             handle = HrtIpcOpenNotifyWithFlag(name, RT_NOTIFY_FLAG_DOWNLOAD_TO_DEV);
      36              :         } else {
      37            0 :             handle = HrtIpcOpenNotify(name);
      38              :         }
      39              :     }
      40            0 :     addr = HrtNotifyGetAddr(handle);
      41            0 :     size = DevCapability::GetInstance().GetNotifySize();
      42            0 :     HCCL_INFO("IpcRemoteNotify[name=%s, handleAddr=0x%llx, id=%u, rmtPid=%u, rmtDevPhyId=%u, devUsed=%d, addr=0x%llx, "
      43              :                         "handle=%p]", name, handleAddr, id, rmtPid, rmtDevPhyId, devUsed, addr, handle);
      44            0 : }
      45              : 
      46            0 : void IpcRemoteNotify::Post(const Stream &stream) const
      47              : {
      48            0 :     HrtNotifyRecord(handle, stream.GetPtr());
      49            0 : }
      50              : 
      51            1 : string IpcRemoteNotify::Describe() const
      52              : {
      53              :     return StringFormat("IpcRemoteNotify[name=%s, handleAddr=0x%llx, id=%u, rmtPid=%u, rmtDevPhyId=%u, devUsed=%d, "
      54              :                         "handle=%p, addr=0x%llx, size=%llu]",
      55            1 :                         name, handleAddr, id, rmtPid, rmtDevPhyId, devUsed, handle, addr, size);
      56              : }
      57              : 
      58              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1