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: 13.6 % 22 3
Test Date: 2026-08-18 17:47:01 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              : 
      11              : #include "ipc_remote_notify.h"
      12              : #include "exchange_ipc_notify_dto.h"
      13              : #include "dev_capability.h"
      14              : namespace Hccl {
      15              : 
      16            2 : IpcRemoteNotify::IpcRemoteNotify() : BaseRemoteNotify(RmaType::IPC) {}
      17              : 
      18            0 : IpcRemoteNotify::IpcRemoteNotify(const Serializable& rmtDto) : BaseRemoteNotify(RmaType::IPC)
      19              : {
      20            0 :     auto dto = dynamic_cast<const ExchangeIpcNotifyDto&>(rmtDto);
      21            0 :     rmtPid = dto.pid;
      22            0 :     handleAddr = dto.handleAddr;
      23            0 :     id = dto.id;
      24            0 :     devUsed = dto.devUsed;
      25            0 :     rmtDevPhyId = dto.devPhyId;
      26            0 :     (void)memcpy_s(name, RTS_IPC_MEM_NAME_LEN, dto.name, RTS_IPC_MEM_NAME_LEN);
      27              : 
      28              :     // OpenIpc
      29            0 :     u32 myPid = HrtDeviceGetBareTgid();
      30            0 :     if (rmtPid == myPid) {
      31            0 :         handle = reinterpret_cast<void*>(handleAddr);
      32              :     } else {
      33            0 :         if (devUsed) {
      34            0 :             handle = HrtIpcOpenNotifyWithFlag(name, RT_NOTIFY_FLAG_DOWNLOAD_TO_DEV);
      35              :         } else {
      36            0 :             handle = HrtIpcOpenNotify(name);
      37              :         }
      38              :     }
      39            0 :     addr = HrtNotifyGetAddr(handle);
      40            0 :     size = DevCapability::GetInstance().GetNotifySize();
      41            0 :     HCCL_INFO(
      42              :         "IpcRemoteNotify[name=%s, handleAddr=0x%llx, id=%u, rmtPid=%u, rmtDevPhyId=%u, devUsed=%d, addr=0x%llx, "
      43              :         "handle=%p]",
      44              :         name, handleAddr, id, rmtPid, rmtDevPhyId, devUsed, addr, handle);
      45            0 : }
      46              : 
      47            0 : void IpcRemoteNotify::Post(const Stream& stream) const { HrtNotifyRecord(handle, stream.GetPtr()); }
      48              : 
      49            1 : string IpcRemoteNotify::Describe() const
      50              : {
      51              :     return StringFormat(
      52              :         "IpcRemoteNotify[name=%s, handleAddr=0x%llx, id=%u, rmtPid=%u, rmtDevPhyId=%u, devUsed=%d, "
      53              :         "handle=%p, addr=0x%llx, size=%llu]",
      54            1 :         name, handleAddr, id, rmtPid, rmtDevPhyId, devUsed, handle, addr, size);
      55              : }
      56              : 
      57              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1