DPDK patches and discussions
 help / color / mirror / Atom feed
From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: pablo.de.lara.guarch@intel.com
Subject: [dpdk-dev] [PATCH 2/3] crypto/scheduler: improve slave configuration
Date: Fri, 17 Feb 2017 12:01:01 +0000	[thread overview]
Message-ID: <1487332862-5719-3-git-send-email-roy.fan.zhang@intel.com> (raw)
In-Reply-To: <1487332862-5719-1-git-send-email-roy.fan.zhang@intel.com>

Since the new device configuration API is updated, we can make use of
this feature to the crypto scheduler PMD to configure its slaves
automatically with the same configurations it got. As originally the
slaves have to be manually configured one by one, this patch should
help reducing the coding complexity.

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 app/test/test_cryptodev.c                    | 24 +-----------------------
 drivers/crypto/scheduler/scheduler_pmd_ops.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 357a92e..6fe5362 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -7382,17 +7382,8 @@ test_scheduler_attach_slave_op(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	uint8_t sched_id = ts_params->valid_devs[0];
-	uint32_t nb_devs, qp_id, i, nb_devs_attached = 0;
+	uint32_t nb_devs, i, nb_devs_attached = 0;
 	int ret;
-	struct rte_cryptodev_config config = {
-			.nb_queue_pairs = 8,
-			.socket_id = SOCKET_ID_ANY,
-			.session_mp = {
-				.nb_objs = 2048,
-				.cache_size = 256
-			}
-	};
-	struct rte_cryptodev_qp_conf qp_conf = {2048};
 
 	/* create 2 AESNI_MB if necessary */
 	nb_devs = rte_cryptodev_count_devtype(
@@ -7418,19 +7409,6 @@ test_scheduler_attach_slave_op(void)
 		if (info.dev_type != RTE_CRYPTODEV_AESNI_MB_PMD)
 			continue;
 
-		ret = rte_cryptodev_configure(i, &config);
-		TEST_ASSERT(ret == 0,
-			"Failed to configure device %u of pmd : %s", i,
-			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
-
-		for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
-			TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
-				i, qp_id, &qp_conf,
-				rte_cryptodev_socket_id(i)),
-				"Failed to setup queue pair %u on "
-				"cryptodev %u", qp_id, i);
-		}
-
 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
 				(uint8_t)i);
 
diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c
index 79be119..ea755e0 100644
--- a/drivers/crypto/scheduler/scheduler_pmd_ops.c
+++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c
@@ -52,11 +52,8 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
 
 	for (i = 0; i < sched_ctx->nb_slaves; i++) {
 		uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
-		struct rte_cryptodev *slave_dev =
-				rte_cryptodev_pmd_get_dev(slave_dev_id);
 
-		ret = (*slave_dev->dev_ops->dev_configure)(slave_dev,
-				config);
+		ret = rte_cryptodev_configure(slave_dev_id, config);
 		if (ret < 0)
 			break;
 	}
@@ -340,11 +337,13 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 /** Setup a queue pair */
 static int
 scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
-	__rte_unused const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
+	const struct rte_cryptodev_qp_conf *qp_conf, int socket_id)
 {
 	struct scheduler_ctx *sched_ctx = dev->data->dev_private;
 	struct scheduler_qp_ctx *qp_ctx;
 	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	uint32_t i;
+	int ret;
 
 	if (snprintf(name, RTE_CRYPTODEV_NAME_MAX_LEN,
 			"CRYTO_SCHE PMD %u QP %u",
@@ -357,6 +356,15 @@ scheduler_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (dev->data->queue_pairs[qp_id] != NULL)
 		scheduler_pmd_qp_release(dev, qp_id);
 
+	for (i = 0; i < sched_ctx->nb_slaves; i++) {
+		uint8_t slave_id = sched_ctx->slaves[i].dev_id;
+
+		ret = rte_cryptodev_queue_pair_setup(slave_id, qp_id,
+				qp_conf, socket_id);
+		if (ret < 0)
+			return ret;
+	}
+
 	/* Allocate the queue pair data structure. */
 	qp_ctx = rte_zmalloc_socket(name, sizeof(*qp_ctx), RTE_CACHE_LINE_SIZE,
 			socket_id);
-- 
2.7.4

  parent reply	other threads:[~2017-02-17 12:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17 12:00 [dpdk-dev] [PATCH 0/3] cryptodev: change device configuration API Fan Zhang
2017-02-17 12:01 ` [dpdk-dev] [PATCH 1/3] " Fan Zhang
2017-03-23 14:55   ` Declan Doherty
2017-02-17 12:01 ` Fan Zhang [this message]
2017-03-23 14:58   ` [dpdk-dev] [PATCH 2/3] crypto/scheduler: improve slave configuration Declan Doherty
2017-03-23 15:09   ` Declan Doherty
2017-03-23 15:13     ` De Lara Guarch, Pablo
2017-02-17 12:01 ` [dpdk-dev] [PATCH 3/3] doc: remove deprecation notice Fan Zhang
2017-02-20 15:20   ` Mcnamara, John
2017-03-27 13:23 ` [dpdk-dev] [PATCH 0/3] cryptodev: change device configuration API De Lara Guarch, Pablo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487332862-5719-3-git-send-email-roy.fan.zhang@intel.com \
    --to=roy.fan.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).