xref: /dpdk/app/test/test_event_eth_rx_adapter.c (revision 1f07a41de08026bd387129cd502c82240e960a86)
1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2a9de470cSBruce Richardson  * Copyright(c) 2017 Intel Corporation
3a9de470cSBruce Richardson  */
43c60274cSJie Zhou 
53c60274cSJie Zhou #include "test.h"
63c60274cSJie Zhou 
7a9de470cSBruce Richardson #include <string.h>
8a9de470cSBruce Richardson #include <rte_common.h>
9a9de470cSBruce Richardson #include <rte_mempool.h>
10a9de470cSBruce Richardson #include <rte_mbuf.h>
11a9de470cSBruce Richardson #include <rte_ethdev.h>
123c60274cSJie Zhou 
133c60274cSJie Zhou #ifdef RTE_EXEC_ENV_WINDOWS
143c60274cSJie Zhou static int
test_event_eth_rx_adapter_common(void)153c60274cSJie Zhou test_event_eth_rx_adapter_common(void)
163c60274cSJie Zhou {
173c60274cSJie Zhou 	printf("event_eth_rx_adapter not supported on Windows, skipping test\n");
183c60274cSJie Zhou 	return TEST_SKIPPED;
193c60274cSJie Zhou }
203c60274cSJie Zhou 
213c60274cSJie Zhou static int
test_event_eth_rx_intr_adapter_common(void)223c60274cSJie Zhou test_event_eth_rx_intr_adapter_common(void)
233c60274cSJie Zhou {
243c60274cSJie Zhou 	printf("event_eth_rx_intr_adapter not supported on Windows, skipping test\n");
253c60274cSJie Zhou 	return TEST_SKIPPED;
263c60274cSJie Zhou }
273c60274cSJie Zhou 
283c60274cSJie Zhou #else
293c60274cSJie Zhou 
30a9de470cSBruce Richardson #include <rte_eventdev.h>
31a9de470cSBruce Richardson #include <rte_bus_vdev.h>
32a9de470cSBruce Richardson 
33a9de470cSBruce Richardson #include <rte_event_eth_rx_adapter.h>
34a9de470cSBruce Richardson 
35a9de470cSBruce Richardson #define MAX_NUM_RX_QUEUE	64
36a9de470cSBruce Richardson #define NB_MBUFS		(8192 * num_ports * MAX_NUM_RX_QUEUE)
37a9de470cSBruce Richardson #define MBUF_CACHE_SIZE		512
38a9de470cSBruce Richardson #define MBUF_PRIV_SIZE		0
39a9de470cSBruce Richardson #define TEST_INST_ID		0
40a9de470cSBruce Richardson #define TEST_DEV_ID		0
41a9de470cSBruce Richardson #define TEST_ETHDEV_ID		0
42a1793ee8SGanapati Kundapura #define TEST_ETH_QUEUE_ID	0
43a9de470cSBruce Richardson 
44a9de470cSBruce Richardson struct event_eth_rx_adapter_test_params {
45a9de470cSBruce Richardson 	struct rte_mempool *mp;
46a9de470cSBruce Richardson 	uint16_t rx_rings, tx_rings;
47a9de470cSBruce Richardson 	uint32_t caps;
48a9de470cSBruce Richardson 	int rx_intr_port_inited;
49a9de470cSBruce Richardson 	uint16_t rx_intr_port;
50a9de470cSBruce Richardson };
51a9de470cSBruce Richardson 
52a9de470cSBruce Richardson static struct event_eth_rx_adapter_test_params default_params;
53df19eda6SJay Jayatheerthan static bool event_dev_created;
54df19eda6SJay Jayatheerthan static bool eth_dev_created;
55a9de470cSBruce Richardson 
56a9de470cSBruce Richardson static inline int
port_init_common(uint16_t port,const struct rte_eth_conf * port_conf,struct rte_mempool * mp)57a9de470cSBruce Richardson port_init_common(uint16_t port, const struct rte_eth_conf *port_conf,
58a9de470cSBruce Richardson 		struct rte_mempool *mp)
59a9de470cSBruce Richardson {
60a9de470cSBruce Richardson 	const uint16_t rx_ring_size = 512, tx_ring_size = 512;
61a9de470cSBruce Richardson 	int retval;
62a9de470cSBruce Richardson 	uint16_t q;
63a9de470cSBruce Richardson 	struct rte_eth_dev_info dev_info;
64a9de470cSBruce Richardson 
65a9de470cSBruce Richardson 	if (!rte_eth_dev_is_valid_port(port))
66a9de470cSBruce Richardson 		return -1;
67a9de470cSBruce Richardson 
68a9de470cSBruce Richardson 	retval = rte_eth_dev_configure(port, 0, 0, port_conf);
69a9de470cSBruce Richardson 
7077339255SIvan Ilchenko 	retval = rte_eth_dev_info_get(port, &dev_info);
7177339255SIvan Ilchenko 	if (retval != 0)
7277339255SIvan Ilchenko 		return retval;
73a9de470cSBruce Richardson 
74a9de470cSBruce Richardson 	default_params.rx_rings = RTE_MIN(dev_info.max_rx_queues,
75a9de470cSBruce Richardson 					MAX_NUM_RX_QUEUE);
76a9de470cSBruce Richardson 	default_params.tx_rings = 1;
77a9de470cSBruce Richardson 
78a9de470cSBruce Richardson 	/* Configure the Ethernet device. */
79a9de470cSBruce Richardson 	retval = rte_eth_dev_configure(port, default_params.rx_rings,
80a9de470cSBruce Richardson 				default_params.tx_rings, port_conf);
81a9de470cSBruce Richardson 	if (retval != 0)
82a9de470cSBruce Richardson 		return retval;
83a9de470cSBruce Richardson 
84a9de470cSBruce Richardson 	for (q = 0; q < default_params.rx_rings; q++) {
85a9de470cSBruce Richardson 		retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
86a9de470cSBruce Richardson 				rte_eth_dev_socket_id(port), NULL, mp);
87a9de470cSBruce Richardson 		if (retval < 0)
88a9de470cSBruce Richardson 			return retval;
89a9de470cSBruce Richardson 	}
90a9de470cSBruce Richardson 
91a9de470cSBruce Richardson 	/* Allocate and set up 1 TX queue per Ethernet port. */
92a9de470cSBruce Richardson 	for (q = 0; q < default_params.tx_rings; q++) {
93a9de470cSBruce Richardson 		retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
94a9de470cSBruce Richardson 				rte_eth_dev_socket_id(port), NULL);
95a9de470cSBruce Richardson 		if (retval < 0)
96a9de470cSBruce Richardson 			return retval;
97a9de470cSBruce Richardson 	}
98a9de470cSBruce Richardson 
99a9de470cSBruce Richardson 	/* Start the Ethernet port. */
100a9de470cSBruce Richardson 	retval = rte_eth_dev_start(port);
101a9de470cSBruce Richardson 	if (retval < 0)
102a9de470cSBruce Richardson 		return retval;
103a9de470cSBruce Richardson 
104a9de470cSBruce Richardson 	/* Display the port MAC address. */
1056d13ea8eSOlivier Matz 	struct rte_ether_addr addr;
1066fcf8586SIgor Romanov 	retval = rte_eth_macaddr_get(port, &addr);
1076fcf8586SIgor Romanov 	if (retval < 0)
1086fcf8586SIgor Romanov 		return retval;
109a9de470cSBruce Richardson 	printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
110a9de470cSBruce Richardson 			   " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
111a7db3afcSAman Deep Singh 			(unsigned int)port, RTE_ETHER_ADDR_BYTES(&addr));
112a9de470cSBruce Richardson 
113a9de470cSBruce Richardson 	/* Enable RX in promiscuous mode for the Ethernet device. */
11470e51a0eSIvan Ilchenko 	retval = rte_eth_promiscuous_enable(port);
11570e51a0eSIvan Ilchenko 	if (retval != 0)
11670e51a0eSIvan Ilchenko 		return retval;
117a9de470cSBruce Richardson 
118a9de470cSBruce Richardson 	return 0;
119a9de470cSBruce Richardson }
120a9de470cSBruce Richardson 
121a9de470cSBruce Richardson static inline int
port_init_rx_intr(uint16_t port,struct rte_mempool * mp)122a9de470cSBruce Richardson port_init_rx_intr(uint16_t port, struct rte_mempool *mp)
123a9de470cSBruce Richardson {
124a9de470cSBruce Richardson 	static const struct rte_eth_conf port_conf_default = {
125a9de470cSBruce Richardson 		.rxmode = {
126295968d1SFerruh Yigit 			.mq_mode = RTE_ETH_MQ_RX_NONE,
127a9de470cSBruce Richardson 		},
128a9de470cSBruce Richardson 		.intr_conf = {
129a9de470cSBruce Richardson 			.rxq = 1,
130a9de470cSBruce Richardson 		},
131a9de470cSBruce Richardson 	};
132a9de470cSBruce Richardson 
133a9de470cSBruce Richardson 	return port_init_common(port, &port_conf_default, mp);
134a9de470cSBruce Richardson }
135a9de470cSBruce Richardson 
136a9de470cSBruce Richardson static inline int
port_init(uint16_t port,struct rte_mempool * mp)137a9de470cSBruce Richardson port_init(uint16_t port, struct rte_mempool *mp)
138a9de470cSBruce Richardson {
139a9de470cSBruce Richardson 	static const struct rte_eth_conf port_conf_default = {
140a9de470cSBruce Richardson 		.rxmode = {
141295968d1SFerruh Yigit 			.mq_mode = RTE_ETH_MQ_RX_NONE,
142a9de470cSBruce Richardson 		},
143a9de470cSBruce Richardson 	};
144a9de470cSBruce Richardson 
145a9de470cSBruce Richardson 	return port_init_common(port, &port_conf_default, mp);
146a9de470cSBruce Richardson }
147a9de470cSBruce Richardson 
148a9de470cSBruce Richardson static int
init_port_rx_intr(int num_ports)149a9de470cSBruce Richardson init_port_rx_intr(int num_ports)
150a9de470cSBruce Richardson {
151a9de470cSBruce Richardson 	int retval;
152a9de470cSBruce Richardson 	uint16_t portid;
153a9de470cSBruce Richardson 	int err;
154a9de470cSBruce Richardson 
155a9de470cSBruce Richardson 	default_params.mp = rte_pktmbuf_pool_create("packet_pool",
156a9de470cSBruce Richardson 						   NB_MBUFS,
157a9de470cSBruce Richardson 						   MBUF_CACHE_SIZE,
158a9de470cSBruce Richardson 						   MBUF_PRIV_SIZE,
159a9de470cSBruce Richardson 						   RTE_MBUF_DEFAULT_BUF_SIZE,
160a9de470cSBruce Richardson 						   rte_socket_id());
161a9de470cSBruce Richardson 	if (!default_params.mp)
162a9de470cSBruce Richardson 		return -ENOMEM;
163a9de470cSBruce Richardson 
164a9de470cSBruce Richardson 	RTE_ETH_FOREACH_DEV(portid) {
165a9de470cSBruce Richardson 		retval = port_init_rx_intr(portid, default_params.mp);
166a9de470cSBruce Richardson 		if (retval)
167a9de470cSBruce Richardson 			continue;
168a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, portid,
169a9de470cSBruce Richardson 							&default_params.caps);
170a9de470cSBruce Richardson 		if (err)
171a9de470cSBruce Richardson 			continue;
172a9de470cSBruce Richardson 		if (!(default_params.caps &
173a9de470cSBruce Richardson 			RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) {
174a9de470cSBruce Richardson 			default_params.rx_intr_port_inited = 1;
175a9de470cSBruce Richardson 			default_params.rx_intr_port = portid;
176a9de470cSBruce Richardson 			return 0;
177a9de470cSBruce Richardson 		}
1780ead65afSIvan Ilchenko 		retval = rte_eth_dev_stop(portid);
1790ead65afSIvan Ilchenko 		TEST_ASSERT(retval == 0, "Failed to stop port %u: %d\n",
1800ead65afSIvan Ilchenko 					portid, retval);
181a9de470cSBruce Richardson 	}
182a9de470cSBruce Richardson 	return 0;
183a9de470cSBruce Richardson }
184a9de470cSBruce Richardson 
185a9de470cSBruce Richardson static int
init_ports(int num_ports)186a9de470cSBruce Richardson init_ports(int num_ports)
187a9de470cSBruce Richardson {
188a9de470cSBruce Richardson 	uint16_t portid;
189a9de470cSBruce Richardson 	int retval;
190a9de470cSBruce Richardson 
191a9de470cSBruce Richardson 	struct rte_mempool *ptr = rte_mempool_lookup("packet_pool");
192a9de470cSBruce Richardson 
193a9de470cSBruce Richardson 	if (ptr == NULL)
194a9de470cSBruce Richardson 		default_params.mp = rte_pktmbuf_pool_create("packet_pool",
195a9de470cSBruce Richardson 						NB_MBUFS,
196a9de470cSBruce Richardson 						MBUF_CACHE_SIZE,
197a9de470cSBruce Richardson 						MBUF_PRIV_SIZE,
198a9de470cSBruce Richardson 						RTE_MBUF_DEFAULT_BUF_SIZE,
199a9de470cSBruce Richardson 						rte_socket_id());
200a9de470cSBruce Richardson 	else
201a9de470cSBruce Richardson 		default_params.mp = ptr;
202a9de470cSBruce Richardson 
203a9de470cSBruce Richardson 	if (!default_params.mp)
204a9de470cSBruce Richardson 		return -ENOMEM;
205a9de470cSBruce Richardson 
206a9de470cSBruce Richardson 	RTE_ETH_FOREACH_DEV(portid) {
207a9de470cSBruce Richardson 		retval = port_init(portid, default_params.mp);
208a9de470cSBruce Richardson 		if (retval)
209a9de470cSBruce Richardson 			return retval;
210a9de470cSBruce Richardson 	}
211a9de470cSBruce Richardson 
212a9de470cSBruce Richardson 	return 0;
213a9de470cSBruce Richardson }
214a9de470cSBruce Richardson 
215a9de470cSBruce Richardson static int
testsuite_setup(void)216a9de470cSBruce Richardson testsuite_setup(void)
217a9de470cSBruce Richardson {
218a9de470cSBruce Richardson 	int err;
219a9de470cSBruce Richardson 	uint8_t count;
220a9de470cSBruce Richardson 	struct rte_event_dev_info dev_info;
221a9de470cSBruce Richardson 
222a9de470cSBruce Richardson 	count = rte_event_dev_count();
223a9de470cSBruce Richardson 	if (!count) {
224a9de470cSBruce Richardson 		printf("Failed to find a valid event device,"
225a9de470cSBruce Richardson 			" testing with event_skeleton device\n");
226df19eda6SJay Jayatheerthan 		err = rte_vdev_init("event_skeleton", NULL);
227df19eda6SJay Jayatheerthan 		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
228df19eda6SJay Jayatheerthan 			    err);
229df19eda6SJay Jayatheerthan 		event_dev_created = true;
230a9de470cSBruce Richardson 	}
231a9de470cSBruce Richardson 
232a9de470cSBruce Richardson 	struct rte_event_dev_config config = {
233a9de470cSBruce Richardson 			.nb_event_queues = 1,
234a9de470cSBruce Richardson 			.nb_event_ports = 1,
235a9de470cSBruce Richardson 	};
236a9de470cSBruce Richardson 
237a9de470cSBruce Richardson 	err = rte_event_dev_info_get(TEST_DEV_ID, &dev_info);
238a9de470cSBruce Richardson 	config.nb_event_queue_flows = dev_info.max_event_queue_flows;
239a9de470cSBruce Richardson 	config.nb_event_port_dequeue_depth =
240a9de470cSBruce Richardson 			dev_info.max_event_port_dequeue_depth;
241a9de470cSBruce Richardson 	config.nb_event_port_enqueue_depth =
242a9de470cSBruce Richardson 			dev_info.max_event_port_enqueue_depth;
243a9de470cSBruce Richardson 	config.nb_events_limit =
244a9de470cSBruce Richardson 			dev_info.max_num_events;
245a9de470cSBruce Richardson 	err = rte_event_dev_configure(TEST_DEV_ID, &config);
246a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
247a9de470cSBruce Richardson 			err);
248a9de470cSBruce Richardson 
249df19eda6SJay Jayatheerthan 	count = rte_eth_dev_count_total();
250df19eda6SJay Jayatheerthan 	if (!count) {
251df19eda6SJay Jayatheerthan 		printf("Testing with net_null device\n");
252df19eda6SJay Jayatheerthan 		err = rte_vdev_init("net_null", NULL);
253df19eda6SJay Jayatheerthan 		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
254df19eda6SJay Jayatheerthan 			    err);
255df19eda6SJay Jayatheerthan 		eth_dev_created = true;
256df19eda6SJay Jayatheerthan 	}
257df19eda6SJay Jayatheerthan 
258a9de470cSBruce Richardson 	/*
259a9de470cSBruce Richardson 	 * eth devices like octeontx use event device to receive packets
260a9de470cSBruce Richardson 	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
261a9de470cSBruce Richardson 	 * call init_ports after rte_event_dev_configure
262a9de470cSBruce Richardson 	 */
263a9de470cSBruce Richardson 	err = init_ports(rte_eth_dev_count_total());
264a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Port initialization failed err %d\n", err);
265a9de470cSBruce Richardson 
266a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, TEST_ETHDEV_ID,
267a9de470cSBruce Richardson 						&default_params.caps);
268a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Failed to get adapter cap err %d\n",
269a9de470cSBruce Richardson 			err);
270a9de470cSBruce Richardson 
271a9de470cSBruce Richardson 	return err;
272a9de470cSBruce Richardson }
273a9de470cSBruce Richardson 
274a9de470cSBruce Richardson static int
testsuite_setup_rx_intr(void)275a9de470cSBruce Richardson testsuite_setup_rx_intr(void)
276a9de470cSBruce Richardson {
277a9de470cSBruce Richardson 	int err;
278a9de470cSBruce Richardson 	uint8_t count;
279a9de470cSBruce Richardson 	struct rte_event_dev_info dev_info;
280a9de470cSBruce Richardson 
281a9de470cSBruce Richardson 	count = rte_event_dev_count();
282a9de470cSBruce Richardson 	if (!count) {
283a9de470cSBruce Richardson 		printf("Failed to find a valid event device,"
284a9de470cSBruce Richardson 			" testing with event_skeleton device\n");
285df19eda6SJay Jayatheerthan 		err = rte_vdev_init("event_skeleton", NULL);
286df19eda6SJay Jayatheerthan 		TEST_ASSERT(err == 0, "Failed to create event_skeleton. err=%d",
287df19eda6SJay Jayatheerthan 			    err);
288df19eda6SJay Jayatheerthan 		event_dev_created = true;
289a9de470cSBruce Richardson 	}
290a9de470cSBruce Richardson 
291a9de470cSBruce Richardson 	struct rte_event_dev_config config = {
292a9de470cSBruce Richardson 		.nb_event_queues = 1,
293a9de470cSBruce Richardson 		.nb_event_ports = 1,
294a9de470cSBruce Richardson 	};
295a9de470cSBruce Richardson 
296a9de470cSBruce Richardson 	err = rte_event_dev_info_get(TEST_DEV_ID, &dev_info);
297a9de470cSBruce Richardson 	config.nb_event_queue_flows = dev_info.max_event_queue_flows;
298a9de470cSBruce Richardson 	config.nb_event_port_dequeue_depth =
299a9de470cSBruce Richardson 			dev_info.max_event_port_dequeue_depth;
300a9de470cSBruce Richardson 	config.nb_event_port_enqueue_depth =
301a9de470cSBruce Richardson 			dev_info.max_event_port_enqueue_depth;
302a9de470cSBruce Richardson 	config.nb_events_limit =
303a9de470cSBruce Richardson 			dev_info.max_num_events;
304a9de470cSBruce Richardson 
305a9de470cSBruce Richardson 	err = rte_event_dev_configure(TEST_DEV_ID, &config);
306a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Event device initialization failed err %d\n",
307a9de470cSBruce Richardson 			err);
308a9de470cSBruce Richardson 
309df19eda6SJay Jayatheerthan 	count = rte_eth_dev_count_total();
310df19eda6SJay Jayatheerthan 	if (!count) {
311df19eda6SJay Jayatheerthan 		printf("Testing with net_null device\n");
312df19eda6SJay Jayatheerthan 		err = rte_vdev_init("net_null", NULL);
313df19eda6SJay Jayatheerthan 		TEST_ASSERT(err == 0, "Failed to create net_null. err=%d",
314df19eda6SJay Jayatheerthan 			    err);
315df19eda6SJay Jayatheerthan 		eth_dev_created = true;
316df19eda6SJay Jayatheerthan 	}
317df19eda6SJay Jayatheerthan 
318a9de470cSBruce Richardson 	/*
319a9de470cSBruce Richardson 	 * eth devices like octeontx use event device to receive packets
320a9de470cSBruce Richardson 	 * so rte_eth_dev_start invokes rte_event_dev_start internally, so
321a9de470cSBruce Richardson 	 * call init_ports after rte_event_dev_configure
322a9de470cSBruce Richardson 	 */
323a9de470cSBruce Richardson 	err = init_port_rx_intr(rte_eth_dev_count_total());
324a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Port initialization failed err %d\n", err);
325a9de470cSBruce Richardson 
326a9de470cSBruce Richardson 	if (!default_params.rx_intr_port_inited)
327a9de470cSBruce Richardson 		return 0;
328a9de470cSBruce Richardson 
329a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID,
330a9de470cSBruce Richardson 						default_params.rx_intr_port,
331a9de470cSBruce Richardson 						&default_params.caps);
332a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Failed to get adapter cap err %d\n", err);
333a9de470cSBruce Richardson 
334a9de470cSBruce Richardson 	return err;
335a9de470cSBruce Richardson }
336a9de470cSBruce Richardson 
337a9de470cSBruce Richardson static void
testsuite_teardown(void)338a9de470cSBruce Richardson testsuite_teardown(void)
339a9de470cSBruce Richardson {
340df19eda6SJay Jayatheerthan 	int err;
341a9de470cSBruce Richardson 	uint32_t i;
342a9de470cSBruce Richardson 	RTE_ETH_FOREACH_DEV(i)
343a9de470cSBruce Richardson 		rte_eth_dev_stop(i);
344a9de470cSBruce Richardson 
345df19eda6SJay Jayatheerthan 	if (eth_dev_created) {
346df19eda6SJay Jayatheerthan 		err = rte_vdev_uninit("net_null");
347df19eda6SJay Jayatheerthan 		if (err)
348df19eda6SJay Jayatheerthan 			printf("Failed to delete net_null. err=%d", err);
349df19eda6SJay Jayatheerthan 		eth_dev_created = false;
350df19eda6SJay Jayatheerthan 	}
351df19eda6SJay Jayatheerthan 
352a9de470cSBruce Richardson 	rte_mempool_free(default_params.mp);
353df19eda6SJay Jayatheerthan 	if (event_dev_created) {
354df19eda6SJay Jayatheerthan 		err = rte_vdev_uninit("event_skeleton");
355df19eda6SJay Jayatheerthan 		if (err)
356df19eda6SJay Jayatheerthan 			printf("Failed to delete event_skeleton. err=%d", err);
357df19eda6SJay Jayatheerthan 		event_dev_created = false;
358df19eda6SJay Jayatheerthan 	}
359df19eda6SJay Jayatheerthan 
360df19eda6SJay Jayatheerthan 	memset(&default_params, 0, sizeof(default_params));
361a9de470cSBruce Richardson }
362a9de470cSBruce Richardson 
363a9de470cSBruce Richardson static void
testsuite_teardown_rx_intr(void)364a9de470cSBruce Richardson testsuite_teardown_rx_intr(void)
365a9de470cSBruce Richardson {
366df19eda6SJay Jayatheerthan 	int err;
367a9de470cSBruce Richardson 	if (!default_params.rx_intr_port_inited)
368a9de470cSBruce Richardson 		return;
369a9de470cSBruce Richardson 
370a9de470cSBruce Richardson 	rte_eth_dev_stop(default_params.rx_intr_port);
371df19eda6SJay Jayatheerthan 	if (eth_dev_created) {
372df19eda6SJay Jayatheerthan 		err = rte_vdev_uninit("net_null");
373df19eda6SJay Jayatheerthan 		if (err)
374df19eda6SJay Jayatheerthan 			printf("Failed to delete net_null. err=%d", err);
375df19eda6SJay Jayatheerthan 		eth_dev_created = false;
376df19eda6SJay Jayatheerthan 	}
377a9de470cSBruce Richardson 	rte_mempool_free(default_params.mp);
378df19eda6SJay Jayatheerthan 	if (event_dev_created) {
379df19eda6SJay Jayatheerthan 		err = rte_vdev_uninit("event_skeleton");
380df19eda6SJay Jayatheerthan 		if (err)
381df19eda6SJay Jayatheerthan 			printf("Failed to delete event_skeleton. err=%d", err);
382df19eda6SJay Jayatheerthan 		event_dev_created = false;
383df19eda6SJay Jayatheerthan 	}
384df19eda6SJay Jayatheerthan 
385df19eda6SJay Jayatheerthan 	memset(&default_params, 0, sizeof(default_params));
386a9de470cSBruce Richardson }
387a9de470cSBruce Richardson 
388a9de470cSBruce Richardson static int
adapter_create(void)389a9de470cSBruce Richardson adapter_create(void)
390a9de470cSBruce Richardson {
391a9de470cSBruce Richardson 	int err;
392a9de470cSBruce Richardson 	struct rte_event_dev_info dev_info;
393a9de470cSBruce Richardson 	struct rte_event_port_conf rx_p_conf;
394a9de470cSBruce Richardson 
395a9de470cSBruce Richardson 	memset(&rx_p_conf, 0, sizeof(rx_p_conf));
396a9de470cSBruce Richardson 
397a9de470cSBruce Richardson 	err = rte_event_dev_info_get(TEST_DEV_ID, &dev_info);
398a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
399a9de470cSBruce Richardson 
400a9de470cSBruce Richardson 	rx_p_conf.new_event_threshold = dev_info.max_num_events;
401a9de470cSBruce Richardson 	rx_p_conf.dequeue_depth = dev_info.max_event_port_dequeue_depth;
402a9de470cSBruce Richardson 	rx_p_conf.enqueue_depth = dev_info.max_event_port_enqueue_depth;
403a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_create(TEST_INST_ID, TEST_DEV_ID,
404a9de470cSBruce Richardson 					&rx_p_conf);
405a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
406a9de470cSBruce Richardson 
407a9de470cSBruce Richardson 	return err;
408a9de470cSBruce Richardson }
409a9de470cSBruce Richardson 
410*1f07a41dSNaga Harish K S V static void
adapter_free(void)411*1f07a41dSNaga Harish K S V adapter_free(void)
412*1f07a41dSNaga Harish K S V {
413*1f07a41dSNaga Harish K S V 	rte_event_eth_rx_adapter_free(TEST_INST_ID);
414*1f07a41dSNaga Harish K S V }
415*1f07a41dSNaga Harish K S V 
416b06bca69SNaga Harish K S V static int
adapter_create_with_params(void)417b06bca69SNaga Harish K S V adapter_create_with_params(void)
418b06bca69SNaga Harish K S V {
419b06bca69SNaga Harish K S V 	int err;
420b06bca69SNaga Harish K S V 	struct rte_event_dev_info dev_info;
421b06bca69SNaga Harish K S V 	struct rte_event_port_conf rx_p_conf;
422b06bca69SNaga Harish K S V 	struct rte_event_eth_rx_adapter_params rxa_params;
423b06bca69SNaga Harish K S V 
424b06bca69SNaga Harish K S V 	memset(&rx_p_conf, 0, sizeof(rx_p_conf));
425b06bca69SNaga Harish K S V 
426b06bca69SNaga Harish K S V 	err = rte_event_dev_info_get(TEST_DEV_ID, &dev_info);
427b06bca69SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
428b06bca69SNaga Harish K S V 
429b06bca69SNaga Harish K S V 	rx_p_conf.new_event_threshold = dev_info.max_num_events;
430b06bca69SNaga Harish K S V 	rx_p_conf.dequeue_depth = dev_info.max_event_port_dequeue_depth;
431b06bca69SNaga Harish K S V 	rx_p_conf.enqueue_depth = dev_info.max_event_port_enqueue_depth;
432b06bca69SNaga Harish K S V 
433b06bca69SNaga Harish K S V 	rxa_params.use_queue_event_buf = false;
434b06bca69SNaga Harish K S V 	rxa_params.event_buf_size = 0;
435b06bca69SNaga Harish K S V 
436*1f07a41dSNaga Harish K S V 	/* Pass rxa_params = NULL */
437*1f07a41dSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
438*1f07a41dSNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, NULL);
439*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
440*1f07a41dSNaga Harish K S V 	if (err == 0)
441*1f07a41dSNaga Harish K S V 		adapter_free();
442*1f07a41dSNaga Harish K S V 
443b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
444b06bca69SNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
445b06bca69SNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
446b06bca69SNaga Harish K S V 
447b06bca69SNaga Harish K S V 	rxa_params.use_queue_event_buf = true;
448b06bca69SNaga Harish K S V 
449b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
450b06bca69SNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
451b06bca69SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
452b06bca69SNaga Harish K S V 
453b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
454b06bca69SNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
455b06bca69SNaga Harish K S V 	TEST_ASSERT(err == -EEXIST, "Expected -EEXIST got %d", err);
456b06bca69SNaga Harish K S V 
457b06bca69SNaga Harish K S V 	return TEST_SUCCESS;
458b06bca69SNaga Harish K S V }
459b06bca69SNaga Harish K S V 
460b06bca69SNaga Harish K S V static int
test_port_conf_cb(uint8_t id,uint8_t event_dev_id,struct rte_event_eth_rx_adapter_conf * conf,void * conf_arg)461*1f07a41dSNaga Harish K S V test_port_conf_cb(uint8_t id, uint8_t event_dev_id,
462*1f07a41dSNaga Harish K S V 		  struct rte_event_eth_rx_adapter_conf *conf,
463*1f07a41dSNaga Harish K S V 		  void *conf_arg)
464*1f07a41dSNaga Harish K S V {
465*1f07a41dSNaga Harish K S V 	struct rte_event_port_conf *port_conf, def_port_conf = {0};
466*1f07a41dSNaga Harish K S V 	uint32_t started;
467*1f07a41dSNaga Harish K S V 	static int port_allocated;
468*1f07a41dSNaga Harish K S V 	static uint8_t port_id;
469*1f07a41dSNaga Harish K S V 	int ret;
470*1f07a41dSNaga Harish K S V 
471*1f07a41dSNaga Harish K S V 	if (port_allocated) {
472*1f07a41dSNaga Harish K S V 		conf->event_port_id = port_id;
473*1f07a41dSNaga Harish K S V 		conf->max_nb_rx = 128;
474*1f07a41dSNaga Harish K S V 		return 0;
475*1f07a41dSNaga Harish K S V 	}
476*1f07a41dSNaga Harish K S V 
477*1f07a41dSNaga Harish K S V 	RTE_SET_USED(id);
478*1f07a41dSNaga Harish K S V 
479*1f07a41dSNaga Harish K S V 	ret = rte_event_dev_attr_get(event_dev_id, RTE_EVENT_DEV_ATTR_STARTED,
480*1f07a41dSNaga Harish K S V 				     &started);
481*1f07a41dSNaga Harish K S V 	if (ret < 0)
482*1f07a41dSNaga Harish K S V 		return ret;
483*1f07a41dSNaga Harish K S V 
484*1f07a41dSNaga Harish K S V 	if (started)
485*1f07a41dSNaga Harish K S V 		rte_event_dev_stop(event_dev_id);
486*1f07a41dSNaga Harish K S V 
487*1f07a41dSNaga Harish K S V 	port_id = 1;
488*1f07a41dSNaga Harish K S V 
489*1f07a41dSNaga Harish K S V 	if (conf_arg != NULL)
490*1f07a41dSNaga Harish K S V 		port_conf = conf_arg;
491*1f07a41dSNaga Harish K S V 	else {
492*1f07a41dSNaga Harish K S V 		port_conf = &def_port_conf;
493*1f07a41dSNaga Harish K S V 		ret = rte_event_port_default_conf_get(event_dev_id, port_id,
494*1f07a41dSNaga Harish K S V 						      port_conf);
495*1f07a41dSNaga Harish K S V 		if (ret < 0)
496*1f07a41dSNaga Harish K S V 			return ret;
497*1f07a41dSNaga Harish K S V 	}
498*1f07a41dSNaga Harish K S V 
499*1f07a41dSNaga Harish K S V 	ret = rte_event_port_setup(event_dev_id, port_id, port_conf);
500*1f07a41dSNaga Harish K S V 	if (ret < 0)
501*1f07a41dSNaga Harish K S V 		return ret;
502*1f07a41dSNaga Harish K S V 
503*1f07a41dSNaga Harish K S V 	conf->event_port_id = port_id;
504*1f07a41dSNaga Harish K S V 	conf->max_nb_rx = 128;
505*1f07a41dSNaga Harish K S V 
506*1f07a41dSNaga Harish K S V 	if (started)
507*1f07a41dSNaga Harish K S V 		rte_event_dev_start(event_dev_id);
508*1f07a41dSNaga Harish K S V 
509*1f07a41dSNaga Harish K S V 	/* Reuse this port number next time this is called */
510*1f07a41dSNaga Harish K S V 	port_allocated = 1;
511*1f07a41dSNaga Harish K S V 
512*1f07a41dSNaga Harish K S V 	return 0;
513*1f07a41dSNaga Harish K S V }
514*1f07a41dSNaga Harish K S V 
515*1f07a41dSNaga Harish K S V static int
adapter_create_ext_with_params(void)516*1f07a41dSNaga Harish K S V adapter_create_ext_with_params(void)
517*1f07a41dSNaga Harish K S V {
518*1f07a41dSNaga Harish K S V 	int err;
519*1f07a41dSNaga Harish K S V 	struct rte_event_dev_info dev_info;
520*1f07a41dSNaga Harish K S V 	struct rte_event_eth_rx_adapter_params rxa_params;
521*1f07a41dSNaga Harish K S V 
522*1f07a41dSNaga Harish K S V 	err = rte_event_dev_info_get(TEST_DEV_ID, &dev_info);
523*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
524*1f07a41dSNaga Harish K S V 
525*1f07a41dSNaga Harish K S V 	rxa_params.use_queue_event_buf = false;
526*1f07a41dSNaga Harish K S V 	rxa_params.event_buf_size = 0;
527*1f07a41dSNaga Harish K S V 
528*1f07a41dSNaga Harish K S V 	/* Pass rxa_params = NULL */
529*1f07a41dSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
530*1f07a41dSNaga Harish K S V 			TEST_DEV_ID, test_port_conf_cb, NULL, NULL);
531*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
532*1f07a41dSNaga Harish K S V 	if (err == 0)
533*1f07a41dSNaga Harish K S V 		adapter_free();
534*1f07a41dSNaga Harish K S V 
535*1f07a41dSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
536*1f07a41dSNaga Harish K S V 			TEST_DEV_ID, test_port_conf_cb, NULL, &rxa_params);
537*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
538*1f07a41dSNaga Harish K S V 
539*1f07a41dSNaga Harish K S V 	rxa_params.event_buf_size = 128;
540*1f07a41dSNaga Harish K S V 
541*1f07a41dSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
542*1f07a41dSNaga Harish K S V 			TEST_DEV_ID, test_port_conf_cb, NULL, &rxa_params);
543*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
544*1f07a41dSNaga Harish K S V 
545*1f07a41dSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_ext_with_params(TEST_INST_ID,
546*1f07a41dSNaga Harish K S V 			TEST_DEV_ID, test_port_conf_cb, NULL, &rxa_params);
547*1f07a41dSNaga Harish K S V 	TEST_ASSERT(err == -EEXIST, "Expected -EEXIST got %d", err);
548*1f07a41dSNaga Harish K S V 
549*1f07a41dSNaga Harish K S V 	return TEST_SUCCESS;
550*1f07a41dSNaga Harish K S V }
551*1f07a41dSNaga Harish K S V 
552*1f07a41dSNaga Harish K S V static int
adapter_queue_event_buf_test(void)553b06bca69SNaga Harish K S V adapter_queue_event_buf_test(void)
554b06bca69SNaga Harish K S V {
555b06bca69SNaga Harish K S V 	int err;
556b06bca69SNaga Harish K S V 	struct rte_event ev;
557b06bca69SNaga Harish K S V 	uint32_t cap;
558b06bca69SNaga Harish K S V 
559b06bca69SNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
560b06bca69SNaga Harish K S V 
561b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, TEST_ETHDEV_ID,
562b06bca69SNaga Harish K S V 					 &cap);
563b06bca69SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
564b06bca69SNaga Harish K S V 
565b06bca69SNaga Harish K S V 	ev.queue_id = 0;
566b06bca69SNaga Harish K S V 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
567b06bca69SNaga Harish K S V 	ev.priority = 0;
568b06bca69SNaga Harish K S V 
569b06bca69SNaga Harish K S V 	queue_config.rx_queue_flags = 0;
570b06bca69SNaga Harish K S V 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) {
571b06bca69SNaga Harish K S V 		ev.flow_id = 1;
572b06bca69SNaga Harish K S V 		queue_config.rx_queue_flags =
573b06bca69SNaga Harish K S V 			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
574b06bca69SNaga Harish K S V 	}
575b06bca69SNaga Harish K S V 	queue_config.ev = ev;
576b06bca69SNaga Harish K S V 	queue_config.servicing_weight = 1;
577b06bca69SNaga Harish K S V 	queue_config.event_buf_size = 0;
578b06bca69SNaga Harish K S V 
579b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
580b06bca69SNaga Harish K S V 					TEST_ETHDEV_ID, 0,
581b06bca69SNaga Harish K S V 					&queue_config);
582b06bca69SNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
583b06bca69SNaga Harish K S V 
584b06bca69SNaga Harish K S V 	queue_config.event_buf_size = 1024;
585b06bca69SNaga Harish K S V 
586b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
587b06bca69SNaga Harish K S V 					TEST_ETHDEV_ID, 0,
588b06bca69SNaga Harish K S V 					&queue_config);
589b06bca69SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
590b06bca69SNaga Harish K S V 
591b06bca69SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
592b06bca69SNaga Harish K S V 						TEST_ETHDEV_ID,
593b06bca69SNaga Harish K S V 						0);
594b06bca69SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
595b06bca69SNaga Harish K S V 
596b06bca69SNaga Harish K S V 	return TEST_SUCCESS;
597b06bca69SNaga Harish K S V }
598b06bca69SNaga Harish K S V 
599b7c71b47SNaga Harish K S V static int
adapter_queue_stats_test(void)600b7c71b47SNaga Harish K S V adapter_queue_stats_test(void)
601b7c71b47SNaga Harish K S V {
602b7c71b47SNaga Harish K S V 	int err;
603b7c71b47SNaga Harish K S V 	struct rte_event ev;
604b7c71b47SNaga Harish K S V 	uint32_t cap;
605b7c71b47SNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
606b7c71b47SNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_stats q_stats;
607b7c71b47SNaga Harish K S V 
608b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_stats_get(TEST_INST_ID,
609b7c71b47SNaga Harish K S V 						TEST_ETHDEV_ID, 0,
610b7c71b47SNaga Harish K S V 						&q_stats);
611b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
612b7c71b47SNaga Harish K S V 
613b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_stats_reset(TEST_INST_ID,
614b7c71b47SNaga Harish K S V 						TEST_ETHDEV_ID, 0);
615b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
616b7c71b47SNaga Harish K S V 
617b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, TEST_ETHDEV_ID,
618b7c71b47SNaga Harish K S V 					 &cap);
619b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
620b7c71b47SNaga Harish K S V 
621b7c71b47SNaga Harish K S V 	ev.queue_id = 0;
622b7c71b47SNaga Harish K S V 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
623b7c71b47SNaga Harish K S V 	ev.priority = 0;
624b7c71b47SNaga Harish K S V 
625b7c71b47SNaga Harish K S V 	queue_config.rx_queue_flags = 0;
626b7c71b47SNaga Harish K S V 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) {
627b7c71b47SNaga Harish K S V 		ev.flow_id = 1;
628b7c71b47SNaga Harish K S V 		queue_config.rx_queue_flags =
629b7c71b47SNaga Harish K S V 			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
630b7c71b47SNaga Harish K S V 	}
631b7c71b47SNaga Harish K S V 	queue_config.ev = ev;
632b7c71b47SNaga Harish K S V 	queue_config.servicing_weight = 1;
633b7c71b47SNaga Harish K S V 	queue_config.event_buf_size = 1024;
634b7c71b47SNaga Harish K S V 
635b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
636b7c71b47SNaga Harish K S V 					TEST_ETHDEV_ID, 0,
637b7c71b47SNaga Harish K S V 					&queue_config);
638b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
639b7c71b47SNaga Harish K S V 
640b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_stats_get(TEST_INST_ID,
641b7c71b47SNaga Harish K S V 						TEST_ETHDEV_ID, 0,
642b7c71b47SNaga Harish K S V 						&q_stats);
643b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
644b7c71b47SNaga Harish K S V 
645b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_stats_reset(TEST_INST_ID,
646b7c71b47SNaga Harish K S V 						TEST_ETHDEV_ID, 0);
647b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
648b7c71b47SNaga Harish K S V 
649b7c71b47SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
650b7c71b47SNaga Harish K S V 						TEST_ETHDEV_ID,
651b7c71b47SNaga Harish K S V 						0);
652b7c71b47SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
653b7c71b47SNaga Harish K S V 
654b7c71b47SNaga Harish K S V 	return TEST_SUCCESS;
655b7c71b47SNaga Harish K S V }
656b7c71b47SNaga Harish K S V 
657a9de470cSBruce Richardson static int
adapter_create_free(void)658a9de470cSBruce Richardson adapter_create_free(void)
659a9de470cSBruce Richardson {
660a9de470cSBruce Richardson 	int err;
661a9de470cSBruce Richardson 
662a9de470cSBruce Richardson 	struct rte_event_port_conf rx_p_conf = {
663a9de470cSBruce Richardson 			.dequeue_depth = 8,
664a9de470cSBruce Richardson 			.enqueue_depth = 8,
665a9de470cSBruce Richardson 			.new_event_threshold = 1200,
666a9de470cSBruce Richardson 	};
667a9de470cSBruce Richardson 
668a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_create(TEST_INST_ID, TEST_DEV_ID,
669a9de470cSBruce Richardson 					NULL);
670a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
671a9de470cSBruce Richardson 
672a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_create(TEST_INST_ID, TEST_DEV_ID,
673a9de470cSBruce Richardson 					&rx_p_conf);
674a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
675a9de470cSBruce Richardson 
676a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_create(TEST_INST_ID,
677a9de470cSBruce Richardson 					TEST_DEV_ID, &rx_p_conf);
678a9de470cSBruce Richardson 	TEST_ASSERT(err == -EEXIST, "Expected -EEXIST %d got %d", -EEXIST, err);
679a9de470cSBruce Richardson 
680a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_free(TEST_INST_ID);
681a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
682a9de470cSBruce Richardson 
683a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_free(TEST_INST_ID);
684a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL %d got %d", -EINVAL, err);
685a9de470cSBruce Richardson 
686a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_free(1);
687a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL %d got %d", -EINVAL, err);
688a9de470cSBruce Richardson 
689a9de470cSBruce Richardson 	return TEST_SUCCESS;
690a9de470cSBruce Richardson }
691a9de470cSBruce Richardson 
692a9de470cSBruce Richardson static int
adapter_create_free_with_params(void)693bc0df25cSNaga Harish K S V adapter_create_free_with_params(void)
694bc0df25cSNaga Harish K S V {
695bc0df25cSNaga Harish K S V 	int err;
696bc0df25cSNaga Harish K S V 
697bc0df25cSNaga Harish K S V 	struct rte_event_port_conf rx_p_conf = {
698bc0df25cSNaga Harish K S V 			.dequeue_depth = 8,
699bc0df25cSNaga Harish K S V 			.enqueue_depth = 8,
700bc0df25cSNaga Harish K S V 			.new_event_threshold = 1200,
701bc0df25cSNaga Harish K S V 	};
702bc0df25cSNaga Harish K S V 
703bc0df25cSNaga Harish K S V 	struct rte_event_eth_rx_adapter_params rxa_params = {
704bc0df25cSNaga Harish K S V 			.event_buf_size = 1024
705bc0df25cSNaga Harish K S V 	};
706bc0df25cSNaga Harish K S V 
707bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
708bc0df25cSNaga Harish K S V 				TEST_DEV_ID, NULL, NULL);
709bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
710bc0df25cSNaga Harish K S V 
711bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
712bc0df25cSNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
713bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
714bc0df25cSNaga Harish K S V 
715bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
716bc0df25cSNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
717bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == -EEXIST, "Expected -EEXIST %d got %d", -EEXIST, err);
718bc0df25cSNaga Harish K S V 
719bc0df25cSNaga Harish K S V 	rxa_params.event_buf_size = 0;
720bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_create_with_params(TEST_INST_ID,
721bc0df25cSNaga Harish K S V 				TEST_DEV_ID, &rx_p_conf, &rxa_params);
722bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
723bc0df25cSNaga Harish K S V 
724bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_free(TEST_INST_ID);
725bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
726bc0df25cSNaga Harish K S V 
727bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_free(TEST_INST_ID);
728bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL %d got %d", -EINVAL, err);
729bc0df25cSNaga Harish K S V 
730bc0df25cSNaga Harish K S V 	err = rte_event_eth_rx_adapter_free(1);
731bc0df25cSNaga Harish K S V 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL %d got %d", -EINVAL, err);
732bc0df25cSNaga Harish K S V 
733bc0df25cSNaga Harish K S V 	return TEST_SUCCESS;
734bc0df25cSNaga Harish K S V }
735bc0df25cSNaga Harish K S V 
736bc0df25cSNaga Harish K S V static int
adapter_queue_add_del(void)737a9de470cSBruce Richardson adapter_queue_add_del(void)
738a9de470cSBruce Richardson {
739a9de470cSBruce Richardson 	int err;
740a9de470cSBruce Richardson 	struct rte_event ev;
741a9de470cSBruce Richardson 	uint32_t cap;
742a9de470cSBruce Richardson 
743bc0df25cSNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
744a9de470cSBruce Richardson 
745a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, TEST_ETHDEV_ID,
746a9de470cSBruce Richardson 					 &cap);
747a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
748a9de470cSBruce Richardson 
749a9de470cSBruce Richardson 	ev.queue_id = 0;
750a9de470cSBruce Richardson 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
751a9de470cSBruce Richardson 	ev.priority = 0;
752a9de470cSBruce Richardson 
753a9de470cSBruce Richardson 	queue_config.rx_queue_flags = 0;
754a9de470cSBruce Richardson 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) {
755a9de470cSBruce Richardson 		ev.flow_id = 1;
756a9de470cSBruce Richardson 		queue_config.rx_queue_flags =
757a9de470cSBruce Richardson 			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
758a9de470cSBruce Richardson 	}
759a9de470cSBruce Richardson 	queue_config.ev = ev;
760a9de470cSBruce Richardson 	queue_config.servicing_weight = 1;
761a9de470cSBruce Richardson 
762a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
763a9de470cSBruce Richardson 						rte_eth_dev_count_total(),
764a9de470cSBruce Richardson 						-1, &queue_config);
765a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
766a9de470cSBruce Richardson 
767a9de470cSBruce Richardson 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) {
768a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
769a9de470cSBruce Richardson 							TEST_ETHDEV_ID, 0,
770a9de470cSBruce Richardson 							&queue_config);
771a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
772a9de470cSBruce Richardson 
773a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
774a9de470cSBruce Richardson 							TEST_ETHDEV_ID, 0);
775a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
776a9de470cSBruce Richardson 
777a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
778a9de470cSBruce Richardson 							TEST_ETHDEV_ID,
779a9de470cSBruce Richardson 							-1,
780a9de470cSBruce Richardson 							&queue_config);
781a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
782a9de470cSBruce Richardson 
783a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
784a9de470cSBruce Richardson 							TEST_ETHDEV_ID,
785a9de470cSBruce Richardson 							-1);
786a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
787a9de470cSBruce Richardson 	} else {
788a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
789a9de470cSBruce Richardson 							TEST_ETHDEV_ID,
790a9de470cSBruce Richardson 							0,
791a9de470cSBruce Richardson 							&queue_config);
792a9de470cSBruce Richardson 		TEST_ASSERT(err == -EINVAL, "Expected EINVAL got %d", err);
793a9de470cSBruce Richardson 
794a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
795a9de470cSBruce Richardson 							TEST_ETHDEV_ID, -1,
796a9de470cSBruce Richardson 							&queue_config);
797a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
798a9de470cSBruce Richardson 
799a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
800a9de470cSBruce Richardson 							TEST_ETHDEV_ID, 0);
801a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
802a9de470cSBruce Richardson 
803a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
804a9de470cSBruce Richardson 							TEST_ETHDEV_ID, -1);
805a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
806a9de470cSBruce Richardson 
807a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
808a9de470cSBruce Richardson 							TEST_ETHDEV_ID, -1);
809a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
810a9de470cSBruce Richardson 	}
811a9de470cSBruce Richardson 
812a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(1, TEST_ETHDEV_ID, -1,
813a9de470cSBruce Richardson 						&queue_config);
814a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
815a9de470cSBruce Richardson 
816a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_del(1, TEST_ETHDEV_ID, -1);
817a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
818a9de470cSBruce Richardson 
819a9de470cSBruce Richardson 	return TEST_SUCCESS;
820a9de470cSBruce Richardson }
821a9de470cSBruce Richardson 
822a9de470cSBruce Richardson static int
adapter_multi_eth_add_del(void)823a9de470cSBruce Richardson adapter_multi_eth_add_del(void)
824a9de470cSBruce Richardson {
825a9de470cSBruce Richardson 	int err;
826a9de470cSBruce Richardson 	struct rte_event ev;
827a9de470cSBruce Richardson 
828aaa75327SJay Jayatheerthan 	uint16_t port_index, port_index_base, drv_id = 0;
829a9de470cSBruce Richardson 	char driver_name[50];
830a9de470cSBruce Richardson 
831bc0df25cSNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
832a9de470cSBruce Richardson 
833a9de470cSBruce Richardson 	ev.queue_id = 0;
834a9de470cSBruce Richardson 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
835a9de470cSBruce Richardson 	ev.priority = 0;
836a9de470cSBruce Richardson 
837a9de470cSBruce Richardson 	queue_config.rx_queue_flags = 0;
838a9de470cSBruce Richardson 	queue_config.ev = ev;
839a9de470cSBruce Richardson 	queue_config.servicing_weight = 1;
840a9de470cSBruce Richardson 
841a9de470cSBruce Richardson 	/* stop eth devices for existing */
842a9de470cSBruce Richardson 	port_index = 0;
8430ead65afSIvan Ilchenko 	for (; port_index < rte_eth_dev_count_total(); port_index += 1) {
8440ead65afSIvan Ilchenko 		err = rte_eth_dev_stop(port_index);
8450ead65afSIvan Ilchenko 		TEST_ASSERT(err == 0, "Failed to stop port %u: %d\n",
8460ead65afSIvan Ilchenko 					port_index, err);
8470ead65afSIvan Ilchenko 	}
848a9de470cSBruce Richardson 
849a9de470cSBruce Richardson 	/* add the max port for rx_adapter */
850a9de470cSBruce Richardson 	port_index = rte_eth_dev_count_total();
851aaa75327SJay Jayatheerthan 	port_index_base = port_index;
852a9de470cSBruce Richardson 	for (; port_index < RTE_MAX_ETHPORTS; port_index += 1) {
85364fc9908SPallantla Poornima 		snprintf(driver_name, sizeof(driver_name), "%s%u", "net_null",
85464fc9908SPallantla Poornima 				drv_id);
855a9de470cSBruce Richardson 		err = rte_vdev_init(driver_name, NULL);
856a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Failed driver %s got %d",
857a9de470cSBruce Richardson 		driver_name, err);
858a9de470cSBruce Richardson 		drv_id += 1;
859a9de470cSBruce Richardson 	}
860a9de470cSBruce Richardson 
861a9de470cSBruce Richardson 	err = init_ports(rte_eth_dev_count_total());
862a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Port initialization failed err %d\n", err);
863a9de470cSBruce Richardson 
864a9de470cSBruce Richardson 	/* eth_rx_adapter_queue_add for n ports */
865a9de470cSBruce Richardson 	port_index = 0;
866a9de470cSBruce Richardson 	for (; port_index < rte_eth_dev_count_total(); port_index += 1) {
867a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
868a9de470cSBruce Richardson 				port_index, -1,
869a9de470cSBruce Richardson 				&queue_config);
870a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
871a9de470cSBruce Richardson 	}
872a9de470cSBruce Richardson 
873a9de470cSBruce Richardson 	/* eth_rx_adapter_queue_del n ports */
874a9de470cSBruce Richardson 	port_index = 0;
875a9de470cSBruce Richardson 	for (; port_index < rte_eth_dev_count_total(); port_index += 1) {
876a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
877a9de470cSBruce Richardson 				port_index, -1);
878a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
879a9de470cSBruce Richardson 	}
880a9de470cSBruce Richardson 
881aaa75327SJay Jayatheerthan 	/* delete vdev ports */
882aaa75327SJay Jayatheerthan 	for (drv_id = 0, port_index = port_index_base;
883aaa75327SJay Jayatheerthan 	     port_index < RTE_MAX_ETHPORTS;
884aaa75327SJay Jayatheerthan 	     drv_id += 1, port_index += 1) {
885aaa75327SJay Jayatheerthan 		snprintf(driver_name, sizeof(driver_name), "%s%u", "net_null",
886aaa75327SJay Jayatheerthan 				drv_id);
887aaa75327SJay Jayatheerthan 		err = rte_vdev_uninit(driver_name);
888aaa75327SJay Jayatheerthan 		TEST_ASSERT(err == 0, "Failed driver %s got %d",
889aaa75327SJay Jayatheerthan 			    driver_name, err);
890aaa75327SJay Jayatheerthan 	}
891aaa75327SJay Jayatheerthan 
892a9de470cSBruce Richardson 	return TEST_SUCCESS;
893a9de470cSBruce Richardson }
894a9de470cSBruce Richardson 
895a9de470cSBruce Richardson static int
adapter_intr_queue_add_del(void)896a9de470cSBruce Richardson adapter_intr_queue_add_del(void)
897a9de470cSBruce Richardson {
898a9de470cSBruce Richardson 	int err;
899a9de470cSBruce Richardson 	struct rte_event ev;
900a9de470cSBruce Richardson 	uint32_t cap;
901a9de470cSBruce Richardson 	uint16_t eth_port;
902bc0df25cSNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
903a9de470cSBruce Richardson 
904a9de470cSBruce Richardson 	if (!default_params.rx_intr_port_inited)
905a9de470cSBruce Richardson 		return 0;
906a9de470cSBruce Richardson 
907a9de470cSBruce Richardson 	eth_port = default_params.rx_intr_port;
908a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_caps_get(TEST_DEV_ID, eth_port, &cap);
909a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
910a9de470cSBruce Richardson 
911a9de470cSBruce Richardson 	ev.queue_id = 0;
912a9de470cSBruce Richardson 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
913a9de470cSBruce Richardson 	ev.priority = 0;
914a9de470cSBruce Richardson 
915a9de470cSBruce Richardson 	queue_config.rx_queue_flags = 0;
916a9de470cSBruce Richardson 	queue_config.ev = ev;
917a9de470cSBruce Richardson 
918a9de470cSBruce Richardson 	/* weight = 0 => interrupt mode */
919a9de470cSBruce Richardson 	queue_config.servicing_weight = 0;
920a9de470cSBruce Richardson 
921a9de470cSBruce Richardson 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) {
922a9de470cSBruce Richardson 		/* add queue 0 */
923a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
924a9de470cSBruce Richardson 							TEST_ETHDEV_ID, 0,
925a9de470cSBruce Richardson 							&queue_config);
926a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
927a9de470cSBruce Richardson 	}
928a9de470cSBruce Richardson 
929a9de470cSBruce Richardson 	/* add all queues */
930a9de470cSBruce Richardson 	queue_config.servicing_weight = 0;
931a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
932a9de470cSBruce Richardson 						TEST_ETHDEV_ID,
933a9de470cSBruce Richardson 						-1,
934a9de470cSBruce Richardson 						&queue_config);
935a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
936a9de470cSBruce Richardson 
937a9de470cSBruce Richardson 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) {
938a9de470cSBruce Richardson 		/* del queue 0 */
939a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
940a9de470cSBruce Richardson 							TEST_ETHDEV_ID,
941a9de470cSBruce Richardson 							0);
942a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
943a9de470cSBruce Richardson 	}
944a9de470cSBruce Richardson 
945a9de470cSBruce Richardson 	/* del remaining queues */
946a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
947a9de470cSBruce Richardson 						TEST_ETHDEV_ID,
948a9de470cSBruce Richardson 						-1);
949a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
950a9de470cSBruce Richardson 
951a9de470cSBruce Richardson 	/* add all queues */
952a9de470cSBruce Richardson 	queue_config.servicing_weight = 0;
953a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
954a9de470cSBruce Richardson 						TEST_ETHDEV_ID,
955a9de470cSBruce Richardson 						-1,
956a9de470cSBruce Richardson 						&queue_config);
957a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
958a9de470cSBruce Richardson 
959a9de470cSBruce Richardson 	/* intr -> poll mode queue */
960a9de470cSBruce Richardson 	queue_config.servicing_weight = 1;
961a9de470cSBruce Richardson 
962a9de470cSBruce Richardson 	if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ) {
963a9de470cSBruce Richardson 		err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
964a9de470cSBruce Richardson 							TEST_ETHDEV_ID,
965a9de470cSBruce Richardson 							0,
966a9de470cSBruce Richardson 							&queue_config);
967a9de470cSBruce Richardson 		TEST_ASSERT(err == 0, "Expected 0 got %d", err);
968a9de470cSBruce Richardson 	}
969a9de470cSBruce Richardson 
970a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
971a9de470cSBruce Richardson 						TEST_ETHDEV_ID,
972a9de470cSBruce Richardson 						-1,
973a9de470cSBruce Richardson 						 &queue_config);
974a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
975a9de470cSBruce Richardson 
976a9de470cSBruce Richardson 	/* del queues */
977a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
978a9de470cSBruce Richardson 						TEST_ETHDEV_ID,
979a9de470cSBruce Richardson 						-1);
980a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
981a9de470cSBruce Richardson 
982a9de470cSBruce Richardson 	return TEST_SUCCESS;
983a9de470cSBruce Richardson }
984a9de470cSBruce Richardson 
985a9de470cSBruce Richardson static int
adapter_start_stop(void)986a9de470cSBruce Richardson adapter_start_stop(void)
987a9de470cSBruce Richardson {
988a9de470cSBruce Richardson 	int err;
989a9de470cSBruce Richardson 	struct rte_event ev;
990a9de470cSBruce Richardson 
991a9de470cSBruce Richardson 	ev.queue_id = 0;
992a9de470cSBruce Richardson 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
993a9de470cSBruce Richardson 	ev.priority = 0;
994a9de470cSBruce Richardson 
995bc0df25cSNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
996a9de470cSBruce Richardson 
997a9de470cSBruce Richardson 	queue_config.rx_queue_flags = 0;
998a9de470cSBruce Richardson 	if (default_params.caps &
999a9de470cSBruce Richardson 		RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID) {
1000a9de470cSBruce Richardson 		ev.flow_id = 1;
1001a9de470cSBruce Richardson 		queue_config.rx_queue_flags =
1002a9de470cSBruce Richardson 			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
1003a9de470cSBruce Richardson 	}
1004a9de470cSBruce Richardson 
1005a9de470cSBruce Richardson 	queue_config.ev = ev;
1006a9de470cSBruce Richardson 	queue_config.servicing_weight = 1;
1007a9de470cSBruce Richardson 
1008a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID, TEST_ETHDEV_ID,
1009a9de470cSBruce Richardson 					-1, &queue_config);
1010a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1011a9de470cSBruce Richardson 
1012a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_start(TEST_INST_ID);
1013a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1014a9de470cSBruce Richardson 
1015a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stop(TEST_INST_ID);
1016a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1017a9de470cSBruce Richardson 
1018a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID, TEST_ETHDEV_ID,
1019a9de470cSBruce Richardson 						-1);
1020a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1021a9de470cSBruce Richardson 
1022a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_start(TEST_INST_ID);
1023a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1024a9de470cSBruce Richardson 
1025a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stop(TEST_INST_ID);
1026a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1027a9de470cSBruce Richardson 
1028a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_start(1);
1029a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1030a9de470cSBruce Richardson 
1031a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stop(1);
1032a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1033a9de470cSBruce Richardson 
1034a9de470cSBruce Richardson 	return TEST_SUCCESS;
1035a9de470cSBruce Richardson }
1036a9de470cSBruce Richardson 
1037a9de470cSBruce Richardson static int
adapter_stats(void)1038a9de470cSBruce Richardson adapter_stats(void)
1039a9de470cSBruce Richardson {
1040a9de470cSBruce Richardson 	int err;
1041a9de470cSBruce Richardson 	struct rte_event_eth_rx_adapter_stats stats;
1042a9de470cSBruce Richardson 
1043a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stats_get(TEST_INST_ID, NULL);
1044a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1045a9de470cSBruce Richardson 
1046a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stats_get(TEST_INST_ID, &stats);
1047a9de470cSBruce Richardson 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1048a9de470cSBruce Richardson 
1049a9de470cSBruce Richardson 	err = rte_event_eth_rx_adapter_stats_get(1, &stats);
1050a9de470cSBruce Richardson 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1051a9de470cSBruce Richardson 
1052a9de470cSBruce Richardson 	return TEST_SUCCESS;
1053a9de470cSBruce Richardson }
1054a9de470cSBruce Richardson 
1055da781e64SGanapati Kundapura static int
adapter_queue_conf(void)1056da781e64SGanapati Kundapura adapter_queue_conf(void)
1057da781e64SGanapati Kundapura {
1058da781e64SGanapati Kundapura 	int err;
1059da781e64SGanapati Kundapura 	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
1060da781e64SGanapati Kundapura 
1061da781e64SGanapati Kundapura 	/* Case 1: queue conf get without any queues in Rx adapter */
1062da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
1063da781e64SGanapati Kundapura 						      TEST_ETHDEV_ID,
1064da781e64SGanapati Kundapura 						      0, &queue_conf);
1065da781e64SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1066da781e64SGanapati Kundapura 
1067da781e64SGanapati Kundapura 	/* Add queue to Rx adapter */
1068da781e64SGanapati Kundapura 	queue_conf.ev.queue_id = 0;
1069da781e64SGanapati Kundapura 	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
1070da781e64SGanapati Kundapura 	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
1071da781e64SGanapati Kundapura 
1072da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1073da781e64SGanapati Kundapura 						 TEST_ETHDEV_ID,
1074da781e64SGanapati Kundapura 						 0, &queue_conf);
1075da781e64SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1076da781e64SGanapati Kundapura 
1077da781e64SGanapati Kundapura 	/* Case 2: queue conf get with queue added to Rx adapter */
1078da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
1079da781e64SGanapati Kundapura 						      TEST_ETHDEV_ID,
1080da781e64SGanapati Kundapura 						      0, &queue_conf);
1081da781e64SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1082da781e64SGanapati Kundapura 
1083da781e64SGanapati Kundapura 	/* Case 3: queue conf get with invalid rx queue id */
1084da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
1085da781e64SGanapati Kundapura 						      TEST_ETHDEV_ID,
1086da781e64SGanapati Kundapura 						      -1, &queue_conf);
1087da781e64SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1088da781e64SGanapati Kundapura 
1089da781e64SGanapati Kundapura 	/* Case 4: queue conf get with NULL queue conf struct */
1090da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_conf_get(TEST_INST_ID,
1091da781e64SGanapati Kundapura 						      TEST_ETHDEV_ID,
1092da781e64SGanapati Kundapura 						      0, NULL);
1093da781e64SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1094da781e64SGanapati Kundapura 
1095da781e64SGanapati Kundapura 	/* Delete queue from the Rx adapter */
1096da781e64SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
1097da781e64SGanapati Kundapura 						 TEST_ETHDEV_ID,
1098da781e64SGanapati Kundapura 						 0);
1099da781e64SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1100da781e64SGanapati Kundapura 
1101da781e64SGanapati Kundapura 	return TEST_SUCCESS;
1102da781e64SGanapati Kundapura }
1103da781e64SGanapati Kundapura 
1104a1793ee8SGanapati Kundapura static int
adapter_pollq_instance_get(void)1105a1793ee8SGanapati Kundapura adapter_pollq_instance_get(void)
1106a1793ee8SGanapati Kundapura {
1107a1793ee8SGanapati Kundapura 	int err;
1108a1793ee8SGanapati Kundapura 	uint8_t inst_id;
1109a1793ee8SGanapati Kundapura 	uint16_t eth_dev_id;
1110a1793ee8SGanapati Kundapura 	struct rte_eth_dev_info dev_info;
1111a1793ee8SGanapati Kundapura 	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
1112a1793ee8SGanapati Kundapura 
1113a1793ee8SGanapati Kundapura 	/* Case 1: Test without configuring eth */
1114a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1115a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1116a1793ee8SGanapati Kundapura 						    &inst_id);
1117a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1118a1793ee8SGanapati Kundapura 
1119a1793ee8SGanapati Kundapura 	/* Case 2: Test with wrong eth port */
1120a1793ee8SGanapati Kundapura 	eth_dev_id = rte_eth_dev_count_total() + 1;
1121a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
1122a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1123a1793ee8SGanapati Kundapura 						    &inst_id);
1124a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1125a1793ee8SGanapati Kundapura 
1126a1793ee8SGanapati Kundapura 	/* Case 3: Test with wrong rx queue */
1127a1793ee8SGanapati Kundapura 	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
1128a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1129a1793ee8SGanapati Kundapura 
1130a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1131a1793ee8SGanapati Kundapura 						    dev_info.max_rx_queues + 1,
1132a1793ee8SGanapati Kundapura 						    &inst_id);
1133a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1134a1793ee8SGanapati Kundapura 
1135a1793ee8SGanapati Kundapura 	/* Case 4: Test with right instance, port & rxq */
1136a1793ee8SGanapati Kundapura 	/* Add queue 1 to Rx adapter */
1137a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
1138a1793ee8SGanapati Kundapura 	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
1139a1793ee8SGanapati Kundapura 	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
1140a1793ee8SGanapati Kundapura 	queue_conf.servicing_weight = 1; /* poll queue */
1141a1793ee8SGanapati Kundapura 
1142a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1143a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1144a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID,
1145a1793ee8SGanapati Kundapura 						 &queue_conf);
1146a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1147a1793ee8SGanapati Kundapura 
1148a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1149a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1150a1793ee8SGanapati Kundapura 						    &inst_id);
1151a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1152a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1153a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1154a1793ee8SGanapati Kundapura 
1155a1793ee8SGanapati Kundapura 	/* Add queue 2 to Rx adapter */
1156a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
1157a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1158a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1159a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID + 1,
1160a1793ee8SGanapati Kundapura 						 &queue_conf);
1161a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1162a1793ee8SGanapati Kundapura 
1163a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1164a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 1,
1165a1793ee8SGanapati Kundapura 						    &inst_id);
1166a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1167a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1168a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1169a1793ee8SGanapati Kundapura 
1170a1793ee8SGanapati Kundapura 	/* Add queue 3 to Rx adapter */
1171a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
1172a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1173a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1174a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID + 2,
1175a1793ee8SGanapati Kundapura 						 &queue_conf);
1176a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1177a1793ee8SGanapati Kundapura 
1178a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1179a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 2,
1180a1793ee8SGanapati Kundapura 						    &inst_id);
1181a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1182a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1183a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1184a1793ee8SGanapati Kundapura 
1185a1793ee8SGanapati Kundapura 	/* Case 5: Test with right instance, port & wrong rxq */
1186a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1187a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 3,
1188a1793ee8SGanapati Kundapura 						    &inst_id);
1189a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1190a1793ee8SGanapati Kundapura 
1191a1793ee8SGanapati Kundapura 	/* Delete all queues from the Rx adapter */
1192a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
1193a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1194a1793ee8SGanapati Kundapura 						 -1);
1195a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1196a1793ee8SGanapati Kundapura 
1197a1793ee8SGanapati Kundapura 	return TEST_SUCCESS;
1198a1793ee8SGanapati Kundapura }
1199a1793ee8SGanapati Kundapura 
1200a1793ee8SGanapati Kundapura static int
adapter_intrq_instance_get(void)1201a1793ee8SGanapati Kundapura adapter_intrq_instance_get(void)
1202a1793ee8SGanapati Kundapura {
1203a1793ee8SGanapati Kundapura 	int err;
1204a1793ee8SGanapati Kundapura 	uint8_t inst_id;
1205a1793ee8SGanapati Kundapura 	uint16_t eth_dev_id;
1206a1793ee8SGanapati Kundapura 	struct rte_eth_dev_info dev_info;
1207a1793ee8SGanapati Kundapura 	struct rte_event_eth_rx_adapter_queue_conf queue_conf = {0};
1208a1793ee8SGanapati Kundapura 
1209a1793ee8SGanapati Kundapura 	/* Case 1: Test without configuring eth */
1210a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1211a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1212a1793ee8SGanapati Kundapura 						    &inst_id);
1213a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1214a1793ee8SGanapati Kundapura 
1215a1793ee8SGanapati Kundapura 	/* Case 2: Test with wrong eth port */
1216a1793ee8SGanapati Kundapura 	eth_dev_id = rte_eth_dev_count_total() + 1;
1217a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(eth_dev_id,
1218a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1219a1793ee8SGanapati Kundapura 						    &inst_id);
1220a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1221a1793ee8SGanapati Kundapura 
1222a1793ee8SGanapati Kundapura 	/* Case 3: Test with wrong rx queue */
1223a1793ee8SGanapati Kundapura 	err = rte_eth_dev_info_get(TEST_ETHDEV_ID, &dev_info);
1224a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1225a1793ee8SGanapati Kundapura 
1226a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1227a1793ee8SGanapati Kundapura 						    dev_info.max_rx_queues + 1,
1228a1793ee8SGanapati Kundapura 						    &inst_id);
1229a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1230a1793ee8SGanapati Kundapura 
1231a1793ee8SGanapati Kundapura 	/* Case 4: Test with right instance, port & rxq */
1232a1793ee8SGanapati Kundapura 	/* Intr enabled eth device can have both polled and intr queues.
1233a1793ee8SGanapati Kundapura 	 * Add polled queue 1 to Rx adapter
1234a1793ee8SGanapati Kundapura 	 */
1235a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID;
1236a1793ee8SGanapati Kundapura 	queue_conf.ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
1237a1793ee8SGanapati Kundapura 	queue_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
1238a1793ee8SGanapati Kundapura 	queue_conf.servicing_weight = 1; /* poll queue */
1239a1793ee8SGanapati Kundapura 
1240a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1241a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1242a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID,
1243a1793ee8SGanapati Kundapura 						 &queue_conf);
1244a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1245a1793ee8SGanapati Kundapura 
1246a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1247a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID,
1248a1793ee8SGanapati Kundapura 						    &inst_id);
1249a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1250a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1251a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1252a1793ee8SGanapati Kundapura 
1253a1793ee8SGanapati Kundapura 	/* Add intr queue 2 to Rx adapter */
1254a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 1;
1255a1793ee8SGanapati Kundapura 	queue_conf.servicing_weight = 0; /* intr  queue */
1256a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1257a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1258a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID + 1,
1259a1793ee8SGanapati Kundapura 						 &queue_conf);
1260a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1261a1793ee8SGanapati Kundapura 
1262a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1263a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 1,
1264a1793ee8SGanapati Kundapura 						    &inst_id);
1265a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1266a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1267a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1268a1793ee8SGanapati Kundapura 
1269a1793ee8SGanapati Kundapura 	/* Add intr queue 3 to Rx adapter */
1270a1793ee8SGanapati Kundapura 	queue_conf.ev.queue_id = TEST_ETH_QUEUE_ID + 2;
1271a1793ee8SGanapati Kundapura 	queue_conf.servicing_weight = 0; /* intr  queue */
1272a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
1273a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1274a1793ee8SGanapati Kundapura 						 TEST_ETH_QUEUE_ID + 2,
1275a1793ee8SGanapati Kundapura 						 &queue_conf);
1276a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1277a1793ee8SGanapati Kundapura 
1278a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1279a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 2,
1280a1793ee8SGanapati Kundapura 						    &inst_id);
1281a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1282a1793ee8SGanapati Kundapura 	TEST_ASSERT(inst_id == TEST_INST_ID, "Expected %d got %d",
1283a1793ee8SGanapati Kundapura 		    TEST_INST_ID, err);
1284a1793ee8SGanapati Kundapura 
1285a1793ee8SGanapati Kundapura 	/* Case 5: Test with right instance, port & wrong rxq */
1286a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_instance_get(TEST_ETHDEV_ID,
1287a1793ee8SGanapati Kundapura 						    TEST_ETH_QUEUE_ID + 3,
1288a1793ee8SGanapati Kundapura 						    &inst_id);
1289a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == -EINVAL, "Expected -EINVAL got %d", err);
1290a1793ee8SGanapati Kundapura 
1291a1793ee8SGanapati Kundapura 	/* Delete all queues from the Rx adapter */
1292a1793ee8SGanapati Kundapura 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
1293a1793ee8SGanapati Kundapura 						 TEST_ETHDEV_ID,
1294a1793ee8SGanapati Kundapura 						 -1);
1295a1793ee8SGanapati Kundapura 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
1296a1793ee8SGanapati Kundapura 
1297a1793ee8SGanapati Kundapura 	return TEST_SUCCESS;
1298a1793ee8SGanapati Kundapura }
1299a1793ee8SGanapati Kundapura 
13003716f521SNaga Harish K S V static int
adapter_get_set_params(void)13013716f521SNaga Harish K S V adapter_get_set_params(void)
13023716f521SNaga Harish K S V {
1303eda6477dSPavan Nikhilesh 	int err, rc;
13043716f521SNaga Harish K S V 	struct rte_event_eth_rx_adapter_runtime_params in_params;
13053716f521SNaga Harish K S V 	struct rte_event_eth_rx_adapter_runtime_params out_params;
13063716f521SNaga Harish K S V 	struct rte_event_eth_rx_adapter_queue_conf queue_config = {0};
13073716f521SNaga Harish K S V 	struct rte_event ev;
13083716f521SNaga Harish K S V 
13093716f521SNaga Harish K S V 	ev.queue_id = 0;
13103716f521SNaga Harish K S V 	ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
13113716f521SNaga Harish K S V 	ev.priority = 0;
13123716f521SNaga Harish K S V 	ev.flow_id = 1;
13133716f521SNaga Harish K S V 
13143716f521SNaga Harish K S V 	queue_config.rx_queue_flags =
13153716f521SNaga Harish K S V 			RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID;
13163716f521SNaga Harish K S V 	queue_config.ev = ev;
13173716f521SNaga Harish K S V 	queue_config.servicing_weight = 1;
13183716f521SNaga Harish K S V 
13193716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_add(TEST_INST_ID,
13203716f521SNaga Harish K S V 						TEST_ETHDEV_ID, 0,
13213716f521SNaga Harish K S V 						&queue_config);
13223716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13233716f521SNaga Harish K S V 
13243716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_init(&in_params);
13253716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13263716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_init(&out_params);
13273716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13283716f521SNaga Harish K S V 
13293716f521SNaga Harish K S V 	/* Case 1: Get the default value of mbufs processed by Rx adapter */
13303716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
13313716f521SNaga Harish K S V 							  &out_params);
1332eda6477dSPavan Nikhilesh 	if (err == -ENOTSUP) {
1333eda6477dSPavan Nikhilesh 		rc = TEST_SKIPPED;
1334eda6477dSPavan Nikhilesh 		goto skip;
1335eda6477dSPavan Nikhilesh 	}
13363716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13373716f521SNaga Harish K S V 
13383716f521SNaga Harish K S V 	/* Case 2: Set max_nb_rx = 32 (=BATCH_SEIZE) */
13393716f521SNaga Harish K S V 	in_params.max_nb_rx = 32;
13403716f521SNaga Harish K S V 
13413716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_set(TEST_INST_ID,
13423716f521SNaga Harish K S V 							  &in_params);
13433716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13443716f521SNaga Harish K S V 
13453716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
13463716f521SNaga Harish K S V 							  &out_params);
13473716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13483716f521SNaga Harish K S V 	TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx,
13493716f521SNaga Harish K S V 		    "Expected %u got %u",
13503716f521SNaga Harish K S V 		    in_params.max_nb_rx, out_params.max_nb_rx);
13513716f521SNaga Harish K S V 
13523716f521SNaga Harish K S V 	/* Case 3: Set max_nb_rx = 192 */
13533716f521SNaga Harish K S V 	in_params.max_nb_rx = 192;
13543716f521SNaga Harish K S V 
13553716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_set(TEST_INST_ID,
13563716f521SNaga Harish K S V 							  &in_params);
13573716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13583716f521SNaga Harish K S V 
13593716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
13603716f521SNaga Harish K S V 							  &out_params);
13613716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13623716f521SNaga Harish K S V 	TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx,
13633716f521SNaga Harish K S V 		    "Expected %u got %u",
13643716f521SNaga Harish K S V 		    in_params.max_nb_rx, out_params.max_nb_rx);
13653716f521SNaga Harish K S V 
13663716f521SNaga Harish K S V 	/* Case 4: Set max_nb_rx = 256 */
13673716f521SNaga Harish K S V 	in_params.max_nb_rx = 256;
13683716f521SNaga Harish K S V 
13693716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_set(TEST_INST_ID,
13703716f521SNaga Harish K S V 							  &in_params);
13713716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13723716f521SNaga Harish K S V 
13733716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
13743716f521SNaga Harish K S V 							  &out_params);
13753716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13763716f521SNaga Harish K S V 	TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx,
13773716f521SNaga Harish K S V 		    "Expected %u got %u",
13783716f521SNaga Harish K S V 		    in_params.max_nb_rx, out_params.max_nb_rx);
13793716f521SNaga Harish K S V 
13803716f521SNaga Harish K S V 	/* Case 5: Set max_nb_rx = 30(<BATCH_SIZE) */
13813716f521SNaga Harish K S V 	in_params.max_nb_rx = 30;
13823716f521SNaga Harish K S V 
13833716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_set(TEST_INST_ID,
13843716f521SNaga Harish K S V 							  &in_params);
13853716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13863716f521SNaga Harish K S V 
13873716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
13883716f521SNaga Harish K S V 							  &out_params);
13893716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
13903716f521SNaga Harish K S V 	TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx,
13913716f521SNaga Harish K S V 		    "Expected %u got %u",
13923716f521SNaga Harish K S V 		    in_params.max_nb_rx, out_params.max_nb_rx);
13933716f521SNaga Harish K S V 
13943716f521SNaga Harish K S V 	/* Case 6: Set max_nb_rx = 512 */
13953716f521SNaga Harish K S V 	in_params.max_nb_rx = 512;
13963716f521SNaga Harish K S V 
13973716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_set(TEST_INST_ID,
13983716f521SNaga Harish K S V 							  &in_params);
13993716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
14003716f521SNaga Harish K S V 
14013716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_runtime_params_get(TEST_INST_ID,
14023716f521SNaga Harish K S V 							  &out_params);
14033716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
14043716f521SNaga Harish K S V 	TEST_ASSERT(in_params.max_nb_rx == out_params.max_nb_rx,
14053716f521SNaga Harish K S V 		    "Expected %u got %u",
14063716f521SNaga Harish K S V 		    in_params.max_nb_rx, out_params.max_nb_rx);
14073716f521SNaga Harish K S V 
1408eda6477dSPavan Nikhilesh 	rc = TEST_SUCCESS;
1409eda6477dSPavan Nikhilesh skip:
14103716f521SNaga Harish K S V 	err = rte_event_eth_rx_adapter_queue_del(TEST_INST_ID,
14113716f521SNaga Harish K S V 						TEST_ETHDEV_ID, 0);
14123716f521SNaga Harish K S V 	TEST_ASSERT(err == 0, "Expected 0 got %d", err);
14133716f521SNaga Harish K S V 
1414eda6477dSPavan Nikhilesh 	return rc;
14153716f521SNaga Harish K S V }
14163716f521SNaga Harish K S V 
1417a9de470cSBruce Richardson static struct unit_test_suite event_eth_rx_tests = {
1418a9de470cSBruce Richardson 	.suite_name = "rx event eth adapter test suite",
1419a9de470cSBruce Richardson 	.setup = testsuite_setup,
1420a9de470cSBruce Richardson 	.teardown = testsuite_teardown,
1421a9de470cSBruce Richardson 	.unit_test_cases = {
1422a9de470cSBruce Richardson 		TEST_CASE_ST(NULL, NULL, adapter_create_free),
1423bc0df25cSNaga Harish K S V 		TEST_CASE_ST(NULL, NULL, adapter_create_free_with_params),
1424a9de470cSBruce Richardson 		TEST_CASE_ST(adapter_create, adapter_free,
1425a9de470cSBruce Richardson 					adapter_queue_add_del),
1426a9de470cSBruce Richardson 		TEST_CASE_ST(adapter_create, adapter_free,
1427a9de470cSBruce Richardson 					adapter_multi_eth_add_del),
1428a9de470cSBruce Richardson 		TEST_CASE_ST(adapter_create, adapter_free, adapter_start_stop),
1429a9de470cSBruce Richardson 		TEST_CASE_ST(adapter_create, adapter_free, adapter_stats),
1430da781e64SGanapati Kundapura 		TEST_CASE_ST(adapter_create, adapter_free, adapter_queue_conf),
1431b06bca69SNaga Harish K S V 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
1432b06bca69SNaga Harish K S V 			     adapter_queue_event_buf_test),
1433b7c71b47SNaga Harish K S V 		TEST_CASE_ST(adapter_create_with_params, adapter_free,
1434b7c71b47SNaga Harish K S V 			     adapter_queue_stats_test),
1435a1793ee8SGanapati Kundapura 		TEST_CASE_ST(adapter_create, adapter_free,
1436a1793ee8SGanapati Kundapura 			     adapter_pollq_instance_get),
14373716f521SNaga Harish K S V 		TEST_CASE_ST(adapter_create, adapter_free,
14383716f521SNaga Harish K S V 			     adapter_get_set_params),
1439*1f07a41dSNaga Harish K S V 		TEST_CASE_ST(adapter_create_ext_with_params, adapter_free,
1440*1f07a41dSNaga Harish K S V 			     adapter_start_stop),
1441a9de470cSBruce Richardson 		TEST_CASES_END() /**< NULL terminate unit test array */
1442a9de470cSBruce Richardson 	}
1443a9de470cSBruce Richardson };
1444a9de470cSBruce Richardson 
1445a9de470cSBruce Richardson static struct unit_test_suite event_eth_rx_intr_tests = {
1446a9de470cSBruce Richardson 	.suite_name = "rx event eth adapter test suite",
1447a9de470cSBruce Richardson 	.setup = testsuite_setup_rx_intr,
1448a9de470cSBruce Richardson 	.teardown = testsuite_teardown_rx_intr,
1449a9de470cSBruce Richardson 	.unit_test_cases = {
1450a9de470cSBruce Richardson 		TEST_CASE_ST(adapter_create, adapter_free,
1451a9de470cSBruce Richardson 			     adapter_intr_queue_add_del),
1452a1793ee8SGanapati Kundapura 		TEST_CASE_ST(adapter_create, adapter_free,
1453a1793ee8SGanapati Kundapura 			     adapter_intrq_instance_get),
1454a9de470cSBruce Richardson 		TEST_CASES_END() /**< NULL terminate unit test array */
1455a9de470cSBruce Richardson 	}
1456a9de470cSBruce Richardson };
1457a9de470cSBruce Richardson 
1458a9de470cSBruce Richardson static int
test_event_eth_rx_adapter_common(void)1459a9de470cSBruce Richardson test_event_eth_rx_adapter_common(void)
1460a9de470cSBruce Richardson {
1461a9de470cSBruce Richardson 	return unit_test_suite_runner(&event_eth_rx_tests);
1462a9de470cSBruce Richardson }
1463a9de470cSBruce Richardson 
1464a9de470cSBruce Richardson static int
test_event_eth_rx_intr_adapter_common(void)1465a9de470cSBruce Richardson test_event_eth_rx_intr_adapter_common(void)
1466a9de470cSBruce Richardson {
1467a9de470cSBruce Richardson 	return unit_test_suite_runner(&event_eth_rx_intr_tests);
1468a9de470cSBruce Richardson }
1469a9de470cSBruce Richardson 
14703c60274cSJie Zhou #endif /* !RTE_EXEC_ENV_WINDOWS */
14713c60274cSJie Zhou 
1472a9de470cSBruce Richardson REGISTER_TEST_COMMAND(event_eth_rx_adapter_autotest,
1473a9de470cSBruce Richardson 		test_event_eth_rx_adapter_common);
1474a9de470cSBruce Richardson REGISTER_TEST_COMMAND(event_eth_rx_intr_adapter_autotest,
1475a9de470cSBruce Richardson 		test_event_eth_rx_intr_adapter_common);
1476