DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: jerin.jacob@caviumnetworks.com, matias.elo@nokia.com,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/3] event/sw: add unit test for unlinks in progress
Date: Thu, 20 Sep 2018 12:22:51 +0100	[thread overview]
Message-ID: <20180920112251.47854-3-harry.van.haaren@intel.com> (raw)
In-Reply-To: <20180920112251.47854-1-harry.van.haaren@intel.com>

This commit adds a unit test that checks the behaviour
of the unlinks_in_progress() function, ensuring that the
returned values are the number of unlinks requested,
until the scheduler runs and "acks" the requests, after
which the count should be zero again.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

v2:
- Add print before running unlink test (Harry)
---
 drivers/event/sw/sw_evdev.c          |  1 +
 drivers/event/sw/sw_evdev_selftest.c | 77 ++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 9e1412537..1175d6cdb 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -123,6 +123,7 @@ sw_port_unlink(struct rte_eventdev *dev, void *port, uint8_t queues[],
 static int
 sw_port_unlinks_in_progress(struct rte_eventdev *dev, void *port)
 {
+	RTE_SET_USED(dev);
 	struct sw_port *p = port;
 	return p->unlinks_in_progress;
 }
diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index c40912db5..d00d5de61 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -1903,6 +1903,77 @@ qid_priorities(struct test *t)
 	return 0;
 }
 
+static int
+unlink_in_progress(struct test *t)
+{
+	/* Test unlinking API, in particular that when an unlink request has
+	 * not yet been seen by the scheduler thread, that the
+	 * unlink_in_progress() function returns the number of unlinks.
+	 */
+	unsigned int i;
+	/* Create instance with 1 ports, and 3 qids */
+	if (init(t, 3, 1) < 0 ||
+			create_ports(t, 1) < 0) {
+		printf("%d: Error initializing device\n", __LINE__);
+		return -1;
+	}
+
+	for (i = 0; i < 3; i++) {
+		/* Create QID */
+		const struct rte_event_queue_conf conf = {
+			.schedule_type = RTE_SCHED_TYPE_ATOMIC,
+			/* increase priority (0 == highest), as we go */
+			.priority = RTE_EVENT_DEV_PRIORITY_NORMAL - i,
+			.nb_atomic_flows = 1024,
+			.nb_atomic_order_sequences = 1024,
+		};
+
+		if (rte_event_queue_setup(evdev, i, &conf) < 0) {
+			printf("%d: error creating qid %d\n", __LINE__, i);
+			return -1;
+		}
+		t->qid[i] = i;
+	}
+	t->nb_qids = i;
+	/* map all QIDs to port */
+	rte_event_port_link(evdev, t->port[0], NULL, NULL, 0);
+
+	if (rte_event_dev_start(evdev) < 0) {
+		printf("%d: Error with start call\n", __LINE__);
+		return -1;
+	}
+
+	/* unlink all ports to have outstanding unlink requests */
+	int ret = rte_event_port_unlink(evdev, t->port[0], NULL, 0);
+	if (ret < 0) {
+		printf("%d: Failed to unlink queues\n", __LINE__);
+		return -1;
+	}
+
+	/* get active unlinks here, expect 3 */
+	int unlinks_in_progress =
+		rte_event_port_unlinks_in_progress(evdev, t->port[0]);
+	if (unlinks_in_progress != 3) {
+		printf("%d: Expected num unlinks in progress == 3, got %d\n",
+				__LINE__, unlinks_in_progress);
+		return -1;
+	}
+
+	/* run scheduler service on this thread to ack the unlinks */
+	rte_service_run_iter_on_app_lcore(t->service_id, 1);
+
+	/* active unlinks expected as 0 as scheduler thread has acked */
+	unlinks_in_progress =
+		rte_event_port_unlinks_in_progress(evdev, t->port[0]);
+	if (unlinks_in_progress != 0) {
+		printf("%d: Expected num unlinks in progress == 0, got %d\n",
+				__LINE__, unlinks_in_progress);
+	}
+
+	cleanup(t);
+	return 0;
+}
+
 static int
 load_balancing(struct test *t)
 {
@@ -3260,6 +3331,12 @@ test_sw_eventdev(void)
 		printf("ERROR - QID Priority test FAILED.\n");
 		goto test_fail;
 	}
+	printf("*** Running Unlink-in-progress test...\n");
+	ret = unlink_in_progress(t);
+	if (ret != 0) {
+		printf("ERROR - Unlink in progress test FAILED.\n");
+		goto test_fail;
+	}
 	printf("*** Running Ordered Reconfigure test...\n");
 	ret = ordered_reconfigure(t);
 	if (ret != 0) {
-- 
2.17.1

  parent reply	other threads:[~2018-09-20 11:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 16:16 [dpdk-dev] [PATCH 1/3] event: add function for reading unlink " Harry van Haaren
2018-09-12 16:16 ` [dpdk-dev] [PATCH 2/3] event/sw: implement unlinks in progress function Harry van Haaren
2018-09-12 16:16 ` [dpdk-dev] [PATCH 3/3] event/sw: add unit test for unlinks in progress Harry van Haaren
2018-09-13 14:45 ` [dpdk-dev] [PATCH 1/3] event: add function for reading unlink " Jerin Jacob
2018-09-18 12:05 ` Elo, Matias (Nokia - FI/Espoo)
2018-09-20 11:22 ` [dpdk-dev] [PATCH v2 " Harry van Haaren
2018-09-20 11:22   ` [dpdk-dev] [PATCH v2 2/3] event/sw: implement unlinks in progress function Harry van Haaren
2018-09-23 11:08     ` Jerin Jacob
2018-09-20 11:22   ` Harry van Haaren [this message]
2018-09-24  8:23   ` [dpdk-dev] [PATCH v3 1/3] event: add function for reading unlink in progress Harry van Haaren
2018-09-24  8:23     ` [dpdk-dev] [PATCH v3 2/3] event/sw: implement unlinks in progress function Harry van Haaren
2018-09-24  8:23     ` [dpdk-dev] [PATCH v3 3/3] event/sw: add unit test for unlinks in progress Harry van Haaren
2018-09-24 14:56     ` [dpdk-dev] [PATCH v3 1/3] event: add function for reading unlink " Jerin Jacob

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=20180920112251.47854-3-harry.van.haaren@intel.com \
    --to=harry.van.haaren@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=matias.elo@nokia.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).