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 114 : RmaConnLite::RmaConnLite(const UbJettyLiteId& id, const UbJettyLiteAttr& attr, const Eid& rmtEid)
20 114 : : dieId_(id.dieId_),
21 114 : funcId_(id.funcId_),
22 114 : jettyId_(id.jettyId_),
23 114 : dbAddr_(attr.dbAddr_),
24 114 : sqVa_(attr.sqVa_),
25 114 : sqDepth_(attr.sqDepth_),
26 114 : jfcPollMode_(attr.jfcPollMode_),
27 114 : tpn_(attr.tpn_),
28 114 : rmtEid_(rmtEid)
29 : {
30 150 : HCCL_INFO(
31 : "RmaConnLite id.dieId %u, id.funcId %u, id.jettyId %u, attr.dbaddr %llu, attr.sqVa %llu, attr.sqDepth %u",
32 : id.dieId_, id.funcId_, id.jettyId_, attr.dbAddr_, attr.sqVa_, attr.sqDepth_);
33 114 : }
34 :
35 1 : RmaConnLite::RmaConnLite(const u64 qpVa) : qpVa_(qpVa) {}
36 :
37 0 : std::unique_ptr<RmaConnLite> RmaConnLite::Create(std::vector<char>& uniqueId)
38 : {
39 0 : BinaryStream binaryStream(uniqueId);
40 : u32 type;
41 0 : binaryStream >> type;
42 0 : auto connType = static_cast<RmaConnLiteType::Value>(type);
43 0 : if (connType == RmaConnLiteType::RDMA) {
44 0 : return std::make_unique<RdmaConnLite>(0); // 待RdmaConnLite构造实现
45 : }
46 0 : if (connType == RmaConnLiteType::P2P) {
47 0 : return std::make_unique<IpcConnLite>(); // 待IpcConnLite构造实现
48 : }
49 0 : if (connType == RmaConnLiteType::UB) {
50 0 : return std::make_unique<UbConnLite>(uniqueId);
51 : }
52 0 : THROW<NotSupportException>(StringFormat("Unsupported rma connection type: %d", connType));
53 : return nullptr;
54 0 : }
55 :
56 6 : std::string RmaConnLite::Describe() { return StringFormat("RmaConnLite"); }
57 :
58 31 : UbJettyLiteId RmaConnLite::GetUbJettyLiteId() const { return UbJettyLiteId(dieId_, funcId_, jettyId_); }
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 { return rmtEid_; }
66 :
67 8 : Eid RmaConnLite::GetLocEid() const { return locEid_; }
68 :
69 1 : u32 RmaConnLite::GetQpVa() const { return qpVa_; }
70 :
71 11 : uint64_t RmaConnLite::GetJettyHandle() const { return jettyHandle_; }
72 :
73 11 : uint32_t RmaConnLite::GetJettyId() const { return jettyId_; }
74 :
75 : } // namespace Hccl
|