LCOV - code coverage report
Current view: top level - drivers/common/qat - qat_pf2vf.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 41 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 20 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2021 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "qat_pf2vf.h"
       6                 :            : #include "adf_pf2vf_msg.h"
       7                 :            : 
       8                 :            : #include <rte_cycles.h>
       9                 :            : 
      10                 :          0 : int qat_pf2vf_exch_msg(struct qat_pci_device *qat_dev,
      11                 :            :                 struct qat_pf2vf_msg pf2vf_msg,
      12                 :            :                 int len, uint8_t *ret)
      13                 :            : {
      14                 :            :         int i = 0;
      15                 :          0 :         struct qat_pf2vf_dev *qat_pf2vf =
      16                 :          0 :         qat_gen_config[qat_dev->qat_dev_gen].pf2vf_dev;
      17                 :          0 :         void *pmisc_bar_addr = qat_dev->misc_bar_io_addr;
      18                 :            :         uint32_t msg = 0, count = 0, val = 0;
      19                 :          0 :         uint32_t vf_csr_off = qat_pf2vf->vf2pf_offset;
      20                 :          0 :         uint32_t pf_csr_off = qat_pf2vf->pf2vf_offset;
      21                 :          0 :         int type_shift = qat_pf2vf->pf2vf_type_shift;
      22                 :          0 :         uint32_t type_mask = qat_pf2vf->pf2vf_type_mask;
      23                 :          0 :         int blck_hdr_shift = qat_pf2vf->pf2vf_data_shift;
      24                 :            :         int data_shift = blck_hdr_shift;
      25                 :            : 
      26   [ #  #  #  # ]:          0 :         switch (pf2vf_msg.msg_type) {
      27                 :          0 :         case ADF_VF2PF_MSGTYPE_GET_SMALL_BLOCK_REQ:
      28                 :          0 :                 data_shift += ADF_VF2PF_SMALL_BLOCK_BYTE_NUM_SHIFT;
      29                 :          0 :                 break;
      30                 :          0 :         case ADF_VF2PF_MSGTYPE_GET_MEDIUM_BLOCK_REQ:
      31                 :          0 :                 data_shift += ADF_VF2PF_MEDIUM_BLOCK_BYTE_NUM_SHIFT;
      32                 :          0 :                 break;
      33                 :          0 :         case ADF_VF2PF_MSGTYPE_GET_LARGE_BLOCK_REQ:
      34                 :          0 :                 data_shift += ADF_VF2PF_LARGE_BLOCK_BYTE_NUM_SHIFT;
      35                 :          0 :                 break;
      36                 :            :         }
      37                 :            : 
      38         [ #  # ]:          0 :         if ((pf2vf_msg.msg_type & type_mask) != pf2vf_msg.msg_type) {
      39                 :          0 :                 QAT_LOG(ERR, "PF2VF message type 0x%X out of range",
      40                 :            :                         pf2vf_msg.msg_type);
      41                 :          0 :                 return -EINVAL;
      42                 :            :         }
      43                 :            : 
      44         [ #  # ]:          0 :         for (; i < len; i++) {
      45                 :            :                 count = 0;
      46         [ #  # ]:          0 :                 if (len == 1) {
      47                 :          0 :                         msg = (pf2vf_msg.msg_type << type_shift) |
      48                 :          0 :                                 (pf2vf_msg.msg_data << (data_shift));
      49                 :            :                 } else
      50                 :          0 :                         msg = (pf2vf_msg.msg_type << type_shift) |
      51                 :          0 :                                 ((pf2vf_msg.msg_data + i) << (data_shift));
      52         [ #  # ]:          0 :                 if (pf2vf_msg.block_hdr > 0)
      53                 :          0 :                         msg |= pf2vf_msg.block_hdr << blck_hdr_shift;
      54                 :          0 :                 msg |= ADF_PFVF_INT | ADF_PFVF_MSGORIGIN_SYSTEM;
      55                 :            : 
      56                 :          0 :                 ADF_CSR_WR(pmisc_bar_addr, vf_csr_off, msg);
      57                 :            :                 /*
      58                 :            :                  * Wait for confirmation from remote that it received
      59                 :            :                  * the message
      60                 :            :                  */
      61                 :            :                 do {
      62                 :          0 :                         rte_delay_us_sleep(ADF_IOV_MSG_ACK_DELAY_US * 2);
      63                 :            :                         val = ADF_CSR_RD(pmisc_bar_addr, vf_csr_off);
      64   [ #  #  #  # ]:          0 :                 } while ((val & ADF_PFVF_INT) &&
      65                 :            :                         (++count < ADF_IOV_MSG_ACK_MAX_RETRY));
      66                 :            : 
      67         [ #  # ]:          0 :                 if (val & ADF_PFVF_INT) {
      68                 :          0 :                         QAT_LOG(ERR, "ACK not received from remote");
      69                 :          0 :                         return -EIO;
      70                 :            :                 }
      71                 :            : 
      72                 :          0 :                 uint32_t pf_val = ADF_CSR_RD(pmisc_bar_addr, pf_csr_off);
      73                 :          0 :                 msg &= ~ADF_PFVF_INT;
      74                 :            :                 ADF_CSR_WR(pmisc_bar_addr, pf_csr_off, msg);
      75                 :            : 
      76                 :          0 :                 *(ret + i) = (uint8_t)(pf_val >> (pf2vf_msg.block_hdr > 0 ?
      77         [ #  # ]:          0 :                                 10 : 8) & 0xff);
      78                 :            :         }
      79                 :            :         return 0;
      80                 :            : }

Generated by: LCOV version 1.14