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 <adapter_tdt.h>
12 : #include "log.h"
13 : #include "workflow_pub.h"
14 : #include "driver/ascend_hal.h"
15 : #include "sal_pub.h"
16 : using namespace hccl;
17 :
18 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif
21 207 : HcclResult hrtOpenTsd()
22 : {
23 : #ifndef HCCD
24 207 : std::string extPam("--hdcType=" + std::to_string(HDC_SERVICE_TYPE_RDMA));
25 : rtNetServiceOpenArgs openArgs;
26 207 : rtProcExtParam extParam{};
27 207 : extParam.paramInfo = extPam.c_str();
28 207 : extParam.paramLen = extPam.size();
29 207 : openArgs.extParamCnt = 1UL;
30 207 : openArgs.extParamList = &extParam;
31 207 : CHK_RET(hrtOpenNetService(&openArgs));
32 207 : HCCL_INFO("hrtOpenTsd success");
33 207 : return HCCL_SUCCESS;
34 : #else
35 : HCCL_ERROR("[hrtOpenTsd]Does not support this interface.");
36 : return HCCL_E_NOT_SUPPORT;
37 : #endif
38 207 : }
39 :
40 0 : HcclResult __hrtOpenNetService([[maybe_unused]] rtNetServiceOpenArgs* openArgs)
41 : {
42 : #if !defined(CCL_KERNEL) && !defined(HCCD)
43 : aclError aclret = rtOpenNetService(openArgs);
44 : if (aclret != ACL_RT_SUCCESS) {
45 : HCCL_ERROR("[hrtOpenNetService]Open NetService failed, err code : %d", aclret);
46 : return HcclResult::HCCL_E_UNAVAIL;
47 : }
48 :
49 : return HCCL_SUCCESS;
50 : #else
51 0 : HCCL_ERROR("[hrtOpenNetService]Does not support this interface.");
52 0 : return HCCL_E_NOT_SUPPORT;
53 : #endif
54 : }
55 : weak_alias(__hrtOpenNetService, hrtOpenNetService);
56 :
57 0 : HcclResult __hrtCloseNetService()
58 : {
59 : #if !defined(CCL_KERNEL) && !defined(HCCD)
60 : aclError aclret = rtCloseNetService();
61 : if (aclret != ACL_RT_SUCCESS) {
62 : HCCL_ERROR("[hrtCloseNetService]Open NetService failed, err code : %d", aclret);
63 : return HcclResult::HCCL_E_UNAVAIL;
64 : }
65 :
66 : return HCCL_SUCCESS;
67 : #else
68 0 : HCCL_ERROR("[hrtCloseNetService]Does not support this interface.");
69 0 : return HCCL_E_NOT_SUPPORT;
70 : #endif
71 : }
72 : weak_alias(__hrtCloseNetService, hrtCloseNetService);
73 :
74 411 : HcclResult hrtTsdCapabilityGet(
75 : [[maybe_unused]] uint32_t deviceLogicId, [[maybe_unused]] int32_t type, [[maybe_unused]] uint64_t ptr)
76 : {
77 : #ifndef HCCD
78 411 : uint32_t tdtStatus = DlTdtFunction::GetInstance().dlTsdCapabilityGet(deviceLogicId, type, ptr);
79 411 : if (tdtStatus != 0) {
80 0 : HCCL_ERROR(
81 : "[Get][TsdCapability]Get TsdCapability failed, tdt error code: %u, error deviceLogicId[%u], ", tdtStatus,
82 : deviceLogicId);
83 0 : return HCCL_E_UNAVAIL;
84 : }
85 411 : HCCL_INFO("Get TsdCapability success. deviceLogicId[%u]", deviceLogicId);
86 411 : return HCCL_SUCCESS;
87 : #else
88 : HCCL_ERROR("[hrtTsdCapabilityGet]Does not support this interface.");
89 : return HCCL_E_NOT_SUPPORT;
90 : #endif
91 : }
92 : #ifdef __cplusplus
93 : } // extern "C"
94 : #endif
|