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