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-07-28 12:11:00 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 +
      58              :         sizeof(struct MsgHead));
      59            0 :     unsigned int cqn = 0;
      60              : 
      61              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTypicalCqCreateData), sizeof(struct MsgHead), rcvBufLen,
      62              :         opResult);
      63              : 
      64            0 :     *opResult = gRaRsVerbsOps.typicalCqCreate(createData->txData.phyId, createData->txData.rdevIndex,
      65              :         createData->txData.cqDepth, &cqn);
      66            0 :     if (*opResult != 0) {
      67            0 :         hccp_err("typical cq create failed ret[%d].", *opResult);
      68            0 :         return 0;
      69              :     }
      70              : 
      71            0 :     createData = (union OpTypicalCqCreateData *)(outBuf + sizeof(struct MsgHead));
      72            0 :     createData->rxData.cqn = cqn;
      73              : 
      74            0 :     return 0;
      75              : }
      76              : 
      77            0 : int RaRsTypicalCqDestroy(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      78              : {
      79            0 :     union OpTypicalCqDestroyData *destroyData = (union OpTypicalCqDestroyData *)(inBuf +
      80              :         sizeof(struct MsgHead));
      81              : 
      82              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpTypicalCqDestroyData), sizeof(struct MsgHead), rcvBufLen,
      83              :         opResult);
      84              : 
      85            0 :     *opResult = gRaRsVerbsOps.typicalCqDestroy(destroyData->txData.phyId, destroyData->txData.rdevIndex,
      86              :         destroyData->txData.cqn);
      87            0 :     if (*opResult != 0) {
      88            0 :         hccp_err("typical cq destroy failed ret[%d].", *opResult);
      89            0 :         return 0;
      90              :     }
      91              : 
      92            0 :     return 0;
      93              : }
      94              : 
      95            0 : int RaRsGetLiteCqAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
      96              : {
      97            0 :     union OpGetLiteCqAttrData *getLiteCqAttrData =
      98              :         (union OpGetLiteCqAttrData *)(inBuf + sizeof(struct MsgHead));
      99            0 :     unsigned int cqn = getLiteCqAttrData->txData.cqn;
     100            0 :     struct rdma_lite_device_cq_attr deviceCqAttr = {0};
     101              : 
     102              :     HCCP_CHECK_PARAM_LEN_RET_HOST(
     103              :         sizeof(union OpGetLiteCqAttrData), sizeof(struct MsgHead), rcvBufLen, opResult);
     104              : 
     105            0 :     *opResult = gRaRsVerbsOps.getLiteCqAttr(getLiteCqAttrData->txData.phyId,
     106              :         getLiteCqAttrData->txData.rdevIndex, cqn, &deviceCqAttr);
     107            0 :     if (*opResult != 0) {
     108            0 :         hccp_err("get lite cq attr failed ret[%d], cqn[%u].", *opResult, cqn);
     109            0 :         return 0;
     110              :     }
     111              : 
     112            0 :     getLiteCqAttrData = (union OpGetLiteCqAttrData *)(outBuf + sizeof(struct MsgHead));
     113            0 :     getLiteCqAttrData->rxData.deviceCqAttr = deviceCqAttr;
     114              : 
     115            0 :     return 0;
     116              : }
     117              : 
     118            0 : int RaRsQpDestroyWithoutCQ(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     119              : {
     120            0 :     union OpQpDestroyData *qpDestroyData = (union OpQpDestroyData *)(inBuf + sizeof(struct MsgHead));
     121              : 
     122              :     HCCP_CHECK_PARAM_LEN_RET_HOST(sizeof(union OpQpDestroyData), sizeof(struct MsgHead), rcvBufLen, opResult);
     123              : 
     124            0 :     *opResult = gRaRsVerbsOps.qpDestroyWithoutCQ(qpDestroyData->txData.phyId, qpDestroyData->txData.rdevIndex,
     125              :         qpDestroyData->txData.qpn);
     126            0 :     if (*opResult != 0) {
     127            0 :         hccp_err("qp destroy without cq failed ret[%d].", *opResult);
     128              :     }
     129              : 
     130            0 :     return 0;
     131              : }
     132              : 
     133            0 : int RaRsGetLiteQpAttr(char *inBuf, char *outBuf, int *outLen, int *opResult, int rcvBufLen)
     134              : {
     135            0 :     union OpLiteQpAttrData *liteQpAttrData =
     136              :         (union OpLiteQpAttrData *)(inBuf + sizeof(struct MsgHead));
     137            0 :     union OpLiteQpAttrData *liteQpAttrOut =
     138              :         (union OpLiteQpAttrData *)(outBuf + sizeof(struct MsgHead));
     139              : 
     140              :     HCCP_CHECK_PARAM_LEN_RET_HOST(
     141              :         sizeof(union OpLiteQpAttrData), sizeof(struct MsgHead), rcvBufLen, opResult);
     142              : 
     143            0 :     *opResult = gRaRsVerbsOps.getLiteQpAttr(liteQpAttrData->txData.phyId,
     144              :         liteQpAttrData->txData.rdevIndex,
     145              :         liteQpAttrData->txData.qpn,
     146              :         (void *)&liteQpAttrOut->rxData.resp);
     147            0 :     if (*opResult != 0) {
     148            0 :         hccp_err("get_lite_qp_attr failed ret[%d].", *opResult);
     149              :     }
     150              : 
     151            0 :     return 0;
     152              : }
        

Generated by: LCOV version 2.0-1