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 : #ifndef HCCLV2_RMA_HOST_NET_CONNECTION_H
11 : #define HCCLV2_RMA_HOST_NET_CONNECTION_H
12 :
13 : #include "hccp_common.h"
14 : #include "enum_factory.h"
15 : #include "hccl_common.h"
16 : #include "exchange_rdma_conn_dto.h"
17 :
18 : // Orion
19 : #include "../../../../../../legacy/ascend950/unified_platform/resource/socket/socket.h"
20 : #include "orion_adapter_hccp.h"
21 :
22 : namespace hcomm {
23 :
24 : class HostRdmaConnection {
25 : public:
26 : struct QpAttrDto {
27 : uint32_t qpn{UINT32_MAX};
28 : uint32_t psn{UINT32_MAX};
29 : uint32_t gid_idx{0};
30 : unsigned char gid[HCCP_GID_RAW_LEN];
31 : char feature[HYPER_FEATURE_LEN];
32 :
33 3 : bool IsValid()
34 : {
35 3 : if (qpn == UINT32_MAX || psn == UINT32_MAX) {
36 0 : return false;
37 : }
38 3 : return true;
39 : }
40 : };
41 : struct RoceAttr {
42 : uint32_t queueNum{0};
43 : uint32_t retryCnt{0};
44 : uint32_t retryInterval{0};
45 : uint32_t tc{0};
46 : uint32_t sl{0};
47 : };
48 225 : MAKE_ENUM(RdmaConnStatus, CLOSED, INIT, QP_CREATED, QP_MODIFIED, SOCKET_TIMEOUT)
49 : HostRdmaConnection(Hccl::Socket* socket, RdmaHandle rdmaHandle);
50 :
51 : HcclResult Init();
52 : HcclResult CreateQp();
53 : // HcclResult GetLocQpAttr(std::unique_ptr<Hccl::Serializable> &locQpAttrserial);
54 : // HcclResult ParseRmtQpAttr(const Hccl::Serializable &rmtQpAttrSerial);
55 : HcclResult GetExchangeDto(std::unique_ptr<Hccl::Serializable>& serial);
56 : HcclResult ParseRmtExchangeDto(const Hccl::Serializable& rmtDto); // 解析收到的远端序列化数据
57 : HcclResult ModifyQp();
58 :
59 : ~HostRdmaConnection();
60 :
61 : std::string Describe() const;
62 20 : Hccl::QpInfo& GetQpInfo() { return qpInfo_; }
63 :
64 : private:
65 : HcclResult DestroyQp();
66 : bool isValidQpAttr();
67 :
68 : Hccl::Socket* socket_{nullptr};
69 : Hccl::RdmaHandle rdmaHandle_{nullptr};
70 : // OpMode opMode_{OpMode::OPBASE};
71 :
72 : Hccl::QpInfo qpInfo_;
73 : RoceAttr roceAttr_{};
74 : void* sendCompChannel_{nullptr};
75 : void* recvCompChannel_{nullptr};
76 : bool isHdcMode_{false};
77 : RdmaConnStatus rdmaConnStatus_{RdmaConnStatus::CLOSED};
78 : QpAttrDto rmtQpAttr_{};
79 : QpAttrDto locQpAttr_{};
80 : };
81 :
82 : } // namespace hcomm
83 :
84 : #endif // HCCLV2_RMA_HOST_NET_CONNECTION_H
|