LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_device/ccu_comp/ccu_channel/ccu_channel_ctx_v2 - ccu_wqebb_mgr_v2.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 34 34
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 3 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 "ccu_wqebb_mgr_v2.h"
      12              : 
      13              : #include "ccu_res_specs.h"
      14              : 
      15              : namespace hcomm {
      16              : 
      17           61 : HcclResult CcuWqeBBMgrV2::Init()
      18              : {
      19           61 :     uint32_t wqeBBNum = 0; // 获取失败或为0场景,分配将按资源不足操作
      20           61 :     uint32_t jettyNum = 0;
      21           61 :     uint32_t blockNum = 0;
      22           61 :     (void)CcuResSpecifications::GetInstance(devLogicId_).GetWqeBBNum(dieId_, wqeBBNum);
      23           61 :     (void)CcuResSpecifications::GetInstance(devLogicId_).GetJettyNum(dieId_, jettyNum);
      24           61 :     if (jettyNum == 0) {
      25            1 :         HCCL_WARNING("[CcuWqeBBMgrV2][%s] failed, jettyNum is [%u].", __func__, jettyNum);
      26            1 :         return HcclResult::HCCL_E_UNAVAIL;
      27              :     }
      28              : 
      29           60 :     blockNum = wqeBBNum / CCU_V2_FIXED_SQ_SIZE;
      30           60 :     allocatedWqeBBBlocks_.resize(blockNum, false);
      31           60 :     return HcclResult::HCCL_SUCCESS;
      32              : }
      33              : 
      34           49 : HcclResult CcuWqeBBMgrV2::Alloc(const WqeBBReq& wqeBBReq, ResInfo& wqeBBInfo)
      35              : {
      36           49 :     wqeBBInfo.startId = wqeBBReq.jettyCtxStartId * CCU_V2_FIXED_SQ_SIZE;
      37           49 :     wqeBBInfo.num = CCU_V2_FIXED_SQ_SIZE;
      38              :     // 检查是否可用,防止重新分配
      39           49 :     if (wqeBBReq.jettyCtxStartId >= allocatedWqeBBBlocks_.size()) {
      40            1 :         HCCL_ERROR(
      41              :             "[CcuWqeBBMgrV2][%s] failed, jetty ctx start id[%u] is not expected, "
      42              :             "more than specNum[%zu].",
      43              :             __func__, wqeBBReq.jettyCtxStartId, allocatedWqeBBBlocks_.size());
      44            1 :         return HcclResult::HCCL_E_INTERNAL;
      45              :     }
      46              : 
      47           48 :     if (allocatedWqeBBBlocks_[wqeBBReq.jettyCtxStartId]) {
      48            1 :         HCCL_ERROR(
      49              :             "[CcuWqeBBMgrV2][%s] failed, the jetty ctx id[%u] has been allocated.", __func__, wqeBBReq.jettyCtxStartId);
      50            1 :         return HcclResult::HCCL_E_INTERNAL;
      51              :     }
      52              : 
      53           47 :     allocatedWqeBBBlocks_[wqeBBReq.jettyCtxStartId] = true;
      54           47 :     HCCL_INFO(
      55              :         "[CcuWqeBBMgrV2][%s] jettyCtxStartId[%u], wqeBBInfo.startId[%u], wqeBBInfo.num[%u]", __func__,
      56              :         wqeBBReq.jettyCtxStartId, wqeBBInfo.startId, wqeBBInfo.num);
      57           47 :     return HcclResult::HCCL_SUCCESS;
      58              : }
      59              : 
      60            6 : HcclResult CcuWqeBBMgrV2::Release(const ResInfo& wqeBBInfo)
      61              : {
      62            6 :     auto startId = wqeBBInfo.startId / CCU_V2_FIXED_SQ_SIZE;
      63            6 :     if (startId >= allocatedWqeBBBlocks_.size()) {
      64            1 :         HCCL_ERROR(
      65              :             "[CcuWqeBBMgrV2][%s] failed, jetty ctx start id[%u] is not expected, "
      66              :             "more than specNum[%zu].",
      67              :             __func__, startId, allocatedWqeBBBlocks_.size());
      68            1 :         return HcclResult::HCCL_E_INTERNAL;
      69              :     }
      70              : 
      71            5 :     if (!allocatedWqeBBBlocks_[startId]) {
      72            1 :         HCCL_ERROR(
      73              :             "[CcuWqeBBMgrV2][%s] failed, jetty ctx start id[%u] is not allocated.", __func__, startId,
      74              :             allocatedWqeBBBlocks_.size());
      75            1 :         return HcclResult::HCCL_E_PARA;
      76              :     }
      77              : 
      78            4 :     allocatedWqeBBBlocks_[startId] = false;
      79            4 :     return HcclResult::HCCL_SUCCESS;
      80              : }
      81              : 
      82              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1