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 5F21CA0C45; Wed, 1 Sep 2021 16:48:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2CE8C4116B; Wed, 1 Sep 2021 16:47:54 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id F39C84117B for ; Wed, 1 Sep 2021 16:47:52 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10094"; a="304344984" X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="304344984" 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:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="466926383" Received: from silpixa00400308.ir.intel.com ([10.237.214.190]) by orsmga007.jf.intel.com with ESMTP; 01 Sep 2021 07:47:50 -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:29 +0100 Message-Id: <20210901144729.26784-5-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 4/4] common/qat: add extra data to qat pci dev 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" Add private data to qat_pci_device struct that will be visible only by specific generation it belongs to. Signed-off-by: Arek Kusztal --- drivers/common/qat/dev/qat_dev_gen1.c | 7 +++ drivers/common/qat/dev/qat_dev_gen1.h | 3 ++ drivers/common/qat/dev/qat_dev_gen2.c | 1 + drivers/common/qat/dev/qat_dev_gen3.c | 1 + drivers/common/qat/dev/qat_dev_gen4.c | 31 ++++++++++- drivers/common/qat/dev/qat_dev_gen4.h | 18 +++++++ drivers/common/qat/meson.build | 2 + drivers/common/qat/qat_device.c | 66 +++++++++++++++-------- drivers/common/qat/qat_device.h | 10 ++-- drivers/common/qat/qat_qp.h | 9 ---- drivers/crypto/qat/dev/qat_sym_pmd_gen4.c | 7 ++- 11 files changed, 113 insertions(+), 42 deletions(-) create mode 100644 drivers/common/qat/dev/qat_dev_gen4.h diff --git a/drivers/common/qat/dev/qat_dev_gen1.c b/drivers/common/qat/dev/qat_dev_gen1.c index 4d60c2a051..3c7a558959 100644 --- a/drivers/common/qat/dev/qat_dev_gen1.c +++ b/drivers/common/qat/dev/qat_dev_gen1.c @@ -227,11 +227,18 @@ qat_dev_read_config_gen1(struct qat_pci_device *qat_dev __rte_unused) return 0; } +int +qat_dev_get_extra_size_gen1(void) +{ + return 0; +} + static struct qat_dev_hw_spec_funcs qat_dev_hw_spec_gen1 = { .qat_dev_reset_ring_pairs = qat_reset_ring_pairs_gen1, .qat_dev_get_transport_bar = qat_dev_get_transport_bar_gen1, .qat_dev_get_misc_bar = qat_dev_get_misc_bar_gen1, .qat_dev_read_config = qat_dev_read_config_gen1, + .qat_dev_get_extra_size = qat_dev_get_extra_size_gen1, }; RTE_INIT(qat_dev_gen_gen1_init) diff --git a/drivers/common/qat/dev/qat_dev_gen1.h b/drivers/common/qat/dev/qat_dev_gen1.h index 9bf4fcf01b..ec0af94655 100644 --- a/drivers/common/qat/dev/qat_dev_gen1.h +++ b/drivers/common/qat/dev/qat_dev_gen1.h @@ -13,6 +13,9 @@ extern const struct qat_qp_hw_data qat_gen1_qps[QAT_MAX_SERVICES] [ADF_MAX_QPS_ON_ANY_SERVICE]; +int +qat_dev_get_extra_size_gen1(void); + int qat_qp_rings_per_service_gen1(struct qat_pci_device *qat_dev, enum qat_service_type service); diff --git a/drivers/common/qat/dev/qat_dev_gen2.c b/drivers/common/qat/dev/qat_dev_gen2.c index ad1b643e00..856463c06f 100644 --- a/drivers/common/qat/dev/qat_dev_gen2.c +++ b/drivers/common/qat/dev/qat_dev_gen2.c @@ -25,6 +25,7 @@ static struct qat_dev_hw_spec_funcs qat_dev_hw_spec_gen2 = { .qat_dev_get_transport_bar = qat_dev_get_transport_bar_gen1, .qat_dev_get_misc_bar = qat_dev_get_misc_bar_gen1, .qat_dev_read_config = qat_dev_read_config_gen1, + .qat_dev_get_extra_size = qat_dev_get_extra_size_gen1, }; RTE_INIT(qat_dev_gen_gen2_init) diff --git a/drivers/common/qat/dev/qat_dev_gen3.c b/drivers/common/qat/dev/qat_dev_gen3.c index 407d21576b..237712f1ef 100644 --- a/drivers/common/qat/dev/qat_dev_gen3.c +++ b/drivers/common/qat/dev/qat_dev_gen3.c @@ -63,6 +63,7 @@ static struct qat_dev_hw_spec_funcs qat_dev_hw_spec_gen3 = { .qat_dev_get_transport_bar = qat_dev_get_transport_bar_gen1, .qat_dev_get_misc_bar = qat_dev_get_misc_bar_gen1, .qat_dev_read_config = qat_dev_read_config_gen1, + .qat_dev_get_extra_size = qat_dev_get_extra_size_gen1, }; RTE_INIT(qat_dev_gen_gen3_init) diff --git a/drivers/common/qat/dev/qat_dev_gen4.c b/drivers/common/qat/dev/qat_dev_gen4.c index 6394e17dde..aecdedf375 100644 --- a/drivers/common/qat/dev/qat_dev_gen4.c +++ b/drivers/common/qat/dev/qat_dev_gen4.c @@ -10,9 +10,27 @@ #include "adf_transport_access_macros_gen4vf.h" #include "adf_pf2vf_msg.h" #include "qat_pf2vf.h" +#include "qat_dev_gen4.h" #include +struct qat_dev_gen4_extra { + struct qat_qp_hw_data qp_gen4_data[QAT_GEN4_BUNDLE_NUM] + [QAT_GEN4_QPS_PER_BUNDLE_NUM]; +}; + +enum qat_service_type qat_dev4_get_qp_serv( + struct qat_dev_gen4_extra *dev_extra, int ring_pair) +{ + return dev_extra->qp_gen4_data[ring_pair][0].service_type; +} + +const struct qat_qp_hw_data *qat_dev4_get_hw( + struct qat_dev_gen4_extra *dev_extra, int ring_pair) +{ + return &dev_extra->qp_gen4_data[ring_pair][0]; +} + static struct qat_pf2vf_dev qat_pf2vf_gen4 = { .pf2vf_offset = ADF_4XXXIOV_PF2VM_OFFSET, .vf2pf_offset = ADF_4XXXIOV_VM2PF_OFFSET, @@ -38,10 +56,11 @@ qat_qp_rings_per_service_gen4(struct qat_pci_device *qat_dev, enum qat_service_type service) { int i = 0, count = 0, max_ops_per_srv = 0; + struct qat_dev_gen4_extra *dev_extra = qat_dev->dev_private; max_ops_per_srv = QAT_GEN4_BUNDLE_NUM; for (i = 0, count = 0; i < max_ops_per_srv; i++) - if (qat_dev->qp_gen4_data[i][0].service_type == service) + if (dev_extra->qp_gen4_data[i][0].service_type == service) count++; return count; } @@ -51,12 +70,13 @@ qat_dev_read_config_gen4(struct qat_pci_device *qat_dev) { int i = 0; uint16_t svc = 0; + struct qat_dev_gen4_extra *dev_extra = qat_dev->dev_private; if (qat_query_svc(qat_dev, (uint8_t *)&svc)) return -EFAULT; for (; i < QAT_GEN4_BUNDLE_NUM; i++) { struct qat_qp_hw_data *hw_data = - &qat_dev->qp_gen4_data[i][0]; + &dev_extra->qp_gen4_data[i][0]; uint8_t svc1 = (svc >> (3 * i)) & 0x7; enum qat_service_type service_type = QAT_SERVICE_INVALID; @@ -239,11 +259,18 @@ qat_dev_get_misc_bar_gen4( return 0; } +static int +qat_dev_get_extra_size_gen4(void) +{ + return sizeof(struct qat_dev_gen4_extra); +} + static struct qat_dev_hw_spec_funcs qat_dev_hw_spec_gen4 = { .qat_dev_reset_ring_pairs = qat_reset_ring_pairs_gen4, .qat_dev_get_transport_bar = qat_dev_get_transport_bar_gen4, .qat_dev_get_misc_bar = qat_dev_get_misc_bar_gen4, .qat_dev_read_config = qat_dev_read_config_gen4, + .qat_dev_get_extra_size = qat_dev_get_extra_size_gen4, }; RTE_INIT(qat_dev_gen_4_init) diff --git a/drivers/common/qat/dev/qat_dev_gen4.h b/drivers/common/qat/dev/qat_dev_gen4.h new file mode 100644 index 0000000000..f588354603 --- /dev/null +++ b/drivers/common/qat/dev/qat_dev_gen4.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#ifndef _QAT_DEV_GEN_H_ +#define _QAT_DEV_GEN_H_ + +#include + +struct qat_dev_gen4_extra; + +enum qat_service_type qat_dev4_get_qp_serv( + struct qat_dev_gen4_extra *dev_extra, int ring_pair); + +const struct qat_qp_hw_data *qat_dev4_get_hw( + struct qat_dev_gen4_extra *dev_extra, int ring_pair); + +#endif diff --git a/drivers/common/qat/meson.build b/drivers/common/qat/meson.build index de54004b4c..6c5db48944 100644 --- a/drivers/common/qat/meson.build +++ b/drivers/common/qat/meson.build @@ -9,6 +9,7 @@ endif qat_crypto = true qat_crypto_path = 'crypto/qat' +qat_devs_path = 'dev' qat_crypto_relpath = '../../' + qat_crypto_path qat_compress = true qat_compress_path = 'compress/qat' @@ -59,6 +60,7 @@ includes += include_directories( 'qat_adf', qat_crypto_relpath, qat_compress_relpath, + qat_devs_path ) if qat_compress diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index 030624b46d..4a33a62824 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -51,6 +51,16 @@ static const struct rte_pci_id pci_id_qat_map[] = { {.device_id = 0}, }; +static int +qat_pci_get_extra_size(enum qat_device_gen qat_dev_gen) +{ + struct qat_dev_hw_spec_funcs *ops_hw = + qat_dev_hw_spec[qat_dev_gen]; + RTE_FUNC_PTR_OR_ERR_RET(ops_hw->qat_dev_get_extra_size, + -ENOTSUP); + return ops_hw->qat_dev_get_extra_size(); +} + static struct qat_pci_device * qat_pci_get_named_dev(const char *name) { @@ -156,15 +166,38 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev, struct qat_dev_cmd_param *qat_dev_cmd_param) { struct qat_pci_device *qat_dev; + enum qat_device_gen qat_dev_gen; uint8_t qat_dev_id = 0; char name[QAT_DEV_NAME_MAX_LEN]; struct rte_devargs *devargs = pci_dev->device.devargs; struct qat_dev_hw_spec_funcs *ops_hw = NULL; struct rte_mem_resource *mem_resource; + int extra_size; rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat"); + switch (pci_dev->id.device_id) { + case 0x0443: + qat_dev_gen = QAT_GEN1; + break; + case 0x37c9: + case 0x19e3: + case 0x6f55: + case 0x18ef: + qat_dev_gen = QAT_GEN2; + break; + case 0x18a1: + qat_dev_gen = QAT_GEN3; + break; + case 0x4941: + qat_dev_gen = QAT_GEN4; + break; + default: + QAT_LOG(ERR, "Invalid dev_id, can't determine generation"); + return NULL; + } + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { const struct rte_memzone *mz = rte_memzone_lookup(name); @@ -194,9 +227,15 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev, QAT_LOG(ERR, "Reached maximum number of QAT devices"); return NULL; } - + extra_size = qat_pci_get_extra_size(qat_dev_gen); + if (extra_size < 0) { + QAT_LOG(ERR, "Error when acquiring extra size len QAT_%d", + qat_dev_id); + return NULL; + } qat_pci_devs[qat_dev_id].mz = rte_memzone_reserve(name, - sizeof(struct qat_pci_device), + sizeof(struct qat_pci_device) + + extra_size, rte_socket_id(), 0); if (qat_pci_devs[qat_dev_id].mz == NULL) { @@ -207,30 +246,11 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev, qat_dev = qat_pci_devs[qat_dev_id].mz->addr; memset(qat_dev, 0, sizeof(*qat_dev)); + qat_dev->dev_private = qat_dev + 1; strlcpy(qat_dev->name, name, QAT_DEV_NAME_MAX_LEN); qat_dev->qat_dev_id = qat_dev_id; qat_pci_devs[qat_dev_id].pci_dev = pci_dev; - switch (pci_dev->id.device_id) { - case 0x0443: - qat_dev->qat_dev_gen = QAT_GEN1; - break; - case 0x37c9: - case 0x19e3: - case 0x6f55: - case 0x18ef: - qat_dev->qat_dev_gen = QAT_GEN2; - break; - case 0x18a1: - qat_dev->qat_dev_gen = QAT_GEN3; - break; - case 0x4941: - qat_dev->qat_dev_gen = QAT_GEN4; - break; - default: - QAT_LOG(ERR, "Invalid dev_id, can't determine generation"); - rte_memzone_free(qat_pci_devs[qat_dev->qat_dev_id].mz); - return NULL; - } + qat_dev->qat_dev_gen = qat_dev_gen; ops_hw = qat_dev_hw_spec[qat_dev->qat_dev_gen]; RTE_FUNC_PTR_OR_ERR_RET(ops_hw->qat_dev_get_misc_bar, NULL); diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h index 531aa663ca..c9923cdc54 100644 --- a/drivers/common/qat/qat_device.h +++ b/drivers/common/qat/qat_device.h @@ -29,12 +29,14 @@ typedef int (*qat_dev_get_misc_bar_t) (struct rte_mem_resource **, struct rte_pci_device *); typedef int (*qat_dev_read_config_t) (struct qat_pci_device *); +typedef int (*qat_dev_get_extra_size_t)(void); struct qat_dev_hw_spec_funcs { qat_dev_reset_ring_pairs_t qat_dev_reset_ring_pairs; qat_dev_get_transport_bar_t qat_dev_get_transport_bar; qat_dev_get_misc_bar_t qat_dev_get_misc_bar; qat_dev_read_config_t qat_dev_read_config; + qat_dev_get_extra_size_t qat_dev_get_extra_size; }; extern struct qat_dev_hw_spec_funcs *qat_dev_hw_spec[]; @@ -75,9 +77,6 @@ struct qat_device_info { */ }; -extern const struct qat_qp_hw_data qat_gen1_qps[][ADF_MAX_QPS_ON_ANY_SERVICE]; -extern const struct qat_qp_hw_data qat_gen3_qps[][ADF_MAX_QPS_ON_ANY_SERVICE]; - extern struct qat_device_info qat_pci_devs[]; struct qat_sym_dev_private; @@ -126,11 +125,10 @@ struct qat_pci_device { /* Data relating to compression service */ struct qat_comp_dev_private *comp_dev; /**< link back to compressdev private data */ - struct qat_qp_hw_data qp_gen4_data[QAT_GEN4_BUNDLE_NUM] - [QAT_GEN4_QPS_PER_BUNDLE_NUM]; - /**< Data of ring configuration on gen4 */ void *misc_bar_io_addr; /**< Address of misc bar */ + void *dev_private; + /**< Address per generation */ }; struct qat_gen_hw_data { diff --git a/drivers/common/qat/qat_qp.h b/drivers/common/qat/qat_qp.h index ffba3a3615..4be54de2d9 100644 --- a/drivers/common/qat/qat_qp.h +++ b/drivers/common/qat/qat_qp.h @@ -38,15 +38,6 @@ struct qat_qp_hw_data { uint16_t rx_msg_size; }; -/** - * Structure with data needed for creation of queue pair on gen4. - */ -struct qat_qp_gen4_data { - struct qat_qp_hw_data qat_qp_hw_data; - uint8_t reserved; - uint8_t valid; -}; - /** * Structure with data needed for creation of queue pair. */ diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c index 834ae88d38..f8f795301c 100644 --- a/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c +++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen4.c @@ -7,6 +7,7 @@ #include "qat_sym_pmd.h" #include "qat_sym_session.h" #include "qat_sym.h" +#include "qat_dev_gen4.h" static struct rte_cryptodev_capabilities qat_gen4_sym_capabilities[] = { QAT_BASE_GEN4_SYM_CAPABILITIES, @@ -18,9 +19,10 @@ qat_select_valid_queue(struct qat_pci_device *qat_dev, int qp_id, enum qat_service_type service_type) { int i = 0, valid_qps = 0; + struct qat_dev_gen4_extra *dev_extra = qat_dev->dev_private; for (; i < QAT_GEN4_BUNDLE_NUM; i++) { - if (qat_dev->qp_gen4_data[i][0].service_type == + if (qat_dev4_get_qp_serv(dev_extra, i) == service_type) { if (valid_qps == qp_id) return i; @@ -39,6 +41,7 @@ static int qat_sym_qp_setup_gen4(struct rte_cryptodev *dev, uint16_t qp_id, struct qat_qp_config qat_qp_conf = { }; struct qat_sym_dev_private *qat_sym_private = dev->data->dev_private; struct qat_pci_device *qat_dev = qat_sym_private->qat_dev; + struct qat_dev_gen4_extra *dev_extra = qat_dev->dev_private; ring_pair = qat_select_valid_queue(qat_sym_private->qat_dev, qp_id, @@ -50,7 +53,7 @@ static int qat_sym_qp_setup_gen4(struct rte_cryptodev *dev, uint16_t qp_id, return -EINVAL; } qat_qp_conf.hw = - &qat_dev->qp_gen4_data[ring_pair][0]; + qat_dev4_get_hw(dev_extra, ring_pair); ret = qat_sym_qp_setup(dev, qp_id, qp_conf, qat_qp_conf, socket_id); -- 2.30.2