LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_service - rs_comm.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 81.2 % 16 13
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 "ra_rs_comm.h"
      12              : #include "dl_ibverbs_function.h"
      13              : #include "dl_net_function.h"
      14              : #include "rs.h"
      15              : 
      16              : struct OpcodeInterfaceInfo gInterfaceInfoList[] = {
      17              :     // outer opcode version: 1.0
      18              :     {RA_RS_SOCKET_CONN, 2},
      19              :     {RA_RS_SOCKET_CLOSE, 2},
      20              :     {RA_RS_SOCKET_ABORT, 1},
      21              :     {RA_RS_SOCKET_LISTEN_START, 2},
      22              :     {RA_RS_SOCKET_LISTEN_STOP, 2},
      23              :     {RA_RS_GET_SOCKET, 3},
      24              :     {RA_RS_SOCKET_SEND, 1},
      25              :     {RA_RS_SOCKET_RECV, 1},
      26              :     {RA_RS_QP_CREATE, 2},
      27              :     {RA_RS_QP_CREATE_WITH_ATTRS, 1},
      28              :     {RA_RS_AI_QP_CREATE, 3},
      29              :     {RA_RS_AI_QP_CREATE_WITH_ATTRS, 1},
      30              :     {RA_RS_TYPICAL_QP_CREATE, 1},
      31              :     {RA_RS_QP_DESTROY, 1},
      32              :     {RA_RS_QP_DESTROY_WITHOUT_CQ, 1},
      33              :     {RA_RS_QP_CONNECT, 2},
      34              :     {RA_RS_TYPICAL_QP_MODIFY, 3},
      35              :     {RA_RS_QP_STATUS, 1},
      36              :     {RA_RS_QP_INFO, 1},
      37              :     {RA_RS_QP_BATCH_MODIFY, 2},
      38              :     {RA_RS_MR_REG, 2},
      39              :     {RA_RS_MR_DEREG, 1},
      40              :     {RA_RS_TYPICAL_MR_REG_V1, 2},
      41              :     {RA_RS_TYPICAL_MR_REG, 1},
      42              :     {RA_RS_REMAP_MR, 1},
      43              :     {RA_RS_TYPICAL_MR_DEREG, 1},
      44              :     {RA_RS_SEND_WR, 1},
      45              :     {RA_RS_GET_NOTIFY_BA, 2},
      46              :     {RA_RS_INIT, 2},
      47              :     {RA_RS_DEINIT, 1},
      48              :     {RA_RS_SOCKET_INIT, 1},
      49              :     {RA_RS_SOCKET_DEINIT, 1},
      50              :     {RA_RS_RDEV_INIT, 2},
      51              :     {RA_RS_RDEV_INIT_WITH_BACKUP, 1},
      52              :     {RA_RS_RDEV_GET_PORT_STATUS, 1},
      53              :     {RA_RS_RDEV_DEINIT, 1},
      54              :     {RA_RS_WLIST_ADD, 1},
      55              :     {RA_RS_WLIST_ADD_V2, 1},
      56              :     {RA_RS_WLIST_DEL, 1},
      57              :     {RA_RS_WLIST_DEL_V2, 1},
      58              :     {RA_RS_ACCEPT_CREDIT_ADD, 1},
      59              :     {RA_RS_GET_IFADDRS, 2},
      60              :     {RA_RS_GET_IFADDRS_V2, 3},
      61              :     {RA_RS_GET_INTERFACE_VERSION, 1},
      62              :     {RA_RS_SEND_WRLIST, 1},
      63              :     {RA_RS_SEND_WRLIST_V2, 1},
      64              :     {RA_RS_SEND_WRLIST_EXT, 1},
      65              :     {RA_RS_SEND_WRLIST_EXT_V2, 1},
      66              :     {RA_RS_SEND_NORMAL_WRLIST, 1},
      67              :     {RA_RS_SET_TSQP_DEPTH, 1},
      68              :     {RA_RS_GET_TSQP_DEPTH, 1},
      69              :     {RA_RS_SET_QP_ATTR_QOS, 1},
      70              :     {RA_RS_SET_QP_ATTR_TIMEOUT, 1},
      71              :     {RA_RS_SET_QP_ATTR_RETRY_CNT, 1},
      72              :     {RA_RS_GET_CQE_ERR_INFO, 1},
      73              :     {RA_RS_GET_CQE_ERR_INFO_NUM, 1},
      74              :     {RA_RS_GET_CQE_ERR_INFO_LIST, 1},
      75              :     {RA_RS_GET_LITE_SUPPORT, 2},
      76              :     {RA_RS_GET_LITE_RDEV_CAP, 1},
      77              :     {RA_RS_GET_LITE_QP_CQ_ATTR, 1},
      78              :     {RA_RS_GET_LITE_QP_ATTR, 1},
      79              :     {RA_RS_GET_LITE_CONNECTED_INFO, 1},
      80              :     {RA_RS_GET_LITE_MEM_ATTR, 1},
      81              :     {RA_RS_PING_INIT, 1},
      82              :     {RA_RS_PING_ADD, 1},
      83              :     {RA_RS_PING_START, 1},
      84              :     {RA_RS_PING_GET_RESULTS, 1},
      85              :     {RA_RS_PING_STOP, 1},
      86              :     {RA_RS_PING_DEL, 1},
      87              :     {RA_RS_PING_DEINIT, 1},
      88              :     {RA_RS_GET_VNIC_IP_INFOS_V1, 1},
      89              :     {RA_RS_GET_VNIC_IP_INFOS, 1},
      90              :     {RA_RS_TLV_INIT_V1, 2},
      91              :     {RA_RS_TLV_INIT, 1},
      92              :     {RA_RS_TLV_DEINIT, 1},
      93              :     {RA_RS_TLV_REQUEST, 1},
      94              :     {RA_RS_TLV_REQUEST_V2, 1},
      95              :     {RA_RS_CUSTOM_CHANNEL_DEPRECATED, 1},
      96              :     {RA_RS_GET_TLS_ENABLE, 1},
      97              :     {RA_RS_GET_SEC_RANDOM, 1},
      98              :     {RA_RS_GET_HCCN_CFG, 3},
      99              :     {RA_RS_GET_ROCE_API_VERSION, 0},
     100              :     {RA_RS_TYPICAL_CQ_CREATE, 1},
     101              :     {RA_RS_GET_LITE_CQ_ATTR, 1},
     102              :     {RA_RS_QP_CREATE_WITH_CQ_WITH_ATTRS, 1},
     103              :     {RA_RS_TYPICAL_CQ_DESTROY, 1},
     104              : 
     105              :     // outer opcode version: 2.0
     106              :     {RA_RS_GET_DEV_EID_INFO_NUM, 1},
     107              :     {RA_RS_GET_DEV_EID_INFO_LIST, 2},
     108              :     {RA_RS_CTX_INIT, 2},
     109              :     {RA_RS_CTX_GET_ASYNC_EVENTS, 2},
     110              :     {RA_RS_CTX_DEINIT, 1},
     111              :     {RA_RS_GET_EID_BY_IP, 1},
     112              :     {RA_RS_GET_IP_BY_EID, 1},
     113              :     {RA_RS_GET_TP_INFO_LIST, 2},
     114              :     {RA_RS_GET_TP_ATTR, 3},
     115              :     {RA_RS_SET_TP_ATTR, 3},
     116              :     {RA_RS_CTX_TOKEN_ID_ALLOC, 1},
     117              :     {RA_RS_CTX_TOKEN_ID_FREE, 1},
     118              :     {RA_RS_LMEM_REG, 1},
     119              :     {RA_RS_LMEM_UNREG, 1},
     120              :     {RA_RS_RMEM_IMPORT, 1},
     121              :     {RA_RS_RMEM_UNIMPORT, 1},
     122              :     {RA_RS_CTX_CHAN_CREATE, 1},
     123              :     {RA_RS_CTX_CHAN_DESTROY, 1},
     124              :     {RA_RS_CTX_CQ_CREATE, 1},
     125              :     {RA_RS_CTX_QUERY_QP_BATCH, 1},
     126              :     {RA_RS_CTX_CQ_DESTROY, 1},
     127              :     {RA_RS_CTX_QP_DESTROY_BATCH, 1},
     128              :     {RA_RS_CTX_QP_CREATE, 1},
     129              :     {RA_RS_CTX_QP_DESTROY, 1},
     130              :     {RA_RS_CTX_QP_IMPORT, 1},
     131              :     {RA_RS_CTX_QP_UNIMPORT_DEPRECATED, 1},
     132              :     {RA_RS_CTX_QP_UNIMPORT, 1},
     133              :     {RA_RS_CTX_QP_BIND, 1},
     134              :     {RA_RS_CTX_QP_UNBIND, 1},
     135              :     {RA_RS_CTX_BATCH_SEND_WR, 1},
     136              :     {RA_RS_CTX_UPDATE_CI, 1},
     137              :     {RA_RS_CTX_GET_AUX_INFO, 1},
     138              :     {RA_RS_CTX_GET_CR_ERR_INFO_LIST, 1},
     139              :     {RA_RS_CTX_GET_UB_CONTEXT, 1},
     140              :     {RA_RS_GET_NET_API_VERSION, 0},
     141              : 
     142              :     // inner opcode version
     143              :     {RA_RS_HDC_SESSION_CLOSE, 1},
     144              :     {RA_RS_GET_VNIC_IP, 1},
     145              :     {RA_RS_NOTIFY_CFG_SET, 1},
     146              :     {RA_RS_NOTIFY_CFG_GET, 1},
     147              :     {RA_RS_SET_PID, 1},
     148              :     {RA_RS_ASYNC_HDC_SESSION_CONNECT, 2},
     149              :     {RA_RS_ASYNC_HDC_SESSION_CLOSE, 1},
     150              : };
     151              : 
     152            3 : RS_ATTRI_VISI_DEF int RsGetInterfaceVersion(unsigned int opcode, unsigned int *version)
     153              : {
     154              :     int i;
     155            3 :     unsigned int interfaceVersion = 0; // default interface is 0 (0: not support this interface opcode)
     156            3 :     int num = sizeof(gInterfaceInfoList) / sizeof(gInterfaceInfoList[0]);
     157              : 
     158            3 :     CHK_PRT_RETURN(version == NULL, hccp_err("rs_get_interface_version failed! version is null"), -EINVAL);
     159              : 
     160            2 :     for (i = 0; i < num; i++) {
     161            2 :         if (opcode == gInterfaceInfoList[i].opcode && opcode != RA_RS_GET_ROCE_API_VERSION &&
     162              :             opcode != RA_RS_GET_NET_API_VERSION) {
     163            1 :             interfaceVersion = gInterfaceInfoList[i].version;
     164            1 :             break;
     165            1 :         } else if (opcode == RA_RS_GET_ROCE_API_VERSION) {
     166            1 :             interfaceVersion = RsRoceGetApiVersion();
     167            1 :             break;
     168            0 :         } else if (opcode == RA_RS_GET_NET_API_VERSION) {
     169            0 :             interfaceVersion = RsNetGetApiVersion();
     170            0 :             break;
     171              :         }
     172              :     }
     173              : 
     174            2 :     *version = interfaceVersion;
     175            2 :     return 0;
     176              : }
        

Generated by: LCOV version 2.0-1