From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6E6281CF61 for ; Fri, 6 Apr 2018 20:52:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2018 11:52:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,416,1517904000"; d="scan'208";a="189275798" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by orsmga004.jf.intel.com with ESMTP; 06 Apr 2018 11:52:47 -0700 From: Fiona Trahe To: dev@dpdk.org, pablo.de.lara.guarch@intel.com Cc: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com Date: Fri, 6 Apr 2018 19:52:03 +0100 Message-Id: <1523040732-3290-22-git-send-email-fiona.trahe@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> References: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> Subject: [dpdk-dev] [PATCH 21/30] crypto/qat: move to using new device structure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Apr 2018 18:52:49 -0000 Struct qat_pmd_private held the data needed by cryptodev, common code now gets most data from struct qat_pci_device instead. qat_pmd_private is trimmed to hold only sym crypto data and renamed qat_sym_private to reflect its usage. Specifically - remove max_nb_queue_pairs from qat_pmd_private, get from qp_hw_data - remove max_nb_sesssions from qat_pmd_private as not needed. - remove qat_gen from qat_pmd_private, get from qat_pci_device instead. - use qat_pci_device throughout common code instead of qat_pmd_private - rename qat_pmd_private to qat_sym_dev_private - this now holds only sym-specific data for the cryptodev API - extend pci device name to _qat for clarity, was just - update qp mem and cookiepool names to reflect the appropriate device, service and qp. - rename qat_dev_info_get() to qat_sym_dev_info_get() as mostly sym, not enough common info to warrant a generic fn. Signed-off-by: Fiona Trahe --- drivers/crypto/qat/qat_device.c | 17 +++++++++------- drivers/crypto/qat/qat_device.h | 37 ++++++++++++++-------------------- drivers/crypto/qat/qat_qp.c | 28 +++++++++++++------------ drivers/crypto/qat/qat_qp.h | 4 ++-- drivers/crypto/qat/qat_sym.c | 11 +++++----- drivers/crypto/qat/qat_sym.h | 8 -------- drivers/crypto/qat/qat_sym_session.c | 8 ++++---- drivers/crypto/qat/rte_qat_cryptodev.c | 32 ++++++++++++++--------------- 8 files changed, 66 insertions(+), 79 deletions(-) diff --git a/drivers/crypto/qat/qat_device.c b/drivers/crypto/qat/qat_device.c index 75af1e8bc..8ad3162e1 100644 --- a/drivers/crypto/qat/qat_device.c +++ b/drivers/crypto/qat/qat_device.c @@ -57,12 +57,12 @@ int qat_dev_close(struct rte_cryptodev *dev) return 0; } -void qat_dev_info_get(struct rte_cryptodev *dev, +void qat_sym_dev_info_get(struct rte_cryptodev *dev, struct rte_cryptodev_info *info) { - struct qat_pmd_private *internals = dev->data->dev_private; + struct qat_sym_dev_private *internals = dev->data->dev_private; const struct qat_qp_hw_data *sym_hw_qps = - qp_gen_config[internals->qat_dev_gen] + qp_gen_config[internals->qat_dev->qat_dev_gen] .qp_hw_data[QAT_SERVICE_SYMMETRIC]; PMD_INIT_FUNC_TRACE(); @@ -71,7 +71,7 @@ void qat_dev_info_get(struct rte_cryptodev *dev, qat_qps_per_service(sym_hw_qps, QAT_SERVICE_SYMMETRIC); info->feature_flags = dev->feature_flags; info->capabilities = internals->qat_dev_capabilities; - info->sym.max_nb_sessions = internals->max_nb_sessions; + info->sym.max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS; info->driver_id = cryptodev_qat_driver_id; info->pci_dev = RTE_DEV_TO_PCI(dev->device); } @@ -83,6 +83,7 @@ qat_pci_get_dev(uint8_t dev_id) { return &qat_pci_devices[dev_id]; } + static struct qat_pci_device * qat_pci_get_named_dev(const char *name) { @@ -133,7 +134,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) char name[QAT_DEV_NAME_MAX_LEN]; rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); - + snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat"); if (qat_pci_get_named_dev(name) != NULL) { PMD_DRV_LOG(ERR, "QAT device with name %s already allocated!", name); @@ -148,6 +149,7 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) qat_dev = qat_pci_get_dev(qat_dev_id); snprintf(qat_dev->name, QAT_DEV_NAME_MAX_LEN, "%s", name); + qat_dev->qat_dev_id = qat_dev_id; qat_dev->pci_dev = pci_dev; switch (qat_dev->pci_dev->id.device_id) { case 0x0443: @@ -169,8 +171,8 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev) qat_nb_pci_devices++; - PMD_DRV_LOG(DEBUG, "QAT device %d allocated, total QATs %d", - qat_dev_id, qat_nb_pci_devices); + PMD_DRV_LOG(DEBUG, "QAT device %d allocated, name %s, total QATs %d", + qat_dev->qat_dev_id, qat_dev->name, qat_nb_pci_devices); return qat_dev; } @@ -185,6 +187,7 @@ qat_pci_device_release(struct rte_pci_device *pci_dev) return -EINVAL; rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + snprintf(name+strlen(name), QAT_DEV_NAME_MAX_LEN-strlen(name), "_qat"); qat_dev = qat_pci_get_named_dev(name); if (qat_dev != NULL) { diff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h index d83ad632c..855bf6c1c 100644 --- a/drivers/crypto/qat/qat_device.h +++ b/drivers/crypto/qat/qat_device.h @@ -32,30 +32,31 @@ extern int qat_sym_qp_release(struct rte_cryptodev *dev, * - config data * - runtime data */ +struct qat_sym_dev_private; struct qat_pci_device { - /* data used by all services */ + /* Data used by all services */ char name[QAT_DEV_NAME_MAX_LEN]; /**< Name of qat pci device */ + uint8_t qat_dev_id; + /**< Device instance for this qat pci device */ struct rte_pci_device *pci_dev; /**< PCI information. */ enum qat_device_gen qat_dev_gen; /**< QAT device generation */ rte_spinlock_t arb_csr_lock; - /* protects accesses to the arbiter CSR */ + /**< lock to protect accesses to the arbiter CSR */ __extension__ uint8_t attached : 1; /**< Flag indicating the device is attached */ - /* data relating to symmetric crypto service */ - struct qat_pmd_private *sym_dev; + /* Data relating to symmetric crypto service */ + struct qat_sym_dev_private *sym_dev; /**< link back to cryptodev private data */ - unsigned int max_nb_sym_queue_pairs; - /**< Max number of queue pairs supported by device */ - /* data relating to compression service */ + /* Data relating to compression service */ - /* data relating to asymmetric crypto service */ + /* Data relating to asymmetric crypto service */ }; @@ -64,21 +65,13 @@ struct qat_pci_device { * there can be one of these on each qat_pci_device (VF), * in future there may also be private data structures for other services. */ -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; - /* QAT device capabilities */ - struct rte_pci_device *pci_dev; - /**< PCI information. */ - uint8_t dev_id; - /**< Device ID for this instance */ +struct qat_sym_dev_private { struct qat_pci_device *qat_dev; /**< The qat pci device hosting the service */ + uint8_t sym_dev_id; + /**< Device instance for this rte_cryptodev */ + const struct rte_cryptodev_capabilities *qat_dev_capabilities; + /* QAT device symmetric crypto capabilities */ }; struct qat_gen_hw_data { @@ -93,7 +86,7 @@ int qat_dev_config(struct rte_cryptodev *dev, 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, +void qat_sym_dev_info_get(struct rte_cryptodev *dev, struct rte_cryptodev_info *info); struct qat_pci_device * diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c index a59735344..4ad4a5326 100644 --- a/drivers/crypto/qat/qat_qp.c +++ b/drivers/crypto/qat/qat_qp.c @@ -102,7 +102,7 @@ const struct qat_qp_hw_data qat_gen1_qps[QAT_MAX_SERVICES] static int qat_qp_check_queue_alignment(uint64_t phys_addr, uint32_t queue_size_bytes); static void qat_queue_delete(struct qat_queue *queue); -static int qat_queue_create(struct qat_pmd_private *qat_dev, +static int qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue, struct qat_qp_config *, uint8_t dir); static int adf_verify_queue_size(uint32_t msg_size, uint32_t msg_num, uint32_t *queue_size_for_csr); @@ -172,7 +172,7 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t queue_size, memzone_flags, queue_size); } -int qat_qp_setup(struct qat_pmd_private *qat_dev, +int qat_qp_setup(struct qat_pci_device *qat_dev, struct qat_qp **qp_addr, uint16_t queue_pair_id, struct qat_qp_config *qat_qp_conf) @@ -182,8 +182,8 @@ int qat_qp_setup(struct qat_pmd_private *qat_dev, char op_cookie_pool_name[RTE_RING_NAMESIZE]; uint32_t i; - PMD_DRV_LOG(DEBUG, "Setup qp %u on device %d gen %d", - queue_pair_id, qat_dev->dev_id, qat_dev->qat_dev_gen); + PMD_DRV_LOG(DEBUG, "Setup qp %u on qat pci device %d gen %d", + queue_pair_id, qat_dev->qat_dev_id, qat_dev->qat_dev_gen); if ((qat_qp_conf->nb_descriptors > ADF_MAX_DESC) || (qat_qp_conf->nb_descriptors < ADF_MIN_DESC)) { @@ -236,10 +236,12 @@ int qat_qp_setup(struct qat_pmd_private *qat_dev, adf_configure_queues(qp); adf_queue_arb_enable(&qp->tx_q, qp->mmap_bar_addr); - snprintf(op_cookie_pool_name, RTE_RING_NAMESIZE, "%s_%s_qp_op_%d_%hu", - pci_dev->driver->driver.name, qat_qp_conf->service_str, - qat_dev->dev_id, queue_pair_id); + snprintf(op_cookie_pool_name, RTE_RING_NAMESIZE, + "%s%d_cookies_%s_qp%hu", + pci_dev->driver->driver.name, qat_dev->qat_dev_id, + qat_qp_conf->service_str, queue_pair_id); + PMD_DRV_LOG(DEBUG, "cookiepool: %s", op_cookie_pool_name); qp->op_cookie_pool = rte_mempool_lookup(op_cookie_pool_name); if (qp->op_cookie_pool == NULL) qp->op_cookie_pool = rte_mempool_create(op_cookie_pool_name, @@ -287,8 +289,8 @@ int qat_qp_release(struct qat_qp **qp_addr) return 0; } - PMD_DRV_LOG(DEBUG, "Free qp %u on device %d", - qp->queue_pair_id, qp->qat_dev->dev_id); + PMD_DRV_LOG(DEBUG, "Free qp %u on qat_pci device %d", + qp->queue_pair_id, qp->qat_dev->qat_dev_id); /* Don't free memory if there are still responses to be processed */ if (qp->inflights16 == 0) { @@ -340,7 +342,7 @@ static void qat_queue_delete(struct qat_queue *queue) } static int -qat_queue_create(struct qat_pmd_private *qat_dev, struct qat_queue *queue, +qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue, struct qat_qp_config *qp_conf, uint8_t dir) { uint64_t queue_base; @@ -365,9 +367,9 @@ qat_queue_create(struct qat_pmd_private *qat_dev, struct qat_queue *queue, * Allocate a memzone for the queue - create a unique name. */ snprintf(queue->memz_name, sizeof(queue->memz_name), - "%s_%s_%s_%d_%d_%d", - pci_dev->driver->driver.name, qp_conf->service_str, - "qp_mem", qat_dev->dev_id, + "%s_%d_%s_%s_%d_%d", + pci_dev->driver->driver.name, qat_dev->qat_dev_id, + qp_conf->service_str, "qp_mem", queue->hw_bundle_number, queue->hw_queue_number); qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes, qp_conf->socket_id); diff --git a/drivers/crypto/qat/qat_qp.h b/drivers/crypto/qat/qat_qp.h index f808e16a5..d482d5732 100644 --- a/drivers/crypto/qat/qat_qp.h +++ b/drivers/crypto/qat/qat_qp.h @@ -85,7 +85,7 @@ struct qat_qp { enum qat_device_gen qat_dev_gen; build_request_t build_request; process_response_t process_response; - struct qat_pmd_private *qat_dev; + struct qat_pci_device *qat_dev; /**< qat device this qp is on */ } __rte_cache_aligned; @@ -101,7 +101,7 @@ int qat_qp_release(struct qat_qp **qp_addr); int -qat_qp_setup(struct qat_pmd_private *qat_dev, +qat_qp_setup(struct qat_pci_device *qat_dev, struct qat_qp **qp_addr, uint16_t queue_pair_id, struct qat_qp_config *qat_qp_conf); diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index b74dfa634..e77fbe4c4 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -204,7 +204,7 @@ qat_sym_pmd_enqueue_op_burst(void *qp, struct rte_crypto_op **ops, return qat_enqueue_op_burst(qp, (void **)ops, nb_ops); } -int +static int qat_sym_process_response(void **op, uint8_t *resp, __rte_unused void *op_cookie, __rte_unused enum qat_device_gen qat_dev_gen) @@ -293,8 +293,7 @@ set_cipher_iv_ccm(uint16_t iv_length, uint16_t iv_offset, iv_length); } - -int +static int qat_sym_build_request(void *in_op, uint8_t *out_msg, void *op_cookie, enum qat_device_gen qat_dev_gen) { @@ -773,9 +772,9 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, struct qat_qp **qp_addr = (struct qat_qp **)&(dev->data->queue_pairs[qp_id]); - struct qat_pmd_private *qat_private = dev->data->dev_private; + struct qat_sym_dev_private *qat_private = dev->data->dev_private; const struct qat_qp_hw_data *sym_hw_qps = - qp_gen_config[qat_private->qat_dev_gen] + qp_gen_config[qat_private->qat_dev->qat_dev_gen] .qp_hw_data[QAT_SERVICE_SYMMETRIC]; const struct qat_qp_hw_data *qp_hw_data = sym_hw_qps + qp_id; @@ -798,7 +797,7 @@ int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qat_qp_conf.socket_id = socket_id; qat_qp_conf.service_str = "sym"; - ret = qat_qp_setup(qat_private, qp_addr, qp_id, &qat_qp_conf); + ret = qat_qp_setup(qat_private->qat_dev, qp_addr, qp_id, &qat_qp_conf); if (ret != 0) return ret; diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index 37bec3ce3..78b40e378 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -29,14 +29,6 @@ struct qat_sym_op_cookie { phys_addr_t qat_sgl_dst_phys_addr; }; -int -qat_sym_build_request(void *in_op, uint8_t *out_msg, - void *op_cookie, enum qat_device_gen qat_dev_gen); - -int -qat_sym_process_response(void **op, uint8_t *resp, - __rte_unused void *op_cookie, enum qat_device_gen qat_dev_gen); - void qat_sym_stats_get(struct rte_cryptodev *dev, struct rte_cryptodev_stats *stats); void qat_sym_stats_reset(struct rte_cryptodev *dev); diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index d71d7fcd1..d8a5d883f 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -64,7 +64,7 @@ bpi_cipher_ctx_init(enum rte_crypto_cipher_algorithm cryptodev_algo, static int qat_is_cipher_alg_supported(enum rte_crypto_cipher_algorithm algo, - struct qat_pmd_private *internals) { + struct qat_sym_dev_private *internals) { int i = 0; const struct rte_cryptodev_capabilities *capability; @@ -84,7 +84,7 @@ qat_is_cipher_alg_supported(enum rte_crypto_cipher_algorithm algo, static int qat_is_auth_alg_supported(enum rte_crypto_auth_algorithm algo, - struct qat_pmd_private *internals) { + struct qat_sym_dev_private *internals) { int i = 0; const struct rte_cryptodev_capabilities *capability; @@ -199,7 +199,7 @@ qat_sym_session_configure_cipher(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, struct qat_sym_session *session) { - struct qat_pmd_private *internals = dev->data->dev_private; + struct qat_sym_dev_private *internals = dev->data->dev_private; struct rte_crypto_cipher_xform *cipher_xform = NULL; int ret; @@ -493,7 +493,7 @@ qat_sym_session_configure_auth(struct rte_cryptodev *dev, struct qat_sym_session *session) { struct rte_crypto_auth_xform *auth_xform = qat_get_auth_xform(xform); - struct qat_pmd_private *internals = dev->data->dev_private; + struct qat_sym_dev_private *internals = dev->data->dev_private; uint8_t *key_data = auth_xform->key.data; uint8_t key_length = auth_xform->key.length; diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c index acc0b924a..6d265d5e3 100644 --- a/drivers/crypto/qat/rte_qat_cryptodev.c +++ b/drivers/crypto/qat/rte_qat_cryptodev.c @@ -33,7 +33,7 @@ static struct rte_cryptodev_ops crypto_qat_ops = { .dev_start = qat_dev_start, .dev_stop = qat_dev_stop, .dev_close = qat_dev_close, - .dev_infos_get = qat_dev_info_get, + .dev_infos_get = qat_sym_dev_info_get, .stats_get = qat_sym_stats_get, .stats_reset = qat_sym_stats_reset, @@ -77,12 +77,12 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) struct rte_cryptodev_pmd_init_params init_params = { .name = "", .socket_id = qat_pci_dev->pci_dev->device.numa_node, - .private_data_size = sizeof(struct qat_pmd_private), + .private_data_size = sizeof(struct qat_sym_dev_private), .max_nb_sessions = RTE_QAT_PMD_MAX_NB_SESSIONS }; char name[RTE_CRYPTODEV_NAME_MAX_LEN]; struct rte_cryptodev *cryptodev; - struct qat_pmd_private *internals; + struct qat_sym_dev_private *internals; snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN, "%s_%s", qat_pci_dev->name, "sym"); @@ -109,27 +109,25 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) internals->qat_dev = qat_pci_dev; qat_pci_dev->sym_dev = internals; - internals->max_nb_sessions = init_params.max_nb_sessions; - internals->pci_dev = RTE_DEV_TO_PCI(cryptodev->device); - internals->dev_id = cryptodev->data->dev_id; - switch (internals->pci_dev->id.device_id) { - case 0x0443: - internals->qat_dev_gen = QAT_GEN1; + internals->sym_dev_id = cryptodev->data->dev_id; + switch (qat_pci_dev->qat_dev_gen) { + case QAT_GEN1: internals->qat_dev_capabilities = qat_gen1_sym_capabilities; break; - case 0x37c9: - case 0x19e3: - case 0x6f55: - internals->qat_dev_gen = QAT_GEN2; + case QAT_GEN2: internals->qat_dev_capabilities = qat_gen2_sym_capabilities; break; default: - PMD_DRV_LOG(ERR, - "Invalid dev_id, can't determine capabilities"); + internals->qat_dev_capabilities = qat_gen2_sym_capabilities; + PMD_DRV_LOG(DEBUG, + "QAT gen %d capabilities unknown, default to GEN2", + qat_pci_dev->qat_dev_gen); break; } - return 0; + PMD_DRV_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d", + name, internals->sym_dev_id); + return 0; } static int @@ -143,7 +141,7 @@ qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev) return 0; /* free crypto device */ - cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->dev_id); + cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->sym_dev_id); rte_cryptodev_pmd_destroy(cryptodev); qat_pci_dev->sym_dev = NULL; -- 2.13.6