2018-06-13 12:14:01 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2018 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qat_common.h"
|
2018-06-13 12:14:07 +00:00
|
|
|
#include "qat_device.h"
|
2018-06-13 12:14:01 +00:00
|
|
|
#include "qat_logs.h"
|
|
|
|
|
|
|
|
int
|
2018-08-02 15:09:26 +00:00
|
|
|
qat_sgl_fill_array(struct rte_mbuf *buf, int64_t offset,
|
2018-07-23 13:05:35 +00:00
|
|
|
void *list_in, uint32_t data_len,
|
|
|
|
const uint16_t max_segs)
|
2018-06-13 12:14:01 +00:00
|
|
|
{
|
2018-08-02 15:09:26 +00:00
|
|
|
int res = -EINVAL;
|
|
|
|
uint32_t buf_len, nr;
|
2018-07-23 13:05:35 +00:00
|
|
|
struct qat_sgl *list = (struct qat_sgl *)list_in;
|
|
|
|
#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
|
|
|
|
uint8_t *virt_addr[max_segs];
|
|
|
|
#endif
|
2018-06-13 12:14:01 +00:00
|
|
|
|
2018-08-02 15:09:26 +00:00
|
|
|
for (nr = buf_len = 0; buf && nr < max_segs; buf = buf->next) {
|
|
|
|
if (offset >= rte_pktmbuf_data_len(buf)) {
|
|
|
|
offset -= rte_pktmbuf_data_len(buf);
|
|
|
|
continue;
|
2018-06-13 12:14:01 +00:00
|
|
|
}
|
|
|
|
|
2018-08-02 15:09:26 +00:00
|
|
|
list->buffers[nr].len = rte_pktmbuf_data_len(buf) - offset;
|
2018-06-13 12:14:01 +00:00
|
|
|
list->buffers[nr].resrvd = 0;
|
2018-08-02 15:09:26 +00:00
|
|
|
list->buffers[nr].addr = rte_pktmbuf_iova_offset(buf, offset);
|
|
|
|
|
2018-07-23 13:05:35 +00:00
|
|
|
#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
|
2018-08-02 15:09:26 +00:00
|
|
|
virt_addr[nr] = rte_pktmbuf_mtod_offset(buf, uint8_t*, offset);
|
2018-07-23 13:05:35 +00:00
|
|
|
#endif
|
2018-08-02 15:09:26 +00:00
|
|
|
offset = 0;
|
2018-06-13 12:14:01 +00:00
|
|
|
buf_len += list->buffers[nr].len;
|
|
|
|
|
2018-07-23 13:05:35 +00:00
|
|
|
if (buf_len >= data_len) {
|
2018-08-02 15:09:26 +00:00
|
|
|
list->buffers[nr].len -= buf_len - data_len;
|
|
|
|
res = 0;
|
|
|
|
break;
|
2018-06-13 12:14:01 +00:00
|
|
|
}
|
|
|
|
++nr;
|
|
|
|
}
|
|
|
|
|
2018-08-02 15:09:26 +00:00
|
|
|
if (unlikely(res != 0)) {
|
|
|
|
if (nr == max_segs) {
|
|
|
|
QAT_DP_LOG(ERR, "Exceeded max segments in QAT SGL (%u)",
|
|
|
|
max_segs);
|
|
|
|
} else {
|
|
|
|
QAT_DP_LOG(ERR, "Mbuf chain is too short");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
list->num_bufs = ++nr;
|
2018-07-23 13:05:35 +00:00
|
|
|
#if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
|
|
|
|
QAT_DP_LOG(INFO, "SGL with %d buffers:", list->num_bufs);
|
2018-08-02 15:09:26 +00:00
|
|
|
for (nr = 0; nr < list->num_bufs; nr++) {
|
2018-07-23 13:05:35 +00:00
|
|
|
QAT_DP_LOG(INFO,
|
|
|
|
"QAT SGL buf %d, len = %d, iova = 0x%012"PRIx64,
|
2018-08-02 15:09:26 +00:00
|
|
|
nr, list->buffers[nr].len,
|
|
|
|
list->buffers[nr].addr);
|
2018-07-23 13:05:35 +00:00
|
|
|
QAT_DP_HEXDUMP_LOG(DEBUG, "qat SGL",
|
2018-08-02 15:09:26 +00:00
|
|
|
virt_addr[nr],
|
|
|
|
list->buffers[nr].len);
|
2018-07-23 13:05:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-08-02 15:09:26 +00:00
|
|
|
}
|
2018-07-23 13:05:35 +00:00
|
|
|
|
2018-08-02 15:09:26 +00:00
|
|
|
return res;
|
2018-06-13 12:14:01 +00:00
|
|
|
}
|
2018-06-13 12:14:07 +00:00
|
|
|
|
|
|
|
void qat_stats_get(struct qat_pci_device *dev,
|
|
|
|
struct qat_common_stats *stats,
|
|
|
|
enum qat_service_type service)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct qat_qp **qp;
|
|
|
|
|
|
|
|
if (stats == NULL || dev == NULL || service >= QAT_SERVICE_INVALID) {
|
2018-06-14 11:03:04 +00:00
|
|
|
QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
|
2018-06-13 12:14:07 +00:00
|
|
|
stats, dev, service);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp = dev->qps_in_use[service];
|
2018-06-13 12:14:09 +00:00
|
|
|
for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
|
2018-06-13 12:14:07 +00:00
|
|
|
if (qp[i] == NULL) {
|
2018-06-14 11:03:04 +00:00
|
|
|
QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
|
2018-06-13 12:14:07 +00:00
|
|
|
service, i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
stats->enqueued_count += qp[i]->stats.enqueued_count;
|
|
|
|
stats->dequeued_count += qp[i]->stats.dequeued_count;
|
|
|
|
stats->enqueue_err_count += qp[i]->stats.enqueue_err_count;
|
|
|
|
stats->dequeue_err_count += qp[i]->stats.dequeue_err_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void qat_stats_reset(struct qat_pci_device *dev,
|
|
|
|
enum qat_service_type service)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct qat_qp **qp;
|
|
|
|
|
|
|
|
if (dev == NULL || service >= QAT_SERVICE_INVALID) {
|
2018-06-14 11:03:04 +00:00
|
|
|
QAT_LOG(ERR, "invalid param: dev %p, service %d",
|
2018-06-13 12:14:07 +00:00
|
|
|
dev, service);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp = dev->qps_in_use[service];
|
2018-06-13 12:14:09 +00:00
|
|
|
for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
|
2018-06-13 12:14:07 +00:00
|
|
|
if (qp[i] == NULL) {
|
2018-06-14 11:03:04 +00:00
|
|
|
QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
|
2018-06-13 12:14:07 +00:00
|
|
|
service, i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
|
|
|
|
}
|
|
|
|
|
2018-06-14 11:03:04 +00:00
|
|
|
QAT_LOG(DEBUG, "QAT: %d stats cleared", service);
|
2018-06-13 12:14:07 +00:00
|
|
|
}
|