patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [19.11 1/3] drivers/qat: improve multi process on qat
@ 2020-07-31 12:05 Arek Kusztal
  2020-07-31 12:05 ` [dpdk-stable] [19.11 2/3] drivers/qat: add multi process handling of driver id Arek Kusztal
  2020-07-31 12:05 ` [dpdk-stable] [19.11 3/3] drivers/qat: add handling of capabilities in multi process Arek Kusztal
  0 siblings, 2 replies; 3+ messages in thread
From: Arek Kusztal @ 2020-07-31 12:05 UTC (permalink / raw)
  To: arkadiuszx.kusztal, fiona.trahe; +Cc: stable

[ upstream commit 9904ff684981e09019103d48af6f39d5a00ac800 ]

This patch refactors qat data into structures which are local
to the process and structures which are intended to be shared by
primary and secondary processes. This enables qat devices to be
used by multi process applications.

Cc: stable@dpdk.org

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
 drivers/common/qat/qat_device.c     | 103 ++++++++++++++++++++++++++----------
 drivers/common/qat/qat_device.h     |  62 ++++++++++++----------
 drivers/common/qat/qat_qp.c         |  29 +++++++---
 drivers/compress/qat/qat_comp_pmd.c |  21 ++++----
 drivers/crypto/qat/qat_asym_pmd.c   |  27 ++++++----
 drivers/crypto/qat/qat_sym_pmd.c    |  27 ++++++----
 6 files changed, 176 insertions(+), 93 deletions(-)

diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index 2a1cf3e..18dbdd5 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -30,8 +30,8 @@ struct qat_gen_hw_data qat_gen_config[] =  {
 	},
 };
 
