From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fiona Trahe Subject: [PATCH 28/30] crypto/qat: create appropriately named device for registration Date: Fri, 6 Apr 2018 19:52:10 +0100 Message-ID: <1523040732-3290-29-git-send-email-fiona.trahe@intel.com> References: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> Cc: fiona.trahe@intel.com, tomaszx.jozwiak@intel.com To: dev@dpdk.org, pablo.de.lara.guarch@intel.com Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4E14C1CF9A for ; Fri, 6 Apr 2018 20:53:02 +0200 (CEST) In-Reply-To: <1523040732-3290-1-git-send-email-fiona.trahe@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For every QAT pci device probed, populate a local rte_device containing an rte_driver. The rte_driver was created in a previous patch to provide a crypto-specific driver name: "crypto_qat". This was previously only used for driver registration, now it's also used in device creation. This allows applications to find devices driven by "crypto_qat". Signed-off-by: Fiona Trahe --- drivers/crypto/qat/qat_device.h | 5 +++++ drivers/crypto/qat/qat_sym_pmd.c | 38 ++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/qat/qat_device.h b/drivers/crypto/qat/qat_device.h index 4201a1c71..3df6520c3 100644 --- a/drivers/crypto/qat/qat_device.h +++ b/drivers/crypto/qat/qat_device.h @@ -50,6 +50,11 @@ struct qat_pci_device { /* Data relating to symmetric crypto service */ struct qat_sym_dev_private *sym_dev; /**< link back to cryptodev private data */ + struct rte_device sym_rte_dev; + /**< This represents the crypto subset of this pci device. + * Register with this rather than with the one in + * pci_dev so that its driver can have a crypto-specific name + */ /* Data relating to compression service */ diff --git a/drivers/crypto/qat/qat_sym_pmd.c b/drivers/crypto/qat/qat_sym_pmd.c index e6760b8f8..28e579b77 100644 --- a/drivers/crypto/qat/qat_sym_pmd.c +++ b/drivers/crypto/qat/qat_sym_pmd.c @@ -232,6 +232,18 @@ qat_sym_pmd_dequeue_op_burst(void *qp, struct rte_crypto_op **ops, return qat_dequeue_op_burst(qp, (void **)ops, nb_ops); } +/* An rte_driver is needed in the registration of both the device and the driver + * with cryptodev. + * The actual qat pci's rte_driver can't be used as its name represents + * the whole pci device with all services. Think of this as a holder for a name + * for the crypto part of the pci device. + */ +static const char qat_sym_drv_name[] = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD); +static const struct rte_driver cryptodev_qat_sym_driver = { + .name = qat_sym_drv_name, + .alias = qat_sym_drv_name +}; + int qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) { @@ -249,12 +261,19 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) qat_pci_dev->name, "sym"); PMD_DRV_LOG(DEBUG, "Creating QAT SYM device %s", name); + /* Populate subset device to use in cryptodev device creation */ + qat_pci_dev->sym_rte_dev.driver = &cryptodev_qat_sym_driver; + qat_pci_dev->sym_rte_dev.numa_node = + qat_pci_dev->pci_dev->device.numa_node; + qat_pci_dev->sym_rte_dev.devargs = NULL; + cryptodev = rte_cryptodev_pmd_create(name, - &qat_pci_dev->pci_dev->device, &init_params); + &(qat_pci_dev->sym_rte_dev), &init_params); if (cryptodev == NULL) return -ENODEV; + qat_pci_dev->sym_rte_dev.name = cryptodev->data->name; cryptodev->driver_id = cryptodev_qat_driver_id; cryptodev->dev_ops = &crypto_qat_ops; @@ -287,7 +306,7 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev) } PMD_DRV_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d", - name, internals->sym_dev_id); + cryptodev->data->name, internals->sym_dev_id); return 0; } @@ -304,23 +323,14 @@ qat_sym_dev_destroy(struct qat_pci_device *qat_pci_dev) /* free crypto device */ cryptodev = rte_cryptodev_pmd_get_dev(qat_pci_dev->sym_dev->sym_dev_id); rte_cryptodev_pmd_destroy(cryptodev); + qat_pci_dev->sym_rte_dev.name = NULL; qat_pci_dev->sym_dev = NULL; return 0; } -/* An rte_driver is needed in the registration of both the device and the driver - * with cryptodev. - * The actual qat pci's rte_driver can't be used as its name represents - * the whole pci device with all services. Think of this as a holder for a name - * for the crypto part of the pci device. - */ -static const char qat_sym_drv_name[] = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD); -static struct rte_driver cryptodev_qat_sym_driver = { - .name = qat_sym_drv_name, - .alias = qat_sym_drv_name -}; static struct cryptodev_driver qat_crypto_drv; -RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, cryptodev_qat_sym_driver, +RTE_PMD_REGISTER_CRYPTO_DRIVER(qat_crypto_drv, + cryptodev_qat_sym_driver, cryptodev_qat_driver_id); -- 2.13.6