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 HCCL_CCU_JETTY_H
12 : #define HCCL_CCU_JETTY_H
13 :
14 : #include <unordered_map>
15 : #include <vector>
16 : #include "ip_address.h"
17 : #include "ccu_dev_mgr.h"
18 : #include "orion_adapter_hccp.h"
19 :
20 : namespace Hccl {
21 : class CcuJetty final {
22 : public:
23 : CcuJetty(const IpAddress &ipAddr, const CcuJettyInfo &jettyInfo);
24 : ~CcuJetty();
25 : CcuJetty(const CcuJetty &that) = delete;
26 : CcuJetty &operator=(const CcuJetty &that) = delete;
27 : CcuJetty(CcuJetty &&that) = delete;
28 : CcuJetty &operator=(CcuJetty &&that) = delete;
29 :
30 : HcclResult CreateJetty();
31 :
32 : HrtRaUbCreateJettyParam GetCreateJettyParam() const;
33 : HrtRaUbJettyCreatedOutParam GetJettyedOutParam() const;
34 :
35 0 : JettyHandle GetJettyHandle() const
36 : {
37 0 : return reinterpret_cast<JettyHandle>(jettyHandlePtr_);
38 : }
39 0 : RdmaHandle GetRdmaHandle() const
40 : {
41 0 : return rdmaHandle_;
42 : }
43 0 : uint16_t GetJettyId() const
44 : {
45 0 : return jettyInfo_.taJettyId;
46 : }
47 : HcclResult Clean();
48 : void GetJettyInfo(ConnJettyInfo& connJettyInfo);
49 :
50 : private:
51 : int32_t devLogicId_{0};
52 : IpAddress ipAddr_{};
53 : CcuJettyInfo jettyInfo_{};
54 :
55 : RdmaHandle rdmaHandle_{nullptr};
56 : bool isCreated_{false};
57 : bool isError_{false};
58 :
59 : RequestHandle reqHandle_{0};
60 : std::vector<char> reqDataBuffer_;
61 : void *jettyHandlePtr_{nullptr};
62 :
63 : HrtRaUbCreateJettyParam inParam_{};
64 : HrtRaUbJettyCreatedOutParam outParam_{};
65 :
66 : HcclResult HandleAsyncRequest();
67 : };
68 :
69 : HcclResult CcuCreateJetty(const IpAddress &ipAddr, const CcuJettyInfo &jettyInfo,
70 : std::unique_ptr<CcuJetty> &ccuJetty);
71 :
72 : } // namespace Hccl
73 : #endif // HCCL_CCU_JETTY_H
|