[dpdk-dev] crypto/scheduler: add mode specific option support

Message ID 1487687379-43345-1-git-send-email-roy.fan.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Fan Zhang Feb. 21, 2017, 2:29 p.m. UTC
  Some scheduling modes may need extra options to be configured,
this patch adds the function prototype for setting/getting
options.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 57 ++++++++++++++++++++++
 drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 27 ++++++++++
 .../scheduler/rte_cryptodev_scheduler_operations.h |  5 ++
 drivers/crypto/scheduler/scheduler_roundrobin.c    | 10 +++-
 4 files changed, 98 insertions(+), 1 deletion(-)
  

Comments

De Lara Guarch, Pablo March 21, 2017, 2:34 p.m. UTC | #1
Hi Fan,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang
> Sent: Tuesday, February 21, 2017 2:30 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo
> Subject: [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option
> support
> 
> Some scheduling modes may need extra options to be configured,
> this patch adds the function prototype for setting/getting
> options.
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 57
> ++++++++++++++++++++++
>  drivers/crypto/scheduler/rte_cryptodev_scheduler.h | 27 ++++++++++
>  .../scheduler/rte_cryptodev_scheduler_operations.h |  5 ++
>  drivers/crypto/scheduler/scheduler_roundrobin.c    | 10 +++-
>  4 files changed, 98 insertions(+), 1 deletion(-)
> 

You are adding two new functions to the API, so you should add them in the version.map file.

Thanks,
Pablo
  

Patch

diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
index 11e8143..c1491ff 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c
@@ -469,3 +469,60 @@  rte_cryptodev_scheduler_load_user_scheduler(uint8_t scheduler_id,
 
 	return 0;
 }
+
+int
+rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, void *option)
+{
+	struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id);
+	struct scheduler_ctx *sched_ctx;
+
+	if (!dev) {
+		CS_LOG_ERR("Operation not supported");
+		return -ENOTSUP;
+	}
+
+	if (!option) {
+		CS_LOG_ERR("Invalid option parameter");
+		return -EINVAL;
+	}
+
+	if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) {
+		CS_LOG_ERR("Operation not supported");
+		return -ENOTSUP;
+	}
+
+	if (dev->data->dev_started) {
+		CS_LOG_ERR("Illegal operation");
+		return -EBUSY;
+	}
+
+	sched_ctx = dev->data->dev_private;
+
+	return (*sched_ctx->ops.option_config)(dev, option, 1);
+}
+
+int
+rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, void *option)
+{
+	struct rte_cryptodev *dev = rte_cryptodev_pmd_get_dev(scheduler_id);
+	struct scheduler_ctx *sched_ctx;
+
+	if (!dev) {
+		CS_LOG_ERR("Operation not supported");
+		return -ENOTSUP;
+	}
+
+	if (!option) {
+		CS_LOG_ERR("Invalid option parameter");
+		return -EINVAL;
+	}
+
+	if (dev->dev_type != RTE_CRYPTODEV_SCHEDULER_PMD) {
+		CS_LOG_ERR("Operation not supported");
+		return -ENOTSUP;
+	}
+
+	sched_ctx = dev->data->dev_private;
+
+	return (*sched_ctx->ops.option_config)(dev, option, 0);
+}
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h
index 7ef44e7..c10867a 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.h
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.h
@@ -143,6 +143,33 @@  rte_cryptodev_scheduler_ordering_set(uint8_t scheduler_id,
 int
 rte_cryptodev_scheduler_ordering_get(uint8_t scheduler_id);
 
+/**
+ * Set the mode specific option
+ *
+ * @param	dev_id		The target scheduler device ID
+ *		option		The mode specific option
+ *
+ * @return
+ *	0 if successful
+ *	negative integer if otherwise.
+ */
+int
+rte_cryptodev_scheduler_option_set(uint8_t scheduler_id, void *option);
+
+/**
+ * Get the mode specific option
+ *
+ * @param	dev_id		The target scheduler device ID
+ *		option		The mode specific option to be written
+ *
+ * @return
+ *	0 if successful
+ *	negative integer if otherwise.
+ */
+int
+rte_cryptodev_scheduler_option_get(uint8_t scheduler_id, void *option);
+
+
 typedef uint16_t (*rte_cryptodev_scheduler_burst_enqueue_t)(void *qp_ctx,
 		struct rte_crypto_op **ops, uint16_t nb_ops);
 
diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h
index 93cf123..fe36c1e 100644
--- a/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h
+++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler_operations.h
@@ -53,6 +53,9 @@  typedef int (*rte_cryptodev_scheduler_config_queue_pair)(
 typedef int (*rte_cryptodev_scheduler_create_private_ctx)(
 		struct rte_cryptodev *dev);
 
+typedef int (*rte_cryptodev_scheduler_config_option)(
+		struct rte_cryptodev *dev, void *option, uint32_t is_set);
+
 struct rte_cryptodev_scheduler_ops {
 	rte_cryptodev_scheduler_slave_attach_t slave_attach;
 	rte_cryptodev_scheduler_slave_attach_t slave_detach;
@@ -63,6 +66,8 @@  struct rte_cryptodev_scheduler_ops {
 	rte_cryptodev_scheduler_config_queue_pair config_queue_pair;
 
 	rte_cryptodev_scheduler_create_private_ctx create_private_ctx;
+
+	rte_cryptodev_scheduler_config_option option_config;
 };
 
 #ifdef __cplusplus
diff --git a/drivers/crypto/scheduler/scheduler_roundrobin.c b/drivers/crypto/scheduler/scheduler_roundrobin.c
index 9545aa9..d262edd 100644
--- a/drivers/crypto/scheduler/scheduler_roundrobin.c
+++ b/drivers/crypto/scheduler/scheduler_roundrobin.c
@@ -415,13 +415,21 @@  scheduler_create_private_ctx(__rte_unused struct rte_cryptodev *dev)
 	return 0;
 }
 
+static int
+scheduler_option(__rte_unused struct rte_cryptodev *dev,
+		__rte_unused void *option, __rte_unused uint32_t is_set)
+{
+	return 0;
+}
+
 struct rte_cryptodev_scheduler_ops scheduler_rr_ops = {
 	slave_attach,
 	slave_detach,
 	scheduler_start,
 	scheduler_stop,
 	scheduler_config_qp,
-	scheduler_create_private_ctx
+	scheduler_create_private_ctx,
+	scheduler_option
 };
 
 struct rte_cryptodev_scheduler scheduler = {