-
-static struct qat_pci_device qat_pci_devices[RTE_PMD_QAT_MAX_PCI_DEVICES];
+/* per-process array of device data */
+struct qat_device_info qat_pci_devs[RTE_PMD_QAT_MAX_PCI_DEVICES];
 static int qat_nb_pci_devices;
 
 /*
@@ -58,26 +58,20 @@ static const struct rte_pci_id pci_id_qat_map[] = {
 };
 
 static struct qat_pci_device *
-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)
 {
-	struct qat_pci_device *dev;
 	unsigned int i;
 
 	if (name == NULL)
 		return NULL;
 
 	for (i = 0; i < RTE_PMD_QAT_MAX_PCI_DEVICES; i++) {
-		dev = &qat_pci_devices[i];
-
-		if ((dev->attached == QAT_ATTACHED) &&
-				(strcmp(dev->name, name) == 0))
-			return dev;
+		if (qat_pci_devs[i].mz &&
+				(strcmp(((struct qat_pci_device *)
+				qat_pci_devs[i].mz->addr)->name, name)
+				== 0))
+			return (struct qat_pci_device *)
+				qat_pci_devs[i].mz->addr;
 	}
 
 	return NULL;
@@ -88,8 +82,9 @@ qat_pci_find_free_device_index(void)
 {
 	uint8_t dev_id;
 
-	for (dev_id = 0; dev_id < RTE_PMD_QAT_MAX_PCI_DEVICES; dev_id++) {
-		if (qat_pci_devices[dev_id].attached == QAT_DETACHED)
+	for (dev_id = 0; dev_id < RTE_PMD_QAT_MAX_PCI_DEVICES;
+			dev_id++) {
+		if (qat_pci_devs[dev_id].mz == NULL)
 			break;
 	}
 	return dev_id;
@@ -109,11 +104,31 @@ struct qat_pci_device *
 qat_pci_device_allocate(struct rte_pci_device *pci_dev)
 {
 	struct qat_pci_device *qat_dev;
-	uint8_t qat_dev_id;
+	uint8_t qat_dev_id = 0;
 	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 (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		const struct rte_memzone *mz = rte_memzone_lookup(name);
+
+		if (mz == NULL) {
+			QAT_LOG(ERR,
+				"Secondary can't find %s mz, did primary create device?",
+				name);
+			return NULL;
+		}
+		qat_dev = mz->addr;
+		qat_pci_devs[qat_dev->qat_dev_id].mz = mz;
+		qat_pci_devs[qat_dev->qat_dev_id].pci_dev = pci_dev;
+		qat_nb_pci_devices++;
+		QAT_LOG(DEBUG, "QAT device %d found, name %s, total QATs %d",
+			qat_dev->qat_dev_id, qat_dev->name, qat_nb_pci_devices);
+		return qat_dev;
+	}
+
+
 	if (qat_pci_get_named_dev(name) != NULL) {
 		QAT_LOG(ERR, "QAT device with name %s already allocated!",
 				name);
@@ -126,12 +141,22 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev)
 		return NULL;
 	}
 
-	qat_dev = qat_pci_get_dev(qat_dev_id);
+	qat_pci_devs[qat_dev_id].mz = rte_memzone_reserve(name,
+		sizeof(struct qat_pci_device),
+		rte_socket_id(), 0);
+
+	if (qat_pci_devs[qat_dev_id].mz == NULL) {
+		QAT_LOG(ERR, "Error when allocating memzone for QAT_%d",
+			qat_dev_id);
+		return NULL;
+	}
+
+	qat_dev = qat_pci_devs[qat_dev_id].mz->addr;
 	memset(qat_dev, 0, sizeof(*qat_dev));
 	strlcpy(qat_dev->name, name, QAT_DEV_NAME_MAX_LEN);
 	qat_dev->qat_dev_id = qat_dev_id;
-	qat_dev->pci_dev = pci_dev;
-	switch (qat_dev->pci_dev->id.device_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;
@@ -145,17 +170,16 @@ qat_pci_device_allocate(struct rte_pci_device *pci_dev)
 		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;
 	}
 
 	rte_spinlock_init(&qat_dev->arb_csr_lock);
 
-	qat_dev->attached = QAT_ATTACHED;
-
 	qat_nb_pci_devices++;
 
-	QAT_LOG(DEBUG, "QAT device %d allocated, name %s, total QATs %d",
-			qat_dev->qat_dev_id, qat_dev->name, qat_nb_pci_devices);
+	QAT_LOG(DEBUG, "QAT device %d found, name %s, total QATs %d",
+		qat_dev->qat_dev_id, qat_dev->name, qat_nb_pci_devices);
 
 	return qat_dev;
 }
@@ -165,6 +189,7 @@ qat_pci_device_release(struct rte_pci_device *pci_dev)
 {
 	struct qat_pci_device *qat_dev;
 	char name[QAT_DEV_NAME_MAX_LEN];
+	int busy = 0;
 
 	if (pci_dev == NULL)
 		return -EINVAL;
@@ -174,15 +199,35 @@ qat_pci_device_release(struct rte_pci_device *pci_dev)
 	qat_dev = qat_pci_get_named_dev(name);
 	if (qat_dev != NULL) {
 
+		struct qat_device_info *inst =
+				&qat_pci_devs[qat_dev->qat_dev_id];
 		/* Check that there are no service devs still on pci device */
-		if (qat_dev->sym_dev != NULL)
-			return -EBUSY;
 
-		qat_dev->attached = QAT_DETACHED;
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			if (qat_dev->sym_dev != NULL) {
+				QAT_LOG(DEBUG, "QAT sym device %s is busy",
+					name);
+				busy = 1;
+			}
+			if (qat_dev->asym_dev != NULL) {
+				QAT_LOG(DEBUG, "QAT asym device %s is busy",
+					name);
+				busy = 1;
+			}
+			if (qat_dev->comp_dev != NULL) {
+				QAT_LOG(DEBUG, "QAT comp device %s is busy",
+					name);
+				busy = 1;
+			}
+			if (busy)
+				return -EBUSY;
+			rte_memzone_free(inst->mz);
+		}
+		memset(inst, 0, sizeof(struct qat_device_info));
 		qat_nb_pci_devices--;
+		QAT_LOG(DEBUG, "QAT device %s released, total QATs %d",
+					name, qat_nb_pci_devices);
 	}
-	QAT_LOG(DEBUG, "QAT device %s released, total QATs %d",
-				name, qat_nb_pci_devices);
 	return 0;
 }
 
diff --git a/drivers/common/qat/qat_device.h b/drivers/common/qat/qat_device.h
index 131375e..6531047 100644
--- a/drivers/common/qat/qat_device.h
+++ b/drivers/common/qat/qat_device.h
@@ -22,6 +22,37 @@ enum qat_comp_num_im_buffers {
 	QAT_NUM_INTERM_BUFS_GEN3 = 20
 };
 
