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 : #include "rma_conn_lite.h"
11 : #include "ipc_conn_lite.h"
12 : #include "rdma_conn_lite.h"
13 : #include "ub_conn_lite.h"
14 : #include "binary_stream.h"
15 : #include "exception_util.h"
16 : #include "not_support_exception.h"
17 : #include "log.h"
18 : namespace Hccl {
19 18 : RmaConnLite::RmaConnLite(const UbJettyLiteId &id, const UbJettyLiteAttr &attr, const Eid &rmtEid)
20 18 : : dieId_(id.dieId_), funcId_(id.funcId_), jettyId_(id.jettyId_), dbAddr_(attr.dbAddr_), sqVa_(attr.sqVa_),
21 18 : sqDepth_(attr.sqDepth_), jfcPollMode_(attr.jfcPollMode_), tpn_(attr.tpn_), rmtEid_(rmtEid)
22 : {
23 54 : HCCL_INFO("RmaConnLite id.dieId %u, id.funcId %u, id.jettyId %u, attr.dbaddr %llu, attr.sqVa %u, attr.sqDepth %u",
24 : id.dieId_, id.funcId_, id.jettyId_, attr.dbAddr_, attr.sqVa_, attr.sqDepth_);
25 18 : }
26 :
27 1 : RmaConnLite::RmaConnLite(const u64 qpVa) : qpVa_(qpVa)
28 : {
29 1 : }
30 :
31 0 : std::unique_ptr<RmaConnLite> RmaConnLite::Create(std::vector<char> &uniqueId)
32 : {
33 0 : BinaryStream binaryStream(uniqueId);
34 : u32 type;
35 0 : binaryStream >> type;
36 0 : auto connType = static_cast<RmaConnLiteType::Value>(type);
37 0 : if (connType == RmaConnLiteType::RDMA) {
38 0 : return std::make_unique<RdmaConnLite>(0); // 待RdmaConnLite构造实现
39 : }
40 0 : if (connType == RmaConnLiteType::P2P) {
41 0 : return std::make_unique<IpcConnLite>(); // 待IpcConnLite构造实现
42 : }
43 0 : if (connType == RmaConnLiteType::UB) {
44 0 : return std::make_unique<UbConnLite>(uniqueId);
45 : }
46 0 : THROW<NotSupportException>(StringFormat("Unsupported rma connection type: %d", connType));
47 : return nullptr;
48 0 : }
49 :
50 6 : std::string RmaConnLite::Describe()
51 : {
52 6 : return StringFormat("RmaConnLite");
53 : }
54 :
55 25 : UbJettyLiteId RmaConnLite::GetUbJettyLiteId() const
56 : {
57 25 : return UbJettyLiteId(dieId_, funcId_, jettyId_);
58 : }
59 :
60 16 : UbJettyLiteAttr RmaConnLite::GetUbJettyLiteAttr() const
61 : {
62 16 : return UbJettyLiteAttr(dbAddr_, sqVa_, sqDepth_, tpn_, dwqeCacheLocked_, jfcPollMode_);
63 : }
64 :
65 24 : Eid RmaConnLite::GetRmtEid() const
66 : {
67 24 : return rmtEid_;
68 : }
69 :
70 8 : Eid RmaConnLite::GetLocEid() const
71 : {
72 8 : return locEid_;
73 : }
74 :
75 1 : u32 RmaConnLite::GetQpVa() const
76 : {
77 1 : return qpVa_;
78 : }
79 :
80 : } // namespace Hccl
|