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