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 : #ifndef CCU_CHANNEL_CTX_MGR_V2_H
12 : #define CCU_CHANNEL_CTX_MGR_V2_H
13 :
14 : #include <vector>
15 :
16 : #include "ccu_channel_ctx_mgr.h"
17 :
18 : #include "ccu_jetty_ctx_mgr_v2.h"
19 :
20 : namespace hcomm {
21 :
22 : #pragma pack(push, 1)
23 : struct ChannelDataV2 {
24 : uint8_t eidRaw[URMA_EID_LEN] = {0};
25 : /********16 Bytes**********/
26 :
27 : uint16_t vtpLow{0};
28 : /********18 Bytes**********/
29 :
30 : uint16_t vtpHigh : 8;
31 : uint16_t ioDieId : 1;
32 : uint16_t rsv3Bits : 7;
33 : /********20 Bytes**********/
34 :
35 : uint16_t rsv[6] = {0};
36 : /********32 Bytes**********/
37 :
38 48 : ChannelDataV2() : vtpHigh(0), ioDieId{0}, rsv3Bits{0} {}
39 : };
40 : #pragma pack(pop)
41 :
42 : class CcuChannelCtxMgrV2 : public CcuChannelCtxMgr {
43 : public:
44 : CcuChannelCtxMgrV2(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId);
45 :
46 : CcuChannelCtxMgrV2() = default;
47 71 : ~CcuChannelCtxMgrV2() override final = default;
48 :
49 : HcclResult Init() override final;
50 : HcclResult Alloc(const ChannelPara& channelPara, std::vector<ChannelInfo>& channelInfos) override final;
51 : HcclResult Config(const ChannelCfg& channelCfg) override final;
52 : HcclResult Release(const uint32_t channelId) override final;
53 :
54 : private:
55 : CcuChannelJettyMap channelJettyMap_{8, 1}; // 默认配比8:1
56 :
57 : CcuJettyCtxMgrV2 jettyCtxMgr_{};
58 :
59 : void AllocateChannelResources(
60 : const ChannelPara& channelPara, const std::vector<CcuJettyInfo>& jettyInfos, uint32_t startChannelId,
61 : std::vector<ChannelInfo>& channelInfos);
62 : };
63 :
64 : }; // namespace hcomm
65 :
66 : #endif
|