LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/client - ra_socket.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 48 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 3 0

            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 "user_log.h"
      12              : #include "ra.h"
      13              : #include "ra_rs_comm.h"
      14              : #include "ra_client_host.h"
      15              : #include "hccp.h"
      16              : 
      17            0 : HCCP_ATTRI_VISI_DEF int RaGetClientSocketErrInfo(struct SocketConnectInfoT conn[],
      18              :     struct SocketErrInfo err[], unsigned int num)
      19              : {
      20            0 :     struct RaSocketHandle *socketHandle = NULL;
      21            0 :     char remoteIp[MAX_IP_LEN] = {0};
      22            0 :     char localIp[MAX_IP_LEN] = {0};
      23            0 :     unsigned int phyId = 0;
      24              :     unsigned int i;
      25              :     int ret;
      26              : 
      27            0 :     CHK_PRT_RETURN(conn == NULL || err == NULL || num == 0 || num > MAX_SOCKET_NUM,
      28              :         hccp_err("[get][ra_socket]conn is NULL or err is NULL or num[%u] is zero or num is greater than %d",
      29              :         num, MAX_SOCKET_NUM), ConverReturnCode(SOCKET_OP, -EINVAL));
      30              : 
      31            0 :     for (i = 0; i < num; i++) {
      32            0 :         socketHandle = (struct RaSocketHandle *)conn[i].socketHandle;
      33            0 :         CHK_PRT_RETURN(socketHandle == NULL || socketHandle->socketOps == NULL ||
      34              :             socketHandle->socketOps->raGetClientSocketErrInfo == NULL,
      35              :             hccp_err("[get][ra_socket]socket_handle or func is NULL"), ConverReturnCode(SOCKET_OP, -EINVAL));
      36              : 
      37            0 :         phyId = socketHandle->rdevInfo.phyId;
      38            0 :         CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
      39              :             hccp_err("[get][ra_socket]RaGetClientSocketErrInfo get phyid failed, phyid[%u] should < max[%u]",
      40              :             phyId, RA_MAX_PHY_ID_NUM), -EINVAL);
      41              : 
      42            0 :         ret = RaInetPton(socketHandle->rdevInfo.family, socketHandle->rdevInfo.localIp, localIp, MAX_IP_LEN);
      43            0 :         CHK_PRT_RETURN(ret != 0, hccp_err("[get][ra_socket]ra_inet_pton for local_ip failed, ret(%d)", ret),
      44              :             ConverReturnCode(SOCKET_OP, ret));
      45              : 
      46            0 :         ret = RaInetPton(socketHandle->rdevInfo.family, conn[i].remoteIp, remoteIp, MAX_IP_LEN);
      47            0 :         CHK_PRT_RETURN(ret != 0, hccp_err("[get][ra_socket]ra_inet_pton for remote_ip failed, ret(%d)", ret),
      48              :             ConverReturnCode(SOCKET_OP, ret));
      49              : 
      50            0 :         hccp_info("Input parameters: [%u]th, phyId[%u], localIp[%s], remoteIp[%s], port[%u], tag[%s]",
      51              :             i, phyId, localIp, remoteIp, conn[i].port, conn[i].tag);
      52              :     }
      53              : 
      54            0 :     ret = socketHandle->socketOps->raGetClientSocketErrInfo(phyId, conn, err, num);
      55            0 :     return ConverReturnCode(SOCKET_OP, ret);
      56              : }
      57              : 
      58            0 : HCCP_ATTRI_VISI_DEF int RaGetServerSocketErrInfo(struct SocketListenInfoT conn[],
      59              :     struct ServerSocketErrInfo err[], unsigned int num)
      60              : {
      61            0 :     struct RaSocketHandle *socketHandle = NULL;
      62            0 :     char localIp[MAX_IP_LEN] = {0};
      63            0 :     unsigned int phyId = 0;
      64              :     unsigned int i;
      65              :     int ret;
      66              : 
      67            0 :     CHK_PRT_RETURN(conn == NULL || err == NULL || num == 0 || num > MAX_SOCKET_NUM,
      68              :         hccp_err("[get][ra_socket]conn is NULL or err is NULL or num[%u] is zero or num is greater than %d",
      69              :         num, MAX_SOCKET_NUM), ConverReturnCode(SOCKET_OP, -EINVAL));
      70              : 
      71            0 :     for (i = 0; i < num; i++) {
      72            0 :         socketHandle = (struct RaSocketHandle *)conn[i].socketHandle;
      73            0 :         CHK_PRT_RETURN(socketHandle == NULL || socketHandle->socketOps == NULL ||
      74              :             socketHandle->socketOps->raGetServerSocketErrInfo == NULL,
      75              :             hccp_err("[get][ra_socket]socket_handle or func is NULL"), ConverReturnCode(SOCKET_OP, -EINVAL));
      76              : 
      77            0 :         phyId = socketHandle->rdevInfo.phyId;
      78            0 :         CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
      79              :             hccp_err("[get][ra_socket]RaGetServerSocketErrInfo get phyid failed, phyid[%u] should < max[%u]", phyId,
      80              :             RA_MAX_PHY_ID_NUM), -EINVAL);
      81              : 
      82            0 :         ret = RaInetPton(socketHandle->rdevInfo.family, socketHandle->rdevInfo.localIp, localIp, MAX_IP_LEN);
      83            0 :         CHK_PRT_RETURN(ret, hccp_err("[get][ra_socket]ra_inet_pton for server_ip failed, ret(%d)", ret),
      84              :             ConverReturnCode(SOCKET_OP, ret));
      85              : 
      86            0 :         hccp_info("Input parameters: [%u]th, phyId[%u], localIp[%s], port[%u]",
      87              :             i, phyId, localIp, conn[i].port);
      88              :     }
      89              : 
      90            0 :     ret = socketHandle->socketOps->raGetServerSocketErrInfo(phyId, conn, err, num);
      91            0 :     return ConverReturnCode(SOCKET_OP, ret);
      92              : }
      93              : 
      94            0 : HCCP_ATTRI_VISI_DEF int RaSocketAcceptCreditAdd(struct SocketListenInfoT conn[], unsigned int num,
      95              :     unsigned int creditLimit)
      96              : {
      97            0 :     struct RaSocketHandle *socketHandle = NULL;
      98            0 :     char localIp[MAX_IP_LEN] = {0};
      99            0 :     unsigned int phyId = 0;
     100              :     unsigned int i;
     101              :     int ret;
     102              : 
     103            0 :     CHK_PRT_RETURN(conn == NULL || num == 0 || num > MAX_SOCKET_NUM || creditLimit == 0,
     104              :         hccp_err("[set][ra_socket]conn is NULL or num[%u] is 0 or greater than %d, or creditLimit[%u] is 0", num,
     105              :         MAX_SOCKET_NUM, creditLimit), ConverReturnCode(SOCKET_OP, -EINVAL));
     106              : 
     107            0 :     for (i = 0; i < num; i++) {
     108            0 :         socketHandle = (struct RaSocketHandle *)conn[i].socketHandle;
     109            0 :         CHK_PRT_RETURN(socketHandle == NULL || socketHandle->socketOps == NULL ||
     110              :             socketHandle->socketOps->raSocketAcceptCreditAdd == NULL,
     111              :             hccp_err("[set][ra_socket]socket_handle or func is NULL"), ConverReturnCode(SOCKET_OP, -EINVAL));
     112              : 
     113            0 :         phyId = socketHandle->rdevInfo.phyId;
     114            0 :         CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
     115              :             hccp_err("[set][ra_socket]phyId(%u) must smaller than %u", phyId, RA_MAX_PHY_ID_NUM),
     116              :             ConverReturnCode(SOCKET_OP, -EINVAL));
     117              : 
     118            0 :         ret = RaInetPton(socketHandle->rdevInfo.family, socketHandle->rdevInfo.localIp, localIp, MAX_IP_LEN);
     119            0 :         CHK_PRT_RETURN(ret, hccp_err("[set][ra_socket]ra_inet_pton for server_ip failed, ret(%d)", ret),
     120              :             ConverReturnCode(SOCKET_OP, ret));
     121              : 
     122            0 :         hccp_run_info("Input parameters: [%u]th, phyId[%u], localIp[%s] port[%u] creditLimit[%u]",
     123              :             i, phyId, localIp, conn[i].port, creditLimit);
     124              :     }
     125              : 
     126            0 :     ret = socketHandle->socketOps->raSocketAcceptCreditAdd(phyId, conn, num, creditLimit);
     127            0 :     return ConverReturnCode(SOCKET_OP, ret);
     128              : }
        

Generated by: LCOV version 2.0-1