LCOV - code coverage report
Current view: top level - base_comm/resources/endpoint_pairs/channels/aicpu/device - dev_aicpu_ts_roce_channel_v2.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 24.2 % 33 8
Test Date: 2026-08-04 10:52:23 Functions: 50.0 % 6 3

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 "dev_aicpu_ts_roce_channel_v2.h"
      12              : #include "log.h"
      13              : #include "aicpu_res_package_helper.h"
      14              : 
      15              :  namespace Hccl {
      16              : 
      17            2 : DevAicpuTsRoceChannelV2::DevAicpuTsRoceChannelV2(std::vector<char> &uniqueId)
      18              : {
      19            2 :     transport_ = std::make_unique<RoceTransportLiteImpl>(uniqueId);
      20            2 : }
      21              : 
      22            2 : DevAicpuTsRoceChannelV2::~DevAicpuTsRoceChannelV2()
      23              : {
      24            2 : }
      25              : 
      26            1 : std::string DevAicpuTsRoceChannelV2::Describe() const
      27              : {
      28            1 :     if (transport_ != nullptr) {
      29            1 :         return transport_->Describe();
      30              :     }
      31            0 :     return "DevAicpuTsRoceChannelV2[transport=nullptr]";
      32              : }
      33              : 
      34            0 : HcclResult DevAicpuTsRoceChannelV2::Create(const void *blob, u64 blobBytes,
      35              :     const HcommDeviceInfo &deviceInfo, ChannelHandle &outHandle)
      36              : {
      37            0 :     CHK_PTR_NULL(blob);
      38            0 :     CHK_PRT_RET(blobBytes == 0,
      39              :         HCCL_ERROR("[DevAicpuTsRoceChannelV2][Create] blobBytes is 0"), HCCL_E_PARA);
      40              : 
      41            0 :     std::vector<char> data(blobBytes);
      42            0 :     CHK_SAFETY_FUNC_RET(memcpy_s(data.data(), data.size(), blob, blobBytes));
      43              : 
      44              :     Hccl::AicpuResPackageHelper helper;
      45            0 :     auto dataVec = helper.ParsePackedData(data);
      46              : 
      47            0 :     Hccl::AicpuResMgrType resType = Hccl::AicpuResMgrType::STREAM;
      48            0 :     if (static_cast<u32>(resType) >= dataVec.size()) {
      49            0 :         HCCL_ERROR("[DevAicpuTsRoceChannelV2][%s] fail, resType[%d], dataVec size[%u]", __func__, resType, dataVec.size());
      50            0 :         return HCCL_E_PARA;
      51              :     }
      52              : 
      53            0 :     transport_ = std::make_unique<RoceTransportLiteImpl>();
      54            0 :     CHK_PTR_NULL(transport_);
      55            0 :     transport_->Init(dataVec[resType].data);
      56              : 
      57            0 :     outHandle = reinterpret_cast<ChannelHandle>(transport_.get());
      58              : 
      59            0 :     HCCL_INFO("[DevAicpuTsRoceChannelV2][Create] success blobBytes[%llu] handle[0x%llx]",
      60              :         static_cast<unsigned long long>(blobBytes),
      61              :         static_cast<unsigned long long>(reinterpret_cast<uintptr_t>(outHandle)));
      62            0 :     return HCCL_SUCCESS;
      63            0 : }
      64              : 
      65            0 : bool DevAicpuTsRoceChannelV2::Destroy(ChannelHandle handle)
      66              : {
      67            0 :     if (transport_ != nullptr && reinterpret_cast<ChannelHandle>(transport_.get()) == handle) {
      68            0 :         transport_.reset();
      69              :     } else {
      70            0 :         auto *transport = reinterpret_cast<RoceTransportLiteImpl *>(handle);
      71            0 :         delete transport;
      72              :     }
      73            0 :     HCCL_DEBUG("[DevAicpuTsRoceChannelV2][Destroy] destroyed handle[0x%llx]", handle);
      74            0 :     return true;
      75              : }
      76              : 
      77              : }
        

Generated by: LCOV version 2.0-1