4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 #include <sys/queue.h>
41 #include <rte_memory.h>
42 #include <rte_memzone.h>
43 #include <rte_launch.h>
45 #include <rte_per_lcore.h>
46 #include <rte_lcore.h>
47 #include <rte_debug.h>
48 #include <rte_ethdev.h>
49 #include <rte_cycles.h>
51 #include <rte_eventdev.h>
56 #define NUM_PACKETS (1<<18)
61 struct rte_mempool *mbuf_pool;
62 uint8_t port[MAX_PORTS];
63 uint8_t qid[MAX_QIDS];
68 struct test_event_dev_stats {
69 uint64_t rx_pkts; /**< Total packets received */
70 uint64_t rx_dropped; /**< Total packets dropped (Eg Invalid QID) */
71 uint64_t tx_pkts; /**< Total packets transmitted */
73 /** Packets received on this port */
74 uint64_t port_rx_pkts[MAX_PORTS];
75 /** Packets dropped on this port */
76 uint64_t port_rx_dropped[MAX_PORTS];
77 /** Packets inflight on this port */
78 uint64_t port_inflight[MAX_PORTS];
79 /** Packets transmitted on this port */
80 uint64_t port_tx_pkts[MAX_PORTS];
81 /** Packets received on this qid */
82 uint64_t qid_rx_pkts[MAX_QIDS];
83 /** Packets dropped on this qid */
84 uint64_t qid_rx_dropped[MAX_QIDS];
85 /** Packets transmitted on this qid */
86 uint64_t qid_tx_pkts[MAX_QIDS];
89 static struct rte_mempool *eventdev_func_mempool;
92 test_sw_eventdev(void)
94 struct test *t = malloc(sizeof(struct test));
96 const char *eventdev_name = "event_sw0";
97 evdev = rte_event_dev_get_dev_id(eventdev_name);
99 printf("%d: Eventdev %s not found - creating.\n",
100 __LINE__, eventdev_name);
101 if (rte_eal_vdev_init(eventdev_name, NULL) < 0) {
102 printf("Error creating eventdev\n");
105 evdev = rte_event_dev_get_dev_id(eventdev_name);
107 printf("Error finding newly created eventdev\n");
112 /* Only create mbuf pool once, reuse for each test run */
113 if (!eventdev_func_mempool) {
114 eventdev_func_mempool = rte_pktmbuf_pool_create(
115 "EVENTDEV_SW_SA_MBUF_POOL",
116 (1<<12), /* 4k buffers */
117 32 /*MBUF_CACHE_SIZE*/,
119 512, /* use very small mbufs */
121 if (!eventdev_func_mempool) {
122 printf("ERROR creating mempool\n");
126 t->mbuf_pool = eventdev_func_mempool;
129 * Free test instance, leaving mempool initialized, and a pointer to it
130 * in static eventdev_func_mempool, as it is re-used on re-runs
137 REGISTER_TEST_COMMAND(eventdev_sw_autotest, test_sw_eventdev);