All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gage Eads <gage.eads@intel.com>
To: dev@dpdk.org
Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com,
	harry.van.haaren@intel.com, bruce.richardson@intel.com,
	santosh.shukla@caviumnetworks.com, nipun.gupta@nxp.com
Subject: [PATCH 2/2] event/sw: support device stop flush callback
Date: Mon,  5 Mar 2018 17:01:10 -0600	[thread overview]
Message-ID: <1520290870-4987-2-git-send-email-gage.eads@intel.com> (raw)
In-Reply-To: <1520290870-4987-1-git-send-email-gage.eads@intel.com>

This commit also adds a flush callback test to the sw eventdev's selftest
suite.

Signed-off-by: Gage Eads <gage.eads@intel.com>
---
 drivers/event/sw/sw_evdev.c          | 25 +++++++++++-
 drivers/event/sw/sw_evdev_selftest.c | 75 +++++++++++++++++++++++++++++++++++-
 2 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index 6672fd8..4b57e5b 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -362,8 +362,25 @@ sw_init_qid_iqs(struct sw_evdev *sw)
 }
 
 static void
-sw_clean_qid_iqs(struct sw_evdev *sw)
+sw_flush_iq(struct rte_eventdev *dev, struct sw_iq *iq)
 {
+	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	while (iq_count(iq) > 0) {
+		struct rte_event event;
+
+		iq_dequeue_burst(sw, iq, &event, 1);
+
+		dev->dev_stop_flush(dev->data->dev_id,
+				    event,
+				    dev->dev_stop_flush_arg);
+	}
+}
+
+static void
+sw_clean_qid_iqs(struct rte_eventdev *dev)
+{
+	struct sw_evdev *sw = sw_pmd_priv(dev);
 	int i, j;
 
 	/* Release the IQ memory of all configured qids */
@@ -373,7 +390,11 @@ sw_clean_qid_iqs(struct sw_evdev *sw)
 		for (j = 0; j < SW_IQS_MAX; j++) {
 			if (!qid->iq[j].head)
 				continue;
+
+			if (dev->dev_stop_flush)
+				sw_flush_iq(dev, &qid->iq[j]);
 			iq_free_chunk_list(sw, qid->iq[j].head);
+
 			qid->iq[j].head = NULL;
 		}
 	}
@@ -702,7 +723,7 @@ static void
 sw_stop(struct rte_eventdev *dev)
 {
 	struct sw_evdev *sw = sw_pmd_priv(dev);
-	sw_clean_qid_iqs(sw);
+	sw_clean_qid_iqs(dev);
 	sw_xstats_uninit(sw);
 	sw->started = 0;
 	rte_smp_wmb();
diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index 78d30e0..f59362e 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -28,6 +28,7 @@
 #define MAX_PORTS 16
 #define MAX_QIDS 16
 #define NUM_PACKETS (1<<18)
+#define DEQUEUE_DEPTH 128
 
 static int evdev;
 
@@ -147,7 +148,7 @@ init(struct test *t, int nb_queues, int nb_ports)
 			.nb_event_ports = nb_ports,
 			.nb_event_queue_flows = 1024,
 			.nb_events_limit = 4096,
-			.nb_event_port_dequeue_depth = 128,
+			.nb_event_port_dequeue_depth = DEQUEUE_DEPTH,
 			.nb_event_port_enqueue_depth = 128,
 	};
 	int ret;
@@ -2807,6 +2808,72 @@ holb(struct test *t) /* test to check we avoid basic head-of-line blocking */
 	return -1;
 }
 
