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_CFG_MGR_H
12 : #define CCU_PFE_CFG_MGR_H
13 :
14 : #include <array>
15 : #include <cstdint>
16 : #include <vector>
17 : #include "hccl_types.h"
18 : #include "ccu_dev_mgr_imp.h"
19 :
20 : namespace hcomm {
21 :
22 : struct PfeJettyCtxCfg {
23 : uint32_t feId{0};
24 : uint32_t startJettyCtxId{0};
25 : uint32_t startTaJettyId{0};
26 : uint8_t size{0};
27 :
28 : PfeJettyCtxCfg() = default;
29 192 : PfeJettyCtxCfg(uint32_t feId, uint32_t startJettyCtxId, uint32_t startTaJettyId, uint8_t size)
30 192 : : feId(feId),
31 192 : startJettyCtxId(startJettyCtxId),
32 192 : startTaJettyId(startTaJettyId),
33 192 : size(size)
34 192 : {}
35 : };
36 :
37 : class CcuPfeCfgMgr {
38 : public:
39 : static CcuPfeCfgMgr& GetInstance(const int32_t deviceLogicId);
40 : HcclResult Init();
41 : HcclResult Deinit();
42 :
43 : std::vector<PfeJettyCtxCfg> GetPfeJettyCtxCfg(const uint8_t dieId);
44 :
45 : private:
46 198 : explicit CcuPfeCfgMgr() = default;
47 66 : ~CcuPfeCfgMgr() = default;
48 : CcuPfeCfgMgr(const CcuPfeCfgMgr& that) = delete;
49 : CcuPfeCfgMgr& operator=(const CcuPfeCfgMgr& that) = delete;
50 :
51 : HcclResult SetPfeJettyCtxCfgMap(const int32_t logicDeviceId);
52 :
53 : private:
54 : bool initFlag_{false};
55 : int32_t devLogicId_{0};
56 : uint32_t devPhyId_{0};
57 : // 每个iodie上PfeJettyCtxCfg的映射关系
58 : std::array<std::vector<PfeJettyCtxCfg>, CCU_MAX_IODIE_NUM> pfeJettyCtxCfgs_{};
59 : };
60 :
61 : }; // namespace hcomm
62 :
63 : #endif // CCU_PFE_CFG_MGR_H
|