LCOV - code coverage report
Current view: top level - drivers/common/qat - qat_common.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 53 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 32 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "qat_common.h"
       6                 :            : #include "qat_device.h"
       7                 :            : #include "qat_logs.h"
       8                 :            : 
       9                 :            : #define QAT_LEGACY_CAPA "qat_legacy_capa"
      10                 :            : 
      11                 :            : static const char *const arguments[] = {
      12                 :            :         QAT_LEGACY_CAPA,
      13                 :            :         NULL
      14                 :            : };
      15                 :            : 
      16                 :            : const char *const *qat_cmdline_defines[QAT_MAX_SERVICES + 1] = {
      17                 :            :         [QAT_MAX_SERVICES] = arguments,
      18                 :            : };
      19                 :            : 
      20                 :            : const char *
      21                 :          0 : qat_service_get_str(enum qat_service_type type)
      22                 :            : {
      23   [ #  #  #  # ]:          0 :         switch (type) {
      24                 :            :         case QAT_SERVICE_SYMMETRIC:
      25                 :            :                 return "sym";
      26                 :          0 :         case QAT_SERVICE_ASYMMETRIC:
      27                 :          0 :                 return "asym";
      28                 :          0 :         case QAT_SERVICE_COMPRESSION:
      29                 :          0 :                 return "comp";
      30                 :          0 :         default:
      31                 :          0 :                 return "invalid";
      32                 :            :         }
      33                 :            : }
      34                 :            : 
      35                 :            : int
      36                 :          0 : qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
      37                 :            :                 void *list_in, uint32_t data_len,
      38                 :            :                 const uint16_t max_segs)
      39                 :            : {
      40                 :            :         int res = -EINVAL;
      41                 :            :         uint32_t buf_len, nr;
      42                 :            :         struct qat_sgl *list = (struct qat_sgl *)list_in;
      43                 :            : #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
      44                 :            :         uint8_t *virt_addr[max_segs];
      45                 :            : #endif
      46                 :            : 
      47   [ #  #  #  # ]:          0 :         for (nr = buf_len = 0; buf &&  nr < max_segs; buf = buf->next)  {
      48         [ #  # ]:          0 :                 if (offset >= rte_pktmbuf_data_len(buf)) {
      49                 :          0 :                         offset -= rte_pktmbuf_data_len(buf);
      50                 :          0 :                         continue;
      51                 :            :                 }
      52                 :            : 
      53                 :          0 :                 list->buffers[nr].len = rte_pktmbuf_data_len(buf) - offset;
      54         [ #  # ]:          0 :                 list->buffers[nr].resrvd = 0;
      55                 :          0 :                 list->buffers[nr].addr = rte_pktmbuf_iova_offset(buf, offset);
      56                 :            : 
      57                 :            : #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
      58                 :            :                 virt_addr[nr] = rte_pktmbuf_mtod_offset(buf, uint8_t*, offset);
      59                 :            : #endif
      60                 :            :                 offset = 0;
      61                 :          0 :                 buf_len += list->buffers[nr].len;
      62                 :            : 
      63         [ #  # ]:          0 :                 if (buf_len >= data_len) {
      64                 :          0 :                         list->buffers[nr].len -= buf_len - data_len;
      65                 :            :                         res = 0;
      66                 :          0 :                         break;
      67                 :            :                 }
      68                 :          0 :                 ++nr;
      69                 :            :         }
      70                 :            : 
      71         [ #  # ]:          0 :         if (unlikely(res != 0)) {
      72         [ #  # ]:          0 :                 if (nr == max_segs) {
      73                 :          0 :                         QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
      74                 :            :                                    max_segs);
      75                 :            :                 } else {
      76                 :          0 :                         QAT_DP_LOG(ERR, "Mbuf chain is too short");
      77                 :            :                 }
      78                 :            :         } else {
      79                 :            : 
      80                 :          0 :                 list->num_bufs = ++nr;
      81                 :            : #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
      82                 :            :                 QAT_DP_LOG(INFO, "SGL with %d buffers:", list->num_bufs);
      83                 :            :                 for (nr = 0; nr < list->num_bufs; nr++) {
      84                 :            :                         QAT_DP_LOG(INFO,
      85                 :            :                                 "QAT SGL buf %d, len = %d, iova = 0x%012"PRIx64,
      86                 :            :                                  nr, list->buffers[nr].len,
      87                 :            :                                  list->buffers[nr].addr);
      88                 :            :                         QAT_DP_HEXDUMP_LOG(DEBUG, "qat SGL",
      89                 :            :                                            virt_addr[nr],
      90                 :            :                                            list->buffers[nr].len);
      91                 :            :                 }
      92                 :            : #endif
      93                 :            :         }
      94                 :            : 
      95                 :          0 :         return res;
      96                 :            : }
      97                 :            : 
      98                 :          0 : void qat_stats_get(struct qat_pci_device *dev,
      99                 :            :                 struct qat_common_stats *stats,
     100                 :            :                 enum qat_service_type service)
     101                 :            : {
     102                 :            :         int i;
     103                 :            :         struct qat_qp **qp;
     104                 :            : 
     105   [ #  #  #  # ]:          0 :         if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
     106                 :          0 :                 QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
     107                 :            :                                 stats, dev, service);
     108                 :          0 :                 return;
     109                 :            :         }
     110                 :            : 
     111                 :          0 :         qp = dev->qps_in_use[service];
     112         [ #  # ]:          0 :         for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
     113         [ #  # ]:          0 :                 if (qp[i] == NULL) {
     114                 :          0 :                         QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
     115                 :            :                                         service, i);
     116                 :          0 :                         continue;
     117                 :            :                 }
     118                 :            : 
     119                 :          0 :                 stats->enqueued_count += qp[i]->stats.enqueued_count;
     120                 :          0 :                 stats->dequeued_count += qp[i]->stats.dequeued_count;
     121                 :          0 :                 stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
     122                 :          0 :                 stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
     123                 :          0 :                 stats->threshold_hit_count += qp[i]->stats.threshold_hit_count;
     124                 :          0 :                 QAT_LOG(DEBUG, "Threshold was used for qp %d %"PRIu64" times",
     125                 :            :                                 i, stats->threshold_hit_count);
     126                 :            :         }
     127                 :            : }
     128                 :            : 
     129                 :          0 : void qat_stats_reset(struct qat_pci_device *dev,
     130                 :            :                 enum qat_service_type service)
     131                 :            : {
     132                 :            :         int i;
     133                 :            :         struct qat_qp **qp;
     134                 :            : 
     135         [ #  # ]:          0 :         if (dev == NULL || service >= QAT_SERVICE_INVALID) {
     136                 :          0 :                 QAT_LOG(ERR, "invalid param: dev %p, service %d",
     137                 :            :                                 dev, service);
     138                 :          0 :                 return;
     139                 :            :         }
     140                 :            : 
     141                 :          0 :         qp = dev->qps_in_use[service];
     142         [ #  # ]:          0 :         for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
     143         [ #  # ]:          0 :                 if (qp[i] == NULL) {
     144                 :          0 :                         QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
     145                 :            :                                         service, i);
     146                 :          0 :                         continue;
     147                 :            :                 }
     148                 :          0 :                 memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
     149                 :            :         }
     150                 :            : 
     151                 :          0 :         QAT_LOG(DEBUG, "QAT: %d stats cleared", service);
     152                 :            : }

Generated by: LCOV version 1.14