+static void
+flush(uint8_t dev_id __rte_unused, struct rte_event event, void *arg)
+{
+	*((uint8_t *) arg) += (event.u64 == 0xCA11BACC) ? 1 : 0;
+}
+
+static int
+dev_stop_flush(struct test *t) /* test to check we can properly flush events */
+{
+	const struct rte_event new_ev = {
+			.op = RTE_EVENT_OP_NEW,
+			.u64 = 0xCA11BACC
+			/* all other fields zero */
+	};
+	struct rte_event ev = new_ev;
+	uint8_t count = 0;
+	int i;
+
+	if (init(t, 1, 1) < 0 ||
+	    create_ports(t, 1) < 0 ||
+	    create_atomic_qids(t, 1) < 0) {
+		printf("%d: Error initializing device\n", __LINE__);
+		return -1;
+	}
+
+	/* Link the queue so *_start() doesn't error out */
+	if (rte_event_port_link(evdev, t->port[0], NULL, NULL, 0) != 1) {
+		printf("%d: Error linking queue to port\n", __LINE__);
+		goto err;
+	}
+
+	if (rte_event_dev_start(evdev) < 0) {
+		printf("%d: Error with start call\n", __LINE__);
+		goto err;
+	}
+
+	for (i = 0; i < DEQUEUE_DEPTH + 1; i++) {
+		if (rte_event_enqueue_burst(evdev, t->port[0], &ev, 1) != 1) {
+			printf("%d: Error enqueuing events\n", __LINE__);
+			goto err;
+		}
+	}
+
+	/* Schedule the events from the port to the IQ. At least one event
+	 * should be remaining in the queue.
+	 */
+	rte_service_run_iter_on_app_lcore(t->service_id, 1);
+
+	if (rte_event_dev_stop_flush_callback_register(evdev, flush, &count)) {
+		printf("%d: Error installing the flush callback\n", __LINE__);
+		goto err;
+	}
+
+	cleanup(t);
+
+	if (count == 0) {
+		printf("%d: Error executing the flush callback\n", __LINE__);
+		goto err;
+	}
+
+	return 0;
+err:
+	rte_event_dev_dump(evdev, stdout);
+	cleanup(t);
+	return -1;
+}
 static int
 worker_loopback_worker_fn(void *arg)
 {
@@ -3211,6 +3278,12 @@ test_sw_eventdev(void)
 		printf("ERROR - Head-of-line-blocking test FAILED.\n");
 		goto test_fail;
 	}
+	printf("*** Running Stop Flush test...\n");
+	ret = dev_stop_flush(t);
+	if (ret != 0) {
+		printf("ERROR - Stop Flush test FAILED.\n");
+		goto test_fail;
+	}
 	if (rte_lcore_count() >= 3) {
 		printf("*** Running Worker loopback test...\n");
 		ret = worker_loopback(t, 0);
-- 
2.7.4

  reply	other threads:[~2018-03-05 23:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 23:01 [PATCH 1/2] eventdev: add device stop flush callback Gage Eads
2018-03-05 23:01 ` Gage Eads [this message]
2018-03-08 23:10 ` [PATCH v2 " Gage Eads
2018-03-08 23:10   ` [PATCH v2 2/2] event/sw: support " Gage Eads
2018-03-12  6:25   ` [PATCH v2 1/2] eventdev: add " Jerin Jacob
2018-03-12 14:30     ` Eads, Gage
2018-03-12 14:38       ` Jerin Jacob
2018-03-15  4:12   ` [PATCH v3 " Gage Eads
2018-03-15  4:12     ` [PATCH v3 2/2] event/sw: support " Gage Eads
2018-03-20  7:44     ` [PATCH v3 1/2] eventdev: add " Jerin Jacob
2018-03-20 14:11       ` Eads, Gage
2018-03-20 14:13     ` [PATCH v4 " Gage Eads
2018-03-20 14:13       ` [PATCH v4 2/2] event/sw: support " Gage Eads
2018-03-23 17:05         ` Van Haaren, Harry
2018-03-26 22:01           ` Eads, Gage
2018-04-02  8:03             ` Jerin Jacob
2018-04-02 15:50               ` Eads, Gage
2018-04-02 17:08                 ` Jerin Jacob
2018-03-23 16:57       ` [PATCH v4 1/2] eventdev: add " Van Haaren, Harry
2018-03-26 21:59         ` Eads, Gage
2018-03-27  8:20           ` Van Haaren, Harry
2018-03-29 11:02             ` Van Haaren, Harry
2018-03-29 18:34               ` Jerin Jacob
2018-03-30  9:54               ` Liang, Ma
2018-04-02  8:01       ` Jerin Jacob
2018-04-02 18:03       ` [PATCH v5] " Gage Eads
2018-04-03  1:26         ` Jerin Jacob
2018-04-03  1:31           ` Jerin Jacob
2018-05-31 13:55 [PATCH 0/2] Improve service stop support Gage Eads
2018-05-31 13:55 ` [PATCH 2/2] event/sw: support device stop flush callback Gage Eads
2018-06-14 10:20   ` Van Haaren, Harry
2018-06-17 12:33     ` 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=1520290870-4987-2-git-send-email-gage.eads@intel.com \
    --to=gage.eads@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=nipun.gupta@nxp.com \
    --cc=santosh.shukla@caviumnetworks.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.