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 : : const char *
10 : 0 : qat_service_get_str(enum qat_service_type type)
11 : : {
12 [ # # # # ]: 0 : switch (type) {
13 : : case QAT_SERVICE_SYMMETRIC:
14 : : return "sym";
15 : 0 : case QAT_SERVICE_ASYMMETRIC:
16 : 0 : return "asym";
17 : 0 : case QAT_SERVICE_COMPRESSION:
18 : 0 : return "comp";
19 : 0 : default:
20 : 0 : return "invalid";
21 : : }
22 : : }
23 : :
24 : : int
25 : 0 : 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)
28 : : {
29 : : int res = -EINVAL;
30 : : uint32_t buf_len, nr;
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];
34 : : #endif
35 : :
36 [ # # # # ]: 0 : for (nr = buf_len = 0; buf && nr < max_segs; buf = buf->next) {
37 [ # # ]: 0 : if (offset >= rte_pktmbuf_data_len(buf)) {
38 : 0 : offset -= rte_pktmbuf_data_len(buf);
39 : 0 : continue;
40 : : }
41 : :
42 : 0 : list->buffers[nr].len = rte_pktmbuf_data_len(buf) - offset;
43 [ # # ]: 0 : list->buffers[nr].resrvd = 0;
44 : 0 : list->buffers[nr].addr = rte_pktmbuf_iova_offset(buf, offset);
45 : :
46 : : #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
47 : : virt_addr[nr] = rte_pktmbuf_mtod_offset(buf, uint8_t*, offset);
48 : : #endif
49 : : offset = 0;
50 : 0 : buf_len += list->buffers[nr].len;
51 : :
52 [ # # ]: 0 : if (buf_len >= data_len) {
53 : 0 : list->buffers[nr].len -= buf_len - data_len;
54 : : res = 0;
55 : 0 : break;
56 : : }
57 : 0 : ++nr;
58 : : }
59 : :
60 [ # # ]: 0 : if (unlikely(res != 0)) {
61 [ # # ]: 0 : if (nr == max_segs) {
62 : 0 : QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
63 : : max_segs);
64 : : } else {
65 : 0 : QAT_DP_LOG(ERR, "Mbuf chain is too short");
66 : : }
67 : : } else {
68 : :
69 : 0 : 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++) {
73 : : QAT_DP_LOG(INFO,
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",
78 : : virt_addr[nr],
79 : : list->buffers[nr].len);
80 : : }
81 : : #endif
82 : : }
83 : :
84 : 0 : return res;
85 : : }
86 : :
87 : 0 : void qat_stats_get(struct qat_pci_device *dev,
88 : : struct qat_common_stats *stats,
89 : : enum qat_service_type service)
90 : : {
91 : : int i;
92 : : struct qat_qp **qp;
93 : :
94 [ # # # # ]: 0 : if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
95 : 0 : QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
96 : : stats, dev, service);
97 : 0 : return;
98 : : }
99 : :
100 : 0 : qp = dev->qps_in_use[service];
101 [ # # ]: 0 : for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
102 [ # # ]: 0 : if (qp[i] == NULL) {
103 : 0 : QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
104 : : service, i);
105 : 0 : continue;
106 : : }
107 : :
108 : 0 : stats->enqueued_count += qp[i]->stats.enqueued_count;
109 : 0 : stats->dequeued_count += qp[i]->stats.dequeued_count;
110 : 0 : stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
111 : 0 : stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
112 : 0 : stats->threshold_hit_count += qp[i]->stats.threshold_hit_count;
113 : 0 : QAT_LOG(DEBUG, "Threshold was used for qp %d %"PRIu64" times",
114 : : i, stats->threshold_hit_count);
115 : : }
116 : : }
117 : :
118 : 0 : void qat_stats_reset(struct qat_pci_device *dev,
119 : : enum qat_service_type service)
120 : : {
121 : : int i;
122 : : struct qat_qp **qp;
123 : :
124 [ # # ]: 0 : if (dev == NULL || service >= QAT_SERVICE_INVALID) {
125 : 0 : QAT_LOG(ERR, "invalid param: dev %p, service %d",
126 : : dev, service);
127 : 0 : return;
128 : : }
129 : :
130 : 0 : qp = dev->qps_in_use[service];
131 [ # # ]: 0 : for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
132 [ # # ]: 0 : if (qp[i] == NULL) {
133 : 0 : QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
134 : : service, i);
135 : 0 : continue;
136 : : }
137 : 0 : memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
138 : : }
139 : :
140 : 0 : QAT_LOG(DEBUG, "QAT: %d stats cleared", service);
141 : : }
|