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, uint64_t buf_start,
11 void *list_in, uint32_t data_len,
12 const uint16_t max_segs)
15 struct qat_sgl *list = (struct qat_sgl *)list_in;
16 /* buf_start allows the first buffer to start at an address before or
17 * after the mbuf data start. It's used to either optimally align the
18 * dma to 64 or to start dma from an offset.
21 uint32_t first_buf_len = rte_pktmbuf_data_len(buf) +
22 (rte_pktmbuf_mtophys(buf) - buf_start);
23 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
24 uint8_t *virt_addr[max_segs];
25 virt_addr[0] = rte_pktmbuf_mtod(buf, uint8_t*) +
26 (rte_pktmbuf_mtophys(buf) - buf_start);
29 list->buffers[0].addr = buf_start;
30 list->buffers[0].resrvd = 0;
31 list->buffers[0].len = first_buf_len;
33 if (data_len <= first_buf_len) {
35 list->buffers[0].len = data_len;
40 buf_len = first_buf_len;
42 if (unlikely(nr == max_segs)) {
43 QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
48 list->buffers[nr].len = rte_pktmbuf_data_len(buf);
49 list->buffers[nr].resrvd = 0;
50 list->buffers[nr].addr = rte_pktmbuf_mtophys(buf);
51 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
52 virt_addr[nr] = rte_pktmbuf_mtod(buf, uint8_t*);
54 buf_len += list->buffers[nr].len;
57 if (buf_len >= data_len) {
58 list->buffers[nr].len -=
67 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
70 QAT_DP_LOG(INFO, "SGL with %d buffers:", list->num_bufs);
71 for (i = 0; i < list->num_bufs; i++) {
73 "QAT SGL buf %d, len = %d, iova = 0x%012"PRIx64,
74 i, list->buffers[i].len,
75 list->buffers[i].addr);
76 QAT_DP_HEXDUMP_LOG(DEBUG, "qat SGL",
77 virt_addr[i], list->buffers[i].len);
85 void qat_stats_get(struct qat_pci_device *dev,
86 struct qat_common_stats *stats,
87 enum qat_service_type service)
92 if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
93 QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
98 qp = dev->qps_in_use[service];
99 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
101 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
106 stats->enqueued_count += qp[i]->stats.enqueued_count;
107 stats->dequeued_count += qp[i]->stats.dequeued_count;
108 stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
109 stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
113 void qat_stats_reset(struct qat_pci_device *dev,
114 enum qat_service_type service)
119 if (dev == NULL || service >= QAT_SERVICE_INVALID) {
120 QAT_LOG(ERR, "invalid param: dev %p, service %d",
125 qp = dev->qps_in_use[service];
126 for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
128 QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
132 memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
135 QAT_LOG(DEBUG, "QAT: %d stats cleared", service);