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 "log.h"
11 : #include "hccl_net_dev_v2.h"
12 : #include "hccl_net_dev_v1.h"
13 : #include "adapter_rts_common.h"
14 : #include "hccl_net_dev.h"
15 :
16 : using namespace std;
17 :
18 0 : HcclResult HcclNetDevOpen(const HcclNetDevInfos *info, HcclNetDev *netDev)
19 : {
20 0 : CHK_PTR_NULL(netDev);
21 0 : CHK_PTR_NULL(info);
22 : DevType devType;
23 0 : CHK_RET(hrtGetDeviceType(devType));
24 0 : if (devType == DevType::DEV_TYPE_950 || devType == DevType::DEV_TYPE_960) {
25 0 : return HcclNetDevOpenV2(info, netDev);
26 : }
27 0 : return HcclNetDevOpenV1(info, netDev);
28 : }
29 :
30 0 : HcclResult HcclNetDevClose(HcclNetDev netDev)
31 : {
32 : // 先销毁设备
33 0 : CHK_PTR_NULL(netDev);
34 :
35 : DevType devType;
36 0 : CHK_RET(hrtGetDeviceType(devType));
37 0 : if (devType == DevType::DEV_TYPE_950 || devType == DevType::DEV_TYPE_960) {
38 0 : return HcclNetDevCloseV2(netDev);
39 : }
40 :
41 0 : return HcclNetDevCloseV1(netDev);
42 : }
43 :
44 0 : HcclResult HcclNetDevGetAddr(HcclNetDev netDev, HcclAddress *addr)
45 : {
46 0 : CHK_PTR_NULL(netDev);
47 0 : CHK_PTR_NULL(addr);
48 :
49 : DevType devType;
50 0 : CHK_RET(hrtGetDeviceType(devType));
51 0 : if (devType == DevType::DEV_TYPE_950 || devType == DevType::DEV_TYPE_960) {
52 0 : return HcclNetDevGetAddrV2(netDev, addr);
53 : }
54 :
55 0 : return HcclNetDevGetAddrV1(netDev, addr);
56 : }
57 :
58 0 : HcclResult HcclNetDevGetBusAddr(HcclDeviceId dstDevId, HcclAddress *busAddr)
59 : {
60 0 : CHK_PTR_NULL(busAddr);
61 :
62 : DevType devType;
63 0 : CHK_RET(hrtGetDeviceType(devType));
64 0 : if (devType == DevType::DEV_TYPE_950 || devType == DevType::DEV_TYPE_960) {
65 0 : return HcclNetDevGetBusAddrV2(dstDevId, busAddr);
66 : }
67 :
68 0 : return HcclNetDevGetBusAddrV1(dstDevId, busAddr);
69 : }
70 :
71 0 : HcclResult HcclNetDevGetNicAddr(int32_t devicePhyId, HcclAddress **addr, uint32_t *addrNum)
72 : {
73 0 : CHK_PTR_NULL(addrNum);
74 0 : CHK_PTR_NULL(addr);
75 :
76 : DevType devType;
77 0 : CHK_RET(hrtGetDeviceType(devType));
78 0 : if (devType == DevType::DEV_TYPE_950 || devType == DevType::DEV_TYPE_960) {
79 0 : return HcclNetDevGetNicAddrV2(devicePhyId, addr, addrNum);
80 : }
81 :
82 0 : return HcclNetDevGetNicAddrV1(devicePhyId, addr, addrNum);
83 : }
|