1 /* 2 * BSD LICENSE 3 * 4 * Copyright (C) Cavium 2017. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * * Neither the name of Cavium nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #include <stdio.h> 34 #include <unistd.h> 35 36 #include "test_order_common.h" 37 38 /* See http://dpdk.org/doc/guides/tools/testeventdev.html for test details */ 39 40 #define NB_QUEUES 2 41 static int 42 order_queue_eventdev_setup(struct evt_test *test, struct evt_options *opt) 43 { 44 int ret; 45 46 const uint8_t nb_workers = evt_nr_active_lcores(opt->wlcores); 47 /* number of active worker cores + 1 producer */ 48 const uint8_t nb_ports = nb_workers + 1; 49 50 const struct rte_event_dev_config config = { 51 .nb_event_queues = NB_QUEUES,/* q0 ordered, q1 atomic */ 52 .nb_event_ports = nb_ports, 53 .nb_events_limit = 4096, 54 .nb_event_queue_flows = opt->nb_flows, 55 .nb_event_port_dequeue_depth = 128, 56 .nb_event_port_enqueue_depth = 128, 57 }; 58 59 ret = rte_event_dev_configure(opt->dev_id, &config); 60 if (ret) { 61 evt_err("failed to configure eventdev %d", opt->dev_id); 62 return ret; 63 } 64 65 /* q0 (ordered queue) configuration */ 66 struct rte_event_queue_conf q0_ordered_conf = { 67 .priority = RTE_EVENT_DEV_PRIORITY_NORMAL, 68 .event_queue_cfg = RTE_EVENT_QUEUE_CFG_ORDERED_ONLY, 69 .nb_atomic_flows = opt->nb_flows, 70 .nb_atomic_order_sequences = opt->nb_flows, 71 }; 72 ret = rte_event_queue_setup(opt->dev_id, 0, &q0_ordered_conf); 73 if (ret) { 74 evt_err("failed to setup queue0 eventdev %d", opt->dev_id); 75 return ret; 76 } 77 78 /* q1 (atomic queue) configuration */ 79 struct rte_event_queue_conf q1_atomic_conf = { 80 .priority = RTE_EVENT_DEV_PRIORITY_NORMAL, 81 .event_queue_cfg = RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY, 82 .nb_atomic_flows = opt->nb_flows, 83 .nb_atomic_order_sequences = opt->nb_flows, 84 }; 85 ret = rte_event_queue_setup(opt->dev_id, 1, &q1_atomic_conf); 86 if (ret) { 87 evt_err("failed to setup queue1 eventdev %d", opt->dev_id); 88 return ret; 89 } 90 91 /* setup one port per worker, linking to all queues */ 92 ret = order_event_dev_port_setup(test, opt, nb_workers, NB_QUEUES); 93 if (ret) 94 return ret; 95 96 ret = rte_event_dev_start(opt->dev_id); 97 if (ret) { 98 evt_err("failed to start eventdev %d", opt->dev_id); 99 return ret; 100 } 101 102 return 0; 103 } 104 105 static void 106 order_queue_opt_dump(struct evt_options *opt) 107 { 108 order_opt_dump(opt); 109 evt_dump("nb_evdev_queues", "%d", NB_QUEUES); 110 } 111 112 static bool 113 order_queue_capability_check(struct evt_options *opt) 114 { 115 struct rte_event_dev_info dev_info; 116 117 rte_event_dev_info_get(opt->dev_id, &dev_info); 118 if (dev_info.max_event_queues < NB_QUEUES || dev_info.max_event_ports < 119 order_nb_event_ports(opt)) { 120 evt_err("not enough eventdev queues=%d/%d or ports=%d/%d", 121 NB_QUEUES, dev_info.max_event_queues, 122 order_nb_event_ports(opt), dev_info.max_event_ports); 123 return false; 124 } 125 126 return true; 127 } 128 129 static const struct evt_test_ops order_queue = { 130 .cap_check = order_queue_capability_check, 131 .opt_check = order_opt_check, 132 .opt_dump = order_queue_opt_dump, 133 .test_setup = order_test_setup, 134 .mempool_setup = order_mempool_setup, 135 .eventdev_setup = order_queue_eventdev_setup, 136 .eventdev_destroy = order_eventdev_destroy, 137 .mempool_destroy = order_mempool_destroy, 138 .test_result = order_test_result, 139 .test_destroy = order_test_destroy, 140 }; 141 142 EVT_TEST_REGISTER(order_queue); 143