LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/client - ra_host_verbs.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 7 0

            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_client_host.h"
      12              : 
      13            0 : HCCP_ATTRI_VISI_DEF int RaQpCreateWithCQWithAttrs(void *rdevHandle, struct QpExtAttrs *extAttrs,
      14              :     unsigned int sendCqn, unsigned int recvCqn, void **qpHandle)
      15              : {
      16            0 :     struct RaRdmaHandle *rdmaHandleTmp = (struct RaRdmaHandle *)rdevHandle;
      17              :     unsigned int phyId;
      18              :     int ret;
      19              : 
      20            0 :     CHK_PRT_RETURN(rdevHandle == NULL || rdmaHandleTmp->rdmaOps == NULL ||
      21              :         rdmaHandleTmp->rdmaOps->raQpCreateWithCQWithAttrs == NULL,
      22              :         hccp_err("[create][ra_qp_with_cq_attrs]rdev_handle is NULL or func is NULL"),
      23              :         ConverReturnCode(RDMA_OP, -EINVAL));
      24              : 
      25            0 :     CHK_PRT_RETURN(qpHandle == NULL, hccp_err("[create][ra_qp_with_cq_attrs]qp_handle is NULL"),
      26              :         ConverReturnCode(RDMA_OP, -EINVAL));
      27              : 
      28            0 :     CHK_PRT_RETURN(extAttrs == NULL, hccp_err("[create][ra_qp_with_cq_attrs]ext_attrs is NULL"),
      29              :         ConverReturnCode(RDMA_OP, -EINVAL));
      30              : 
      31            0 :     CHK_PRT_RETURN(extAttrs->version != QP_CREATE_WITH_ATTR_VERSION,
      32              :         hccp_err("[create][ra_qp_with_cq_attrs]attr version[%d] mismatch, expect [%d]", extAttrs->version,
      33              :         QP_CREATE_WITH_ATTR_VERSION), ConverReturnCode(RDMA_OP, -EINVAL));
      34              : 
      35            0 :     CHK_PRT_RETURN(extAttrs->qpMode < 0 || extAttrs->qpMode >= RA_RS_ERR_QP_MODE,
      36              :         hccp_err("[create][ra_qp_with_cq_attrs]QP mode[%d] must greater or equal to 0 and less than %d",
      37              :         extAttrs->qpMode, RA_RS_ERR_QP_MODE), ConverReturnCode(RDMA_OP, -EINVAL));
      38              :     // no need and disallow to set data_plane_flag, set it to default value 0
      39            0 :     extAttrs->dataPlaneFlag.value = 0;
      40              : 
      41            0 :     phyId = rdmaHandleTmp->rdevInfo.phyId;
      42            0 :     CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
      43              :         hccp_err("[create][ra_qp_with_cq_attrs]phyId(%u) must greater or equal to 0 and less than %d!", phyId,
      44              :         RA_MAX_PHY_ID_NUM), ConverReturnCode(RDMA_OP, -EINVAL));
      45              : 
      46            0 :     hccp_run_info("Input parameters: phyId[%u] qp_mode[%d] sendCqn[%u] recvCqn[%u] qpAttr.cap{%u,%u,%u,%u,%u}"\
      47              :         " qp_type[%u] sqSigAll[%d], cnt[%u]", phyId, extAttrs->qpMode, sendCqn, recvCqn,
      48              :         extAttrs->qpAttr.cap.max_send_wr, extAttrs->qpAttr.cap.max_recv_wr,
      49              :         extAttrs->qpAttr.cap.max_send_sge, extAttrs->qpAttr.cap.max_recv_sge,
      50              :         extAttrs->qpAttr.cap.max_inline_data, extAttrs->qpAttr.qp_type, extAttrs->qpAttr.sq_sig_all,
      51              :         rdmaHandleTmp->qpCnt);
      52              : 
      53            0 :     rdmaHandleTmp->qpCnt++;
      54            0 :     ret = rdmaHandleTmp->rdmaOps->raQpCreateWithCQWithAttrs(rdmaHandleTmp, extAttrs, sendCqn, recvCqn, qpHandle);
      55            0 :     CHK_PRT_RETURN(ret != 0 || *qpHandle == NULL,
      56              :         hccp_err("[create][ra_qp_with_cq_attrs]create qp failed, ret(%d) phyId(%u)", ret, phyId),
      57              :         ConverReturnCode(RDMA_OP, ret));
      58              : 
      59            0 :     return 0;
      60              : }
      61              : 
      62              : 
      63            0 : HCCP_ATTRI_VISI_DEF int RaTypicalCqCreate(void *rdevHandle, unsigned int cqDepth, unsigned int *cqn,
      64              :     void **cqHandle)
      65              : {
      66            0 :     struct RaRdmaHandle *rdmaHandleTmp = (struct RaRdmaHandle *)rdevHandle;
      67              :     unsigned int phyId;
      68              :     int ret;
      69              : 
      70            0 :     CHK_PRT_RETURN(rdevHandle == NULL || rdmaHandleTmp->rdmaOps == NULL ||
      71              :         rdmaHandleTmp->rdmaOps->raTypicalCqCreate == NULL,
      72              :         hccp_err("[create][ra_typical_cq]rdev_handle is NULL or func is NULL"),
      73              :         ConverReturnCode(RDMA_OP, -EINVAL));
      74              : 
      75            0 :     CHK_PRT_RETURN(cqHandle == NULL || cqn == NULL,
      76              :         hccp_err("[create][ra_typical_cq]cq_handle or cqn is NULL"),
      77              :         ConverReturnCode(RDMA_OP, -EINVAL));
      78              : 
      79            0 :     phyId = rdmaHandleTmp->rdevInfo.phyId;
      80            0 :     CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
      81              :         hccp_err("[create][ra_typical_cq]phyId(%u) exceeds max(%u)", phyId, RA_MAX_PHY_ID_NUM),
      82              :         ConverReturnCode(RDMA_OP, -EINVAL));
      83              : 
      84            0 :     hccp_run_info("RaTypicalCqCreate: phyId[%u], cqDepth[%u]", phyId, cqDepth);
      85              : 
      86            0 :     ret = rdmaHandleTmp->rdmaOps->raTypicalCqCreate(rdmaHandleTmp, cqDepth, cqn, cqHandle);
      87            0 :     CHK_PRT_RETURN(ret != 0 || *cqHandle == NULL,
      88              :         hccp_err("[create][ra_typical_cq]create cq failed ret(%d) phyId(%u)", ret, phyId),
      89              :         ConverReturnCode(RDMA_OP, ret));
      90              : 
      91            0 :     return 0;
      92              : }
      93              : 
      94            0 : HCCP_ATTRI_VISI_DEF int RaTypicalCqDestroy(void *rdevHandle, unsigned int cqn, void *cqHandle)
      95              : {
      96            0 :     struct RaRdmaHandle *rdmaHandleTmp = (struct RaRdmaHandle *)rdevHandle;
      97              :     unsigned int phyId;
      98              :     int ret;
      99              : 
     100            0 :     CHK_PRT_RETURN(rdevHandle == NULL || rdmaHandleTmp->rdmaOps == NULL ||
     101              :         rdmaHandleTmp->rdmaOps->raTypicalCqDestroy == NULL,
     102              :         hccp_err("[destroy][ra_typical_cq]rdev_handle is NULL or func is NULL"),
     103              :         ConverReturnCode(RDMA_OP, -EINVAL));
     104              : 
     105            0 :     CHK_PRT_RETURN(cqHandle == NULL,
     106              :         hccp_err("[destroy][ra_typical_cq]cq_handle is NULL"),
     107              :         ConverReturnCode(RDMA_OP, -EINVAL));
     108              : 
     109            0 :     phyId = rdmaHandleTmp->rdevInfo.phyId;
     110            0 :     CHK_PRT_RETURN(phyId >= RA_MAX_PHY_ID_NUM,
     111              :         hccp_err("[destroy][ra_typical_cq]phyId(%u) exceeds max(%u)", phyId, RA_MAX_PHY_ID_NUM),
     112              :         ConverReturnCode(RDMA_OP, -EINVAL));
     113              : 
     114            0 :     hccp_run_info("RaTypicalCqDestroy: phyId[%u], cqn[%u]", phyId, cqn);
     115              : 
     116            0 :     ret = rdmaHandleTmp->rdmaOps->raTypicalCqDestroy(rdmaHandleTmp, cqn, cqHandle);
     117            0 :     CHK_PRT_RETURN(ret != 0,
     118              :         hccp_err("[destroy][ra_typical_cq]destroy cq failed ret(%d) phyId(%u)", ret, phyId),
     119              :         ConverReturnCode(RDMA_OP, ret));
     120              : 
     121            0 :     return 0;
     122              : }
     123              : 
     124            0 : HCCP_ATTRI_VISI_DEF int RaQpDestroyWithoutCQ(void *qpHandle)
     125              : {
     126            0 :     struct RaQpHandle *raQpHandle = (struct RaQpHandle *)qpHandle;
     127              :     int ret;
     128              : 
     129            0 :     CHK_PRT_RETURN(qpHandle == NULL,
     130              :         hccp_err("[destroy][ra_qp]qp_handle is NULL"),
     131              :         ConverReturnCode(RDMA_OP, -EINVAL));
     132              : 
     133            0 :     CHK_PRT_RETURN(raQpHandle->rdmaOps == NULL || raQpHandle->rdmaOps->raQpDestroyWithoutCQ == NULL,
     134              :         hccp_err("[destroy][ra_qp]rdma_ops is NULL or ra_qp_handle->rdma_ops->ra_qp_destroy_without_cq is NULL, invalid"),
     135              :         ConverReturnCode(RDMA_OP, -EINVAL));
     136              : 
     137            0 :     hccp_run_info("Input parameters: qpn[%u], phyId[%u], rdevIndex[%u] qpMode[%d] flag[%d]",
     138              :         raQpHandle->qpn, raQpHandle->phyId, raQpHandle->rdevIndex, raQpHandle->qpMode, raQpHandle->flag);
     139              : 
     140            0 :     ret = raQpHandle->rdmaOps->raQpDestroyWithoutCQ(raQpHandle);
     141            0 :     return ConverReturnCode(RDMA_OP, ret);
     142              : }
     143              : 
     144            0 : HCCP_ATTRI_VISI_DEF int RaSendWrVerbs(void *qpHandle, struct SendWrVerbs *wr, struct SendWrRsp *opRsp)
     145              : {
     146            0 :     struct RaQpHandle *raQpHandle = (struct RaQpHandle *)qpHandle;
     147              :     int ret;
     148              : 
     149            0 :     CHK_PRT_RETURN(qpHandle == NULL || wr == NULL || wr->sgList == NULL || opRsp == NULL,
     150              :         hccp_err("[send][ra_wr]qp_handle or wr or sg_list or op_rsp is NULL, para error!"),
     151              :         ConverReturnCode(RDMA_OP, -EINVAL));
     152              : 
     153            0 :     CHK_PRT_RETURN(raQpHandle->rdmaOps == NULL || raQpHandle->rdmaOps->raSendWrVerbs == NULL,
     154              :         hccp_err("[send][ra_wr]rdma_ops is NULL or ra_qp_handle->rdma_ops->ra_send_wr_verbs is NULL, invalid"),
     155              :         ConverReturnCode(RDMA_OP, -EINVAL));
     156              : 
     157            0 :     ret = raQpHandle->rdmaOps->raSendWrVerbs(raQpHandle, wr, opRsp);
     158            0 :     return ConverReturnCode(RDMA_OP, ret);
     159              : }
     160              : 
     161            0 : HCCP_ATTRI_VISI_DEF int RaRecvWrVerbs(void *qpHandle, struct RecvWrVerbs *wr)
     162              : {
     163            0 :     struct RaQpHandle *raQpHandle = (struct RaQpHandle *)qpHandle;
     164              :     int ret;
     165              : 
     166            0 :     CHK_PRT_RETURN(qpHandle == NULL || wr == NULL || wr->sgList == NULL,
     167              :         hccp_err("[recv][ra_wr]qp_handle or wr or sg_list is NULL, para error!"),
     168              :         ConverReturnCode(RDMA_OP, -EINVAL));
     169              : 
     170            0 :     CHK_PRT_RETURN(raQpHandle->rdmaOps == NULL || raQpHandle->rdmaOps->raRecvWrVerbs == NULL,
     171              :         hccp_err("[recv][ra_wr]rdma_ops is NULL or ra_qp_handle->rdma_ops->ra_recv_wr_verbs is NULL, invalid"),
     172              :         ConverReturnCode(RDMA_OP, -EINVAL));
     173              : 
     174            0 :     ret = raQpHandle->rdmaOps->raRecvWrVerbs(raQpHandle, wr);
     175            0 :     return ConverReturnCode(RDMA_OP, ret);
     176              : }
     177              : 
     178            0 : HCCP_ATTRI_VISI_DEF int RaPollTypicalCq(void *cqHandle, unsigned int numEntries, void *wc)
     179              : {
     180            0 :     struct RaTypicalCqHandle *cqHdc = (struct RaTypicalCqHandle *)cqHandle;
     181            0 :     if (cqHandle == NULL || wc == NULL) {
     182            0 :         hccp_err("[ra_poll]cq_handle is NULL or wc is NULL, para error!");
     183            0 :         return ConverReturnCode(RDMA_OP, -EINVAL);
     184              :     }
     185            0 :     if (cqHdc->rdmaOps == NULL || cqHdc->rdmaOps->raPollTypicalCq == NULL) {
     186            0 :         hccp_err("[ra_poll]rdma_ops is NULL or ra_poll_typical_cq is NULL, invalid");
     187            0 :         return ConverReturnCode(RDMA_OP, -EINVAL);
     188              :     }
     189            0 :     int ret = cqHdc->rdmaOps->raPollTypicalCq(cqHdc, numEntries, wc);
     190            0 :     if (ret < 0) {
     191            0 :         return ConverReturnCode(RDMA_OP, ret);
     192              :     }
     193            0 :     return ret;
     194              : }
        

Generated by: LCOV version 2.0-1