DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
To: dev@dpdk.org
Cc: thomas.monjalon@6wind.com, bruce.richardson@intel.com,
	harry.van.haaren@intel.com, hemant.agrawal@nxp.com,
	gage.eads@intel.com, nipun.gupta@nxp.com,
	santosh.shukla@caviumnetworks.com,
	Jerin Jacob <jerin.jacob@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH 24/39] app/test: octeontx unit test case helper functions
Date: Fri,  3 Mar 2017 22:58:06 +0530	[thread overview]
Message-ID: <1488562101-6658-25-git-send-email-jerin.jacob@caviumnetworks.com> (raw)
In-Reply-To: <1488562101-6658-1-git-send-email-jerin.jacob@caviumnetworks.com>

Add helper functions to generate, inject, consume and validate the events.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 app/test/test_eventdev_octeontx.c | 202 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 202 insertions(+)

diff --git a/app/test/test_eventdev_octeontx.c b/app/test/test_eventdev_octeontx.c
index e28880b..8a03920 100644
--- a/app/test/test_eventdev_octeontx.c
+++ b/app/test/test_eventdev_octeontx.c
@@ -54,6 +54,52 @@
 static int evdev;
 static struct rte_mempool *eventdev_test_mempool;
 
+struct event_attr {
+	uint32_t flow_id;
+	uint8_t event_type;
+	uint8_t sub_event_type;
+	uint8_t sched_type;
+	uint8_t queue;
+	uint8_t port;
+};
+
+
+static uint32_t seqn_list_index;
+static int seqn_list[NUM_PACKETS];
+
+static inline void
+seqn_list_init(void)
+{
+	RTE_BUILD_BUG_ON(NUM_PACKETS < MAX_EVENTS);
+	memset(seqn_list, 0, sizeof(seqn_list));
+	seqn_list_index = 0;
+}
+
+static inline int
+seqn_list_update(int val)
+{
+	if (seqn_list_index >= NUM_PACKETS)
+		return TEST_FAILED;
+
+	seqn_list[seqn_list_index++] = val;
+	rte_smp_wmb();
+	return TEST_SUCCESS;
+}
+
+static inline int
+seqn_list_check(int limit)
+{
+	int i;
+
+	for (i = 0; i < limit; i++) {
+		if (seqn_list[i] != i) {
+			printf("Seqn mismatch %d %d\n", seqn_list[i], i);
+			return TEST_FAILED;
+		}
+	}
+	return TEST_SUCCESS;
+}
+
 static int
 testsuite_setup(void)
 {
@@ -205,6 +251,162 @@ eventdev_teardown(void)
 	rte_mempool_free(eventdev_test_mempool);
 }
 
