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

Generated by: LCOV version 2.0-1