From 0a01574db43cb8ed62aa84484a7d3ddca1e74fa4 Mon Sep 17 00:00:00 2001 From: Fiona Trahe Date: Wed, 13 Jun 2018 14:13:46 +0200 Subject: [PATCH] crypto/qat: add device files This commit adds new qat_device file. Following objects were moved: qat_crypto.h => qat_device.h - struct qat_pmd_private - uint8_t cryptodev_qat_driver_id - int qat_crypto_sym_qp_release (EXTERN) - int qat_dev_config() - int qat_dev_start() - void qat_dev_stop() - int qat_dev_close() - void qat_dev_info_get() qat_crypto.c => qat_device.c - int qat_dev_config() - int qat_dev_start() - void qat_dev_stop() - int qat_dev_close() - void qat_dev_info_get() Signed-off-by: Arkadiusz Kusztal Signed-off-by: Fiona Trahe --- drivers/crypto/qat/Makefile | 1 + drivers/crypto/qat/meson.build | 3 +- drivers/crypto/qat/qat_crypto.c | 51 ----------------------------- drivers/crypto/qat/qat_crypto.h | 22 +------------ drivers/crypto/qat/qat_device.c | 57 +++++++++++++++++++++++++++++++++ drivers/crypto/qat/qat_device.h | 36 +++++++++++++++++++++ 6 files changed, 97 insertions(+), 73 deletions(-) create mode 100644 drivers/crypto/qat/qat_device.c create mode 100644 drivers/crypto/qat/qat_device.h diff --git a/drivers/crypto/qat/Makefile b/drivers/crypto/qat/Makefile index 07266a5e95..6bdd116796 100644 --- a/drivers/crypto/qat/Makefile +++ b/drivers/crypto/qat/Makefile @@ -22,6 +22,7 @@ LDLIBS += -lrte_pci -lrte_bus_pci # library source files SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat_crypto.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat_device.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat_qp.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += qat_adf/qat_algs_build_desc.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_QAT) += rte_qat_cryptodev.c diff --git a/drivers/crypto/qat/meson.build b/drivers/crypto/qat/meson.build index 006cd6557e..51630e31b4 100644 --- a/drivers/crypto/qat/meson.build +++ b/drivers/crypto/qat/meson.build @@ -7,7 +7,8 @@ if not dep.found() endif sources = files('qat_crypto.c', 'qat_qp.c', 'qat_adf/qat_algs_build_desc.c', - 'rte_qat_cryptodev.c') + 'rte_qat_cryptodev.c', + 'qat_device.c') includes += include_directories('qat_adf') deps += ['bus_pci'] ext_deps += dep diff --git a/drivers/crypto/qat/qat_crypto.c b/drivers/crypto/qat/qat_crypto.c index d9ce2a136d..928a504759 100644 --- a/drivers/crypto/qat/qat_crypto.c +++ b/drivers/crypto/qat/qat_crypto.c @@ -1609,57 +1609,6 @@ static inline uint32_t adf_modulo(uint32_t data, uint32_t shift) return data - mult; } -int qat_dev_config(__rte_unused struct rte_cryptodev *dev, - __rte_unused struct rte_cryptodev_config *config) -{ - PMD_INIT_FUNC_TRACE(); - return 0; -} - -int qat_dev_start(__rte_unused struct rte_cryptodev *dev) -{ - PMD_INIT_FUNC_TRACE(); - return 0; -} - -void qat_dev_stop(__rte_unused struct rte_cryptodev *dev) -{ - PMD_INIT_FUNC_TRACE(); -} - -int qat_dev_close(struct rte_cryptodev *dev) -{ - int i, ret; - - PMD_INIT_FUNC_TRACE(); - - for (i = 0; i < dev->data->nb_queue_pairs; i++) { - ret = qat_crypto_sym_qp_release(dev, i); - if (ret < 0) - return ret; - } - - return 0; -} - -void qat_dev_info_get(struct rte_cryptodev *dev, - struct rte_cryptodev_info *info) -{ - struct qat_pmd_private *internals = dev->data->dev_private; - - PMD_INIT_FUNC_TRACE(); - if (info != NULL) { - info->max_nb_queue_pairs = - ADF_NUM_SYM_QPS_PER_BUNDLE * - ADF_NUM_BUNDLES_PER_DEV; - info->feature_flags = dev->feature_flags; - info->capabilities = internals->qat_dev_capabilities; - info->sym.max_nb_sessions = internals->max_nb_sessions; - info->driver_id = cryptodev_qat_driver_id; - info->pci_dev = RTE_DEV_TO_PCI(dev->device); - } -} - void qat_crypto_sym_stats_get(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats) { diff --git a/drivers/crypto/qat/qat_crypto.h b/drivers/crypto/qat/qat_crypto.h index 5190d25e56..46f03ccdee 100644 --- a/drivers/crypto/qat/qat_crypto.h +++ b/drivers/crypto/qat/qat_crypto.h @@ -9,6 +9,7 @@ #include #include "qat_common.h" +#include "qat_device.h" #include "qat_crypto_capabilities.h" /* @@ -64,27 +65,6 @@ struct qat_qp { enum qat_device_gen qat_dev_gen; } __rte_cache_aligned; -/** private data structure for each QAT device */ -struct qat_pmd_private { - unsigned max_nb_queue_pairs; - /**< Max number of queue pairs supported by device */ - unsigned max_nb_sessions; - /**< Max number of sessions supported by device */ - enum qat_device_gen qat_dev_gen; - /**< QAT device generation */ - const struct rte_cryptodev_capabilities *qat_dev_capabilities; -}; - -extern uint8_t cryptodev_qat_driver_id; - -int qat_dev_config(struct rte_cryptodev *dev, - struct rte_cryptodev_config *config); -int qat_dev_start(struct rte_cryptodev *dev); -void qat_dev_stop(struct rte_cryptodev *dev); -int qat_dev_close(struct rte_cryptodev *dev); -void qat_dev_info_get(struct rte_cryptodev *dev, - struct rte_cryptodev_info *info); - void qat_crypto_sym_stats_get(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats); void qat_crypto_sym_stats_reset(struct rte_cryptodev *dev); diff --git a/drivers/crypto/qat/qat_device.c b/drivers/crypto/qat/qat_device.c new file mode 100644 index 0000000000..c2bf9b7a76 --- /dev/null +++ b/drivers/crypto/qat/qat_device.c @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ + +#include "qat_device.h" +#include "adf_transport_access_macros.h" + +int qat_dev_config(__rte_unused struct rte_cryptodev *dev, + __rte_unused struct rte_cryptodev_config *config) +{ + PMD_INIT_FUNC_TRACE(); + return 0; +} + +int qat_dev_start(__rte_unused struct rte_cryptodev *dev) +{ + PMD_INIT_FUNC_TRACE(); + return 0; +} + +void qat_dev_stop(__rte_unused struct rte_cryptodev *dev) +{ + PMD_INIT_FUNC_TRACE(); +} + +int qat_dev_close(struct rte_cryptodev *dev) +{ + int i, ret; + + PMD_INIT_FUNC_TRACE(); + + for (i = 0; i < dev->data->nb_queue_pairs; i++) { + ret = qat_crypto_sym_qp_release(dev, i); + if (ret < 0) + return ret; + } + + return 0; +} + +void qat_dev_info_get(struct rte_cryptodev *dev, + struct rte_cryptodev_info *info) +{ + struct qat_pmd_private *internals = dev->data->dev_private; + + PMD_INIT_FUNC_TRACE(); + if (info != NULL) { + info->max_nb_queue_pairs = + ADF_NUM_SYM_QPS_PER_BUNDLE * + ADF_NUM_BUNDLES_PER_DEV; + info->feature_flags = dev->feature_flags; + info->capabilities = internals->qat_dev_capabilities; + info->sym.max_nb_sessions = internals->max_nb_sessions; + info->driver_id = cryptodev_qat_driver_id; + info->pci_dev = RTE_DEV_TO_PCI(dev->device); + } +} diff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h new file mode 100644 index 0000000000..5c48fdb936 --- /dev/null +++ b/drivers/crypto/qat/qat_device.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Intel Corporation + */ +#ifndef _QAT_DEVICE_H_ +#define _QAT_DEVICE_H_ + +#include +#include +#include "qat_common.h" +#include "qat_logs.h" + +extern uint8_t cryptodev_qat_driver_id; + +extern int qat_crypto_sym_qp_release(struct rte_cryptodev *dev, + uint16_t queue_pair_id); + +/** private data structure for each QAT device */ +struct qat_pmd_private { + unsigned int max_nb_queue_pairs; + /**< Max number of queue pairs supported by device */ + unsigned int max_nb_sessions; + /**< Max number of sessions supported by device */ + enum qat_device_gen qat_dev_gen; + /**< QAT device generation */ + const struct rte_cryptodev_capabilities *qat_dev_capabilities; +}; + +int qat_dev_config(struct rte_cryptodev *dev, + struct rte_cryptodev_config *config); +int qat_dev_start(struct rte_cryptodev *dev); +void qat_dev_stop(struct rte_cryptodev *dev); +int qat_dev_close(struct rte_cryptodev *dev); +void qat_dev_info_get(struct rte_cryptodev *dev, + struct rte_cryptodev_info *info); + +#endif /* _QAT_DEVICE_H_ */ -- 2.20.1