From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <roy.fan.zhang@intel.com>
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by dpdk.org (Postfix) with ESMTP id 3A340952
 for <dev@dpdk.org>; Tue, 21 Feb 2017 15:28:36 +0100 (CET)
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 21 Feb 2017 06:28:35 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.35,189,1484035200"; d="scan'208";a="936431228"
Received: from silpixa00381633.ir.intel.com (HELO
 silpixa00381633.ger.corp.intel.com) ([10.237.222.114])
 by orsmga003.jf.intel.com with ESMTP; 21 Feb 2017 06:28:34 -0800
From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com
Date: Tue, 21 Feb 2017 14:29:39 +0000
Message-Id: <1487687379-43345-1-git-send-email-roy.fan.zhang@intel.com>
X-Mailer: git-send-email 2.7.4
Subject: [dpdk-dev] [PATCH] crypto/scheduler: add mode specific option
	support
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 21 Feb 2017 14:28:36 -0000

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(-)

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 = {
-- 
2.7.4