16f1b8288STimothy McDaniel /* SPDX-License-Identifier: BSD-3-Clause
26f1b8288STimothy McDaniel * Copyright(c) 2016-2020 Intel Corporation
36f1b8288STimothy McDaniel */
46f1b8288STimothy McDaniel
56f1b8288STimothy McDaniel #include <stdio.h>
66f1b8288STimothy McDaniel #include <string.h>
76f1b8288STimothy McDaniel #include <stdint.h>
86f1b8288STimothy McDaniel #include <errno.h>
96f1b8288STimothy McDaniel #include <unistd.h>
106f1b8288STimothy McDaniel #include <sys/queue.h>
116f1b8288STimothy McDaniel
126f1b8288STimothy McDaniel #include <rte_memory.h>
136f1b8288STimothy McDaniel #include <rte_memzone.h>
146f1b8288STimothy McDaniel #include <rte_launch.h>
156f1b8288STimothy McDaniel #include <rte_eal.h>
166f1b8288STimothy McDaniel #include <rte_per_lcore.h>
176f1b8288STimothy McDaniel #include <rte_lcore.h>
186f1b8288STimothy McDaniel #include <rte_debug.h>
196f1b8288STimothy McDaniel #include <rte_ethdev.h>
206f1b8288STimothy McDaniel #include <rte_cycles.h>
216f1b8288STimothy McDaniel #include <rte_eventdev.h>
226f1b8288STimothy McDaniel #include <rte_pause.h>
236f1b8288STimothy McDaniel
246f1b8288STimothy McDaniel #include "dlb2_priv.h"
256f1b8288STimothy McDaniel #include "rte_pmd_dlb2.h"
266f1b8288STimothy McDaniel
276f1b8288STimothy McDaniel #define MAX_PORTS 32
286f1b8288STimothy McDaniel #define MAX_QIDS 32
296f1b8288STimothy McDaniel #define DEFAULT_NUM_SEQ_NUMS 64
306f1b8288STimothy McDaniel
316f1b8288STimothy McDaniel static struct rte_mempool *eventdev_func_mempool;
326f1b8288STimothy McDaniel static int evdev;
336f1b8288STimothy McDaniel
346f1b8288STimothy McDaniel struct test {
356f1b8288STimothy McDaniel struct rte_mempool *mbuf_pool;
366f1b8288STimothy McDaniel int nb_qids;
376f1b8288STimothy McDaniel };
386f1b8288STimothy McDaniel
396f1b8288STimothy McDaniel /* initialization and config */
406f1b8288STimothy McDaniel static inline int
init(struct test * t,int nb_queues,int nb_ports)416f1b8288STimothy McDaniel init(struct test *t, int nb_queues, int nb_ports)
426f1b8288STimothy McDaniel {
436f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
446f1b8288STimothy McDaniel struct rte_event_dev_info info;
456f1b8288STimothy McDaniel int ret;
466f1b8288STimothy McDaniel
476f1b8288STimothy McDaniel memset(t, 0, sizeof(*t));
486f1b8288STimothy McDaniel
496f1b8288STimothy McDaniel t->mbuf_pool = eventdev_func_mempool;
506f1b8288STimothy McDaniel
516f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
526f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
536f1b8288STimothy McDaniel return -1;
546f1b8288STimothy McDaniel }
556f1b8288STimothy McDaniel
566f1b8288STimothy McDaniel config.nb_event_queues = nb_queues;
576f1b8288STimothy McDaniel config.nb_event_ports = nb_ports;
586f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
596f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
606f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
616f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
626f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
636f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
646f1b8288STimothy McDaniel
656f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
666f1b8288STimothy McDaniel if (ret < 0)
676f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
686f1b8288STimothy McDaniel
696f1b8288STimothy McDaniel return ret;
706f1b8288STimothy McDaniel }
716f1b8288STimothy McDaniel
726f1b8288STimothy McDaniel static inline int
create_ports(int num_ports)736f1b8288STimothy McDaniel create_ports(int num_ports)
746f1b8288STimothy McDaniel {
756f1b8288STimothy McDaniel int i;
766f1b8288STimothy McDaniel
776f1b8288STimothy McDaniel if (num_ports > MAX_PORTS)
786f1b8288STimothy McDaniel return -1;
796f1b8288STimothy McDaniel
806f1b8288STimothy McDaniel for (i = 0; i < num_ports; i++) {
816f1b8288STimothy McDaniel struct rte_event_port_conf conf;
826f1b8288STimothy McDaniel
836f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, i, &conf)) {
846f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n",
856f1b8288STimothy McDaniel __LINE__);
866f1b8288STimothy McDaniel return -1;
876f1b8288STimothy McDaniel }
886f1b8288STimothy McDaniel
896f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, i, &conf) < 0) {
906f1b8288STimothy McDaniel printf("%d: Error setting up port %d\n", __LINE__, i);
916f1b8288STimothy McDaniel return -1;
926f1b8288STimothy McDaniel }
936f1b8288STimothy McDaniel }
946f1b8288STimothy McDaniel
956f1b8288STimothy McDaniel return 0;
966f1b8288STimothy McDaniel }
976f1b8288STimothy McDaniel
986f1b8288STimothy McDaniel static inline int
create_lb_qids(struct test * t,int num_qids,uint32_t flags)996f1b8288STimothy McDaniel create_lb_qids(struct test *t, int num_qids, uint32_t flags)
1006f1b8288STimothy McDaniel {
1016f1b8288STimothy McDaniel int i;
1026f1b8288STimothy McDaniel
1036f1b8288STimothy McDaniel for (i = t->nb_qids; i < t->nb_qids + num_qids; i++) {
1046f1b8288STimothy McDaniel struct rte_event_queue_conf conf;
1056f1b8288STimothy McDaniel
1066f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, i, &conf)) {
1076f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n",
1086f1b8288STimothy McDaniel __LINE__);
1096f1b8288STimothy McDaniel return -1;
1106f1b8288STimothy McDaniel }
1116f1b8288STimothy McDaniel
1126f1b8288STimothy McDaniel conf.schedule_type = flags;
1136f1b8288STimothy McDaniel
1146f1b8288STimothy McDaniel if (conf.schedule_type == RTE_SCHED_TYPE_PARALLEL)
1156f1b8288STimothy McDaniel conf.nb_atomic_order_sequences = 0;
1166f1b8288STimothy McDaniel else
1176f1b8288STimothy McDaniel conf.nb_atomic_order_sequences = DEFAULT_NUM_SEQ_NUMS;
1186f1b8288STimothy McDaniel
1196f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, i, &conf) < 0) {
1206f1b8288STimothy McDaniel printf("%d: error creating qid %d\n", __LINE__, i);
1216f1b8288STimothy McDaniel return -1;
1226f1b8288STimothy McDaniel }
1236f1b8288STimothy McDaniel }
1246f1b8288STimothy McDaniel
1256f1b8288STimothy McDaniel t->nb_qids += num_qids;
1266f1b8288STimothy McDaniel if (t->nb_qids > MAX_QIDS)
1276f1b8288STimothy McDaniel return -1;
1286f1b8288STimothy McDaniel
1296f1b8288STimothy McDaniel return 0;
1306f1b8288STimothy McDaniel }
1316f1b8288STimothy McDaniel
1326f1b8288STimothy McDaniel static inline int
create_atomic_qids(struct test * t,int num_qids)1336f1b8288STimothy McDaniel create_atomic_qids(struct test *t, int num_qids)
1346f1b8288STimothy McDaniel {
1356f1b8288STimothy McDaniel return create_lb_qids(t, num_qids, RTE_SCHED_TYPE_ATOMIC);
1366f1b8288STimothy McDaniel }
1376f1b8288STimothy McDaniel
1386f1b8288STimothy McDaniel /* destruction */
1396f1b8288STimothy McDaniel static inline void
cleanup(void)1406f1b8288STimothy McDaniel cleanup(void)
1416f1b8288STimothy McDaniel {
1426f1b8288STimothy McDaniel int ret = 0;
1436f1b8288STimothy McDaniel
1446f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
1456f1b8288STimothy McDaniel ret = rte_event_dev_close(evdev);
1466f1b8288STimothy McDaniel
1476f1b8288STimothy McDaniel if (ret)
1486f1b8288STimothy McDaniel printf("%d: rte_event_dev_close failed, ret = %d\n",
1496f1b8288STimothy McDaniel __LINE__, ret);
1506f1b8288STimothy McDaniel };
1516f1b8288STimothy McDaniel
1526f1b8288STimothy McDaniel static inline int
enqueue_timeout(uint8_t port_id,struct rte_event * ev,uint64_t tmo_us)1536f1b8288STimothy McDaniel enqueue_timeout(uint8_t port_id, struct rte_event *ev, uint64_t tmo_us)
1546f1b8288STimothy McDaniel {
1556f1b8288STimothy McDaniel const uint64_t start = rte_get_timer_cycles();
1566f1b8288STimothy McDaniel const uint64_t ticks = (tmo_us * rte_get_timer_hz()) / 1E6;
1576f1b8288STimothy McDaniel
1586f1b8288STimothy McDaniel while ((rte_get_timer_cycles() - start) < ticks) {
1596f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, port_id, ev, 1) == 1)
1606f1b8288STimothy McDaniel return 0;
1616f1b8288STimothy McDaniel
1626f1b8288STimothy McDaniel if (rte_errno != -ENOSPC) {
1636f1b8288STimothy McDaniel printf("enqueue_burst returned rte_errno %d\n",
1646f1b8288STimothy McDaniel rte_errno);
1656f1b8288STimothy McDaniel return -1;
1666f1b8288STimothy McDaniel }
1676f1b8288STimothy McDaniel }
1686f1b8288STimothy McDaniel printf("%s time out\n", __func__);
1696f1b8288STimothy McDaniel return -1;
1706f1b8288STimothy McDaniel }
1716f1b8288STimothy McDaniel
1726f1b8288STimothy McDaniel static void
flush(uint8_t id __rte_unused,struct rte_event event,void * arg __rte_unused)1736f1b8288STimothy McDaniel flush(uint8_t id __rte_unused, struct rte_event event, void *arg __rte_unused)
1746f1b8288STimothy McDaniel {
1756f1b8288STimothy McDaniel rte_pktmbuf_free(event.mbuf);
1766f1b8288STimothy McDaniel }
1776f1b8288STimothy McDaniel
1786f1b8288STimothy McDaniel static int
test_stop_flush(struct test * t)1796f1b8288STimothy McDaniel test_stop_flush(struct test *t) /* test to check we can properly flush events */
1806f1b8288STimothy McDaniel {
1816f1b8288STimothy McDaniel struct rte_event ev;
1826f1b8288STimothy McDaniel uint32_t dequeue_depth;
1836f1b8288STimothy McDaniel unsigned int i, count;
1846f1b8288STimothy McDaniel uint8_t queue_id;
1856f1b8288STimothy McDaniel
1866f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_NEW;
1876f1b8288STimothy McDaniel
1886f1b8288STimothy McDaniel if (init(t, 2, 1) < 0 ||
1896f1b8288STimothy McDaniel create_ports(1) < 0 ||
1906f1b8288STimothy McDaniel create_atomic_qids(t, 2) < 0) {
1916f1b8288STimothy McDaniel printf("%d: Error initializing device\n", __LINE__);
1926f1b8288STimothy McDaniel return -1;
1936f1b8288STimothy McDaniel }
1946f1b8288STimothy McDaniel
1956f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, NULL, NULL, 0) != 2) {
1966f1b8288STimothy McDaniel printf("%d: Error linking queues to the port\n", __LINE__);
1976f1b8288STimothy McDaniel goto err;
1986f1b8288STimothy McDaniel }
1996f1b8288STimothy McDaniel
2006f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
2016f1b8288STimothy McDaniel printf("%d: Error with start call\n", __LINE__);
2026f1b8288STimothy McDaniel goto err;
2036f1b8288STimothy McDaniel }
2046f1b8288STimothy McDaniel
2056f1b8288STimothy McDaniel /* Unlink queue 1 so the PMD's stop callback has to cleanup an unlinked
2066f1b8288STimothy McDaniel * queue.
2076f1b8288STimothy McDaniel */
2086f1b8288STimothy McDaniel queue_id = 1;
2096f1b8288STimothy McDaniel
2106f1b8288STimothy McDaniel if (rte_event_port_unlink(evdev, 0, &queue_id, 1) != 1) {
2116f1b8288STimothy McDaniel printf("%d: Error unlinking queue 1 from port\n", __LINE__);
2126f1b8288STimothy McDaniel goto err;
2136f1b8288STimothy McDaniel }
2146f1b8288STimothy McDaniel
21547dc89feSTimothy McDaniel if (t->mbuf_pool)
2166f1b8288STimothy McDaniel count = rte_mempool_avail_count(t->mbuf_pool);
21747dc89feSTimothy McDaniel else {
21847dc89feSTimothy McDaniel printf("%d: mbuf_pool is NULL\n", __LINE__);
21947dc89feSTimothy McDaniel goto err;
22047dc89feSTimothy McDaniel }
2216f1b8288STimothy McDaniel
2226f1b8288STimothy McDaniel if (rte_event_port_attr_get(evdev,
2236f1b8288STimothy McDaniel 0,
2246f1b8288STimothy McDaniel RTE_EVENT_PORT_ATTR_DEQ_DEPTH,
2256f1b8288STimothy McDaniel &dequeue_depth)) {
2267be78d02SJosh Soref printf("%d: Error retrieving dequeue depth\n", __LINE__);
2276f1b8288STimothy McDaniel goto err;
2286f1b8288STimothy McDaniel }
2296f1b8288STimothy McDaniel
2306f1b8288STimothy McDaniel /* Send QEs to queue 0 */
2316f1b8288STimothy McDaniel for (i = 0; i < dequeue_depth + 1; i++) {
2326f1b8288STimothy McDaniel ev.mbuf = rte_pktmbuf_alloc(t->mbuf_pool);
2336f1b8288STimothy McDaniel ev.queue_id = 0;
2346f1b8288STimothy McDaniel ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
2356f1b8288STimothy McDaniel
2366f1b8288STimothy McDaniel if (enqueue_timeout(0, &ev, 1000)) {
2376f1b8288STimothy McDaniel printf("%d: Error enqueuing events\n", __LINE__);
2386f1b8288STimothy McDaniel goto err;
2396f1b8288STimothy McDaniel }
2406f1b8288STimothy McDaniel }
2416f1b8288STimothy McDaniel
2426f1b8288STimothy McDaniel /* Send QEs to queue 1 */
2436f1b8288STimothy McDaniel for (i = 0; i < dequeue_depth + 1; i++) {
2446f1b8288STimothy McDaniel ev.mbuf = rte_pktmbuf_alloc(t->mbuf_pool);
2456f1b8288STimothy McDaniel ev.queue_id = 1;
2466f1b8288STimothy McDaniel ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
2476f1b8288STimothy McDaniel
2486f1b8288STimothy McDaniel if (enqueue_timeout(0, &ev, 1000)) {
2496f1b8288STimothy McDaniel printf("%d: Error enqueuing events\n", __LINE__);
2506f1b8288STimothy McDaniel goto err;
2516f1b8288STimothy McDaniel }
2526f1b8288STimothy McDaniel }
2536f1b8288STimothy McDaniel
2546f1b8288STimothy McDaniel /* Now the DLB is scheduling events from the port to the IQ, and at
2556f1b8288STimothy McDaniel * least one event should be remaining in each queue.
2566f1b8288STimothy McDaniel */
2576f1b8288STimothy McDaniel
2586f1b8288STimothy McDaniel if (rte_event_dev_stop_flush_callback_register(evdev, flush, NULL)) {
2596f1b8288STimothy McDaniel printf("%d: Error installing the flush callback\n", __LINE__);
2606f1b8288STimothy McDaniel goto err;
2616f1b8288STimothy McDaniel }
2626f1b8288STimothy McDaniel
2636f1b8288STimothy McDaniel cleanup();
2646f1b8288STimothy McDaniel
2656f1b8288STimothy McDaniel if (count != rte_mempool_avail_count(t->mbuf_pool)) {
2666f1b8288STimothy McDaniel printf("%d: Error executing the flush callback\n", __LINE__);
2676f1b8288STimothy McDaniel goto err;
2686f1b8288STimothy McDaniel }
2696f1b8288STimothy McDaniel
2706f1b8288STimothy McDaniel if (rte_event_dev_stop_flush_callback_register(evdev, NULL, NULL)) {
2716f1b8288STimothy McDaniel printf("%d: Error uninstalling the flush callback\n", __LINE__);
2726f1b8288STimothy McDaniel goto err;
2736f1b8288STimothy McDaniel }
2746f1b8288STimothy McDaniel
2756f1b8288STimothy McDaniel return 0;
2766f1b8288STimothy McDaniel err:
2776f1b8288STimothy McDaniel cleanup();
2786f1b8288STimothy McDaniel return -1;
2796f1b8288STimothy McDaniel }
2806f1b8288STimothy McDaniel
2816f1b8288STimothy McDaniel static int
test_single_link(void)2826f1b8288STimothy McDaniel test_single_link(void)
2836f1b8288STimothy McDaniel {
2846f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
2856f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
2866f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
2876f1b8288STimothy McDaniel struct rte_event_dev_info info;
2886f1b8288STimothy McDaniel uint8_t queue_id;
2896f1b8288STimothy McDaniel int ret;
2906f1b8288STimothy McDaniel
2916f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
2926f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
2936f1b8288STimothy McDaniel return -1;
2946f1b8288STimothy McDaniel }
2956f1b8288STimothy McDaniel
2966f1b8288STimothy McDaniel config.nb_event_queues = 2;
2976f1b8288STimothy McDaniel config.nb_event_ports = 2;
2986f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 1;
2996f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
3006f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
3016f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
3026f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
3036f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
3046f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
3056f1b8288STimothy McDaniel
3066f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
3076f1b8288STimothy McDaniel if (ret < 0) {
3086f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
3096f1b8288STimothy McDaniel return -1;
3106f1b8288STimothy McDaniel }
3116f1b8288STimothy McDaniel
3126f1b8288STimothy McDaniel /* Create a directed port */
3136f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
3146f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
3156f1b8288STimothy McDaniel goto err;
3166f1b8288STimothy McDaniel }
3176f1b8288STimothy McDaniel
3186f1b8288STimothy McDaniel port_conf.event_port_cfg = RTE_EVENT_PORT_CFG_SINGLE_LINK;
3196f1b8288STimothy McDaniel
3206f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
3216f1b8288STimothy McDaniel printf("%d: port 0 setup expected to succeed\n", __LINE__);
3226f1b8288STimothy McDaniel goto err;
3236f1b8288STimothy McDaniel }
3246f1b8288STimothy McDaniel
3256f1b8288STimothy McDaniel /* Attempt to create another directed port */
3266f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 1, &port_conf) == 0) {
3276f1b8288STimothy McDaniel printf("%d: port 1 setup expected to fail\n", __LINE__);
3286f1b8288STimothy McDaniel goto err;
3296f1b8288STimothy McDaniel }
3306f1b8288STimothy McDaniel
3316f1b8288STimothy McDaniel port_conf.event_port_cfg = 0;
3326f1b8288STimothy McDaniel
3336f1b8288STimothy McDaniel /* Create a load-balanced port */
3346f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 1, &port_conf) < 0) {
3356f1b8288STimothy McDaniel printf("%d: port 1 setup expected to succeed\n", __LINE__);
3366f1b8288STimothy McDaniel goto err;
3376f1b8288STimothy McDaniel }
3386f1b8288STimothy McDaniel
3396f1b8288STimothy McDaniel /* Create a directed queue */
3406f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
3416f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
3426f1b8288STimothy McDaniel goto err;
3436f1b8288STimothy McDaniel }
3446f1b8288STimothy McDaniel
3456f1b8288STimothy McDaniel queue_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
3466f1b8288STimothy McDaniel
3476f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
3486f1b8288STimothy McDaniel printf("%d: queue 0 setup expected to succeed\n", __LINE__);
3496f1b8288STimothy McDaniel goto err;
3506f1b8288STimothy McDaniel }
3516f1b8288STimothy McDaniel
3526f1b8288STimothy McDaniel /* Attempt to create another directed queue */
3536f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 1, &queue_conf) == 0) {
3546f1b8288STimothy McDaniel printf("%d: queue 1 setup expected to fail\n", __LINE__);
3556f1b8288STimothy McDaniel goto err;
3566f1b8288STimothy McDaniel }
3576f1b8288STimothy McDaniel
3586f1b8288STimothy McDaniel /* Create a load-balanced queue */
3596f1b8288STimothy McDaniel queue_conf.event_queue_cfg = 0;
3606f1b8288STimothy McDaniel
3616f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 1, &queue_conf) < 0) {
3626f1b8288STimothy McDaniel printf("%d: queue 1 setup expected to succeed\n", __LINE__);
3636f1b8288STimothy McDaniel goto err;
3646f1b8288STimothy McDaniel }
3656f1b8288STimothy McDaniel
3666f1b8288STimothy McDaniel /* Attempt to link directed and load-balanced resources */
3676f1b8288STimothy McDaniel queue_id = 1;
3686f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) == 1) {
3696f1b8288STimothy McDaniel printf("%d: port 0 link expected to fail\n", __LINE__);
3706f1b8288STimothy McDaniel goto err;
3716f1b8288STimothy McDaniel }
3726f1b8288STimothy McDaniel
3736f1b8288STimothy McDaniel queue_id = 0;
3746f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 1, &queue_id, NULL, 1) == 1) {
3756f1b8288STimothy McDaniel printf("%d: port 1 link expected to fail\n", __LINE__);
3766f1b8288STimothy McDaniel goto err;
3776f1b8288STimothy McDaniel }
3786f1b8288STimothy McDaniel
3796f1b8288STimothy McDaniel /* Link ports to queues */
3806f1b8288STimothy McDaniel queue_id = 0;
3816f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
3826f1b8288STimothy McDaniel printf("%d: port 0 link expected to succeed\n", __LINE__);
3836f1b8288STimothy McDaniel goto err;
3846f1b8288STimothy McDaniel }
3856f1b8288STimothy McDaniel
3866f1b8288STimothy McDaniel queue_id = 1;
3876f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 1, &queue_id, NULL, 1) != 1) {
3886f1b8288STimothy McDaniel printf("%d: port 1 link expected to succeed\n", __LINE__);
3896f1b8288STimothy McDaniel goto err;
3906f1b8288STimothy McDaniel }
3916f1b8288STimothy McDaniel
3926f1b8288STimothy McDaniel ret = rte_event_dev_close(evdev);
3936f1b8288STimothy McDaniel if (ret)
3946f1b8288STimothy McDaniel printf("%d: rte_event_dev_close failed, ret = %d\n",
3956f1b8288STimothy McDaniel __LINE__, ret);
3966f1b8288STimothy McDaniel
3976f1b8288STimothy McDaniel return 0;
3986f1b8288STimothy McDaniel
3996f1b8288STimothy McDaniel err:
4006f1b8288STimothy McDaniel ret = rte_event_dev_close(evdev);
4016f1b8288STimothy McDaniel if (ret)
4026f1b8288STimothy McDaniel printf("%d: rte_event_dev_close failed, ret = %d\n",
4036f1b8288STimothy McDaniel __LINE__, ret);
4046f1b8288STimothy McDaniel
4056f1b8288STimothy McDaniel return -1;
4066f1b8288STimothy McDaniel }
4076f1b8288STimothy McDaniel
4086f1b8288STimothy McDaniel #define NUM_LDB_PORTS 64
4096f1b8288STimothy McDaniel #define NUM_LDB_QUEUES 32
4106f1b8288STimothy McDaniel
4116f1b8288STimothy McDaniel static int
test_info_get(void)4126f1b8288STimothy McDaniel test_info_get(void)
4136f1b8288STimothy McDaniel {
4146f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
4156f1b8288STimothy McDaniel struct rte_event_dev_info info;
4166f1b8288STimothy McDaniel int ret;
4176f1b8288STimothy McDaniel
4186f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
4196f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
4206f1b8288STimothy McDaniel return -1;
4216f1b8288STimothy McDaniel }
4226f1b8288STimothy McDaniel
4236f1b8288STimothy McDaniel if (info.max_event_ports != NUM_LDB_PORTS) {
4246f1b8288STimothy McDaniel printf("%d: Got %u ports, expected %u\n",
4256f1b8288STimothy McDaniel __LINE__, info.max_event_ports, NUM_LDB_PORTS);
4266f1b8288STimothy McDaniel goto err;
4276f1b8288STimothy McDaniel }
4286f1b8288STimothy McDaniel
4296f1b8288STimothy McDaniel if (info.max_event_queues != NUM_LDB_QUEUES) {
4306f1b8288STimothy McDaniel printf("%d: Got %u queues, expected %u\n",
4316f1b8288STimothy McDaniel __LINE__, info.max_event_queues, NUM_LDB_QUEUES);
4326f1b8288STimothy McDaniel goto err;
4336f1b8288STimothy McDaniel }
4346f1b8288STimothy McDaniel
4356f1b8288STimothy McDaniel config.nb_event_ports = info.max_event_ports;
4366f1b8288STimothy McDaniel config.nb_event_queues = NUM_LDB_QUEUES + info.max_event_ports / 2;
4376f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = info.max_event_ports / 2;
4386f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
4396f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
4406f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
4416f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
4426f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
4436f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
4446f1b8288STimothy McDaniel
4456f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
4466f1b8288STimothy McDaniel if (ret < 0) {
4476f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
4486f1b8288STimothy McDaniel return -1;
4496f1b8288STimothy McDaniel }
4506f1b8288STimothy McDaniel
4516f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
4526f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
4536f1b8288STimothy McDaniel goto err;
4546f1b8288STimothy McDaniel }
4556f1b8288STimothy McDaniel
4566f1b8288STimothy McDaniel /* The DLB2 PMD only reports load-balanced ports and queues in its
4576f1b8288STimothy McDaniel * info_get function. Confirm that these values don't include the
4586f1b8288STimothy McDaniel * directed port or queue counts.
4596f1b8288STimothy McDaniel */
4606f1b8288STimothy McDaniel
4616f1b8288STimothy McDaniel if (info.max_event_ports != NUM_LDB_PORTS) {
4626f1b8288STimothy McDaniel printf("%d: Got %u ports, expected %u\n",
4636f1b8288STimothy McDaniel __LINE__, info.max_event_ports, NUM_LDB_PORTS);
4646f1b8288STimothy McDaniel goto err;
4656f1b8288STimothy McDaniel }
4666f1b8288STimothy McDaniel
4676f1b8288STimothy McDaniel if (info.max_event_queues != NUM_LDB_QUEUES) {
4686f1b8288STimothy McDaniel printf("%d: Got %u queues, expected %u\n",
4696f1b8288STimothy McDaniel __LINE__, info.max_event_queues, NUM_LDB_QUEUES);
4706f1b8288STimothy McDaniel goto err;
4716f1b8288STimothy McDaniel }
4726f1b8288STimothy McDaniel
4736f1b8288STimothy McDaniel ret = rte_event_dev_close(evdev);
4746f1b8288STimothy McDaniel if (ret) {
4756f1b8288STimothy McDaniel printf("%d: rte_event_dev_close failed, ret = %d\n",
4766f1b8288STimothy McDaniel __LINE__, ret);
4776f1b8288STimothy McDaniel return -1;
4786f1b8288STimothy McDaniel }
4796f1b8288STimothy McDaniel return 0;
4806f1b8288STimothy McDaniel
4816f1b8288STimothy McDaniel err:
4826f1b8288STimothy McDaniel ret = rte_event_dev_close(evdev);
4836f1b8288STimothy McDaniel if (ret)
4846f1b8288STimothy McDaniel printf("%d: rte_event_dev_close failed, ret = %d\n",
4856f1b8288STimothy McDaniel __LINE__, ret);
4866f1b8288STimothy McDaniel
4876f1b8288STimothy McDaniel return -1;
4886f1b8288STimothy McDaniel }
4896f1b8288STimothy McDaniel
4906f1b8288STimothy McDaniel static int
test_reconfiguration_link(void)4916f1b8288STimothy McDaniel test_reconfiguration_link(void)
4926f1b8288STimothy McDaniel {
4936f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
4946f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
4956f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
4966f1b8288STimothy McDaniel struct rte_event_dev_info info;
4976f1b8288STimothy McDaniel uint8_t queue_id;
4986f1b8288STimothy McDaniel int ret, i;
4996f1b8288STimothy McDaniel
5006f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
5016f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
5026f1b8288STimothy McDaniel return -1;
5036f1b8288STimothy McDaniel }
5046f1b8288STimothy McDaniel
5056f1b8288STimothy McDaniel config.nb_event_queues = 2;
5066f1b8288STimothy McDaniel config.nb_event_ports = 2;
5076f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 0;
5086f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
5096f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
5106f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
5116f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
5126f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
5136f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
5146f1b8288STimothy McDaniel
5156f1b8288STimothy McDaniel /* Configure the device with 2 LDB ports and 2 LDB queues */
5166f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
5176f1b8288STimothy McDaniel if (ret < 0) {
5186f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
5196f1b8288STimothy McDaniel return -1;
5206f1b8288STimothy McDaniel }
5216f1b8288STimothy McDaniel
5226f1b8288STimothy McDaniel /* Configure the ports and queues */
5236f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
5246f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
5256f1b8288STimothy McDaniel goto err;
5266f1b8288STimothy McDaniel }
5276f1b8288STimothy McDaniel
5286f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
5296f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, i, &port_conf) < 0) {
5306f1b8288STimothy McDaniel printf("%d: port %d setup expected to succeed\n",
5316f1b8288STimothy McDaniel __LINE__, i);
5326f1b8288STimothy McDaniel goto err;
5336f1b8288STimothy McDaniel }
5346f1b8288STimothy McDaniel }
5356f1b8288STimothy McDaniel
5366f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
5376f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
5386f1b8288STimothy McDaniel goto err;
5396f1b8288STimothy McDaniel }
5406f1b8288STimothy McDaniel
5416f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
5426f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, i, &queue_conf) < 0) {
5436f1b8288STimothy McDaniel printf("%d: queue %d setup expected to succeed\n",
5446f1b8288STimothy McDaniel __LINE__, i);
5456f1b8288STimothy McDaniel goto err;
5466f1b8288STimothy McDaniel }
5476f1b8288STimothy McDaniel }
5486f1b8288STimothy McDaniel
5496f1b8288STimothy McDaniel /* Link P0->Q0 and P1->Q1 */
5506f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
5516f1b8288STimothy McDaniel queue_id = i;
5526f1b8288STimothy McDaniel
5536f1b8288STimothy McDaniel if (rte_event_port_link(evdev, i, &queue_id, NULL, 1) != 1) {
5546f1b8288STimothy McDaniel printf("%d: port %d link expected to succeed\n",
5556f1b8288STimothy McDaniel __LINE__, i);
5566f1b8288STimothy McDaniel goto err;
5576f1b8288STimothy McDaniel }
5586f1b8288STimothy McDaniel }
5596f1b8288STimothy McDaniel
5606f1b8288STimothy McDaniel /* Start the device */
5616f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
5626f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
5636f1b8288STimothy McDaniel goto err;
5646f1b8288STimothy McDaniel }
5656f1b8288STimothy McDaniel
5666f1b8288STimothy McDaniel /* Stop the device */
5676f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
5686f1b8288STimothy McDaniel
5696f1b8288STimothy McDaniel /* Reconfigure device */
5706f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
5716f1b8288STimothy McDaniel if (ret < 0) {
5726f1b8288STimothy McDaniel printf("%d: Error re-configuring device\n", __LINE__);
5736f1b8288STimothy McDaniel return -1;
5746f1b8288STimothy McDaniel }
5756f1b8288STimothy McDaniel
5766f1b8288STimothy McDaniel /* Configure P1 and Q1, leave P0 and Q0 to be configured by the PMD. */
5776f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 1, &port_conf) < 0) {
5786f1b8288STimothy McDaniel printf("%d: port 1 setup expected to succeed\n",
5796f1b8288STimothy McDaniel __LINE__);
5806f1b8288STimothy McDaniel goto err;
5816f1b8288STimothy McDaniel }
5826f1b8288STimothy McDaniel
5836f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 1, &queue_conf) < 0) {
5846f1b8288STimothy McDaniel printf("%d: queue 1 setup expected to succeed\n",
5856f1b8288STimothy McDaniel __LINE__);
5866f1b8288STimothy McDaniel goto err;
5876f1b8288STimothy McDaniel }
5886f1b8288STimothy McDaniel
5896f1b8288STimothy McDaniel /* Link P0->Q0 and Q1 */
5906f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
5916f1b8288STimothy McDaniel queue_id = i;
5926f1b8288STimothy McDaniel
5936f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
5946f1b8288STimothy McDaniel printf("%d: P0->Q%d link expected to succeed\n",
5956f1b8288STimothy McDaniel __LINE__, i);
5966f1b8288STimothy McDaniel goto err;
5976f1b8288STimothy McDaniel }
5986f1b8288STimothy McDaniel }
5996f1b8288STimothy McDaniel
6006f1b8288STimothy McDaniel /* Link P1->Q0 and Q1 */
6016f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
6026f1b8288STimothy McDaniel queue_id = i;
6036f1b8288STimothy McDaniel
6046f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 1, &queue_id, NULL, 1) != 1) {
6056f1b8288STimothy McDaniel printf("%d: P1->Q%d link expected to succeed\n",
6066f1b8288STimothy McDaniel __LINE__, i);
6076f1b8288STimothy McDaniel goto err;
6086f1b8288STimothy McDaniel }
6096f1b8288STimothy McDaniel }
6106f1b8288STimothy McDaniel
6116f1b8288STimothy McDaniel /* Start the device */
6126f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
6136f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
6146f1b8288STimothy McDaniel goto err;
6156f1b8288STimothy McDaniel }
6166f1b8288STimothy McDaniel
6176f1b8288STimothy McDaniel /* Stop the device */
6186f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
6196f1b8288STimothy McDaniel
6206f1b8288STimothy McDaniel /* Configure device with 2 DIR ports and 2 DIR queues */
6216f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 2;
6226f1b8288STimothy McDaniel
6236f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
6246f1b8288STimothy McDaniel if (ret < 0) {
6256f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
6266f1b8288STimothy McDaniel return -1;
6276f1b8288STimothy McDaniel }
6286f1b8288STimothy McDaniel
6296f1b8288STimothy McDaniel /* Configure the ports and queues */
6306f1b8288STimothy McDaniel port_conf.event_port_cfg = RTE_EVENT_PORT_CFG_SINGLE_LINK;
6316f1b8288STimothy McDaniel
6326f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
6336f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, i, &port_conf) < 0) {
6346f1b8288STimothy McDaniel printf("%d: port %d setup expected to succeed\n",
6356f1b8288STimothy McDaniel __LINE__, i);
6366f1b8288STimothy McDaniel goto err;
6376f1b8288STimothy McDaniel }
6386f1b8288STimothy McDaniel }
6396f1b8288STimothy McDaniel
6406f1b8288STimothy McDaniel queue_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
6416f1b8288STimothy McDaniel
6426f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
6436f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, i, &queue_conf) < 0) {
6446f1b8288STimothy McDaniel printf("%d: queue %d setup expected to succeed\n",
6456f1b8288STimothy McDaniel __LINE__, i);
6466f1b8288STimothy McDaniel goto err;
6476f1b8288STimothy McDaniel }
6486f1b8288STimothy McDaniel }
6496f1b8288STimothy McDaniel
6506f1b8288STimothy McDaniel /* Link P0->Q0 and P1->Q1 */
6516f1b8288STimothy McDaniel for (i = 0; i < 2; i++) {
6526f1b8288STimothy McDaniel queue_id = i;
6536f1b8288STimothy McDaniel
6546f1b8288STimothy McDaniel if (rte_event_port_link(evdev, i, &queue_id, NULL, 1) != 1) {
6556f1b8288STimothy McDaniel printf("%d: port %d link expected to succeed\n",
6566f1b8288STimothy McDaniel __LINE__, i);
6576f1b8288STimothy McDaniel goto err;
6586f1b8288STimothy McDaniel }
6596f1b8288STimothy McDaniel }
6606f1b8288STimothy McDaniel
6616f1b8288STimothy McDaniel /* Start the device */
6626f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
6636f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
6646f1b8288STimothy McDaniel goto err;
6656f1b8288STimothy McDaniel }
6666f1b8288STimothy McDaniel
6676f1b8288STimothy McDaniel /* Stop the device */
6686f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
6696f1b8288STimothy McDaniel
6706f1b8288STimothy McDaniel /* Reconfigure device */
6716f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
6726f1b8288STimothy McDaniel if (ret < 0) {
6736f1b8288STimothy McDaniel printf("%d: Error re-configuring device\n", __LINE__);
6746f1b8288STimothy McDaniel return -1;
6756f1b8288STimothy McDaniel }
6766f1b8288STimothy McDaniel
6776f1b8288STimothy McDaniel /* Configure P1 and Q0, leave P0 and Q1 to be configured by the PMD. */
6786f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 1, &port_conf) < 0) {
6796f1b8288STimothy McDaniel printf("%d: port 1 setup expected to succeed\n",
6806f1b8288STimothy McDaniel __LINE__);
6816f1b8288STimothy McDaniel goto err;
6826f1b8288STimothy McDaniel }
6836f1b8288STimothy McDaniel
6846f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
6856f1b8288STimothy McDaniel printf("%d: queue 1 setup expected to succeed\n",
6866f1b8288STimothy McDaniel __LINE__);
6876f1b8288STimothy McDaniel goto err;
6886f1b8288STimothy McDaniel }
6896f1b8288STimothy McDaniel
6906f1b8288STimothy McDaniel /* Link P0->Q1 */
6916f1b8288STimothy McDaniel queue_id = 1;
6926f1b8288STimothy McDaniel
6936f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
6946f1b8288STimothy McDaniel printf("%d: P0->Q%d link expected to succeed\n",
6956f1b8288STimothy McDaniel __LINE__, i);
6966f1b8288STimothy McDaniel goto err;
6976f1b8288STimothy McDaniel }
6986f1b8288STimothy McDaniel
6996f1b8288STimothy McDaniel /* Link P1->Q0 */
7006f1b8288STimothy McDaniel queue_id = 0;
7016f1b8288STimothy McDaniel
7026f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 1, &queue_id, NULL, 1) != 1) {
7036f1b8288STimothy McDaniel printf("%d: P1->Q%d link expected to succeed\n",
7046f1b8288STimothy McDaniel __LINE__, i);
7056f1b8288STimothy McDaniel goto err;
7066f1b8288STimothy McDaniel }
7076f1b8288STimothy McDaniel
7086f1b8288STimothy McDaniel /* Start the device */
7096f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
7106f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
7116f1b8288STimothy McDaniel goto err;
7126f1b8288STimothy McDaniel }
7136f1b8288STimothy McDaniel
7146f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
7156f1b8288STimothy McDaniel
7166f1b8288STimothy McDaniel config.nb_event_queues = 5;
7176f1b8288STimothy McDaniel config.nb_event_ports = 5;
7186f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 1;
7196f1b8288STimothy McDaniel
7206f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
7216f1b8288STimothy McDaniel if (ret < 0) {
7226f1b8288STimothy McDaniel printf("%d: Error re-configuring device\n", __LINE__);
7236f1b8288STimothy McDaniel return -1;
7246f1b8288STimothy McDaniel }
7256f1b8288STimothy McDaniel
7266f1b8288STimothy McDaniel for (i = 0; i < config.nb_event_queues - 1; i++) {
7276f1b8288STimothy McDaniel port_conf.event_port_cfg = 0;
7286f1b8288STimothy McDaniel queue_conf.event_queue_cfg = 0;
7296f1b8288STimothy McDaniel
7306f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, i, &port_conf) < 0) {
7316f1b8288STimothy McDaniel printf("%d: port %d setup expected to succeed\n",
7326f1b8288STimothy McDaniel __LINE__, i);
7336f1b8288STimothy McDaniel goto err;
7346f1b8288STimothy McDaniel }
7356f1b8288STimothy McDaniel
7366f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, i, &queue_conf) < 0) {
7376f1b8288STimothy McDaniel printf("%d: queue %d setup expected to succeed\n",
7386f1b8288STimothy McDaniel __LINE__, i);
7396f1b8288STimothy McDaniel goto err;
7406f1b8288STimothy McDaniel }
7416f1b8288STimothy McDaniel
7426f1b8288STimothy McDaniel queue_id = i;
7436f1b8288STimothy McDaniel
7446f1b8288STimothy McDaniel if (rte_event_port_link(evdev, i, &queue_id, NULL, 1) != 1) {
7456f1b8288STimothy McDaniel printf("%d: P%d->Q%d link expected to succeed\n",
7466f1b8288STimothy McDaniel __LINE__, i, i);
7476f1b8288STimothy McDaniel goto err;
7486f1b8288STimothy McDaniel }
7496f1b8288STimothy McDaniel }
7506f1b8288STimothy McDaniel
7516f1b8288STimothy McDaniel port_conf.event_port_cfg = RTE_EVENT_PORT_CFG_SINGLE_LINK;
7526f1b8288STimothy McDaniel queue_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
7536f1b8288STimothy McDaniel
7546f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, i, &port_conf) < 0) {
7556f1b8288STimothy McDaniel printf("%d: port %d setup expected to succeed\n",
7566f1b8288STimothy McDaniel __LINE__, i);
7576f1b8288STimothy McDaniel goto err;
7586f1b8288STimothy McDaniel }
7596f1b8288STimothy McDaniel
7606f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, i, &queue_conf) < 0) {
7616f1b8288STimothy McDaniel printf("%d: queue %d setup expected to succeed\n",
7626f1b8288STimothy McDaniel __LINE__, i);
7636f1b8288STimothy McDaniel goto err;
7646f1b8288STimothy McDaniel }
7656f1b8288STimothy McDaniel
7666f1b8288STimothy McDaniel queue_id = i;
7676f1b8288STimothy McDaniel
7686f1b8288STimothy McDaniel if (rte_event_port_link(evdev, i, &queue_id, NULL, 1) != 1) {
7696f1b8288STimothy McDaniel printf("%d: P%d->Q%d link expected to succeed\n",
7706f1b8288STimothy McDaniel __LINE__, i, i);
7716f1b8288STimothy McDaniel goto err;
7726f1b8288STimothy McDaniel }
7736f1b8288STimothy McDaniel
7746f1b8288STimothy McDaniel /* Start the device */
7756f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
7766f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
7776f1b8288STimothy McDaniel goto err;
7786f1b8288STimothy McDaniel }
7796f1b8288STimothy McDaniel
7806f1b8288STimothy McDaniel /* Stop the device */
7816f1b8288STimothy McDaniel rte_event_dev_stop(evdev);
7826f1b8288STimothy McDaniel
7836f1b8288STimothy McDaniel config.nb_event_ports += 1;
7846f1b8288STimothy McDaniel
7856f1b8288STimothy McDaniel /* Reconfigure device with 1 more load-balanced port */
7866f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
7876f1b8288STimothy McDaniel if (ret < 0) {
7886f1b8288STimothy McDaniel printf("%d: Error re-configuring device\n", __LINE__);
7896f1b8288STimothy McDaniel return -1;
7906f1b8288STimothy McDaniel }
7916f1b8288STimothy McDaniel
7926f1b8288STimothy McDaniel port_conf.event_port_cfg = 0;
7936f1b8288STimothy McDaniel
7946f1b8288STimothy McDaniel /* Configure the new port */
7956f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, config.nb_event_ports - 1,
7966f1b8288STimothy McDaniel &port_conf) < 0) {
7976f1b8288STimothy McDaniel printf("%d: port 1 setup expected to succeed\n",
7986f1b8288STimothy McDaniel __LINE__);
7996f1b8288STimothy McDaniel goto err;
8006f1b8288STimothy McDaniel }
8016f1b8288STimothy McDaniel
8026f1b8288STimothy McDaniel /* Start the device */
8036f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
8046f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
8056f1b8288STimothy McDaniel goto err;
8066f1b8288STimothy McDaniel }
8076f1b8288STimothy McDaniel
8086f1b8288STimothy McDaniel cleanup();
8096f1b8288STimothy McDaniel return 0;
8106f1b8288STimothy McDaniel
8116f1b8288STimothy McDaniel err:
8126f1b8288STimothy McDaniel cleanup();
8136f1b8288STimothy McDaniel return -1;
8146f1b8288STimothy McDaniel }
8156f1b8288STimothy McDaniel
8166f1b8288STimothy McDaniel static int
test_load_balanced_traffic(void)8176f1b8288STimothy McDaniel test_load_balanced_traffic(void)
8186f1b8288STimothy McDaniel {
8196f1b8288STimothy McDaniel uint64_t timeout;
8206f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
8216f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
8226f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
8236f1b8288STimothy McDaniel struct rte_event_dev_info info;
8246f1b8288STimothy McDaniel struct rte_event ev;
8256f1b8288STimothy McDaniel uint8_t queue_id;
8266f1b8288STimothy McDaniel int ret;
8276f1b8288STimothy McDaniel
8286f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
8296f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
8306f1b8288STimothy McDaniel return -1;
8316f1b8288STimothy McDaniel }
8326f1b8288STimothy McDaniel
8336f1b8288STimothy McDaniel config.nb_event_queues = 1;
8346f1b8288STimothy McDaniel config.nb_event_ports = 1;
8356f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 0;
8366f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
8376f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
8386f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
8396f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
8406f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
8416f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
8426f1b8288STimothy McDaniel
8436f1b8288STimothy McDaniel /* Configure the device with 1 LDB port and queue */
8446f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
8456f1b8288STimothy McDaniel if (ret < 0) {
8466f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
8476f1b8288STimothy McDaniel return -1;
8486f1b8288STimothy McDaniel }
8496f1b8288STimothy McDaniel
8506f1b8288STimothy McDaniel /* Configure the ports and queues */
8516f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
8526f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
8536f1b8288STimothy McDaniel goto err;
8546f1b8288STimothy McDaniel }
8556f1b8288STimothy McDaniel
8566f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
8576f1b8288STimothy McDaniel printf("%d: port 0 setup expected to succeed\n",
8586f1b8288STimothy McDaniel __LINE__);
8596f1b8288STimothy McDaniel goto err;
8606f1b8288STimothy McDaniel }
8616f1b8288STimothy McDaniel
8626f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
8636f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
8646f1b8288STimothy McDaniel goto err;
8656f1b8288STimothy McDaniel }
8666f1b8288STimothy McDaniel
8676f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
8686f1b8288STimothy McDaniel printf("%d: queue 0 setup expected to succeed\n",
8696f1b8288STimothy McDaniel __LINE__);
8706f1b8288STimothy McDaniel goto err;
8716f1b8288STimothy McDaniel }
8726f1b8288STimothy McDaniel
8736f1b8288STimothy McDaniel /* Link P0->Q0 */
8746f1b8288STimothy McDaniel queue_id = 0;
8756f1b8288STimothy McDaniel
8766f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
8776f1b8288STimothy McDaniel printf("%d: port 0 link expected to succeed\n",
8786f1b8288STimothy McDaniel __LINE__);
8796f1b8288STimothy McDaniel goto err;
8806f1b8288STimothy McDaniel }
8816f1b8288STimothy McDaniel
8826f1b8288STimothy McDaniel /* Start the device */
8836f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
8846f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
8856f1b8288STimothy McDaniel goto err;
8866f1b8288STimothy McDaniel }
8876f1b8288STimothy McDaniel
8886f1b8288STimothy McDaniel /* Enqueue 1 NEW event */
8896f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_NEW;
8906f1b8288STimothy McDaniel ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
8916f1b8288STimothy McDaniel ev.queue_id = 0;
8926f1b8288STimothy McDaniel ev.priority = 0;
8936f1b8288STimothy McDaniel ev.u64 = 0;
8946f1b8288STimothy McDaniel
8956f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
8966f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
8976f1b8288STimothy McDaniel __LINE__);
8986f1b8288STimothy McDaniel goto err;
8996f1b8288STimothy McDaniel }
9006f1b8288STimothy McDaniel
9016f1b8288STimothy McDaniel /* Dequeue and enqueue 1 FORWARD event */
9026f1b8288STimothy McDaniel timeout = 0xFFFFFFFFF;
9036f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
9046f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
9056f1b8288STimothy McDaniel __LINE__);
9066f1b8288STimothy McDaniel goto err;
9076f1b8288STimothy McDaniel }
9086f1b8288STimothy McDaniel
9096f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_FORWARD;
9106f1b8288STimothy McDaniel
9116f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
9126f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
9136f1b8288STimothy McDaniel __LINE__);
9146f1b8288STimothy McDaniel goto err;
9156f1b8288STimothy McDaniel }
9166f1b8288STimothy McDaniel
9176f1b8288STimothy McDaniel /* Dequeue and enqueue 1 RELEASE operation */
9186f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
9196f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
9206f1b8288STimothy McDaniel __LINE__);
9216f1b8288STimothy McDaniel goto err;
9226f1b8288STimothy McDaniel }
9236f1b8288STimothy McDaniel
9246f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_RELEASE;
9256f1b8288STimothy McDaniel
9266f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
9276f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
9286f1b8288STimothy McDaniel __LINE__);
9296f1b8288STimothy McDaniel goto err;
9306f1b8288STimothy McDaniel }
9316f1b8288STimothy McDaniel
9326f1b8288STimothy McDaniel cleanup();
9336f1b8288STimothy McDaniel return 0;
9346f1b8288STimothy McDaniel
9356f1b8288STimothy McDaniel err:
9366f1b8288STimothy McDaniel cleanup();
9376f1b8288STimothy McDaniel return -1;
9386f1b8288STimothy McDaniel }
9396f1b8288STimothy McDaniel
9406f1b8288STimothy McDaniel static int
test_directed_traffic(void)9416f1b8288STimothy McDaniel test_directed_traffic(void)
9426f1b8288STimothy McDaniel {
9436f1b8288STimothy McDaniel uint64_t timeout;
9446f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
9456f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
9466f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
9476f1b8288STimothy McDaniel struct rte_event_dev_info info;
9486f1b8288STimothy McDaniel struct rte_event ev;
9496f1b8288STimothy McDaniel uint8_t queue_id;
9506f1b8288STimothy McDaniel int ret;
9516f1b8288STimothy McDaniel
9526f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
9536f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
9546f1b8288STimothy McDaniel return -1;
9556f1b8288STimothy McDaniel }
9566f1b8288STimothy McDaniel
9576f1b8288STimothy McDaniel config.nb_event_queues = 1;
9586f1b8288STimothy McDaniel config.nb_event_ports = 1;
9596f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 1;
9606f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
9616f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
9626f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
9636f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
9646f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
9656f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
9666f1b8288STimothy McDaniel
9676f1b8288STimothy McDaniel /* Configure the device with 1 DIR port and queue */
9686f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
9696f1b8288STimothy McDaniel if (ret < 0) {
9706f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
9716f1b8288STimothy McDaniel return -1;
9726f1b8288STimothy McDaniel }
9736f1b8288STimothy McDaniel
9746f1b8288STimothy McDaniel /* Configure the ports and queues */
9756f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
9766f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
9776f1b8288STimothy McDaniel goto err;
9786f1b8288STimothy McDaniel }
9796f1b8288STimothy McDaniel
9806f1b8288STimothy McDaniel port_conf.event_port_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
9816f1b8288STimothy McDaniel
9826f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
9836f1b8288STimothy McDaniel printf("%d: port 0 setup expected to succeed\n",
9846f1b8288STimothy McDaniel __LINE__);
9856f1b8288STimothy McDaniel goto err;
9866f1b8288STimothy McDaniel }
9876f1b8288STimothy McDaniel
9886f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
9896f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
9906f1b8288STimothy McDaniel goto err;
9916f1b8288STimothy McDaniel }
9926f1b8288STimothy McDaniel
9936f1b8288STimothy McDaniel queue_conf.event_queue_cfg = RTE_EVENT_QUEUE_CFG_SINGLE_LINK;
9946f1b8288STimothy McDaniel
9956f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
9966f1b8288STimothy McDaniel printf("%d: queue 0 setup expected to succeed\n",
9976f1b8288STimothy McDaniel __LINE__);
9986f1b8288STimothy McDaniel goto err;
9996f1b8288STimothy McDaniel }
10006f1b8288STimothy McDaniel
10016f1b8288STimothy McDaniel /* Link P0->Q0 */
10026f1b8288STimothy McDaniel queue_id = 0;
10036f1b8288STimothy McDaniel
10046f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
10056f1b8288STimothy McDaniel printf("%d: port 0 link expected to succeed\n",
10066f1b8288STimothy McDaniel __LINE__);
10076f1b8288STimothy McDaniel goto err;
10086f1b8288STimothy McDaniel }
10096f1b8288STimothy McDaniel
10106f1b8288STimothy McDaniel /* Start the device */
10116f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
10126f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
10136f1b8288STimothy McDaniel goto err;
10146f1b8288STimothy McDaniel }
10156f1b8288STimothy McDaniel
10166f1b8288STimothy McDaniel /* Enqueue 1 NEW event */
10176f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_NEW;
10186f1b8288STimothy McDaniel ev.queue_id = 0;
10196f1b8288STimothy McDaniel ev.priority = 0;
10206f1b8288STimothy McDaniel ev.u64 = 0;
10216f1b8288STimothy McDaniel
10226f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
10236f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
10246f1b8288STimothy McDaniel __LINE__);
10256f1b8288STimothy McDaniel goto err;
10266f1b8288STimothy McDaniel }
10276f1b8288STimothy McDaniel
10286f1b8288STimothy McDaniel /* Dequeue and enqueue 1 FORWARD event */
10296f1b8288STimothy McDaniel timeout = 0xFFFFFFFFF;
10306f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
10316f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
10326f1b8288STimothy McDaniel __LINE__);
10336f1b8288STimothy McDaniel goto err;
10346f1b8288STimothy McDaniel }
10356f1b8288STimothy McDaniel
10366f1b8288STimothy McDaniel if (ev.queue_id != 0) {
10376f1b8288STimothy McDaniel printf("%d: invalid dequeued event queue ID (%d)\n",
10386f1b8288STimothy McDaniel __LINE__, ev.queue_id);
10396f1b8288STimothy McDaniel goto err;
10406f1b8288STimothy McDaniel }
10416f1b8288STimothy McDaniel
10426f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_FORWARD;
10436f1b8288STimothy McDaniel
10446f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
10456f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
10466f1b8288STimothy McDaniel __LINE__);
10476f1b8288STimothy McDaniel goto err;
10486f1b8288STimothy McDaniel }
10496f1b8288STimothy McDaniel
10506f1b8288STimothy McDaniel /* Dequeue and enqueue 1 RELEASE operation */
10516f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
10526f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
10536f1b8288STimothy McDaniel __LINE__);
10546f1b8288STimothy McDaniel goto err;
10556f1b8288STimothy McDaniel }
10566f1b8288STimothy McDaniel
10576f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_RELEASE;
10586f1b8288STimothy McDaniel
10596f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
10606f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
10616f1b8288STimothy McDaniel __LINE__);
10626f1b8288STimothy McDaniel goto err;
10636f1b8288STimothy McDaniel }
10646f1b8288STimothy McDaniel
10656f1b8288STimothy McDaniel cleanup();
10666f1b8288STimothy McDaniel return 0;
10676f1b8288STimothy McDaniel
10686f1b8288STimothy McDaniel err:
10696f1b8288STimothy McDaniel cleanup();
10706f1b8288STimothy McDaniel return -1;
10716f1b8288STimothy McDaniel }
10726f1b8288STimothy McDaniel
10736f1b8288STimothy McDaniel static int
test_deferred_sched(void)10746f1b8288STimothy McDaniel test_deferred_sched(void)
10756f1b8288STimothy McDaniel {
10766f1b8288STimothy McDaniel uint64_t timeout;
10776f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
10786f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
10796f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
10806f1b8288STimothy McDaniel struct rte_event_dev_info info;
10816f1b8288STimothy McDaniel const int num_events = 128;
10826f1b8288STimothy McDaniel struct rte_event ev;
10836f1b8288STimothy McDaniel uint8_t queue_id;
10846f1b8288STimothy McDaniel int ret, i;
10856f1b8288STimothy McDaniel
10866f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
10876f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
10886f1b8288STimothy McDaniel return -1;
10896f1b8288STimothy McDaniel }
10906f1b8288STimothy McDaniel
10916f1b8288STimothy McDaniel config.nb_event_queues = 1;
10926f1b8288STimothy McDaniel config.nb_event_ports = 2;
10936f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 0;
10946f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
10956f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
10966f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
10976f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
10986f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
10996f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
11006f1b8288STimothy McDaniel
11016f1b8288STimothy McDaniel /* Configure the device with 2 LDB ports and 1 queue */
11026f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
11036f1b8288STimothy McDaniel if (ret < 0) {
11046f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
11056f1b8288STimothy McDaniel return -1;
11066f1b8288STimothy McDaniel }
11076f1b8288STimothy McDaniel
11086f1b8288STimothy McDaniel ret = rte_pmd_dlb2_set_token_pop_mode(evdev, 0, DEFERRED_POP);
11096f1b8288STimothy McDaniel if (ret < 0) {
11106f1b8288STimothy McDaniel printf("%d: Error setting deferred scheduling\n", __LINE__);
11116f1b8288STimothy McDaniel goto err;
11126f1b8288STimothy McDaniel }
11136f1b8288STimothy McDaniel
11146f1b8288STimothy McDaniel ret = rte_pmd_dlb2_set_token_pop_mode(evdev, 1, DEFERRED_POP);
11156f1b8288STimothy McDaniel if (ret < 0) {
11166f1b8288STimothy McDaniel printf("%d: Error setting deferred scheduling\n", __LINE__);
11176f1b8288STimothy McDaniel goto err;
11186f1b8288STimothy McDaniel }
11196f1b8288STimothy McDaniel
11206f1b8288STimothy McDaniel /* Configure the ports and queues */
11216f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
11226f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
11236f1b8288STimothy McDaniel goto err;
11246f1b8288STimothy McDaniel }
11256f1b8288STimothy McDaniel
11266f1b8288STimothy McDaniel port_conf.dequeue_depth = 1;
11276f1b8288STimothy McDaniel
11286f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
11296f1b8288STimothy McDaniel printf("%d: port 0 setup expected to succeed\n",
11306f1b8288STimothy McDaniel __LINE__);
11316f1b8288STimothy McDaniel goto err;
11326f1b8288STimothy McDaniel }
11336f1b8288STimothy McDaniel
11346f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 1, &port_conf) < 0) {
11356f1b8288STimothy McDaniel printf("%d: port 1 setup expected to succeed\n",
11366f1b8288STimothy McDaniel __LINE__);
11376f1b8288STimothy McDaniel goto err;
11386f1b8288STimothy McDaniel }
11396f1b8288STimothy McDaniel
11406f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
11416f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
11426f1b8288STimothy McDaniel goto err;
11436f1b8288STimothy McDaniel }
11446f1b8288STimothy McDaniel
11456f1b8288STimothy McDaniel queue_conf.schedule_type = RTE_SCHED_TYPE_PARALLEL;
11466f1b8288STimothy McDaniel queue_conf.nb_atomic_order_sequences = 0;
11476f1b8288STimothy McDaniel
11486f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
11496f1b8288STimothy McDaniel printf("%d: queue 0 setup expected to succeed\n",
11506f1b8288STimothy McDaniel __LINE__);
11516f1b8288STimothy McDaniel goto err;
11526f1b8288STimothy McDaniel }
11536f1b8288STimothy McDaniel
11546f1b8288STimothy McDaniel /* Link P0->Q0 and P1->Q0 */
11556f1b8288STimothy McDaniel queue_id = 0;
11566f1b8288STimothy McDaniel
11576f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
11586f1b8288STimothy McDaniel printf("%d: port 0 link expected to succeed\n",
11596f1b8288STimothy McDaniel __LINE__);
11606f1b8288STimothy McDaniel goto err;
11616f1b8288STimothy McDaniel }
11626f1b8288STimothy McDaniel
11636f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 1, &queue_id, NULL, 1) != 1) {
11646f1b8288STimothy McDaniel printf("%d: port 1 link expected to succeed\n",
11656f1b8288STimothy McDaniel __LINE__);
11666f1b8288STimothy McDaniel goto err;
11676f1b8288STimothy McDaniel }
11686f1b8288STimothy McDaniel
11696f1b8288STimothy McDaniel /* Start the device */
11706f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
11716f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
11726f1b8288STimothy McDaniel goto err;
11736f1b8288STimothy McDaniel }
11746f1b8288STimothy McDaniel
11756f1b8288STimothy McDaniel /* Enqueue 128 NEW events */
11766f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_NEW;
11776f1b8288STimothy McDaniel ev.sched_type = RTE_SCHED_TYPE_PARALLEL;
11786f1b8288STimothy McDaniel ev.queue_id = 0;
11796f1b8288STimothy McDaniel ev.priority = 0;
11806f1b8288STimothy McDaniel ev.u64 = 0;
11816f1b8288STimothy McDaniel
11826f1b8288STimothy McDaniel for (i = 0; i < num_events; i++) {
11836f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
11846f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
11856f1b8288STimothy McDaniel __LINE__);
11866f1b8288STimothy McDaniel goto err;
11876f1b8288STimothy McDaniel }
11886f1b8288STimothy McDaniel }
11896f1b8288STimothy McDaniel
11906f1b8288STimothy McDaniel /* Dequeue one event from port 0 */
11916f1b8288STimothy McDaniel timeout = 0xFFFFFFFFF;
11926f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
11936f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
11946f1b8288STimothy McDaniel __LINE__);
11956f1b8288STimothy McDaniel goto err;
11966f1b8288STimothy McDaniel }
11976f1b8288STimothy McDaniel
11986f1b8288STimothy McDaniel /* Dequeue (and release) all other events from port 1. Deferred
11996f1b8288STimothy McDaniel * scheduling ensures no other events are scheduled to port 0 without a
12006f1b8288STimothy McDaniel * subsequent rte_event_dequeue_burst() call.
12016f1b8288STimothy McDaniel */
12026f1b8288STimothy McDaniel for (i = 0; i < num_events - 1; i++) {
12036f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 1, &ev, 1, timeout) != 1) {
12046f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
12056f1b8288STimothy McDaniel __LINE__);
12066f1b8288STimothy McDaniel goto err;
12076f1b8288STimothy McDaniel }
12086f1b8288STimothy McDaniel
12096f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_RELEASE;
12106f1b8288STimothy McDaniel
12116f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 1, &ev, 1) != 1) {
12126f1b8288STimothy McDaniel printf("%d: RELEASE enqueue expected to succeed\n",
12136f1b8288STimothy McDaniel __LINE__);
12146f1b8288STimothy McDaniel goto err;
12156f1b8288STimothy McDaniel }
12166f1b8288STimothy McDaniel }
12176f1b8288STimothy McDaniel
12186f1b8288STimothy McDaniel cleanup();
12196f1b8288STimothy McDaniel return 0;
12206f1b8288STimothy McDaniel
12216f1b8288STimothy McDaniel err:
12226f1b8288STimothy McDaniel cleanup();
12236f1b8288STimothy McDaniel return -1;
12246f1b8288STimothy McDaniel }
12256f1b8288STimothy McDaniel
12266f1b8288STimothy McDaniel static int
test_delayed_pop(void)12276f1b8288STimothy McDaniel test_delayed_pop(void)
12286f1b8288STimothy McDaniel {
12296f1b8288STimothy McDaniel uint64_t timeout;
12306f1b8288STimothy McDaniel struct rte_event_dev_config config = {0};
12316f1b8288STimothy McDaniel struct rte_event_queue_conf queue_conf;
12326f1b8288STimothy McDaniel struct rte_event_port_conf port_conf;
12336f1b8288STimothy McDaniel struct rte_event_dev_info info;
12346f1b8288STimothy McDaniel int ret, i, num_events;
12356f1b8288STimothy McDaniel struct rte_event ev;
12366f1b8288STimothy McDaniel uint8_t queue_id;
12376f1b8288STimothy McDaniel
12386f1b8288STimothy McDaniel if (rte_event_dev_info_get(evdev, &info)) {
12396f1b8288STimothy McDaniel printf("%d: Error querying device info\n", __LINE__);
12406f1b8288STimothy McDaniel return -1;
12416f1b8288STimothy McDaniel }
12426f1b8288STimothy McDaniel
12436f1b8288STimothy McDaniel config.nb_event_queues = 1;
12446f1b8288STimothy McDaniel config.nb_event_ports = 1;
12456f1b8288STimothy McDaniel config.nb_single_link_event_port_queues = 0;
12466f1b8288STimothy McDaniel config.nb_event_queue_flows = info.max_event_queue_flows;
12476f1b8288STimothy McDaniel config.nb_events_limit = info.max_num_events;
12486f1b8288STimothy McDaniel config.nb_event_port_dequeue_depth = info.max_event_port_dequeue_depth;
12496f1b8288STimothy McDaniel config.nb_event_port_enqueue_depth = info.max_event_port_enqueue_depth;
12506f1b8288STimothy McDaniel config.dequeue_timeout_ns = info.max_dequeue_timeout_ns;
12516f1b8288STimothy McDaniel config.event_dev_cfg = RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT;
12526f1b8288STimothy McDaniel
12536f1b8288STimothy McDaniel /* Configure the device with 1 LDB port and queue */
12546f1b8288STimothy McDaniel ret = rte_event_dev_configure(evdev, &config);
12556f1b8288STimothy McDaniel if (ret < 0) {
12566f1b8288STimothy McDaniel printf("%d: Error configuring device\n", __LINE__);
12576f1b8288STimothy McDaniel return -1;
12586f1b8288STimothy McDaniel }
12596f1b8288STimothy McDaniel
12606f1b8288STimothy McDaniel ret = rte_pmd_dlb2_set_token_pop_mode(evdev, 0, DELAYED_POP);
12616f1b8288STimothy McDaniel if (ret < 0) {
12626f1b8288STimothy McDaniel printf("%d: Error setting deferred scheduling\n", __LINE__);
12636f1b8288STimothy McDaniel goto err;
12646f1b8288STimothy McDaniel }
12656f1b8288STimothy McDaniel
12666f1b8288STimothy McDaniel /* Configure the ports and queues */
12676f1b8288STimothy McDaniel if (rte_event_port_default_conf_get(evdev, 0, &port_conf)) {
12686f1b8288STimothy McDaniel printf("%d: Error querying default port conf\n", __LINE__);
12696f1b8288STimothy McDaniel goto err;
12706f1b8288STimothy McDaniel }
12716f1b8288STimothy McDaniel
12726f1b8288STimothy McDaniel port_conf.event_port_cfg = RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL;
12736f1b8288STimothy McDaniel
12746f1b8288STimothy McDaniel if (rte_event_port_setup(evdev, 0, &port_conf) < 0) {
12756f1b8288STimothy McDaniel printf("%d: port 0 setup expected to succeed\n",
12766f1b8288STimothy McDaniel __LINE__);
12776f1b8288STimothy McDaniel goto err;
12786f1b8288STimothy McDaniel }
12796f1b8288STimothy McDaniel
12806f1b8288STimothy McDaniel if (rte_event_queue_default_conf_get(evdev, 0, &queue_conf)) {
12816f1b8288STimothy McDaniel printf("%d: Error querying default queue conf\n", __LINE__);
12826f1b8288STimothy McDaniel goto err;
12836f1b8288STimothy McDaniel }
12846f1b8288STimothy McDaniel
12856f1b8288STimothy McDaniel if (rte_event_queue_setup(evdev, 0, &queue_conf) < 0) {
12866f1b8288STimothy McDaniel printf("%d: queue 0 setup expected to succeed\n",
12876f1b8288STimothy McDaniel __LINE__);
12886f1b8288STimothy McDaniel goto err;
12896f1b8288STimothy McDaniel }
12906f1b8288STimothy McDaniel
12916f1b8288STimothy McDaniel /* Link P0->Q0 */
12926f1b8288STimothy McDaniel queue_id = 0;
12936f1b8288STimothy McDaniel
12946f1b8288STimothy McDaniel if (rte_event_port_link(evdev, 0, &queue_id, NULL, 1) != 1) {
12956f1b8288STimothy McDaniel printf("%d: port 0 link expected to succeed\n",
12966f1b8288STimothy McDaniel __LINE__);
12976f1b8288STimothy McDaniel goto err;
12986f1b8288STimothy McDaniel }
12996f1b8288STimothy McDaniel
13006f1b8288STimothy McDaniel /* Start the device */
13016f1b8288STimothy McDaniel if (rte_event_dev_start(evdev) < 0) {
13026f1b8288STimothy McDaniel printf("%d: device start failed\n", __LINE__);
13036f1b8288STimothy McDaniel goto err;
13046f1b8288STimothy McDaniel }
13056f1b8288STimothy McDaniel
13066f1b8288STimothy McDaniel num_events = 2 * port_conf.dequeue_depth;
13076f1b8288STimothy McDaniel
13086f1b8288STimothy McDaniel /* Enqueue 2 * dequeue_depth NEW events */
13096f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_NEW;
13106f1b8288STimothy McDaniel ev.sched_type = RTE_SCHED_TYPE_ATOMIC;
13116f1b8288STimothy McDaniel ev.queue_id = 0;
13126f1b8288STimothy McDaniel ev.priority = 0;
13136f1b8288STimothy McDaniel ev.u64 = 0;
13146f1b8288STimothy McDaniel
13156f1b8288STimothy McDaniel for (i = 0; i < num_events; i++) {
13166f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
13176f1b8288STimothy McDaniel printf("%d: NEW enqueue expected to succeed\n",
13186f1b8288STimothy McDaniel __LINE__);
13196f1b8288STimothy McDaniel goto err;
13206f1b8288STimothy McDaniel }
13216f1b8288STimothy McDaniel }
13226f1b8288STimothy McDaniel
132307d55c41STimothy McDaniel /* Dequeue dequeue_depth events but only release dequeue_depth - 1.
13246f1b8288STimothy McDaniel * Delayed pop won't perform the pop and no more events will be
13256f1b8288STimothy McDaniel * scheduled.
13266f1b8288STimothy McDaniel */
13276f1b8288STimothy McDaniel timeout = 0xFFFFFFFFF;
13286f1b8288STimothy McDaniel
13296f1b8288STimothy McDaniel for (i = 0; i < port_conf.dequeue_depth; i++) {
13306f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
13316f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
13326f1b8288STimothy McDaniel __LINE__);
13336f1b8288STimothy McDaniel goto err;
13346f1b8288STimothy McDaniel }
13356f1b8288STimothy McDaniel }
13366f1b8288STimothy McDaniel
13376f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_RELEASE;
13386f1b8288STimothy McDaniel
133907d55c41STimothy McDaniel for (i = 0; i < port_conf.dequeue_depth - 1; i++) {
13406f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
13416f1b8288STimothy McDaniel printf("%d: RELEASE enqueue expected to succeed\n",
13426f1b8288STimothy McDaniel __LINE__);
13436f1b8288STimothy McDaniel goto err;
13446f1b8288STimothy McDaniel }
13456f1b8288STimothy McDaniel }
13466f1b8288STimothy McDaniel
13476f1b8288STimothy McDaniel timeout = 0x10000;
13486f1b8288STimothy McDaniel
13496f1b8288STimothy McDaniel ret = rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout);
13506f1b8288STimothy McDaniel if (ret != 0) {
13516f1b8288STimothy McDaniel printf("%d: event dequeue expected to fail (ret = %d)\n",
13526f1b8288STimothy McDaniel __LINE__, ret);
13536f1b8288STimothy McDaniel goto err;
13546f1b8288STimothy McDaniel }
13556f1b8288STimothy McDaniel
13566f1b8288STimothy McDaniel /* Release one more event. This will trigger the token pop, and
13575fe46ce0SRashmi Shetty * dequeue_depth more events will be scheduled to the device.
13586f1b8288STimothy McDaniel */
13596f1b8288STimothy McDaniel ev.op = RTE_EVENT_OP_RELEASE;
13606f1b8288STimothy McDaniel
13616f1b8288STimothy McDaniel if (rte_event_enqueue_burst(evdev, 0, &ev, 1) != 1) {
13626f1b8288STimothy McDaniel printf("%d: RELEASE enqueue expected to succeed\n",
13636f1b8288STimothy McDaniel __LINE__);
13646f1b8288STimothy McDaniel goto err;
13656f1b8288STimothy McDaniel }
13666f1b8288STimothy McDaniel
13676f1b8288STimothy McDaniel timeout = 0xFFFFFFFFF;
13686f1b8288STimothy McDaniel
13695fe46ce0SRashmi Shetty for (i = 0; i < port_conf.dequeue_depth; i++) {
13706f1b8288STimothy McDaniel if (rte_event_dequeue_burst(evdev, 0, &ev, 1, timeout) != 1) {
13716f1b8288STimothy McDaniel printf("%d: event dequeue expected to succeed\n",
13726f1b8288STimothy McDaniel __LINE__);
13736f1b8288STimothy McDaniel goto err;
13746f1b8288STimothy McDaniel }
13756f1b8288STimothy McDaniel }
13766f1b8288STimothy McDaniel
13776f1b8288STimothy McDaniel cleanup();
13786f1b8288STimothy McDaniel return 0;
13796f1b8288STimothy McDaniel
13806f1b8288STimothy McDaniel err:
13816f1b8288STimothy McDaniel cleanup();
13826f1b8288STimothy McDaniel return -1;
13836f1b8288STimothy McDaniel }
13846f1b8288STimothy McDaniel
13856f1b8288STimothy McDaniel static int
do_selftest(void)13866f1b8288STimothy McDaniel do_selftest(void)
13876f1b8288STimothy McDaniel {
13886f1b8288STimothy McDaniel struct test t;
13896f1b8288STimothy McDaniel int ret;
13906f1b8288STimothy McDaniel
13916f1b8288STimothy McDaniel /* Only create mbuf pool once, reuse for each test run */
13926f1b8288STimothy McDaniel if (!eventdev_func_mempool) {
13936f1b8288STimothy McDaniel eventdev_func_mempool =
13946f1b8288STimothy McDaniel rte_pktmbuf_pool_create("EVENTDEV_DLB2_ST_POOL",
13956f1b8288STimothy McDaniel (1 << 12), /* 4k buffers */
13966f1b8288STimothy McDaniel 32 /*MBUF_CACHE_SIZE*/,
13976f1b8288STimothy McDaniel 0,
13986f1b8288STimothy McDaniel 512, /* use very small mbufs */
13996f1b8288STimothy McDaniel rte_socket_id());
14006f1b8288STimothy McDaniel if (!eventdev_func_mempool) {
14016f1b8288STimothy McDaniel printf("ERROR creating mempool\n");
14026f1b8288STimothy McDaniel goto test_fail;
14036f1b8288STimothy McDaniel }
14046f1b8288STimothy McDaniel }
14056f1b8288STimothy McDaniel t.mbuf_pool = eventdev_func_mempool;
14066f1b8288STimothy McDaniel
14076f1b8288STimothy McDaniel printf("*** Running Stop Flush test...\n");
14086f1b8288STimothy McDaniel ret = test_stop_flush(&t);
14096f1b8288STimothy McDaniel if (ret != 0) {
14106f1b8288STimothy McDaniel printf("ERROR - Stop Flush test FAILED.\n");
14116f1b8288STimothy McDaniel return ret;
14126f1b8288STimothy McDaniel }
14136f1b8288STimothy McDaniel
14146f1b8288STimothy McDaniel printf("*** Running Single Link test...\n");
14156f1b8288STimothy McDaniel ret = test_single_link();
14166f1b8288STimothy McDaniel if (ret != 0) {
14176f1b8288STimothy McDaniel printf("ERROR - Single Link test FAILED.\n");
14186f1b8288STimothy McDaniel
14196f1b8288STimothy McDaniel goto test_fail;
14206f1b8288STimothy McDaniel }
14216f1b8288STimothy McDaniel
14226f1b8288STimothy McDaniel printf("*** Running Info Get test...\n");
14236f1b8288STimothy McDaniel ret = test_info_get();
14246f1b8288STimothy McDaniel if (ret != 0) {
14256f1b8288STimothy McDaniel printf("ERROR - Stop Flush test FAILED.\n");
14266f1b8288STimothy McDaniel return ret;
14276f1b8288STimothy McDaniel }
14286f1b8288STimothy McDaniel
14296f1b8288STimothy McDaniel printf("*** Running Reconfiguration Link test...\n");
14306f1b8288STimothy McDaniel ret = test_reconfiguration_link();
14316f1b8288STimothy McDaniel if (ret != 0) {
14326f1b8288STimothy McDaniel printf("ERROR - Reconfiguration Link test FAILED.\n");
14336f1b8288STimothy McDaniel
14346f1b8288STimothy McDaniel goto test_fail;
14356f1b8288STimothy McDaniel }
14366f1b8288STimothy McDaniel
14376f1b8288STimothy McDaniel printf("*** Running Load-Balanced Traffic test...\n");
14386f1b8288STimothy McDaniel ret = test_load_balanced_traffic();
14396f1b8288STimothy McDaniel if (ret != 0) {
14406f1b8288STimothy McDaniel printf("ERROR - Load-Balanced Traffic test FAILED.\n");
14416f1b8288STimothy McDaniel
14426f1b8288STimothy McDaniel goto test_fail;
14436f1b8288STimothy McDaniel }
14446f1b8288STimothy McDaniel
14456f1b8288STimothy McDaniel printf("*** Running Directed Traffic test...\n");
14466f1b8288STimothy McDaniel ret = test_directed_traffic();
14476f1b8288STimothy McDaniel if (ret != 0) {
14486f1b8288STimothy McDaniel printf("ERROR - Directed Traffic test FAILED.\n");
14496f1b8288STimothy McDaniel
14506f1b8288STimothy McDaniel goto test_fail;
14516f1b8288STimothy McDaniel }
14526f1b8288STimothy McDaniel
14536f1b8288STimothy McDaniel printf("*** Running Deferred Scheduling test...\n");
14546f1b8288STimothy McDaniel ret = test_deferred_sched();
14556f1b8288STimothy McDaniel if (ret != 0) {
14566f1b8288STimothy McDaniel printf("ERROR - Deferred Scheduling test FAILED.\n");
14576f1b8288STimothy McDaniel
14586f1b8288STimothy McDaniel goto test_fail;
14596f1b8288STimothy McDaniel }
14606f1b8288STimothy McDaniel
14616f1b8288STimothy McDaniel printf("*** Running Delayed Pop test...\n");
14626f1b8288STimothy McDaniel ret = test_delayed_pop();
14636f1b8288STimothy McDaniel if (ret != 0) {
14646f1b8288STimothy McDaniel printf("ERROR - Delayed Pop test FAILED.\n");
14656f1b8288STimothy McDaniel
14666f1b8288STimothy McDaniel goto test_fail;
14676f1b8288STimothy McDaniel }
14686f1b8288STimothy McDaniel
14696f1b8288STimothy McDaniel return 0;
14706f1b8288STimothy McDaniel
14716f1b8288STimothy McDaniel test_fail:
14726f1b8288STimothy McDaniel return -1;
14736f1b8288STimothy McDaniel }
14746f1b8288STimothy McDaniel
14756f1b8288STimothy McDaniel int
test_dlb2_eventdev(void)14766f1b8288STimothy McDaniel test_dlb2_eventdev(void)
14776f1b8288STimothy McDaniel {
1478*3dd079faSBruce Richardson const char *dlb2_eventdev_name = "event_dlb2";
14796f1b8288STimothy McDaniel uint8_t num_evdevs = rte_event_dev_count();
14806f1b8288STimothy McDaniel int i, ret = 0;
14816f1b8288STimothy McDaniel int found = 0, skipped = 0, passed = 0, failed = 0;
14826f1b8288STimothy McDaniel struct rte_event_dev_info info;
14836f1b8288STimothy McDaniel
14846f1b8288STimothy McDaniel for (i = 0; found + skipped < num_evdevs && i < RTE_EVENT_MAX_DEVS;
14856f1b8288STimothy McDaniel i++) {
14866f1b8288STimothy McDaniel ret = rte_event_dev_info_get(i, &info);
14876f1b8288STimothy McDaniel if (ret < 0)
14886f1b8288STimothy McDaniel continue;
14896f1b8288STimothy McDaniel
14906f1b8288STimothy McDaniel /* skip non-dlb2 event devices */
14916f1b8288STimothy McDaniel if (strncmp(info.driver_name, dlb2_eventdev_name,
1492*3dd079faSBruce Richardson strlen(dlb2_eventdev_name)) != 0) {
14936f1b8288STimothy McDaniel skipped++;
14946f1b8288STimothy McDaniel continue;
14956f1b8288STimothy McDaniel }
14966f1b8288STimothy McDaniel
14976f1b8288STimothy McDaniel evdev = rte_event_dev_get_dev_id(info.driver_name);
14986f1b8288STimothy McDaniel if (evdev < 0) {
14996f1b8288STimothy McDaniel printf("Could not get dev_id for eventdev with name %s, i=%d\n",
15006f1b8288STimothy McDaniel info.driver_name, i);
15016f1b8288STimothy McDaniel skipped++;
15026f1b8288STimothy McDaniel continue;
15036f1b8288STimothy McDaniel }
15046f1b8288STimothy McDaniel found++;
15056f1b8288STimothy McDaniel printf("Running selftest on eventdev %s\n", info.driver_name);
15066f1b8288STimothy McDaniel ret = do_selftest();
15076f1b8288STimothy McDaniel if (ret == 0) {
15086f1b8288STimothy McDaniel passed++;
15096f1b8288STimothy McDaniel printf("Selftest passed for eventdev %s\n",
15106f1b8288STimothy McDaniel info.driver_name);
15116f1b8288STimothy McDaniel } else {
15126f1b8288STimothy McDaniel failed++;
15136f1b8288STimothy McDaniel printf("Selftest failed for eventdev %s, err=%d\n",
15146f1b8288STimothy McDaniel info.driver_name, ret);
15156f1b8288STimothy McDaniel }
15166f1b8288STimothy McDaniel }
15176f1b8288STimothy McDaniel
15186f1b8288STimothy McDaniel printf("Ran selftest on %d eventdevs, %d skipped, %d passed, %d failed\n",
15196f1b8288STimothy McDaniel found, skipped, passed, failed);
15206f1b8288STimothy McDaniel return ret;
15216f1b8288STimothy McDaniel }
1522