From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E1875A0C45; Wed, 1 Sep 2021 16:47:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 705224116C; Wed, 1 Sep 2021 16:47:51 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 6284A41157 for ; Wed, 1 Sep 2021 16:47:49 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10094"; a="304344977" X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="304344977" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 07:47:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="466926366" Received: from silpixa00400308.ir.intel.com ([10.237.214.190]) by orsmga007.jf.intel.com with ESMTP; 01 Sep 2021 07:47:47 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, roy.fan.zhang@intel.com, Arek Kusztal Date: Wed, 1 Sep 2021 15:47:28 +0100 Message-Id: <20210901144729.26784-4-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210901144729.26784-1-arkadiuszx.kusztal@intel.com> References: <20210901144729.26784-1-arkadiuszx.kusztal@intel.com> Subject: [dpdk-dev] [PATCH 3/4] crypto/qat: move capabilities initialization to spec files X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Move capabilites static struct to particular generations into separate translation units that it can be isolated from each other. Signed-off-by: Arek Kusztal --- drivers/crypto/qat/dev/qat_sym_pmd_gen1.c | 27 ++++++++- drivers/crypto/qat/dev/qat_sym_pmd_gen2.c | 25 ++++++++- drivers/crypto/qat/dev/qat_sym_pmd_gen3.c | 26 ++++++++- drivers/crypto/qat/dev/qat_sym_pmd_gen4.c | 24 +++++++- drivers/crypto/qat/qat_sym_pmd.c | 68 +++++++---------------- drivers/crypto/qat/qat_sym_pmd.h | 19 ++++++- 6 files changed, 135 insertions(+), 54 deletions(-) diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c index 4a4dc9ab55..40ec77f846 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c @@ -8,6 +8,12 @@ #include "qat_sym_session.h" #include "qat_sym.h" #include "qat_sym_pmd_gen1.h" +#include "qat_sym_capabilities.h" + +static struct rte_cryptodev_capabilities qat_gen1_sym_capabilities[] = { + QAT_BASE_GEN1_SYM_CAPABILITIES, + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; int qat_sym_qp_setup_gen1(struct rte_cryptodev *dev, uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, @@ -49,7 +55,24 @@ struct rte_cryptodev_ops crypto_qat_gen1_ops = { .sym_configure_raw_dp_ctx = qat_sym_configure_dp_ctx, }; -RTE_INIT(qat_sym_pmd_gen1_init) +static struct +qat_capabilities_info get_capabilties_gen1( + struct qat_pci_device *qat_dev __rte_unused) { - QAT_CRYPTODEV_OPS[QAT_GEN1] = &crypto_qat_gen1_ops; + struct qat_capabilities_info capa_info; + + capa_info.data = qat_gen1_sym_capabilities; + capa_info.size = sizeof(qat_gen1_sym_capabilities); + return capa_info; } + +static struct +qat_sym_pmd_dev_ops qat_sym_pmd_ops_gen1 = { + .qat_sym_get_capabilities = get_capabilties_gen1, +}; + +RTE_INIT(qat_sym_pmd_gen1_init) +{ + QAT_CRYPTODEV_OPS[QAT_GEN1] = &crypto_qat_gen1_ops; + qat_sym_pmd_ops[QAT_GEN1] = &qat_sym_pmd_ops_gen1; +} \ No newline at end of file diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen2.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen2.c index 6344d7de13..18dfca3a84 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen2.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen2.c @@ -7,9 +7,16 @@ #include "qat_sym_pmd.h" #include "qat_sym_session.h" #include "qat_sym.h" +#include "qat_sym_capabilities.h" #define MIXED_CRYPTO_MIN_FW_VER 0x04090000 +static struct rte_cryptodev_capabilities qat_gen2_sym_capabilities[] = { + QAT_BASE_GEN1_SYM_CAPABILITIES, + QAT_EXTRA_GEN2_SYM_CAPABILITIES, + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + static int qat_sym_qp_setup_gen2(struct rte_cryptodev *dev, uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, int socket_id) @@ -74,7 +81,23 @@ struct rte_cryptodev_ops crypto_qat_gen2_ops = { .sym_configure_raw_dp_ctx = qat_sym_configure_dp_ctx, }; +static struct +qat_capabilities_info get_capabilties_gen2( + struct qat_pci_device *qat_dev __rte_unused) +{ + struct qat_capabilities_info capa_info; + capa_info.data = qat_gen2_sym_capabilities; + capa_info.size = sizeof(qat_gen2_sym_capabilities); + return capa_info; +} + +static struct +qat_sym_pmd_dev_ops qat_sym_pmd_ops_gen2 = { + .qat_sym_get_capabilities = get_capabilties_gen2, +}; + RTE_INIT(qat_sym_pmd_gen2) { - QAT_CRYPTODEV_OPS[QAT_GEN2] = &crypto_qat_gen2_ops; + QAT_CRYPTODEV_OPS[QAT_GEN2] = &crypto_qat_gen2_ops; + qat_sym_pmd_ops[QAT_GEN2] = &qat_sym_pmd_ops_gen2; } diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen3.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen3.c index f8488cd122..e914a09362 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen3.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen3.c @@ -9,6 +9,13 @@ #include "qat_sym.h" #include "qat_sym_pmd_gen1.h" +static struct rte_cryptodev_capabilities qat_gen3_sym_capabilities[] = { + QAT_BASE_GEN1_SYM_CAPABILITIES, + QAT_EXTRA_GEN2_SYM_CAPABILITIES, + QAT_EXTRA_GEN3_SYM_CAPABILITIES, + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + struct rte_cryptodev_ops crypto_qat_gen3_ops = { /* Device related operations */ @@ -33,7 +40,24 @@ struct rte_cryptodev_ops crypto_qat_gen3_ops = { .sym_configure_raw_dp_ctx = qat_sym_configure_dp_ctx, }; +static struct +qat_capabilities_info get_capabilties_gen3( + struct qat_pci_device *qat_dev __rte_unused) +{ + struct qat_capabilities_info capa_info; + capa_info.data = qat_gen3_sym_capabilities; + capa_info.size = sizeof(qat_gen3_sym_capabilities); + return capa_info; +} + +static struct +qat_sym_pmd_dev_ops qat_sym_pmd_ops_gen3 = { + .qat_sym_get_capabilities = get_capabilties_gen3, +}; + + RTE_INIT(qat_sym_pmd_gen3_init) { - QAT_CRYPTODEV_OPS[QAT_GEN3] = &crypto_qat_gen3_ops; + QAT_CRYPTODEV_OPS[QAT_GEN3] = &crypto_qat_gen3_ops; + qat_sym_pmd_ops[QAT_GEN3] = &qat_sym_pmd_ops_gen3; } diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c index 9470e78fb1..834ae88d38 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c @@ -8,6 +8,11 @@ #include "qat_sym_session.h" #include "qat_sym.h" +static struct rte_cryptodev_capabilities qat_gen4_sym_capabilities[] = { + QAT_BASE_GEN4_SYM_CAPABILITIES, + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + static int qat_select_valid_queue(struct qat_pci_device *qat_dev, int qp_id, enum qat_service_type service_type) @@ -76,7 +81,24 @@ struct rte_cryptodev_ops crypto_qat_gen4_ops = { .sym_configure_raw_dp_ctx = qat_sym_configure_dp_ctx, }; +static struct +qat_capabilities_info get_capabilties_gen4( + struct qat_pci_device *qat_dev __rte_unused) +{ + struct qat_capabilities_info capa_info; + + capa_info.data = qat_gen4_sym_capabilities; + capa_info.size = sizeof(qat_gen4_sym_capabilities); + return capa_info; +} + +static struct +qat_sym_pmd_dev_ops qat_sym_pmd_ops_gen4 = { + .qat_sym_get_capabilities = get_capabilties_gen4, +}; + RTE_INIT(qat_sym_pmd_gen4_init) { - QAT_CRYPTODEV_OPS[QAT_GEN4] = &crypto_qat_gen4_ops; + QAT_CRYPTODEV_OPS[QAT_GEN4] = &crypto_qat_gen4_ops; + qat_sym_pmd_ops[QAT_GEN4] = &qat_sym_pmd_ops_gen4; } diff --git a/drivers/crypto/qat/qat_sym_pmd.c b/drivers/crypto/qat/qat_sym_pmd.c index ee1a7e52bc..dc1dcbe34f 100644 --- a/drivers/crypto/qat/qat_sym_pmd.c +++ b/drivers/crypto/qat/qat_sym_pmd.c @@ -22,28 +22,9 @@ uint8_t qat_sym_driver_id; -static const struct rte_cryptodev_capabilities qat_gen1_sym_capabilities[] = { - QAT_BASE_GEN1_SYM_CAPABILITIES, - RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() -}; - -static const struct rte_cryptodev_capabilities qat_gen2_sym_capabilities[] = { - QAT_BASE_GEN1_SYM_CAPABILITIES, - QAT_EXTRA_GEN2_SYM_CAPABILITIES, - RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() -}; - -static const struct rte_cryptodev_capabilities qat_gen3_sym_capabilities[] = { - QAT_BASE_GEN1_SYM_CAPABILITIES, - QAT_EXTRA_GEN2_SYM_CAPABILITIES, - QAT_EXTRA_GEN3_SYM_CAPABILITIES, - RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() -}; - -static const struct rte_cryptodev_capabilities qat_gen4_sym_capabilities[] = { - QAT_BASE_GEN4_SYM_CAPABILITIES, - RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() -}; +struct qat_capabilities_info qat_sym_capabilities[QAT_DEV_GEN_NO]; +struct rte_cryptodev_ops *QAT_CRYPTODEV_OPS[QAT_DEV_GEN_NO]; +struct qat_sym_pmd_dev_ops *qat_sym_pmd_ops[QAT_DEV_GEN_NO]; #ifdef RTE_LIB_SECURITY static const struct rte_cryptodev_capabilities @@ -62,6 +43,16 @@ static const struct rte_security_capability qat_security_capabilities[] = { struct rte_cryptodev_ops *QAT_CRYPTODEV_OPS[QAT_DEV_GEN_NO]; +static struct +qat_capabilities_info qat_sym_get_capa_info( + struct qat_pci_device *qat_dev) +{ + struct qat_sym_pmd_dev_ops *ops = + qat_sym_pmd_ops[qat_dev->qat_dev_gen]; + + return ops->qat_sym_get_capabilities(qat_dev); +} + int qat_sym_dev_config(__rte_unused struct rte_cryptodev *dev, __rte_unused struct rte_cryptodev_config *config) { @@ -83,7 +74,7 @@ int qat_sym_dev_close(struct rte_cryptodev *dev) int i, ret; for (i = 0; i < dev->data->nb_queue_pairs; i++) { - ret = qat_sym_qp_release(dev, i); + ret = dev->dev_ops->queue_pair_release(dev, i); if (ret < 0) return ret; } @@ -171,7 +162,7 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, /* If qp is already in use free ring memory and qp metadata. */ if (*qp_addr != NULL) { - ret = qat_sym_qp_release(dev, qp_id); + ret = dev->dev_ops->queue_pair_release(dev, qp_id); if (ret < 0) return -EBUSY; } @@ -283,6 +274,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev, char capa_memz_name[RTE_CRYPTODEV_NAME_MAX_LEN]; struct rte_cryptodev *cryptodev; struct qat_sym_dev_private *internals; + struct qat_capabilities_info capa_info; const struct rte_cryptodev_capabilities *capabilities; uint64_t capa_size; @@ -370,30 +362,10 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev, internals->qat_dev = qat_pci_dev; internals->sym_dev_id = cryptodev->data->dev_id; - switch (qat_pci_dev->qat_dev_gen) { - case QAT_GEN1: - capabilities = qat_gen1_sym_capabilities; - capa_size = sizeof(qat_gen1_sym_capabilities); - break; - case QAT_GEN2: - capabilities = qat_gen2_sym_capabilities; - capa_size = sizeof(qat_gen2_sym_capabilities); - break; - case QAT_GEN3: - capabilities = qat_gen3_sym_capabilities; - capa_size = sizeof(qat_gen3_sym_capabilities); - break; - case QAT_GEN4: - capabilities = qat_gen4_sym_capabilities; - capa_size = sizeof(qat_gen4_sym_capabilities); - break; - default: - QAT_LOG(DEBUG, - "QAT gen %d capabilities unknown", - qat_pci_dev->qat_dev_gen); - ret = -(EINVAL); - goto error; - } + + capa_info = qat_sym_get_capa_info(qat_pci_dev); + capabilities = capa_info.data; + capa_size = capa_info.size; internals->capa_mz = rte_memzone_lookup(capa_memz_name); if (internals->capa_mz == NULL) { diff --git a/drivers/crypto/qat/qat_sym_pmd.h b/drivers/crypto/qat/qat_sym_pmd.h index f676a296e4..a03d2a0f04 100644 --- a/drivers/crypto/qat/qat_sym_pmd.h +++ b/drivers/crypto/qat/qat_sym_pmd.h @@ -26,7 +26,24 @@ extern uint8_t qat_sym_driver_id; -extern struct rte_cryptodev_ops *QAT_CRYPTODEV_OPS[]; +struct qat_capabilities_info { + struct rte_cryptodev_capabilities *data; + uint64_t size; +}; + +extern struct +rte_cryptodev_ops *QAT_CRYPTODEV_OPS[]; +extern struct +qat_capabilities_info qat_sym_capabilities[]; + +typedef struct qat_capabilities_info (*get_capabilities_info_t) + (struct qat_pci_device *qat_dev); + +struct qat_sym_pmd_dev_ops { + get_capabilities_info_t qat_sym_get_capabilities; +}; + +extern struct qat_sym_pmd_dev_ops *qat_sym_pmd_ops[]; /** private data structure for a QAT device. * This QAT device is a device offering only symmetric crypto service, -- 2.30.2