diff mbox series

[v10,3/7] test/eth_rx: add test case for instance get API

Message ID 20220623093036.708448-3-ganapati.kundapura@intel.com (mailing list archive)
State Deferred
Delegated to: Jerin Jacob
Headers show
Series [v10,1/7] eventdev/eth_rx: add adapter instance get API | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ganapati Kundapura June 23, 2022, 9:30 a.m. UTC
Added test case for rte_event_eth_rx_adapter_instance_get()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

Reviewed-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
 app/test/test_event_eth_rx_adapter.c | 203 ++++++++++++++++++++++++++++++++++-
 1 file changed, 202 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index e358a70..1da7782 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -39,6 +39,7 @@  test_event_eth_rx_intr_adapter_common(void)
 #define TEST_INST_ID		0
 #define TEST_DEV_ID		0
 #define TEST_ETHDEV_ID		0
+#define TEST_ETH_QUEUE_ID	0
 
 struct event_eth_rx_adapter_test_params {
 	struct rte_mempool *mp;
@@ -1001,6 +1002,202 @@  adapter_queue_conf(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_pollq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Add queue 1 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
+static int
+adapter_intrq_instance_get(void)
+{
+	int err;
+	uint8_t inst_id;
+	uint16_t eth_dev_id;
+	struct rte_eth_dev_info dev_info;
+	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
+
+	/* Case 1: Test without configuring eth */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 2: Test with wrong eth port */
+	eth_dev_id = rte_eth_dev_count_total() + 1;
+	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 3: Test with wrong rx queue */
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    dev_info.max_rx_queues + 1,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Case 4: Test with right instance, port & rxq */
+	/* Intr enabled eth device can have both polled and intr queues.
+	 * Add polled queue 1 to Rx adapter
+	 */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
+	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
+	queue_conf.servicing_weight = 1; /* poll queue */
+
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 2 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 1,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 1,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Add intr queue 3 to Rx adapter */
+	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
+	queue_conf.servicing_weight = 0; /* intr  queue */
+	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 TEST_ETH_QUEUE_ID + 2,
+						 &queue_conf);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 2,
+						    &inst_id);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
+		    TEST_INST_ID, err);
+
+	/* Case 5: Test with right instance, port & wrong rxq */
+	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
+						    TEST_ETH_QUEUE_ID + 3,
+						    &inst_id);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	/* Delete all queues from the Rx adapter */
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+						 TEST_ETHDEV_ID,
+						 -1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite event_eth_rx_tests = {
 	.suite_name = "rx event eth adapter test suite",
 	.setup = testsuite_setup,
@@ -1019,6 +1216,8 @@  static struct unit_test_suite event_eth_rx_tests = {
 			     adapter_queue_event_buf_test),
 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
 			     adapter_queue_stats_test),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_pollq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };
@@ -1029,7 +1228,9 @@  static struct unit_test_suite event_eth_rx_intr_tests = {
 	.teardown = testsuite_teardown_rx_intr,
 	.unit_test_cases = {
 		TEST_CASE_ST(adapter_create, adapter_free,
-			adapter_intr_queue_add_del),
+			     adapter_intr_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+			     adapter_intrq_instance_get),
 		TEST_CASES_END() /**< NULL terminate unit test array */
 	}
 };