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 : #ifndef CCU_PFE_MGR_H
12 : #define CCU_PFE_MGR_H
13 :
14 : #include <vector>
15 : #include <unordered_map>
16 :
17 : #include "ccu_dev_mgr_imp.h"
18 : #include "ccu_pfe_cfg_mgr.h"
19 :
20 : namespace hcomm {
21 :
22 : struct PfeJettyStrategy {
23 : uint32_t feId; // FE index.
24 : uint32_t pfeId; // PFE ctx index.
25 : uint32_t startTaJettyId; // PFE assigned to CCU starting jetty index.
26 : uint8_t size; // PFE assigned to CCU jetty num.
27 : uint32_t startLocalJettyCtxId; // PFE assigned to CCU starting local jetty index.
28 : };
29 :
30 : #pragma pack(push, 1)
31 : struct PfeCtx {
32 : uint16_t startJettyId; // PFE assigned to CCU starting jetty index.
33 : /********2 Bytes**********/
34 :
35 : uint16_t jettyNum : 7; // PFE assigned to CCU total jetty num.
36 : uint16_t startLocalJettyCtxId : 7; // CCU maintained starting jetty context index.
37 : uint16_t rsvBit : 2;
38 : /********4 Bytes**********/
39 :
40 : uint16_t rsv[2];
41 : /********8 Bytes**********/
42 : };
43 : #pragma pack(pop)
44 :
45 : class CcuPfeMgr {
46 : public:
47 223 : CcuPfeMgr(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId)
48 223 : : devLogicId_(devLogicId),
49 223 : dieId_(dieId),
50 223 : devPhyId_(devPhyId) {};
51 : CcuPfeMgr() = default;
52 223 : ~CcuPfeMgr() = default;
53 :
54 : HcclResult Init();
55 : HcclResult GetPfeStrategy(uint32_t feId, PfeJettyStrategy& pfeJettyStrategy) const;
56 :
57 : private:
58 : int32_t devLogicId_{0};
59 : uint8_t dieId_{0};
60 : uint32_t devPhyId_{0};
61 :
62 : std::unordered_map<uint32_t, struct PfeJettyStrategy> pfeJettyMap_;
63 : };
64 :
65 : }; // namespace hcomm
66 :
67 : #endif // CCU_PFE_MGR_H
|