LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/common/src/h2d_tlv - hccl_h2dtlv.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 51.4 % 37 19
Test Date: 2026-08-18 17:47:01 Functions: 33.3 % 6 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 <unistd.h>
      12              : #include <hccl/hccl_types.h>
      13              : #include "hccl_communicator.h"
      14              : #include "adapter_hccp_common.h"
      15              : #include "../nslbdp/hccl_nslbdp_pub.h"
      16              : #include "hccl_h2dtlv.h"
      17              : 
      18              : namespace hccl {
      19              : 
      20          235 : hcclH2dTlv& hcclH2dTlv::GetInstance()
      21              : {
      22              :     static hcclH2dTlv phcclH2dTlv;
      23          235 :     return phcclH2dTlv;
      24              : }
      25              : 
      26          235 : HcclResult hcclH2dTlv::InitHccpChannel(u32 devicePhyId)
      27              : {
      28              :     /* 避免重复初始化  */
      29          235 :     if (hcclH2dTlvInitFlag_ == true) {
      30           21 :         HCCL_INFO("hcclNslbDp getHccpInitFlag is init");
      31           21 :         return HCCL_SUCCESS;
      32              :     }
      33              : 
      34          214 :     u32 phyID = (static_cast<s32>(devicePhyId) == HOST_DEVICE_ID) ? 0 : devicePhyId;
      35              :     nslb_inithccp_info nslbHccp;
      36          214 :     nslbHccp.version = NSLBDP_HCCP_VERSION;
      37          214 :     nslbHccp.phyId = phyID;
      38          214 :     nslbHccp.nic_posion = NSLBDP_HCCP_NICPOSION;
      39              : 
      40          214 :     u32 tlvBuffersize = 0;
      41              :     void* tlvHandle;
      42          214 :     HCCL_INFO(
      43              :         "Entry InitHccpChannel version:[%u]-phy_id:[%u]-nic_posion:[%u] .", nslbHccp.version, nslbHccp.phyId,
      44              :         nslbHccp.nic_posion);
      45              : 
      46          214 :     HcclResult ret = H2DTlvInit(reinterpret_cast<TlvInitInfo*>(&nslbHccp), &tlvBuffersize, &tlvHandle);
      47          214 :     if (ret != HCCL_SUCCESS) {
      48          213 :         return ret;
      49              :     }
      50              : 
      51            1 :     hcclH2dTlvBuffsize_ = tlvBuffersize;
      52            1 :     hcclH2dTlvHandle_ = tlvHandle;
      53            1 :     hcclH2dTlvInitFlag_ = true;
      54            1 :     return HCCL_SUCCESS;
      55              : }
      56              : 
      57            0 : void hcclH2dTlv::DeinitHccpChannel()
      58              : {
      59            0 :     if (hcclH2dTlvInitFlag_ == false) {
      60            0 :         HCCL_INFO("Hccp channel is already deinit.");
      61            0 :         return;
      62              :     }
      63            0 :     if (hcclH2dTlvHandle_ == nullptr) {
      64            0 :         HCCL_INFO("Try to deinit hccp channel while hcclH2dTlvHandle_ is null.");
      65            0 :         return;
      66              :     }
      67            0 :     HcclResult ret = H2DTlvDeinit(hcclH2dTlvHandle_);
      68            0 :     if (ret != HCCL_SUCCESS) {
      69            0 :         HCCL_WARNING("DeInit hccp channel failed ret[%u].", ret);
      70            0 :         return;
      71              :     }
      72              : 
      73            0 :     hcclH2dTlvBuffsize_ = H2D_TLVBUFFERSIZE;
      74            0 :     hcclH2dTlvHandle_ = nullptr;
      75            0 :     hcclH2dTlvInitFlag_ = false;
      76            0 :     return;
      77              : }
      78              : 
      79            0 : bool hcclH2dTlv::GetH2dTlvInitFlag() { return hcclH2dTlvInitFlag_; }
      80              : 
      81            0 : unsigned int hcclH2dTlv::GetH2dTlvBufferSize() { return hcclH2dTlvBuffsize_; }
      82              : 
      83            0 : void* hcclH2dTlv::GetH2dTlvHandle() { return hcclH2dTlvHandle_; }
      84              : 
      85              : } // namespace hccl
        

Generated by: LCOV version 2.0-1