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

Generated by: LCOV version 2.0-1