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: 85.2 % 27 23
Test Date: 2026-08-04 10:52:23 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 : }
      32              : 
      33           66 : CcuEidInfo::~CcuEidInfo()
      34              : {
      35           66 :     initflag_ = false;
      36           66 : }
      37              : 
      38           30 : HcclResult CcuEidInfo::GetEidInfo(int32_t logicDeviceId, std::vector<HrtDevEidInfo> &eidInfo)
      39              : {
      40           30 :     if (!initflag_) {
      41            5 :         HRaInfo                      info(HrtNetworkMode::HDC, HrtGetDevicePhyIdByIndex(logicDeviceId));
      42            5 :         vector<HrtDevEidInfo> eidInfoList =  HrtRaGetDevEidInfoList(info);
      43              : 
      44            5 :         if (eidInfoList.empty()) {
      45            6 :             HCCL_WARNING("[GetEidInfo] Get EidInfo failed, logicDeviceId=%d", logicDeviceId);
      46            2 :             return HCCL_E_DRV;
      47              :         }
      48              : 
      49            3 :         eidInfoList_.assign(eidInfoList.begin(), eidInfoList.end());
      50            3 :         initflag_ = true;
      51            5 :     }
      52              : 
      53           28 :     if (eidInfoList_.empty()) {
      54            0 :         HCCL_WARNING("[GetEidInfo] EidInfo is empty, logicDeviceId=%d", logicDeviceId);
      55            0 :         return HCCL_E_DRV;
      56              :     }
      57              : 
      58           28 :     eidInfo.assign(eidInfoList_.begin(), eidInfoList_.end());
      59              : 
      60           84 :     HCCL_INFO("[GetEidInfo] Get EidInfo success, logicDeviceId=%d, eidInfo size=%u",
      61              :         logicDeviceId, eidInfo.size());
      62              : 
      63           28 :     return HCCL_SUCCESS;
      64              : }
      65              : 
      66              : }; // Hccl
        

Generated by: LCOV version 2.0-1