+static inline void
+update_event_and_validation_attr(struct rte_mbuf *m, struct rte_event *ev,
+			uint32_t flow_id, uint8_t event_type,
+			uint8_t sub_event_type, uint8_t sched_type,
+			uint8_t queue, uint8_t port)
+{
+	struct event_attr *attr;
+
+	/* Store the event attributes in mbuf for future reference */
+	attr = rte_pktmbuf_mtod(m, struct event_attr *);
+	attr->flow_id = flow_id;
+	attr->event_type = event_type;
+	attr->sub_event_type = sub_event_type;
+	attr->sched_type = sched_type;
+	attr->queue = queue;
+	attr->port = port;
+
+	ev->flow_id = flow_id;
+	ev->sub_event_type = sub_event_type;
+	ev->event_type = event_type;
+	/* Inject the new event */
+	ev->op = RTE_EVENT_OP_NEW;
+	ev->sched_type = sched_type;
+	ev->queue_id = queue;
+	ev->mbuf = m;
+}
+
+static inline int
+inject_events(uint32_t flow_id, uint8_t event_type, uint8_t sub_event_type,
+		uint8_t sched_type, uint8_t queue, uint8_t port,
+		unsigned int events)
+{
+	struct rte_mbuf *m;
+	unsigned int i;
+
+	for (i = 0; i < events; i++) {
+		struct rte_event ev = {0};
+
+		m = rte_pktmbuf_alloc(eventdev_test_mempool);
+		TEST_ASSERT_NOT_NULL(m, "mempool alloc failed");
+
+		m->seqn = i;
+		update_event_and_validation_attr(m, &ev, flow_id, event_type,
+			sub_event_type, sched_type, queue, port);
+		rte_event_enqueue_burst(evdev, port, &ev, 1);
+	}
+	return 0;
+}
+
+static inline int
+check_excess_events(uint8_t port)
+{
+	int i;
+	uint16_t valid_event;
+	struct rte_event ev;
+
+	/* Check for excess events, try for a few times and exit */
+	for (i = 0; i < 32; i++) {
+		valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
+
+		TEST_ASSERT_SUCCESS(valid_event, "Unexpected valid event=%d",
+					ev.mbuf->seqn);
+	}
+	return 0;
+}
+
+static inline int
+generate_random_events(const unsigned int total_events)
+{
+	struct rte_event_dev_info info;
+	unsigned int i;
+	int ret;
+
+	ret = rte_event_dev_info_get(evdev, &info);
+	TEST_ASSERT_SUCCESS(ret, "Failed to get event dev info");
+	for (i = 0; i < total_events; i++) {
+		ret = inject_events(
+			rte_rand() % info.max_event_queue_flows /*flow_id */,
+			rte_rand() % (RTE_EVENT_TYPE_CPU + 1) /* event_type */,
+			rte_rand() % 256 /* sub_event_type */,
+			rte_rand() % (RTE_SCHED_TYPE_PARALLEL + 1),
+			rte_rand() % rte_event_queue_count(evdev) /* queue */,
+			0 /* port */,
+			1 /* events */);
+		if (ret)
+			return TEST_FAILED;
+	}
+	return ret;
+}
+
+static inline int
+validate_event(struct rte_event *ev)
+{
+	struct event_attr *attr;
+
+	attr = rte_pktmbuf_mtod(ev->mbuf, struct event_attr *);
+	TEST_ASSERT_EQUAL(attr->flow_id, ev->flow_id,
+			"flow_id mismatch enq=%d deq =%d",
+			attr->flow_id, ev->flow_id);
+	TEST_ASSERT_EQUAL(attr->event_type, ev->event_type,
+			"event_type mismatch enq=%d deq =%d",
+			attr->event_type, ev->event_type);
+	TEST_ASSERT_EQUAL(attr->sub_event_type, ev->sub_event_type,
+			"sub_event_type mismatch enq=%d deq =%d",
+			attr->sub_event_type, ev->sub_event_type);
+	TEST_ASSERT_EQUAL(attr->sched_type, ev->sched_type,
+			"sched_type mismatch enq=%d deq =%d",
+			attr->sched_type, ev->sched_type);
+	TEST_ASSERT_EQUAL(attr->queue, ev->queue_id,
+			"queue mismatch enq=%d deq =%d",
+			attr->queue, ev->queue_id);
+	return 0;
+}
+
+typedef int (*validate_event_cb)(uint32_t index, uint8_t port,
+				 struct rte_event *ev);
+
+static inline int
+consume_events(uint8_t port, const uint32_t total_events, validate_event_cb fn)
+{
+	int ret;
+	uint16_t valid_event;
+	uint32_t events = 0, forward_progress_cnt = 0, index = 0;
+	struct rte_event ev;
+
+	while (1) {
+		if (++forward_progress_cnt > UINT16_MAX) {
+			printf("Detected deadlock\n");
+			return TEST_FAILED;
+		}
+
+		valid_event = rte_event_dequeue_burst(evdev, port, &ev, 1, 0);
+		if (!valid_event)
+			continue;
+
+		forward_progress_cnt = 0;
+		ret = validate_event(&ev);
+		if (ret)
+			return TEST_FAILED;
+
+		if (fn != NULL) {
+			ret = fn(index, port, &ev);
+			TEST_ASSERT_SUCCESS(ret,
+				"Failed to validate test specific event");
+		}
+
+		++index;
+
+		rte_pktmbuf_free(ev.mbuf);
+		if (++events >= total_events)
+			break;
+	}
+
+	return check_excess_events(port);
+}
+
 static struct unit_test_suite eventdev_octeontx_testsuite  = {
 	.suite_name = "eventdev octeontx unit test suite",
 	.setup = testsuite_setup,
-- 
2.5.5

  parent reply	other threads:[~2017-03-03 17:30 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 17:27 [dpdk-dev] Cavium OCTEONTX ssovf eventdev PMD Jerin Jacob
2017-03-03 17:27 ` [dpdk-dev] [PATCH 01/39] eventdev: update PMD dequeue timeout conversion callback Jerin Jacob
2017-03-15 17:27   ` Van Haaren, Harry
2017-03-16  8:30     ` Jerin Jacob
2017-03-23 10:11     ` Jerin Jacob
2017-03-03 17:27 ` [dpdk-dev] [PATCH 02/39] app/test: fix eventdev reconfigure test Jerin Jacob
2017-03-15 17:28   ` Van Haaren, Harry
2017-03-23 10:11     ` Jerin Jacob
2017-03-03 17:27 ` [dpdk-dev] [PATCH 03/39] mk: handle intra drivers dependencies for shared build Jerin Jacob
2017-03-03 17:27 ` [dpdk-dev] [PATCH 04/39] event/octeontx: add build and log infrastructure Jerin Jacob
2017-03-23 15:14   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 05/39] event/octeontx: probe ssovf pcie devices Jerin Jacob
2017-03-23 15:39   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 06/39] event/octeontx: probe ssowvf " Jerin Jacob
2017-03-23 15:44   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 07/39] event/octeontx: add vdev interface functions Jerin Jacob
2017-03-23 16:07   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 08/39] event/octeontx: add mailbox support Jerin Jacob
2017-03-23 16:46   ` Eads, Gage
2017-03-24  9:57     ` Jerin Jacob
2017-03-03 17:27 ` [dpdk-dev] [PATCH 09/39] event/octeontx: add octeontx eventdev driver Jerin Jacob
2017-03-23 17:07   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 10/39] event/octeontx: add device capabilities function Jerin Jacob
2017-03-23 17:08   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 11/39] event/octeontx: add configure function Jerin Jacob
2017-03-23 18:09   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 12/39] event/octeontx: add support for event queues Jerin Jacob
2017-03-23 18:10   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 13/39] event/octeontx: add support for event ports Jerin Jacob
2017-03-23 18:14   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 14/39] event/octeontx: add support for linking queues to ports Jerin Jacob
2017-03-23 18:16   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 15/39] event/octeontx: add support dequeue timeout tick conversion Jerin Jacob
2017-03-23 18:17   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 16/39] event/octeontx: add dump function for easier debugging Jerin Jacob
2017-03-23 18:20   ` Eads, Gage
2017-03-03 17:27 ` [dpdk-dev] [PATCH 17/39] event/octeontx: add SSO HW device operations Jerin Jacob
2017-03-22 15:29   ` Eads, Gage
2017-03-23 18:24     ` Eads, Gage
2017-03-03 17:28 ` [dpdk-dev] [PATCH 18/39] event/octeontx: add support worker enqueue function Jerin Jacob
2017-03-23 18:27   ` Eads, Gage
2017-03-03 17:28 ` [dpdk-dev] [PATCH 19/39] event/octeontx: add support worker dequeue function Jerin Jacob
2017-03-20 21:11   ` Eads, Gage
2017-03-21  3:21     ` Jerin Jacob
2017-03-23 18:51   ` Eads, Gage
2017-03-24 11:16     ` Jerin Jacob
2017-03-03 17:28 ` [dpdk-dev] [PATCH 20/39] event/octeontx: add start function Jerin Jacob
2017-03-23 18:59   ` Eads, Gage
2017-03-03 17:28 ` [dpdk-dev] [PATCH 21/39] event/octeontx: add stop and close function Jerin Jacob
2017-03-23 19:02   ` Eads, Gage
2017-03-03 17:28 ` [dpdk-dev] [PATCH 22/39] app/test: octeontx eventdev unit test infrastructure Jerin Jacob
2017-03-23 11:55   ` Van Haaren, Harry
2017-03-24 13:40     ` Jerin Jacob
2017-03-24 13:47       ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 23/39] app/test: octeontx unit test case setup and teardown Jerin Jacob
2017-03-23 11:56   ` Van Haaren, Harry
2017-03-03 17:28 ` Jerin Jacob [this message]
2017-03-23 12:00   ` [dpdk-dev] [PATCH 24/39] app/test: octeontx unit test case helper functions Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 25/39] app/test: octeontx simple event enqueue and dequeue test Jerin Jacob
2017-03-23 12:01   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 26/39] app/test: octeontx multi queue " Jerin Jacob
2017-03-23 12:02   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 27/39] app/test: octeontx eventdev priority test Jerin Jacob
2017-03-23 12:03   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 28/39] app/test: add infrastructure for multicore octeontx tests Jerin Jacob
2017-03-23 12:03   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 29/39] app/test: octeontx multi queue and multi core/port tests Jerin Jacob
2017-03-23 12:04   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 30/39] app/test: octeontx single link establishment test Jerin Jacob
2017-03-23 12:05   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 31/39] app/test: octeontx multi " Jerin Jacob
2017-03-23 12:06   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 32/39] app/test: octeontx flow based two stage sched type test Jerin Jacob
2017-03-23 12:07   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 33/39] app/test: octeontx queue " Jerin Jacob
2017-03-23 12:08   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 34/39] app/test: octeontx flow based maximum stage pipeline Jerin Jacob
2017-03-23 12:08   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 35/39] app/test: octeontx queue " Jerin Jacob
2017-03-23 12:09   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 36/39] app/test: octeontx queue and flow based max " Jerin Jacob
2017-03-23 12:09   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 37/39] app/test: octeontx producer-consumer based order test Jerin Jacob
2017-03-23 12:10   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 38/39] app/test: add remaining tests based on existing helpers Jerin Jacob
2017-03-23 12:11   ` Van Haaren, Harry
2017-03-03 17:28 ` [dpdk-dev] [PATCH 39/39] doc: add OCTEONTX ssovf details Jerin Jacob
2017-03-20 20:20   ` Eads, Gage
2017-03-20 21:38   ` Eads, Gage
2017-03-21  3:18     ` Jerin Jacob
2017-03-23 12:47   ` Van Haaren, Harry
2017-03-31 19:34 ` [dpdk-dev] [PATCH v2 00/38] Cavium OCTEONTX ssovf eventdev PMD Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 01/38] event/octeontx: add build and log infrastructure Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 02/38] event/octeontx: probe ssovf pcie devices Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 03/38] event/octeontx: probe ssowvf " Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 04/38] event/octeontx: add vdev interface functions Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 05/38] event/octeontx: add mailbox support Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 06/38] event/octeontx: add octeontx eventdev driver Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 07/38] event/octeontx: add device capabilities function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 08/38] event/octeontx: add configure function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 09/38] event/octeontx: add support for event queues Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 10/38] event/octeontx: add support for event ports Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 11/38] event/octeontx: add support for linking queues to ports Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 12/38] event/octeontx: add support dequeue timeout tick conversion Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 13/38] event/octeontx: add dump function for easier debugging Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 14/38] event/octeontx: add SSO HW device operations Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 15/38] event/octeontx: add support worker enqueue function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 16/38] event/octeontx: add support worker dequeue function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 17/38] event/octeontx: add start function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 18/38] event/octeontx: add stop and close function Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 19/38] test/test: octeontx eventdev unit test infrastructure Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 20/38] test/test: octeontx unit test case setup and teardown Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 21/38] test/test: octeontx unit test case helper functions Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 22/38] test/test: octeontx simple event enqueue and dequeue test Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 23/38] test/test: octeontx multi queue " Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 24/38] test/test: octeontx eventdev priority test Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 25/38] test/test: add infrastructure for multicore octeontx tests Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 26/38] test/test: octeontx multi queue and multi core/port tests Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 27/38] test/test: octeontx single link establishment test Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 28/38] test/test: octeontx multi " Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 29/38] test/test: octeontx flow based two stage sched type test Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 30/38] test/test: octeontx queue " Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 31/38] test/test: octeontx flow based maximum stage pipeline Jerin Jacob
2017-03-31 19:34   ` [dpdk-dev] [PATCH v2 32/38] test/test: octeontx queue " Jerin Jacob
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 33/38] test/test: octeontx queue and flow based max " Jerin Jacob
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 34/38] test/test: octeontx producer-consumer based order test Jerin Jacob
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 35/38] test/test: add remaining tests based on existing helpers Jerin Jacob
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 36/38] doc: add OCTEONTX ssovf details Jerin Jacob
2017-04-02 12:29     ` Mcnamara, John
2017-04-03  4:49       ` Jerin Jacob
2017-04-02 15:20     ` Mcnamara, John
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 37/38] maintainers: claim OCTEONTX eventdev PMD maintainership Jerin Jacob
2017-03-31 19:35   ` [dpdk-dev] [PATCH v2 38/38] doc: add Cavium OCTEONTX eventdev PMD to 17.05 release notes Jerin Jacob
2017-04-02 12:18     ` Mcnamara, John
2017-04-03 11:29   ` [dpdk-dev] [PATCH v2 00/38] Cavium OCTEONTX ssovf eventdev PMD 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=1488562101-6658-25-git-send-email-jerin.jacob@caviumnetworks.com \
    --to=jerin.jacob@caviumnetworks.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=gage.eads@intel.com \
    --cc=harry.van.haaren@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=nipun.gupta@nxp.com \
    --cc=santosh.shukla@caviumnetworks.com \
    --cc=thomas.monjalon@6wind.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).