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 162 : PfeJettyCtxCfg(uint32_t feId, uint32_t startJettyCtxId, uint32_t startTaJettyId, uint8_t size) :
30 162 : feId(feId), startJettyCtxId(startJettyCtxId), startTaJettyId(startTaJettyId), size(size) {}
31 : };
32 :
33 : class CcuPfeCfgMgr {
34 : public:
35 : static CcuPfeCfgMgr &GetInstance(const int32_t deviceLogicId);
36 : HcclResult Init();
37 : HcclResult Deinit();
38 :
39 : std::vector<PfeJettyCtxCfg> GetPfeJettyCtxCfg(const uint8_t dieId);
40 :
41 : private:
42 198 : explicit CcuPfeCfgMgr() = default;
43 66 : ~CcuPfeCfgMgr() = default;
44 : CcuPfeCfgMgr(const CcuPfeCfgMgr &that) = delete;
45 : CcuPfeCfgMgr &operator=(const CcuPfeCfgMgr &that) = delete;
46 :
47 : HcclResult SetPfeJettyCtxCfgMap(const int32_t logicDeviceId);
48 :
49 : private:
50 : bool initFlag_{false};
51 : int32_t devLogicId_{0};
52 : uint32_t devPhyId_{0};
53 : // 每个iodie上PfeJettyCtxCfg的映射关系
54 : std::array<std::vector<PfeJettyCtxCfg>, CCU_MAX_IODIE_NUM> pfeJettyCtxCfgs_{};
55 :
56 : };
57 :
58 : }; // Hccl
59 :
60 : #endif // CCU_PFE_CFG_MGR_H
|