LCOV - code coverage report
Current view: top level - base_comm/resources/hccp/rdma_agent/adapter - ra_adp_verbs.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 58 0
Test Date: 2026-08-17 10:19:35 Functions: 0.0 % 6 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              : #define _GNU_SOURCE
      12              : #include "ra_adp.h"
      13              : #include "rs.h"
      14              : #include "ra_adp_verbs.h"
      15              : 
      16              : static struct RaRsVerbsOps gRaRsVerbsOps = {
      17              :     .qpCreateWithCQWithAttrs = RsQpCreateWithCQWithAttrs,
      18              :     .typicalCqCreate = RsTypicalCqCreate,
      19              :     .typicalCqDestroy = RsTypicalCqDestroy,
      20              :     .getLiteCqAttr = RsGetLiteCqAttr,
      21              :     .qpDestroyWithoutCQ = RsQpDestroyWithoutCQ,
      22              :     .getLiteQpAttr = RsGetLiteQpAttr,
      23              : };
      24              : 
      25            0 : int RaRsQpCreateWithCQWithAttrs(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      26              : {
      27            0 :     union OpQpCreateWithCQWithAttrsData *createData = NULL;
      28            0 :     struct RsQpNormWithAttrs qpNorm = {0};
      29            0 :     struct RsQpRespWithAttrs qpResp = {0};
      30              : 
      31              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpQpCreateWithCQWithAttrsData), sizeof(struct MsgHead), rcvBufLen,
      32              :         opResult);
      33              : 
      34            0 :     createData = (union OpQpCreateWithCQWithAttrsData *)(inBuf + sizeof(struct MsgHead));
      35              : 
      36            0 :     qpNorm.isExp = 1;
      37            0 :     qpNorm.isExt = 1;
      38            0 :     qpNorm.extAttrs = createData->txData.extAttrs;
      39              : 
      40            0 :     *opResult = gRaRsVerbsOps.qpCreateWithCQWithAttrs(createData->txData.phyId, createData->txData.rdevIndex,
      41              :         createData->txData.sendCqn, createData->txData.recvCqn, &qpNorm, &qpResp);
      42            0 :     if (*opResult != 0) {
      43            0 :         hccp_err("qp create with cq with attrs failed ret[%d].", *opResult);
      44            0 :         return 0;
      45              :     }
      46              : 
      47            0 :     createData = (union OpQpCreateWithCQWithAttrsData *)(outBuf + sizeof(struct MsgHead));
      48            0 :     createData->rxData.qpn = qpResp.qpn;
      49            0 :     createData->rxData.psn = qpResp.psn;
      50            0 :     createData->rxData.gidIdx = qpResp.gidIdx;
      51              : 
      52            0 :     return 0;
      53              : }
      54              : 
      55            0 : int RaRsTypicalCqCreate(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      56              : {
      57            0 :     union OpTypicalCqCreateData *createData = (union OpTypicalCqCreateData *)(inBuf + sizeof(struct MsgHead));
      58            0 :     unsigned int cqn = 0;
      59              : 
      60              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTypicalCqCreateData), sizeof(struct MsgHead), rcvBufLen, opResult);
      61              : 
      62            0 :     *opResult = gRaRsVerbsOps.typicalCqCreate(createData->txData.phyId, createData->txData.rdevIndex,
      63              :         createData->txData.cqDepth, &cqn);
      64            0 :     if (*opResult != 0) {
      65            0 :         hccp_err("typical cq create failed ret[%d].", *opResult);
      66            0 :         return 0;
      67              :     }
      68              : 
      69            0 :     createData = (union OpTypicalCqCreateData *)(outBuf + sizeof(struct MsgHead));
      70            0 :     createData->rxData.cqn = cqn;
      71              : 
      72            0 :     return 0;
      73              : }
      74              : 
      75            0 : int RaRsTypicalCqDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      76              : {
      77            0 :     union OpTypicalCqDestroyData *destroyData = (union OpTypicalCqDestroyData *)(inBuf + sizeof(struct MsgHead));
      78              : 
      79              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTypicalCqDestroyData), sizeof(struct MsgHead), rcvBufLen, opResult);
      80              : 
      81            0 :     *opResult = gRaRsVerbsOps.typicalCqDestroy(destroyData->txData.phyId, destroyData->txData.rdevIndex,
      82              :         destroyData->txData.cqn);
      83            0 :     if (*opResult != 0) {
      84            0 :         hccp_err("typical cq destroy failed ret[%d].", *opResult);
      85            0 :         return 0;
      86              :     }
      87              : 
      88            0 :     return 0;
      89              : }
      90              : 
      91            0 : int RaRsGetLiteCqAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      92              : {
      93            0 :     union OpGetLiteCqAttrData *getLiteCqAttrData = (union OpGetLiteCqAttrData *)(inBuf + sizeof(struct MsgHead));
      94            0 :     unsigned int cqn = getLiteCqAttrData->txData.cqn;
      95            0 :     struct rdma_lite_device_cq_attr deviceCqAttr = {0};
      96              : 
      97              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpGetLiteCqAttrData), sizeof(struct MsgHead), rcvBufLen, opResult);
      98              : 
      99            0 :     *opResult = gRaRsVerbsOps.getLiteCqAttr(getLiteCqAttrData->txData.phyId, getLiteCqAttrData->txData.rdevIndex, cqn,
     100              :         &deviceCqAttr);
     101            0 :     if (*opResult != 0) {
     102            0 :         hccp_err("get lite cq attr failed ret[%d], cqn[%u].", *opResult, cqn);
     103            0 :         return 0;
     104              :     }
     105              : 
     106            0 :     getLiteCqAttrData = (union OpGetLiteCqAttrData *)(outBuf + sizeof(struct MsgHead));
     107            0 :     getLiteCqAttrData->rxData.deviceCqAttr = deviceCqAttr;
     108              : 
     109            0 :     return 0;
     110              : }
     111              : 
     112            0 : int RaRsQpDestroyWithoutCQ(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     113              : {
     114            0 :     union OpQpDestroyData *qpDestroyData = (union OpQpDestroyData *)(inBuf + sizeof(struct MsgHead));
     115              : 
     116              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpQpDestroyData), sizeof(struct MsgHead), rcvBufLen, opResult);
     117              : 
     118            0 :     *opResult = gRaRsVerbsOps.qpDestroyWithoutCQ(qpDestroyData->txData.phyId, qpDestroyData->txData.rdevIndex,
     119              :         qpDestroyData->txData.qpn);
     120            0 :     if (*opResult != 0) {
     121            0 :         hccp_err("qp destroy without cq failed ret[%d].", *opResult);
     122              :     }
     123              : 
     124            0 :     return 0;
     125              : }
     126              : 
     127            0 : int RaRsGetLiteQpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     128              : {
     129            0 :     union OpLiteQpAttrData *liteQpAttrData = (union OpLiteQpAttrData *)(inBuf + sizeof(struct MsgHead));
     130            0 :     union OpLiteQpAttrData *liteQpAttrOut = (union OpLiteQpAttrData *)(outBuf + sizeof(struct MsgHead));
     131              : 
     132              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpLiteQpAttrData), sizeof(struct MsgHead), rcvBufLen, opResult);
     133              : 
     134            0 :     *opResult = gRaRsVerbsOps.getLiteQpAttr(liteQpAttrData->txData.phyId, liteQpAttrData->txData.rdevIndex,
     135              :         liteQpAttrData->txData.qpn, (void *)&liteQpAttrOut->rxData.resp);
     136            0 :     if (*opResult != 0) {
     137            0 :         hccp_err("get_lite_qp_attr failed ret[%d].", *opResult);
     138              :     }
     139              : 
     140            0 :     return 0;
     141              : }
        

Generated by: LCOV version 2.0-1