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_MANAGER_H
12 : #define CCU_PFE_MANAGER_H
13 :
14 : #include <vector>
15 : #include <unordered_map>
16 : #include "orion_adapter_rts.h"
17 : #include "ccu_pfe_cfg_generator.h"
18 : #include "ccu_device_manager.h"
19 :
20 : namespace Hccl {
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 : CcuPfeMgr(const int32_t devLogicId, const uint8_t dieId, const uint32_t devPhyId);
48 24 : CcuPfeMgr() = default;
49 49 : ~CcuPfeMgr() = default;
50 :
51 : HcclResult GetPfeStrategy(uint32_t feId, PfeJettyStrategy& pfeJettyStrategy) const;
52 :
53 : private:
54 : int32_t devLogicId_{0};
55 : uint8_t dieId_{0};
56 : uint32_t devPhyId_{0};
57 :
58 : std::unordered_map<uint32_t, struct PfeJettyStrategy> pfeMap;
59 : };
60 :
61 : }; // namespace Hccl
62 :
63 : #endif // CCU_PFE_MANAGER_H
|