LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/client - ra_ping.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 89.7 % 204 183
Test Date: 2026-08-04 10:52:23 Functions: 90.0 % 10 9

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

Generated by: LCOV version 2.0-1