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

Generated by: LCOV version 2.0-1