LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_device/ccu_component - ccu_eid_info.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 83.3 % 24 20
Test Date: 2026-08-17 10:19:35 Functions: 80.0 % 5 4

            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 "ccu_eid_info.h"
      11              : 
      12              : #include "hccl_common_v2.h"
      13              : #include "orion_adapter_rts.h"
      14              : 
      15              : namespace Hccl {
      16              : 
      17           30 : CcuEidInfo& CcuEidInfo::GetInstance(int32_t logicDeviceId)
      18              : {
      19           96 :     static CcuEidInfo ccuEidInfo[MAX_MODULE_DEVICE_NUM + 1];
      20              : 
      21           30 :     if (static_cast<u32>(logicDeviceId) > MAX_MODULE_DEVICE_NUM) {
      22            0 :         HCCL_WARNING("[CcuEidInfo] GetInstance failed, logicDeviceId=%d, ret=%d", logicDeviceId, HCCL_E_PARA);
      23            0 :         return ccuEidInfo[0];
      24              :     }
      25              : 
      26           30 :     return ccuEidInfo[logicDeviceId];
      27              : }
      28              : 
      29           66 : CcuEidInfo::CcuEidInfo() {}
      30              : 
      31           66 : CcuEidInfo::~CcuEidInfo() { initflag_ = false; }
      32              : 
      33           30 : HcclResult CcuEidInfo::GetEidInfo(int32_t logicDeviceId, std::vector<HrtDevEidInfo>& eidInfo)
      34              : {
      35           30 :     if (!initflag_) {
      36            5 :         HRaInfo info(HrtNetworkMode::HDC, HrtGetDevicePhyIdByIndex(logicDeviceId));
      37            5 :         vector<HrtDevEidInfo> eidInfoList = HrtRaGetDevEidInfoList(info);
      38              : 
      39            5 :         if (eidInfoList.empty()) {
      40            6 :             HCCL_WARNING("[GetEidInfo] Get EidInfo failed, logicDeviceId=%d", logicDeviceId);
      41            2 :             return HCCL_E_DRV;
      42              :         }
      43              : 
      44            3 :         eidInfoList_.assign(eidInfoList.begin(), eidInfoList.end());
      45            3 :         initflag_ = true;
      46            5 :     }
      47              : 
      48           28 :     if (eidInfoList_.empty()) {
      49            0 :         HCCL_WARNING("[GetEidInfo] EidInfo is empty, logicDeviceId=%d", logicDeviceId);
      50            0 :         return HCCL_E_DRV;
      51              :     }
      52              : 
      53           28 :     eidInfo.assign(eidInfoList_.begin(), eidInfoList_.end());
      54              : 
      55           84 :     HCCL_INFO("[GetEidInfo] Get EidInfo success, logicDeviceId=%d, eidInfo size=%u", logicDeviceId, eidInfo.size());
      56              : 
      57           28 :     return HCCL_SUCCESS;
      58              : }
      59              : 
      60              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1