+struct qat_device_info {
+	const struct rte_memzone *mz;
+	/**< mz to store the qat_pci_device so it can be
+	 * shared across processes
+	 */
+	struct rte_pci_device *pci_dev;
+	struct rte_device sym_rte_dev;
+	/**< This represents the crypto sym 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
+	 */
+
+	struct rte_device asym_rte_dev;
+	/**< This represents the crypto asym 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
+	 */
+
+	struct rte_device comp_rte_dev;
+	/**< This represents the compression subset of this pci device.
+	 * Register with this rather than with the one in
+	 * pci_dev so that its driver can have a compression-specific name
+	 */
+};
+
+extern struct qat_device_info qat_pci_devs[];
+
+struct qat_sym_dev_private;
+struct qat_asym_dev_private;
+struct qat_comp_dev_private;
+
 /*
  * This struct holds all the data about a QAT pci device
  * including data about all services it supports.
@@ -29,27 +60,20 @@ enum qat_comp_num_im_buffers {
  *  - hw_data
  *  - config data
  *  - runtime data
+ * Note: as this data can be shared in a multi-process scenario,
+ * any pointers in it must also point to shared memory.
  */
-struct qat_sym_dev_private;
-struct qat_asym_dev_private;
-struct qat_comp_dev_private;
-
 struct qat_pci_device {
 
 	/* 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. */
+	/**< Id of device instance for this qat pci device */
 	enum qat_device_gen qat_dev_gen;
 	/**< QAT device generation */
 	rte_spinlock_t arb_csr_lock;
 	/**< lock to protect accesses to the arbiter CSR */
-	__extension__
-	uint8_t attached : 1;
-	/**< Flag indicating the device is attached */
 
 	struct qat_qp *qps_in_use[QAT_MAX_SERVICES][ADF_MAX_QPS_ON_ANY_SERVICE];
 	/**< links to qps set up for each service, index same as on API */
@@ -57,32 +81,14 @@ 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 sym 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 asymmetric crypto service */
 	struct qat_asym_dev_private *asym_dev;
 	/**< link back to cryptodev private data */
-	struct rte_device asym_rte_dev;
-	/**< This represents the crypto asym 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 */
 	struct qat_comp_dev_private *comp_dev;
 	/**< link back to compressdev private data */
-	struct rte_device comp_rte_dev;
-	/**< This represents the compression subset of this pci device.
-	 * Register with this rather than with the one in
-	 * pci_dev so that its driver can have a compression-specific name
-	 */
-
-	/* Data relating to asymmetric crypto service */
-
 };
 
 struct qat_gen_hw_data {
diff --git a/drivers/common/qat/qat_qp.c b/drivers/common/qat/qat_qp.c
index 03f11f8..474e1cd 100644
--- a/drivers/common/qat/qat_qp.c
+++ b/drivers/common/qat/qat_qp.c
@@ -191,7 +191,8 @@ int qat_qp_setup(struct qat_pci_device *qat_dev,
 
 {
 	struct qat_qp *qp;
-	struct rte_pci_device *pci_dev = qat_dev->pci_dev;
+	struct rte_pci_device *pci_dev =
+			qat_pci_devs[qat_dev->qat_dev_id].pci_dev;
 	char op_cookie_pool_name[RTE_RING_NAMESIZE];
 	uint32_t i;
 
@@ -263,7 +264,7 @@ int qat_qp_setup(struct qat_pci_device *qat_dev,
 				qp->nb_descriptors,
 				qat_qp_conf->cookie_size, 64, 0,
 				NULL, NULL, NULL, NULL,
-				qat_dev->pci_dev->device.numa_node,
+				pci_dev->device.numa_node,
 				0);
 	if (!qp->op_cookie_pool) {
 		QAT_LOG(ERR, "QAT PMD Cannot create"
@@ -368,7 +369,8 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
 	uint64_t queue_base;
 	void *io_addr;
 	const struct rte_memzone *qp_mz;
-	struct rte_pci_device *pci_dev = qat_dev->pci_dev;
+	struct rte_pci_device *pci_dev =
+			qat_pci_devs[qat_dev->qat_dev_id].pci_dev;
 	int ret = 0;
 	uint16_t desc_size = (dir == ADF_RING_DIR_TX ?
 			qp_conf->hw->tx_msg_size : qp_conf->hw->rx_msg_size);
@@ -392,7 +394,7 @@ qat_queue_create(struct qat_pci_device *qat_dev, struct qat_queue *queue,
 		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,
-			qat_dev->pci_dev->device.numa_node);
+			pci_dev->device.numa_node);
 	if (qp_mz == NULL) {
 		QAT_LOG(ERR, "Failed to allocate ring memzone");
 		return -ENOMEM;
@@ -575,7 +577,7 @@ qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 	register struct qat_queue *queue;
 	struct qat_qp *tmp_qp = (struct qat_qp *)qp;
 	register uint32_t nb_ops_sent = 0;
-	register int ret;
+	register int ret = -1;
 	uint16_t nb_ops_possible = nb_ops;
 	register uint8_t *base_addr;
 	register uint32_t tail;
@@ -600,9 +602,24 @@ qat_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops)
 	}
 
 	while (nb_ops_sent != nb_ops_possible) {
-		ret = tmp_qp->build_request(*ops, base_addr + tail,
+		if (tmp_qp->service_type == QAT_SERVICE_SYMMETRIC) {
+#ifdef BUILD_QAT_SYM
+			ret = qat_sym_build_request(*ops, base_addr + tail,
 				tmp_qp->op_cookies[tail / queue->msg_size],
 				tmp_qp->qat_dev_gen);
+#endif
+		} else if (tmp_qp->service_type == QAT_SERVICE_COMPRESSION) {
+			ret = qat_comp_build_request(*ops, base_addr + tail,
+				tmp_qp->op_cookies[tail / queue->msg_size],
+				tmp_qp->qat_dev_gen);
+		} else if (tmp_qp->service_type == QAT_SERVICE_ASYMMETRIC) {
+#ifdef BUILD_QAT_ASYM
+			ret = qat_asym_build_request(*ops, base_addr + tail,
+				tmp_qp->op_cookies[tail / queue->msg_size],
+				tmp_qp->qat_dev_gen);
+#endif
+		}
+
 		if (ret != 0) {
 			tmp_qp->stats.enqueue_err_count++;
 			/*
diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c
index 05b7dfe..9aeb9db 100644
--- a/drivers/compress/qat/qat_comp_pmd.c
+++ b/drivers/compress/qat/qat_comp_pmd.c
@@ -662,6 +662,8 @@ static const struct rte_driver compdev_qat_driver = {
 int
 qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
 {
+	struct qat_device_info *qat_dev_instance =
+			&qat_pci_devs[qat_pci_dev->qat_dev_id];
 	if (qat_pci_dev->qat_dev_gen == QAT_GEN3) {
 		QAT_LOG(ERR, "Compression PMD not supported on QAT c4xxx");
 		return 0;
@@ -669,7 +671,7 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
 
 	struct rte_compressdev_pmd_init_params init_params = {
 		.name = "",
-		.socket_id = qat_pci_dev->pci_dev->device.numa_node,
+		.socket_id = qat_dev_instance->pci_dev->device.numa_node,
 	};
 	char name[RTE_COMPRESSDEV_NAME_MAX_LEN];
 	struct rte_compressdev *compressdev;
@@ -680,13 +682,13 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
 	QAT_LOG(DEBUG, "Creating QAT COMP device %s", name);
 
 	/* Populate subset device to use in compressdev device creation */
-	qat_pci_dev->comp_rte_dev.driver = &compdev_qat_driver;
-	qat_pci_dev->comp_rte_dev.numa_node =
-					qat_pci_dev->pci_dev->device.numa_node;
-	qat_pci_dev->comp_rte_dev.devargs = NULL;
+	qat_dev_instance->comp_rte_dev.driver = &compdev_qat_driver;
+	qat_dev_instance->comp_rte_dev.numa_node =
+			qat_dev_instance->pci_dev->device.numa_node;
+	qat_dev_instance->comp_rte_dev.devargs = NULL;
 
 	compressdev = rte_compressdev_pmd_create(name,
-			&(qat_pci_dev->comp_rte_dev),
+			&(qat_dev_instance->comp_rte_dev),
 			sizeof(struct qat_comp_dev_private),
 			&init_params);
 
@@ -700,10 +702,12 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
 
 	compressdev->feature_flags = RTE_COMPDEV_FF_HW_ACCELERATED;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	comp_dev = compressdev->data->dev_private;
 	comp_dev->qat_dev = qat_pci_dev;
 	comp_dev->compressdev = compressdev;
-	qat_pci_dev->comp_dev = comp_dev;
 
 	switch (qat_pci_dev->qat_dev_gen) {
 	case QAT_GEN1:
@@ -712,13 +716,12 @@ qat_comp_dev_create(struct qat_pci_device *qat_pci_dev)
 		comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities;
 		break;
 	default:
-		comp_dev->qat_dev_capabilities = qat_comp_gen_capabilities;
 		QAT_LOG(DEBUG,
 			"QAT gen %d capabilities unknown, default to GEN1",
 					qat_pci_dev->qat_dev_gen);
 		break;
 	}
-
+	qat_pci_dev->comp_dev = comp_dev;
 	QAT_LOG(DEBUG,
 		    "Created QAT COMP device %s as compressdev instance %d",
 			name, compressdev->data->dev_id);
diff --git a/drivers/crypto/qat/qat_asym_pmd.c b/drivers/crypto/qat/qat_asym_pmd.c
index c8a52b6..e8443d9 100644
--- a/drivers/crypto/qat/qat_asym_pmd.c
+++ b/drivers/crypto/qat/qat_asym_pmd.c
@@ -237,9 +237,13 @@ static const struct rte_driver cryptodev_qat_asym_driver = {
 int
 qat_asym_dev_create(struct qat_pci_device *qat_pci_dev)
 {
+	struct qat_device_info *qat_dev_instance =
+			&qat_pci_devs[qat_pci_dev->qat_dev_id];
+
 	struct rte_cryptodev_pmd_init_params init_params = {
 			.name = "",
-			.socket_id = qat_pci_dev->pci_dev->device.numa_node,
+			.socket_id =
+				qat_dev_instance->pci_dev->device.numa_node,
 			.private_data_size = sizeof(struct qat_asym_dev_private)
 	};
 	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
@@ -251,18 +255,18 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev)
 	QAT_LOG(DEBUG, "Creating QAT ASYM device %s\n", name);
 
 	/* Populate subset device to use in cryptodev device creation */
-	qat_pci_dev->asym_rte_dev.driver = &cryptodev_qat_asym_driver;
-	qat_pci_dev->asym_rte_dev.numa_node =
-				qat_pci_dev->pci_dev->device.numa_node;
-	qat_pci_dev->asym_rte_dev.devargs = NULL;
+	qat_dev_instance->asym_rte_dev.driver = &cryptodev_qat_asym_driver;
+	qat_dev_instance->asym_rte_dev.numa_node =
+			qat_dev_instance->pci_dev->device.numa_node;
+	qat_dev_instance->asym_rte_dev.devargs = NULL;
 
 	cryptodev = rte_cryptodev_pmd_create(name,
-			&(qat_pci_dev->asym_rte_dev), &init_params);
+			&(qat_dev_instance->asym_rte_dev), &init_params);
 
 	if (cryptodev == NULL)
 		return -ENODEV;
 
-	qat_pci_dev->asym_rte_dev.name = cryptodev->data->name;
+	qat_dev_instance->asym_rte_dev.name = cryptodev->data->name;
 	cryptodev->driver_id = cryptodev_qat_asym_driver_id;
 	cryptodev->dev_ops = &crypto_qat_ops;
 
@@ -274,13 +278,16 @@ qat_asym_dev_create(struct qat_pci_device *qat_pci_dev)
 			RTE_CRYPTODEV_FF_ASYM_SESSIONLESS |
 			RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP |
 			RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	internals = cryptodev->data->dev_private;
 	internals->qat_dev = qat_pci_dev;
-	qat_pci_dev->asym_dev = internals;
-
 	internals->asym_dev_id = cryptodev->data->dev_id;
 	internals->qat_dev_capabilities = qat_gen1_asym_capabilities;
 
+	qat_pci_dev->asym_dev = internals;
 	QAT_LOG(DEBUG, "Created QAT ASYM device %s as cryptodev instance %d",
 			cryptodev->data->name, internals->asym_dev_id);
 	return 0;
@@ -300,7 +307,7 @@ qat_asym_dev_destroy(struct qat_pci_device *qat_pci_dev)
 	cryptodev = rte_cryptodev_pmd_get_dev(
 			qat_pci_dev->asym_dev->asym_dev_id);
 	rte_cryptodev_pmd_destroy(cryptodev);
-	qat_pci_dev->asym_rte_dev.name = NULL;
+	qat_pci_devs[qat_pci_dev->qat_dev_id].asym_rte_dev.name = NULL;
 	qat_pci_dev->asym_dev = NULL;
 
 	return 0;
diff --git a/drivers/crypto/qat/qat_sym_pmd.c b/drivers/crypto/qat/qat_sym_pmd.c
index 71f21ce..cb5b4fe 100644
--- a/drivers/crypto/qat/qat_sym_pmd.c
+++ b/drivers/crypto/qat/qat_sym_pmd.c
@@ -239,9 +239,13 @@ static const struct rte_driver cryptodev_qat_sym_driver = {
 int
 qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)
 {
+	struct qat_device_info *qat_dev_instance =
+			&qat_pci_devs[qat_pci_dev->qat_dev_id];
+
 	struct rte_cryptodev_pmd_init_params init_params = {
 			.name = "",
-			.socket_id = qat_pci_dev->pci_dev->device.numa_node,
+			.socket_id =
+				qat_dev_instance->pci_dev->device.numa_node,
 			.private_data_size = sizeof(struct qat_sym_dev_private)
 	};
 	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
@@ -253,18 +257,18 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)
 	QAT_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;
+	qat_dev_instance->sym_rte_dev.driver = &cryptodev_qat_sym_driver;
+	qat_dev_instance->sym_rte_dev.numa_node =
+			qat_dev_instance->pci_dev->device.numa_node;
+	qat_dev_instance->sym_rte_dev.devargs = NULL;
 
 	cryptodev = rte_cryptodev_pmd_create(name,
-			&(qat_pci_dev->sym_rte_dev), &init_params);
+			&(qat_dev_instance->sym_rte_dev), &init_params);
 
 	if (cryptodev == NULL)
 		return -ENODEV;
 
-	qat_pci_dev->sym_rte_dev.name = cryptodev->data->name;
+	qat_dev_instance->sym_rte_dev.name = cryptodev->data->name;
 	cryptodev->driver_id = cryptodev_qat_driver_id;
 	cryptodev->dev_ops = &crypto_qat_ops;
 
@@ -281,9 +285,11 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)
 			RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
 			RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	internals = cryptodev->data->dev_private;
 	internals->qat_dev = qat_pci_dev;
-	qat_pci_dev->sym_dev = internals;
 
 	internals->sym_dev_id = cryptodev->data->dev_id;
 	switch (qat_pci_dev->qat_dev_gen) {
@@ -295,13 +301,12 @@ qat_sym_dev_create(struct qat_pci_device *qat_pci_dev)
 		internals->qat_dev_capabilities = qat_gen2_sym_capabilities;
 		break;
 	default:
-		internals->qat_dev_capabilities = qat_gen2_sym_capabilities;
 		QAT_LOG(DEBUG,
 			"QAT gen %d capabilities unknown, default to GEN2",
 					qat_pci_dev->qat_dev_gen);
 		break;
 	}
-
+	qat_pci_dev->sym_dev = internals;
 	QAT_LOG(DEBUG, "Created QAT SYM device %s as cryptodev instance %d",
 			cryptodev->data->name, internals->sym_dev_id);
 	return 0;
@@ -320,7 +325,7 @@ 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_devs[qat_pci_dev->qat_dev_id].sym_rte_dev.name = NULL;
 	qat_pci_dev->sym_dev = NULL;
 
 	return 0;
-- 
2.1.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 12:05 [dpdk-stable] [19.11 1/3] drivers/qat: improve multi process on qat Arek Kusztal
2020-07-31 12:05 ` [dpdk-stable] [19.11 2/3] drivers/qat: add multi process handling of driver id Arek Kusztal
2020-07-31 12:05 ` [dpdk-stable] [19.11 3/3] drivers/qat: add handling of capabilities in multi process Arek Kusztal

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox