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 46 : ChannelDataV2()
39 46 : : vtpHigh(0), ioDieId{0}, rsv3Bits{0}
40 : {
41 46 : }
42 : };
43 : #pragma pack(pop)
44 :
45 : class CcuChannelCtxMgrV2 : public CcuChannelCtxMgr {
46 : public:
47 : CcuChannelCtxMgrV2(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId);
48 :
49 : CcuChannelCtxMgrV2() = default;
50 67 : ~CcuChannelCtxMgrV2() override final = default;
51 :
52 : HcclResult Init() override final;
53 : HcclResult Alloc(const ChannelPara &channelPara, std::vector<ChannelInfo> &channelInfos) override final;
54 : HcclResult Config(const ChannelCfg &channelCfg) override final;
55 : HcclResult Release(const uint32_t channelId) override final;
56 :
57 : private:
58 : CcuChannelJettyMap channelJettyMap_{8, 1}; // 默认配比8:1
59 :
60 : CcuJettyCtxMgrV2 jettyCtxMgr_{};
61 :
62 : void AllocateChannelResources(const ChannelPara &channelPara,
63 : const std::vector<CcuJettyInfo> &jettyInfos, uint32_t startChannelId,
64 : std::vector<ChannelInfo> &channelInfos);
65 : };
66 :
67 : }; // namespace hcomm
68 :
69 : #endif
|