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