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 : #include "net_device.h"
12 :
13 : namespace Hccl {
14 11 : HcclNetDevice::HcclNetDevice(const NetDevInfo& info)
15 : {
16 11 : netDevInfo_ = info;
17 33 : HCCL_DEBUG("HcclNetDevice created: %p", this);
18 11 : }
19 :
20 33 : HcclNetDevice::~HcclNetDevice() { HCCL_DEBUG("HcclNetDevice destroyed: %p", this); }
21 :
22 8 : NetDevInfo HcclNetDevice::GetNetDevInfo() const { return netDevInfo_; }
23 1 : InnerNetDev* HcclNetDevice::GetInnerNetDev() const { return ndev_; }
24 9 : void HcclNetDevice::SetInnerNetDev(InnerNetDev* value) { ndev_ = value; }
25 :
26 3 : RdmaHandle HcclNetDevice::GetRdmaHandle() const
27 : {
28 3 : if (ndev_) {
29 3 : return ndev_->getRdmaHandle();
30 : }
31 0 : return nullptr;
32 : }
33 :
34 2 : std::pair<TokenIdHandle, uint32_t> HcclNetDevice::GetTokenIdInfo(const BufferKey<uintptr_t, u64>& bufKey) const
35 : {
36 2 : if (ndev_) {
37 2 : return ndev_->getTokenIdInfo(bufKey);
38 : }
39 0 : return std::pair<TokenIdHandle, uint32_t>{};
40 : }
41 :
42 0 : void HcclNetDevice::PutTokenIdInfo(const BufferKey<uintptr_t, u64>& bufKey, TokenIdHandle tokenIdHandle) const
43 : {
44 0 : if (ndev_) {
45 0 : ndev_->putTokenIdInfo(bufKey, tokenIdHandle);
46 : }
47 0 : }
48 :
49 3 : bool HcclNetDevice::IsUB() { return netDevInfo_.protoType == LinkProtoType::UB; }
50 :
51 : } // namespace Hccl
|