LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_device/ccu_component/ccu_channel - ccu_channel_mgr.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 33 33
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 5 5

            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 "ccu_channel_mgr.h"
      12              : 
      13              : #include "ccu_res_specs_legacy.h"
      14              : 
      15              : namespace Hccl {
      16              : 
      17           34 : static void DumpJettyCtxInfo(const JettyInfo& info)
      18              : {
      19          102 :     HCCL_RUN_INFO(
      20              :         "[CcuChannelMgr][%s] local jetty context id[%u], ta jetty id[%u], "
      21              :         "ta jetty type[%s], sq depth[%u], wqe basic block start id[%u].",
      22              :         __func__, info.jettyCtxId, info.taJettyId, info.jettyType.Describe().c_str(), info.sqDepth, info.wqeBBStartId);
      23              : 
      24           34 :     if (info.jettyType == CcuJettyType::CCUM_CACHED_JETTY) {
      25          102 :         HCCL_RUN_INFO(
      26              :             "[CcuChannelMgr][%s] sq buffer va[%llu], sq buffer size[%u].", __func__, info.sqBufVa, info.sqBufSize);
      27              :     }
      28           34 : }
      29              : 
      30           28 : void DumpChannelResInfo(const uint32_t feId, const ChannelInfo& info)
      31              : {
      32           28 :     const auto& jettyInfos = info.jettyInfos;
      33           84 :     HCCL_RUN_INFO(
      34              :         "[CcuChannelMgr][%s]: fe id[%u], channel id[%u], die id[%u], "
      35              :         "used jetty num[%zu].",
      36              :         __func__, feId, info.channelId, info.dieId, jettyInfos.size());
      37              : 
      38           62 :     for (const auto& jettyInfo : jettyInfos) {
      39           34 :         DumpJettyCtxInfo(jettyInfo);
      40              :     }
      41           28 : }
      42              : 
      43           28 : bool IsEidEmpty(const uint8_t (&eidRaw)[URMA_EID_LEN])
      44              : {
      45          444 :     for (uint32_t i = 0; i < URMA_EID_LEN; i++) {
      46          418 :         if (eidRaw[i] != 0) {
      47            2 :             return false;
      48              :         }
      49              :     }
      50              : 
      51           26 :     return true;
      52              : }
      53              : 
      54           24 : CcuChannelMgr::CcuChannelMgr(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId)
      55           24 :     : devLogicId(devLogicId),
      56           24 :       dieId(dieId),
      57           24 :       devPhyId(devPhyId)
      58              : {
      59           24 :     uint32_t strategy = 0; // 获取失败或为0场景,分配将按资源不足操作
      60           24 :     (void)CcuResSpecifications::GetInstance(devLogicId).GetChannelNum(dieId, strategy);
      61           24 :     channelResInfos.resize(strategy);
      62           24 : }
      63              : 
      64           32 : bool CcuChannelMgr::CheckIfChannelAllocated(const uint32_t channelId) const
      65              : {
      66           32 :     const uint32_t strategy = channelResInfos.size();
      67           32 :     if (channelId >= strategy) {
      68            3 :         HCCL_ERROR(
      69              :             "[CcuChannelMgrV1][%s] failed, channelId[%u] is invalid, "
      70              :             "should be less than the channel strategy[%u], devLogicId[%d], dieId[%u].",
      71              :             __func__, channelId, strategy, devLogicId, dieId);
      72            1 :         return false;
      73              :     }
      74              : 
      75           31 :     if (channelResInfos[channelId].allocated == false) {
      76            3 :         HCCL_ERROR(
      77              :             "[CcuChannelMgrV1][%s] failed, channelId[%u] has not been "
      78              :             "allocated yet, devLogicId[%d], dieId[%u].",
      79              :             __func__, channelId, devLogicId, dieId);
      80            1 :         return false;
      81              :     }
      82              : 
      83           30 :     return true;
      84              : }
      85              : 
      86              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1