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 <stdlib.h>
12 : #include <string.h>
13 : #include <errno.h>
14 : #include "hccp_ping.h"
15 : #include "ra.h"
16 : #include "ra_client_host.h"
17 : #include "user_log.h"
18 : #include "ra_hdc_ping.h"
19 : #include "ra_rs_comm.h"
20 : #include "ra_ping.h"
21 : #include "ra_rs_err.h"
22 :
23 : struct RaPingOps gRaHdcPingOps = {
24 : .raPingInit = RaHdcPingInit,
25 : .raPingTargetAdd = RaHdcPingTargetAdd,
26 : .raPingTaskStart = RaHdcPingTaskStart,
27 : .raPingGetResults = RaHdcPingGetResults,
28 : .raPingTargetDel = RaHdcPingTargetDel,
29 : .raPingTaskStop = RaHdcPingTaskStop,
30 : .raPingDeinit = RaHdcPingDeinit,
31 : };
32 :
33 0 : STATIC int RaUdevInitCheck(unsigned int phyId, void *pingHandle)
34 : {
35 0 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
36 : hccp_err("[check][ra_ping_init]phyId(%u) is invalid! "
37 : "it must greater or equal to 0 and less than %d!",
38 : phyId, RA_MAX_PHY_ID_NUM),
39 : -EINVAL);
40 0 : CHK_PRT_RETURN(pingHandle == NULL, hccp_err("[check][ra_ping_init]phyId(%u) ping_handle is null!", phyId), -EINVAL);
41 0 : return 0;
42 : }
43 :
44 8 : STATIC int RaPingInitGetHandle(struct PingInitAttr *initAttr, struct PingInitInfo *initInfo,
45 : struct RaPingHandle *pingHandle)
46 : {
47 8 : char localIp[MAX_IP_LEN] = {0};
48 : int ret;
49 :
50 8 : CHK_PRT_RETURN(initAttr == NULL || initInfo == NULL, hccp_err("[init][ra_ping]initAttr or init_info is NULL"),
51 : -EINVAL);
52 7 : CHK_PRT_RETURN(initAttr->mode != NETWORK_OFFLINE, hccp_err("[init][ra_ping]mode:%d do not support", initAttr->mode),
53 : -EINVAL);
54 :
55 5 : if (initAttr->protocol == PROTOCOL_RDMA) {
56 5 : CHK_PRT_RETURN(initAttr->commInfo.rdma.udpSport > MAX_PORT_NUM,
57 : hccp_err("[init][ra_ping]udp_sport %u invalid", initAttr->commInfo.rdma.udpSport), -EINVAL);
58 4 : ret = RaRdevInitCheck(initAttr->mode, initAttr->dev.rdma, localIp, MAX_IP_LEN, pingHandle);
59 4 : CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_ping]ra_rdev_init_check failed, ret(%d)", ret), -EINVAL);
60 :
61 2 : pingHandle->phyId = initAttr->dev.rdma.phyId;
62 2 : hccp_run_info("Input parameters: phyId[%u], nicPosition[%d] family[%d] ip[%s] bufferSize[0x%x]",
63 : initAttr->dev.rdma.phyId, initAttr->mode, initAttr->dev.rdma.family, localIp, initAttr->bufferSize);
64 0 : } else if (initAttr->protocol == PROTOCOL_UDMA) {
65 0 : ret = RaUdevInitCheck(initAttr->ub.phyId, pingHandle);
66 0 : CHK_PRT_RETURN(ret != 0, hccp_err("[init][ra_ping]ra_ub_dev_init_check failed, ret(%d)", ret), -EINVAL);
67 :
68 0 : pingHandle->phyId = initAttr->ub.phyId;
69 0 : hccp_run_info("Input parameters: phyId[%u], nicPosition[%d], eidIndex[%u] bufferSize[0x%x]", initAttr->ub.phyId,
70 : initAttr->mode, initAttr->dev.ub.eidIndex, initAttr->bufferSize);
71 : } else {
72 0 : hccp_err("[init][ra_ping]protocol:%d do not support", initAttr->protocol);
73 0 : return -ENOTSUPP;
74 : }
75 2 : pingHandle->protocol = initAttr->protocol;
76 :
77 2 : pingHandle->pingOps = &gRaHdcPingOps;
78 2 : CHK_PRT_RETURN(pingHandle->pingOps->raPingInit == NULL, hccp_err("[init][ra_ping]ra_ping_init is NULL"), -EINVAL);
79 2 : CHK_PRT_RETURN(initAttr->bufferSize == 0 || initAttr->bufferSize % (unsigned int)RA_RS_4K_PAGE_SIZE != 0,
80 : hccp_err("[init][ra_ping]initAttr->buffer_size:0x%x not 0x%xB aligned", initAttr->bufferSize,
81 : (unsigned int)RA_RS_4K_PAGE_SIZE),
82 : -EINVAL);
83 1 : pingHandle->bufferSize = initAttr->bufferSize;
84 :
85 1 : ret = pthread_mutex_init(&pingHandle->mutex, NULL);
86 1 : CHK_PRT_RETURN(ret, hccp_err("[init][ra_ping]init mutext failed, ret:%d", ret), ret);
87 :
88 1 : return 0;
89 : }
90 :
91 5 : HCCP_ATTRI_VISI_DEF int RaPingInit(struct PingInitAttr *initAttr, struct PingInitInfo *initInfo, void **pingHandle)
92 : {
93 5 : struct RaPingHandle *pingHandleTmp = NULL;
94 : int ret;
95 :
96 5 : CHK_PRT_RETURN(pingHandle == NULL, hccp_err("[init][ra_ping]ping_handle is NULL"), -EINVAL);
97 :
98 4 : pingHandleTmp = calloc(1, sizeof(struct RaPingHandle));
99 4 : CHK_PRT_RETURN(pingHandleTmp == NULL, hccp_err("[init][ra_ping]calloc for ping_handle failed"),
100 : ConverReturnCode(HCCP_INIT, -ENOMEM));
101 :
102 3 : ret = RaPingInitGetHandle(initAttr, initInfo, pingHandleTmp);
103 3 : if (ret != 0) {
104 2 : hccp_err("[init][ra_ping]ra_ping_init_get_handle failed, ret(%d)", ret);
105 2 : goto err;
106 : }
107 :
108 1 : ret = pingHandleTmp->pingOps->raPingInit(pingHandleTmp, initAttr, initInfo);
109 1 : if (ret != 0) {
110 0 : (void)pthread_mutex_destroy(&pingHandleTmp->mutex);
111 0 : goto err;
112 : }
113 :
114 1 : *pingHandle = (void *)pingHandleTmp;
115 :
116 1 : return 0;
117 :
118 2 : err:
119 2 : free(pingHandleTmp);
120 2 : pingHandleTmp = NULL;
121 2 : return ConverReturnCode(HCCP_INIT, ret);
122 : }
123 :
124 6 : HCCP_ATTRI_VISI_DEF int RaPingTargetAdd(void *pingHandle, struct PingTargetInfo target[], uint32_t num)
125 : {
126 6 : struct RaPingHandle *pingHandleTmp = NULL;
127 : unsigned int phyId;
128 : int ret;
129 :
130 6 : CHK_PRT_RETURN(pingHandle == NULL || target == NULL || num == 0,
131 : hccp_err("[add][ra_ping]ping_handle or target "
132 : "is NULL, or num is 0"),
133 : ConverReturnCode(RDMA_OP, -EINVAL));
134 :
135 5 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
136 5 : CHK_PRT_RETURN(pingHandleTmp->pingOps == NULL || pingHandleTmp->pingOps->raPingTargetAdd == NULL,
137 : hccp_err("[add][ra_ping]ping_ops or ra_ping_target_add is NULL"), ConverReturnCode(RDMA_OP, -EINVAL));
138 :
139 4 : phyId = pingHandleTmp->phyId;
140 4 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
141 : hccp_err("[add][ra_ping]phyId(%u) must less than %d!", phyId, RA_MAX_PHY_ID_NUM),
142 : ConverReturnCode(RDMA_OP, -EINVAL));
143 3 : CHK_PRT_RETURN(pingHandleTmp->targetCnt + num < num,
144 : hccp_err("[add][ra_ping]pingHandleTmp->targetCnt + num is out of range"), ConverReturnCode(RDMA_OP, -EINVAL));
145 :
146 3 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
147 : // disallow add target when task is running
148 3 : if (pingHandleTmp->taskCnt != 0) {
149 1 : hccp_err("[add][ra_ping]task_cnt:%u != 0 invalid, task already running", pingHandleTmp->taskCnt);
150 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
151 1 : return ConverReturnCode(RDMA_OP, -EEXIST);
152 : }
153 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
154 :
155 2 : ret = pingHandleTmp->pingOps->raPingTargetAdd(pingHandleTmp, target, num);
156 2 : if (ret != 0) {
157 1 : return ConverReturnCode(RDMA_OP, ret);
158 : }
159 :
160 : // increase target cnt
161 1 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
162 1 : pingHandleTmp->targetCnt += num;
163 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
164 1 : return 0;
165 : }
166 :
167 8 : HCCP_ATTRI_VISI_DEF int RaPingTaskStart(void *pingHandle, struct PingTaskAttr *attr)
168 : {
169 8 : struct RaPingHandle *pingHandleTmp = NULL;
170 : unsigned int phyId;
171 : int ret;
172 :
173 8 : CHK_PRT_RETURN(pingHandle == NULL || attr == NULL, hccp_err("[start][ra_ping]ping_handle is NULL or attr is NULL"),
174 : ConverReturnCode(RDMA_OP, -EINVAL));
175 :
176 7 : CHK_PRT_RETURN(attr->packetCnt == 0 || attr->packetInterval == 0 || attr->timeoutInterval == 0,
177 : hccp_err("[start][ra_ping]packet_cnt:%u or packet_interval:%u or timeout_interval:%u is 0", attr->packetCnt,
178 : attr->packetInterval, attr->timeoutInterval),
179 : ConverReturnCode(RDMA_OP, -EINVAL));
180 :
181 7 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
182 7 : CHK_PRT_RETURN(pingHandleTmp->pingOps == NULL || pingHandleTmp->pingOps->raPingTaskStart == NULL,
183 : hccp_err("[start][ra_ping]ping_ops is NULL or ping_ops->ra_ping_task_start is NULL"),
184 : ConverReturnCode(RDMA_OP, -EINVAL));
185 :
186 6 : phyId = pingHandleTmp->phyId;
187 6 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
188 : hccp_err("[start][ra_ping]phyId(%u) must less than %d!", phyId, RA_MAX_PHY_ID_NUM),
189 : ConverReturnCode(RDMA_OP, -EINVAL));
190 :
191 5 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
192 : // disallow multi task running or no target to start
193 5 : if (pingHandleTmp->taskCnt != 0) {
194 1 : hccp_warn("[start][ra_ping]task_cnt:%u != 0 invalid, task already running", pingHandleTmp->taskCnt);
195 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
196 1 : return ConverReturnCode(RDMA_OP, -EEXIST);
197 : }
198 4 : if (pingHandleTmp->targetCnt == 0) {
199 1 : hccp_warn("[start][ra_ping]target_cnt is 0 invalid, no target exist");
200 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
201 1 : return ConverReturnCode(RDMA_OP, -ENODEV);
202 : }
203 :
204 : // increase task cnt to avoid lock contention, trigger task running
205 3 : pingHandleTmp->taskCnt++;
206 3 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
207 :
208 3 : hccp_run_info("Input parameters: phyId[%u], packetCnt[%u] interval[%u] timeoutInterval[%u], targetCnt[%u]", phyId,
209 : attr->packetCnt, attr->packetInterval, attr->timeoutInterval, pingHandleTmp->targetCnt);
210 :
211 3 : ret = pingHandleTmp->pingOps->raPingTaskStart(pingHandleTmp, attr);
212 3 : if (ret != 0) {
213 : // trigger failed, decrease task cnt
214 2 : hccp_err("[start][ra_ping]ping_task_start failed, ret(%d)", ret);
215 2 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
216 2 : pingHandleTmp->taskCnt--;
217 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
218 2 : return ConverReturnCode(RDMA_OP, ret);
219 : }
220 :
221 1 : return 0;
222 : }
223 :
224 6 : HCCP_ATTRI_VISI_DEF int RaPingGetResults(void *pingHandle, struct PingTargetResult target[], uint32_t *num)
225 : {
226 6 : struct RaPingHandle *pingHandleTmp = NULL;
227 : unsigned int phyId;
228 : int ret;
229 :
230 6 : if (pingHandle == NULL || target == NULL || num == NULL || *num == 0) {
231 1 : hccp_err("[get][ra_ping]ping_handle is NULL or target is NULL or num is NULL or *num is 0");
232 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
233 : }
234 :
235 5 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
236 5 : if (pingHandleTmp->pingOps == NULL || pingHandleTmp->pingOps->raPingGetResults == NULL) {
237 1 : hccp_err("[get][ra_ping]ping_ops is NULL or ping_ops->ra_ping_get_results is NULL");
238 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
239 : }
240 :
241 4 : phyId = pingHandleTmp->phyId;
242 4 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
243 : hccp_err("[get][ra_ping]phyId(%u) must less than %d!", phyId, RA_MAX_PHY_ID_NUM),
244 : ConverReturnCode(RDMA_OP, -EINVAL));
245 :
246 : // num invalid, bigger than target exist
247 3 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
248 3 : if (pingHandleTmp->targetCnt < *num) {
249 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
250 1 : hccp_err("[get][ra_ping]target_cnt:%u < num:%u, invalid", pingHandleTmp->targetCnt, *num);
251 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
252 : }
253 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
254 :
255 2 : ret = pingHandleTmp->pingOps->raPingGetResults(pingHandleTmp, target, num);
256 2 : return ConverReturnCode(RDMA_OP, ret);
257 : }
258 :
259 7 : HCCP_ATTRI_VISI_DEF int RaPingTargetDel(void *pingHandle, struct PingTargetCommInfo target[], uint32_t num)
260 : {
261 7 : struct RaPingHandle *pingHandleTmp = NULL;
262 : unsigned int phyId;
263 : int ret;
264 :
265 7 : if (pingHandle == NULL || target == NULL || num == 0) {
266 1 : hccp_err("[del][ra_ping]ping_handle is NULL or target is NULL or num:%u is 0", num);
267 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
268 : }
269 :
270 6 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
271 6 : if (pingHandleTmp->pingOps == NULL || pingHandleTmp->pingOps->raPingTargetDel == NULL) {
272 1 : hccp_err("[del][ra_ping]ping_ops is NULL or ping_ops->ra_ping_target_del is NULL");
273 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
274 : }
275 :
276 5 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
277 : // disallow del target when task is running
278 5 : if (pingHandleTmp->taskCnt != 0) {
279 1 : hccp_err("[del][ra_ping]task_cnt:%u != 0 invalid, task already running", pingHandleTmp->taskCnt);
280 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
281 1 : return ConverReturnCode(RDMA_OP, -EEXIST);
282 : }
283 : // num invalid, bigger than target exist
284 4 : if (pingHandleTmp->targetCnt < num) {
285 2 : hccp_err("[del][ra_ping]target_cnt:%u < num:%u, invalid", pingHandleTmp->targetCnt, num);
286 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
287 2 : return ConverReturnCode(RDMA_OP, -EINVAL);
288 : }
289 : // decrease target cnt to avoid lock contention, trigger target del
290 2 : pingHandleTmp->targetCnt -= num;
291 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
292 :
293 2 : phyId = pingHandleTmp->phyId;
294 2 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
295 : hccp_err("[del][ra_ping]phyId(%u) must less than %d!", phyId, RA_MAX_PHY_ID_NUM),
296 : ConverReturnCode(RDMA_OP, -EINVAL));
297 :
298 1 : ret = pingHandleTmp->pingOps->raPingTargetDel(pingHandleTmp, target, num);
299 1 : if (ret != 0) {
300 : // trigger del failed, increase target cnt
301 0 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
302 0 : pingHandleTmp->targetCnt += num;
303 0 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
304 0 : return ConverReturnCode(RDMA_OP, ret);
305 : }
306 :
307 1 : return 0;
308 : }
309 :
310 6 : HCCP_ATTRI_VISI_DEF int RaPingTaskStop(void *pingHandle)
311 : {
312 6 : struct RaPingHandle *pingHandleTmp = NULL;
313 : unsigned int phyId;
314 : int ret;
315 :
316 6 : if (pingHandle == NULL) {
317 1 : hccp_err("[stop][ra_ping]ping_handle is NULL");
318 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
319 : }
320 :
321 5 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
322 5 : if (pingHandleTmp->pingOps == NULL || pingHandleTmp->pingOps->raPingTaskStop == NULL) {
323 1 : hccp_err("[stop][ra_ping]ping_ops is NULL or ping_ops->ra_ping_task_stop is NULL");
324 1 : return ConverReturnCode(RDMA_OP, -EINVAL);
325 : }
326 :
327 4 : phyId = pingHandleTmp->phyId;
328 4 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
329 : hccp_err("[stop][ra_ping]phyId(%u) must less than %d!", phyId, RA_MAX_PHY_ID_NUM),
330 : ConverReturnCode(RDMA_OP, -EINVAL));
331 :
332 : // no task to stop
333 3 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
334 3 : if (pingHandleTmp->taskCnt == 0) {
335 1 : hccp_warn("[stop][ra_ping]task_cnt is 0 invalid, no task running");
336 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
337 1 : return ConverReturnCode(RDMA_OP, -ENODEV);
338 : }
339 : // decrease task cnt to avoid lock contention, trigger task stop
340 2 : pingHandleTmp->taskCnt--;
341 2 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
342 :
343 2 : hccp_run_info("Input parameters: phyId[%u], targetCnt[%u]", phyId, pingHandleTmp->targetCnt);
344 :
345 2 : ret = pingHandleTmp->pingOps->raPingTaskStop(pingHandleTmp);
346 2 : if (ret != 0) {
347 : // trigger failed, increase task cnt
348 1 : RA_PTHREAD_MUTEX_LOCK(&pingHandleTmp->mutex);
349 1 : pingHandleTmp->taskCnt++;
350 1 : RA_PTHREAD_MUTEX_UNLOCK(&pingHandleTmp->mutex);
351 1 : return ConverReturnCode(RDMA_OP, ret);
352 : }
353 :
354 1 : return 0;
355 : }
356 :
357 4 : STATIC int RaPingDeinitParaCheck(struct RaPingHandle *pingHandle)
358 : {
359 4 : char localIp[MAX_IP_LEN] = {0};
360 : union PingDev devInfo;
361 : unsigned int phyId;
362 : int ret;
363 :
364 4 : CHK_PRT_RETURN(pingHandle->pingOps == NULL || pingHandle->pingOps->raPingDeinit == NULL,
365 : hccp_err("[deinit][ra_ping]ping_ops is NULL or ra_ping_deinit is NULL"), -EINVAL);
366 :
367 2 : phyId = pingHandle->phyId;
368 2 : CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
369 : hccp_err("[deinit][ra_ping]phyId(%u) must smaller than %u", phyId, RA_MAX_PHY_ID_NUM), -EINVAL);
370 :
371 2 : devInfo = pingHandle->dev;
372 2 : if (pingHandle->protocol == PROTOCOL_RDMA) {
373 2 : ret = RaInetPton(devInfo.rdma.family, devInfo.rdma.localIp, localIp, MAX_IP_LEN);
374 2 : CHK_PRT_RETURN(ret != 0, hccp_err("[deinit][ra_ping]ra_inet_pton for local_ip failed, ret(%d)", ret), ret);
375 1 : hccp_run_info("Input parameters: phyId[%u] dev_index[%u] family[%d] local_ip[%s] target_cnt[%u] task_cnt[%u]",
376 : phyId, pingHandle->devIndex, devInfo.rdma.family, localIp, pingHandle->targetCnt, pingHandle->taskCnt);
377 0 : } else if (pingHandle->protocol == PROTOCOL_UDMA) {
378 0 : hccp_run_info("Input parameters: eid_index[%u] eid[0x%016llx%016llx] target_cnt[%u] task_cnt[%u]",
379 : devInfo.ub.eidIndex, devInfo.ub.eid.in6.subnetPrefix, devInfo.ub.eid.in6.interfaceId, pingHandle->targetCnt,
380 : pingHandle->taskCnt);
381 : } else {
382 0 : hccp_err("[deinit][ra_ping]protocol:%d do not support", pingHandle->protocol);
383 0 : return -ENOTSUPP;
384 : }
385 :
386 1 : return 0;
387 : }
388 :
389 4 : HCCP_ATTRI_VISI_DEF int RaPingDeinit(void *pingHandle)
390 : {
391 4 : struct RaPingHandle *pingHandleTmp = NULL;
392 : int ret;
393 :
394 4 : if (pingHandle == NULL) {
395 1 : hccp_err("[deinit][ra_ping]ping_handle is NULL");
396 1 : return ConverReturnCode(HCCP_INIT, -EINVAL);
397 : }
398 3 : pingHandleTmp = (struct RaPingHandle *)pingHandle;
399 :
400 3 : ret = RaPingDeinitParaCheck(pingHandleTmp);
401 3 : if (ret != 0) {
402 1 : hccp_err("[deinit][ra_ping]ra_ping_deinit_para_check failed, ret(%d)", ret);
403 1 : return ConverReturnCode(HCCP_INIT, ret);
404 : }
405 :
406 2 : ret = pingHandleTmp->pingOps->raPingDeinit(pingHandleTmp);
407 2 : if (ret != 0) {
408 1 : hccp_err("[deinit][ra_ping]ra_ping_deinit failed, ret(%d)", ret);
409 : }
410 :
411 2 : pingHandleTmp->pingOps = NULL;
412 2 : (void)pthread_mutex_destroy(&pingHandleTmp->mutex);
413 2 : free(pingHandleTmp);
414 2 : pingHandleTmp = NULL;
415 2 : return ConverReturnCode(HCCP_INIT, ret);
416 : }
|