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 :
32 3 : bool IsValid() {
33 3 : if (qpn == UINT32_MAX || psn == UINT32_MAX) {
34 0 : return false;
35 : }
36 3 : return true;
37 : }
38 : };
39 : struct RoceAttr {
40 : uint32_t queueNum{0};
41 : uint32_t retryCnt{0};
42 : uint32_t retryInterval{0};
43 : uint32_t tc{0};
44 : uint32_t sl{0};
45 : };
46 201 : MAKE_ENUM(RdmaConnStatus, CLOSED, INIT, QP_CREATED, QP_MODIFIED, SOCKET_TIMEOUT)
47 : HostRdmaConnection(Hccl::Socket *socket, RdmaHandle rdmaHandle);
48 :
49 : HcclResult Init();
50 : HcclResult CreateQp();
51 : // HcclResult GetLocQpAttr(std::unique_ptr<Hccl::Serializable> &locQpAttrserial);
52 : // HcclResult ParseRmtQpAttr(const Hccl::Serializable &rmtQpAttrSerial);
53 : HcclResult GetExchangeDto(std::unique_ptr<Hccl::Serializable> &serial);
54 : HcclResult ParseRmtExchangeDto(const Hccl::Serializable &rmtDto); // 解析收到的远端序列化数据
55 : HcclResult ModifyQp();
56 :
57 : ~HostRdmaConnection();
58 :
59 : std::string Describe() const ;
60 8 : Hccl::QpInfo& GetQpInfo()
61 : {
62 8 : return qpInfo_;
63 : }
64 :
65 :
66 :
67 : private:
68 : HcclResult DestroyQp();
69 : bool isValidQpAttr();
70 :
71 : Hccl::Socket *socket_{nullptr};
72 : Hccl::RdmaHandle rdmaHandle_{nullptr};
73 : // OpMode opMode_{OpMode::OPBASE};
74 :
75 : Hccl::QpInfo qpInfo_;
76 : RoceAttr roceAttr_{};
77 : void *sendCompChannel_{nullptr};
78 : void *recvCompChannel_{nullptr};
79 : bool isHdcMode_{false};
80 : RdmaConnStatus rdmaConnStatus_{RdmaConnStatus::CLOSED};
81 : QpAttrDto rmtQpAttr_{};
82 : QpAttrDto locQpAttr_{};
83 : };
84 :
85 : } // namespace hcomm
86 :
87 : #endif // HCCLV2_RMA_HOST_NET_CONNECTION_H
|