numam-dpdk/drivers/common/qat/qat_common.c
Tomasz Jozwiak 98c4a35c73 crypto/qat: move common qat files to common dir
-  moved common qat files to common/qat dir.
  -  changed common/qat/Makefile, common/qat/meson.build,
     drivers/Makefile, crypto/Makefile
     to add possibility of using new files locations
  -  added README file into crypto/qat to clarify where
     the build is made from
  -  updated MAINTAINERS file

Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
2018-07-11 00:55:30 +02:00

108 lines
2.4 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2018 Intel Corporation
*/
#include "qat_common.h"
#include "qat_device.h"
#include "qat_logs.h"
int
qat_sgl_fill_array(struct rte_mbuf *buf, uint64_t buf_start,
struct qat_sgl *list, uint32_t data_len)
{
int nr = 1;
uint32_t buf_len = rte_pktmbuf_iova(buf) -
buf_start + rte_pktmbuf_data_len(buf);
list->buffers[0].addr = buf_start;
list->buffers[0].resrvd = 0;
list->buffers[0].len = buf_len;
if (data_len <= buf_len) {
list->num_bufs = nr;
list->buffers[0].len = data_len;
return 0;
}
buf = buf->next;
while (buf) {
if (unlikely(nr == QAT_SGL_MAX_NUMBER)) {
QAT_LOG(ERR,
"QAT PMD exceeded size of QAT SGL entry(%u)",
QAT_SGL_MAX_NUMBER);
return -EINVAL;
}
list->buffers[nr].len = rte_pktmbuf_data_len(buf);
list->buffers[nr].resrvd = 0;
list->buffers[nr].addr = rte_pktmbuf_iova(buf);
buf_len += list->buffers[nr].len;
buf = buf->next;
if (buf_len > data_len) {
list->buffers[nr].len -=
buf_len - data_len;
buf = NULL;
}
++nr;
}
list->num_bufs = nr;
return 0;
}
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) {
QAT_LOG(ERR, "invalid param: stats %p, dev %p, service %d",
stats, dev, service);
return;
}
qp = dev->qps_in_use[service];
for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
if (qp[i] == NULL) {
QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
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) {
QAT_LOG(ERR, "invalid param: dev %p, service %d",
dev, service);
return;
}
qp = dev->qps_in_use[service];
for (i = 0; i < ADF_MAX_QPS_ON_ANY_SERVICE; i++) {
if (qp[i] == NULL) {
QAT_LOG(DEBUG, "Service %d Uninitialised qp %d",
service, i);
continue;
}
memset(&(qp[i]->stats), 0, sizeof(qp[i]->stats));
}
QAT_LOG(DEBUG, "QAT: %d stats cleared", service);
}