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_ctx_mgr.h"
12 :
13 : #include "ccu_res_specs.h"
14 :
15 : namespace hcomm {
16 :
17 81 : static void DumpJettyCtxInfo(const JettyInfo &info)
18 : {
19 81 : HCCL_RUN_INFO("[CcuChannelCtxMgr][%s] local jetty context id[%u], ta jetty id[%u], "
20 : "ta jetty type[%s], sq depth[%u], wqe basic block start id[%u].",
21 : __func__, info.jettyCtxId, info.taJettyId, info.jettyType.Describe().c_str(),
22 : info.sqDepth, info.wqeBBStartId);
23 :
24 81 : if (info.jettyType == CcuJettyType::CCUM_CACHED_JETTY) {
25 72 : HCCL_RUN_INFO("[CcuChannelCtxMgr][%s] sq buffer va[%llu], sq buffer size[%u].",
26 : __func__, info.sqBufVa, info.sqBufSize);
27 : }
28 81 : }
29 :
30 81 : void DumpChannelResInfo(const uint32_t feId, const ChannelInfo &info)
31 : {
32 81 : const auto &jettyInfos = info.jettyInfos;
33 81 : HCCL_RUN_INFO("[CcuChannelCtxMgr][%s]: fe id[%u], channel id[%u], die id[%u], "
34 : "used jetty num[%zu].", __func__, feId, info.channelId, info.dieId,
35 : jettyInfos.size());
36 :
37 162 : for (const auto &jettyInfo: jettyInfos) {
38 81 : DumpJettyCtxInfo(jettyInfo);
39 : }
40 81 : }
41 :
42 78 : bool IsEidEmpty(const uint8_t (&eidRaw)[URMA_EID_LEN])
43 : {
44 302 : for (uint32_t i = 0; i < URMA_EID_LEN; i++) {
45 288 : if (eidRaw[i] != 0) {
46 64 : return false;
47 : }
48 : }
49 :
50 14 : return true;
51 : }
52 :
53 83 : bool CcuChannelCtxMgr::CheckIfChannelAllocated(const uint32_t channelId) const
54 : {
55 83 : const uint32_t strategy = channelResInfos_.size();
56 83 : if (channelId >= strategy) {
57 2 : HCCL_ERROR("[CcuChannelCtxMgrV1][%s] failed, channelId[%u] is invalid, "
58 : "should be less than the channel strategy[%u], devLogicId[%d], dieId[%u].",
59 : __func__, channelId, strategy, devLogicId_, dieId_);
60 2 : return false;
61 : }
62 :
63 81 : if (!channelResInfos_[channelId].allocated) {
64 2 : HCCL_ERROR("[CcuChannelCtxMgrV1][%s] failed, channelId[%u] has not been "
65 : "allocated yet, devLogicId[%d], dieId[%u].", __func__, channelId,
66 : devLogicId_, dieId_);
67 2 : return false;
68 : }
69 :
70 79 : return true;
71 : }
72 :
73 : }; // namespace hcomm
|