1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #include "qat_common.h"
6 #include "qat_device.h"
10 qat_service_get_str(enum qat_service_type type)
13 case QAT_SERVICE_SYMMETRIC:
15 case QAT_SERVICE_ASYMMETRIC:
17 case QAT_SERVICE_COMPRESSION:
25 qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
26 void *list_in, uint32_t data_len,
27 const uint16_t max_segs)
31 struct qat_sgl *list = (struct qat_sgl *)list_in;
32 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
33 uint8_t *virt_addr[max_segs];
36 for (nr = buf_len = 0; buf && nr < max_segs; buf = buf->next) {
37 if (offset >= rte_pktmbuf_data_len(buf)) {
38 offset -= rte_pktmbuf_data_len(buf);
42 list->buffers[nr].len = rte_pktmbuf_data_len(buf) - offset;
43 list->buffers[nr].resrvd = 0;
44 list->buffers[nr].addr = rte_pktmbuf_iova_offset(buf, offset);
46 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
47 virt_addr[nr] = rte_pktmbuf_mtod_offset(buf, uint8_t*, offset);
50 buf_len += list->buffers[nr].len;
52 if (buf_len >= data_len) {
53 list->buffers[nr].len -= buf_len - data_len;
60 if (unlikely(res != 0)) {
62 QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
65 QAT_DP_LOG(ERR, "Mbuf chain is too short");
69 list->num_bufs = ++nr;
70 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
71 QAT_DP_LOG(INFO, "SGL with %d buffers:", list->num_bufs);
72 for (nr = 0; nr < list->num_bufs; nr++) {
74 "QAT SGL buf %d, len = %d, iova = 0x%012"PRIx64,
75 nr, list->buffers[nr].len,
76 list->buffers[nr].addr);
77 QAT_DP_HEXDUMP_LOG(DEBUG, "qat SGL",
79 list->buffers[nr].len);
87 void qat_stats_get(struct qat_pci_device *dev,
88 struct qat_common_stats *stats,
89 enum qat_service_type service)
94 if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
95 QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
100 qp = dev->qps_in_use[service];
101 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
103 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
108 stats->enqueued_count += qp[i]->stats.enqueued_count;
109 stats->dequeued_count += qp[i]->stats.dequeued_count;
110 stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
111 stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
112 stats->threshold_hit_count += qp[i]->stats.threshold_hit_count;
113 QAT_LOG(DEBUG, "Threshold was used for qp %d %"PRIu64" times",
114 i, stats->threshold_hit_count);
118 void qat_stats_reset(struct qat_pci_device *dev,
119 enum qat_service_type service)
124 if (dev == NULL || service >= QAT_SERVICE_INVALID) {
125 QAT_LOG(ERR, "invalid param: dev %p, service %d",
130 qp = dev->qps_in_use[service];
131 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
133 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
137 memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
140 QAT_LOG(DEBUG, "QAT: %d stats cleared", service);