[1/2] cryptodev: add function to check if qp was setup

Message ID 20200610185308.15220-1-arkadiuszx.kusztal@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [1/2] cryptodev: add function to check if qp was setup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS

Commit Message

Arkadiusz Kusztal June 10, 2020, 6:53 p.m. UTC
  From: Fiona Trahe <fiona.trahe@intel.com>

This patch adds function that can check if queue pair
was already setup. This may be useful when dealing with
multi process approach in cryptodev.

Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 28 ++++++++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h | 14 ++++++++++++++
 2 files changed, 42 insertions(+)
  

Comments

Fiona Trahe June 11, 2020, 1:42 p.m. UTC | #1
Hi Arek,

> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Wednesday, June 10, 2020 7:53 PM
> To: dev@dpdk.org
> Cc: akhil.goyal@nxp.com; Trahe, Fiona <fiona.trahe@intel.com>; arkaduszx.kusztal@intel.com
> Subject: [PATCH 1/2] cryptodev: add function to check if qp was setup
> 
> From: Fiona Trahe <fiona.trahe@intel.com>
> 
> This patch adds function that can check if queue pair
> was already setup. This may be useful when dealing with
> multi process approach in cryptodev.
> 
> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
> ---
>  lib/librte_cryptodev/rte_cryptodev.c | 28 ++++++++++++++++++++++++++++
>  lib/librte_cryptodev/rte_cryptodev.h | 14 ++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
> index e37b83a..705387b 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.c
> +++ b/lib/librte_cryptodev/rte_cryptodev.c
> @@ -1080,6 +1080,34 @@ rte_cryptodev_close(uint8_t dev_id)
>  }
> 
>  int
> +rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id)
[Fiona] This should be marked as experimental & added to map file

> +{
> +	struct rte_cryptodev *dev;
> +
> +	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
> +		CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
> +		return -(ENODEV);
> +	}
> +
> +	dev = &rte_crypto_devices[dev_id];
> +	if (queue_pair_id >= dev->data->nb_queue_pairs) {
> +		CDEV_LOG_ERR("Invalid queue_pair_id=%d", queue_pair_id);
> +		return -(ENODEV);
[Fiona]  -EINVAL would be more appropriate here

> +	}
> +	void **qps = dev->data->queue_pairs;
> +
> +	if (qps[queue_pair_id])	{
> +		CDEV_LOG_INFO("qp %d on dev %d is initialised",
[Fiona] This and below should use CDEV_LOG_DEBUG
> +			queue_pair_id, dev_id);
> +		return 1;
> +	}
> +
> +	CDEV_LOG_INFO("qp %d on dev %d is not initialised",
> +		queue_pair_id, dev_id);
> +	return 0;
> +}
> +
> +int
>  rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
>  		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
> 
> diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
> index 4aaee73..d01a658 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.h
> +++ b/lib/librte_cryptodev/rte_cryptodev.h
> @@ -727,6 +727,20 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
>  		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
> 
>  /**
> + * Get the status of queue pairs setup on a specific crypto device
> + *
> + * @param	dev_id			Crypto device identifier.
> + * @param	queue_pair_id	The index of the queue pair to check.
> + *
> + * @return
> + *   - 0: qp was not configured
> + *   - 1: qp was configured
> + *   - -ENODEV: device was not configured
> + */
> +int
> +rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id);
> +
> +/**
>   * Get the number of queue pairs on a specific crypto device
>   *
>   * @param	dev_id		Crypto device identifier.
> --
> 2.1.0
  

Patch

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index e37b83a..705387b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -1080,6 +1080,34 @@  rte_cryptodev_close(uint8_t dev_id)
 }
 
 int
+rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id)
+{
+	struct rte_cryptodev *dev;
+
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) {
+		CDEV_LOG_ERR("Invalid dev_id=%" PRIu8, dev_id);
+		return -(ENODEV);
+	}
+
+	dev = &rte_crypto_devices[dev_id];
+	if (queue_pair_id >= dev->data->nb_queue_pairs) {
+		CDEV_LOG_ERR("Invalid queue_pair_id=%d", queue_pair_id);
+		return -(ENODEV);
+	}
+	void **qps = dev->data->queue_pairs;
+
+	if (qps[queue_pair_id])	{
+		CDEV_LOG_INFO("qp %d on dev %d is initialised",
+			queue_pair_id, dev_id);
+		return 1;
+	}
+
+	CDEV_LOG_INFO("qp %d on dev %d is not initialised",
+		queue_pair_id, dev_id);
+	return 0;
+}
+
+int
 rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 4aaee73..d01a658 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -727,6 +727,20 @@  rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
 		const struct rte_cryptodev_qp_conf *qp_conf, int socket_id);
 
 /**
+ * Get the status of queue pairs setup on a specific crypto device
+ *
+ * @param	dev_id			Crypto device identifier.
+ * @param	queue_pair_id	The index of the queue pair to check.
+ *
+ * @return
+ *   - 0: qp was not configured
+ *   - 1: qp was configured
+ *   - -ENODEV: device was not configured
+ */
+int
+rte_cryptodev_get_qp_status(uint8_t dev_id, uint16_t queue_pair_id);
+
+/**
  * Get the number of queue pairs on a specific crypto device
  *
  * @param	dev_id		Crypto device identifier.