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 :
45 : private:
46 : int32_t devLogicId_{0};
47 : Hccl::IpAddress ipAddr_{};
48 : CcuJettyInfo jettyInfo_{};
49 :
50 : CtxHandle ctxHandle_{nullptr};
51 : bool isCreated_{false};
52 : bool isError_{false};
53 :
54 : RequestHandle reqHandle_{0};
55 : std::vector<char> reqDataBuffer_{};
56 : void* jettyHandlePtr_{nullptr};
57 :
58 : HrtRaUbCreateJettyParam inParam_{};
59 : HrtRaUbJettyCreatedOutParam outParam_{};
60 : bool mappedJettyPrioritySet_{false};
61 : uint8_t mappedJettyPriority_{0};
62 :
63 : HcclResult HandleAsyncRequest();
64 : RdmaHandle rdmaHandle_{nullptr};
65 : };
66 :
67 : HcclResult
68 : CcuCreateJetty(const Hccl::IpAddress& ipAddr, const CcuJettyInfo& jettyInfo, std::unique_ptr<CcuJetty>& ccuJetty);
69 :
70 : } // namespace hcomm
71 : #endif // HCOMM_CCU_JETTY_H
|