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_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
11 void *list_in, uint32_t data_len,
12 const uint16_t max_segs)
16 struct qat_sgl *list = (struct qat_sgl *)list_in;
17 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
18 uint8_t *virt_addr[max_segs];
21 for (nr = buf_len = 0; buf && nr < max_segs; buf = buf->next) {
22 if (offset >= rte_pktmbuf_data_len(buf)) {
23 offset -= rte_pktmbuf_data_len(buf);
27 list->buffers[nr].len = rte_pktmbuf_data_len(buf) - offset;
28 list->buffers[nr].resrvd = 0;
29 list->buffers[nr].addr = rte_pktmbuf_iova_offset(buf, offset);
31 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
32 virt_addr[nr] = rte_pktmbuf_mtod_offset(buf, uint8_t*, offset);
35 buf_len += list->buffers[nr].len;
37 if (buf_len >= data_len) {
38 list->buffers[nr].len -= buf_len - data_len;
45 if (unlikely(res != 0)) {
47 QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
50 QAT_DP_LOG(ERR, "Mbuf chain is too short");
54 list->num_bufs = ++nr;
55 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
56 QAT_DP_LOG(INFO, "SGL with %d buffers:", list->num_bufs);
57 for (nr = 0; nr < list->num_bufs; nr++) {
59 "QAT SGL buf %d, len = %d, iova = 0x%012"PRIx64,
60 nr, list->buffers[nr].len,
61 list->buffers[nr].addr);
62 QAT_DP_HEXDUMP_LOG(DEBUG, "qat SGL",
64 list->buffers[nr].len);
72 void qat_stats_get(struct qat_pci_device *dev,
73 struct qat_common_stats *stats,
74 enum qat_service_type service)
79 if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
80 QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
85 qp = dev->qps_in_use[service];
86 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
88 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
93 stats->enqueued_count += qp[i]->stats.enqueued_count;
94 stats->dequeued_count += qp[i]->stats.dequeued_count;
95 stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
96 stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
97 stats->threshold_hit_count += qp[i]->stats.threshold_hit_count;
98 QAT_LOG(DEBUG, "Threshold was used for qp %d %"PRIu64" times",
99 i, stats->threshold_hit_count);
103 void qat_stats_reset(struct qat_pci_device *dev,
104 enum qat_service_type service)
109 if (dev == NULL || service >= QAT_SERVICE_INVALID) {
110 QAT_LOG(ERR, "invalid param: dev %p, service %d",
115 qp = dev->qps_in_use[service];
116 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
118 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
122 memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
125 QAT_LOG(DEBUG, "QAT: %d stats cleared", service);