[3/3] test/event: unit test to burst add Rx queues to adapter

Message ID 20250207140910.721374-4-sthotton@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Jerin Jacob
Headers
Series Rx adapter API to add Rx queues in burst |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Shijith Thotton Feb. 7, 2025, 2:09 p.m. UTC
Added unit test for adding queues to Rx adapter in bursts using
rte_event_eth_rx_adapter_queues_add().

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 app/test/test_event_eth_rx_adapter.c | 86 ++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
  

Patch

diff --git a/app/test/test_event_eth_rx_adapter.c b/app/test/test_event_eth_rx_adapter.c
index 0233c87779..92b7ff6d99 100644
--- a/app/test/test_event_eth_rx_adapter.c
+++ b/app/test/test_event_eth_rx_adapter.c
@@ -9,6 +9,7 @@ 
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_malloc.h>
 
 #ifdef RTE_EXEC_ENV_WINDOWS
 static int
@@ -819,6 +820,89 @@  adapter_queue_add_del(void)
 	return TEST_SUCCESS;
 }
 
+static int
+adapter_queues_add_del(void)
+{
+	struct rte_event_eth_rx_adapter_queue_conf *queue_conf;
+	struct rte_event_dev_info event_dev_info;
+	struct rte_eth_dev_info dev_info;
+	uint16_t i, max_rx_queues;
+	int32_t *rx_queue_ids;
+	struct rte_event ev;
+	uint32_t cap;
+	int err;
+
+	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, TEST_ETHDEV_ID, &cap);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	max_rx_queues = RTE_MIN(dev_info.max_rx_queues, MAX_NUM_RX_QUEUE);
+
+	err = rte_event_dev_info_get(TEST_DEV_ID, &event_dev_info);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	queue_conf = rte_zmalloc(NULL, sizeof(*queue_conf) * max_rx_queues, 0);
+	TEST_ASSERT(queue_conf != NULL, "Failed to allocate memory");
+
+	rx_queue_ids = rte_zmalloc(NULL, sizeof(*rx_queue_ids) * max_rx_queues, 0);
+	TEST_ASSERT(rx_queue_ids != NULL, "Failed to allocate memory");
+
+	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
+	for (i = 0; i < max_rx_queues; i++) {
+		rx_queue_ids[i] = i;
+		ev.queue_id = i % event_dev_info.max_event_queues;
+		if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) {
+			ev.flow_id = 1;
+			queue_conf[i].rx_queue_flags =
+				RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
+		}
+		queue_conf[i].ev = ev;
+		queue_conf[i].servicing_weight = 1;
+	}
+
+	err = rte_event_eth_rx_adapter_queues_add(TEST_INST_ID,
+						  rte_eth_dev_count_total(),
+						  rx_queue_ids, queue_conf, 0);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	err = rte_event_eth_rx_adapter_queues_add(TEST_INST_ID + 1, TEST_ETHDEV_ID,
+						  NULL, queue_conf, 0);
+	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
+
+	err = rte_event_eth_rx_adapter_queues_add(TEST_INST_ID, TEST_ETHDEV_ID,
+						  rx_queue_ids, queue_conf, 1);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID, TEST_ETHDEV_ID, 0);
+	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) {
+		err = rte_event_eth_rx_adapter_queues_add(
+			TEST_INST_ID, TEST_ETHDEV_ID, rx_queue_ids, queue_conf,
+			max_rx_queues);
+		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+							 TEST_ETHDEV_ID, -1);
+		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	} else {
+		err = rte_event_eth_rx_adapter_queues_add(
+			TEST_INST_ID, TEST_ETHDEV_ID, NULL, queue_conf, 0);
+		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+
+		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
+							 TEST_ETHDEV_ID, -1);
+		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
+	}
+
+	rte_free(rx_queue_ids);
+	rte_free(queue_conf);
+
+	return TEST_SUCCESS;
+}
+
 static int
 adapter_multi_eth_add_del(void)
 {
@@ -1423,6 +1507,8 @@  static struct unit_test_suite event_eth_rx_tests = {
 		TEST_CASE_ST(NULL, NULL, adapter_create_free_with_params),
 		TEST_CASE_ST(adapter_create, adapter_free,
 					adapter_queue_add_del),
+		TEST_CASE_ST(adapter_create, adapter_free,
+					adapter_queues_add_del),
 		TEST_CASE_ST(adapter_create, adapter_free,
 					adapter_multi_eth_add_del),
 		TEST_CASE_ST(adapter_create, adapter_free, adapter_start_stop),