4 * Copyright(c) 2010-2016 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.
38 #include <sys/types.h>
40 #include <sys/queue.h>
45 #include <rte_common.h>
46 #include <rte_byteorder.h>
48 #include <rte_memory.h>
49 #include <rte_memcpy.h>
51 #include <rte_per_lcore.h>
52 #include <rte_launch.h>
53 #include <rte_atomic.h>
54 #include <rte_cycles.h>
55 #include <rte_prefetch.h>
56 #include <rte_lcore.h>
57 #include <rte_branch_prediction.h>
58 #include <rte_interrupts.h>
60 #include <rte_random.h>
61 #include <rte_debug.h>
62 #include <rte_ether.h>
63 #include <rte_ethdev.h>
64 #include <rte_mempool.h>
70 #include <rte_string_fns.h>
74 struct app_params app;
76 static const char usage[] = "\n";
85 app_parse_port_mask(const char *arg)
94 port_mask = strtoul(arg, &end, 16);
95 if ((end == NULL) || (*end != '\0'))
102 for (i = 0; i < 64; i++) {
103 if ((port_mask & (1LLU << i)) == 0)
106 if (app.n_ports >= APP_MAX_PORTS)
109 app.ports[app.n_ports] = i;
113 if (!rte_is_power_of_2(app.n_ports))
122 } app_args_table[] = {
123 {"none", e_APP_PIPELINE_NONE},
124 {"stub", e_APP_PIPELINE_STUB},
125 {"hash-8-ext", e_APP_PIPELINE_HASH_KEY8_EXT},
126 {"hash-8-lru", e_APP_PIPELINE_HASH_KEY8_LRU},
127 {"hash-16-ext", e_APP_PIPELINE_HASH_KEY16_EXT},
128 {"hash-16-lru", e_APP_PIPELINE_HASH_KEY16_LRU},
129 {"hash-32-ext", e_APP_PIPELINE_HASH_KEY32_EXT},
130 {"hash-32-lru", e_APP_PIPELINE_HASH_KEY32_LRU},
131 {"hash-spec-8-ext", e_APP_PIPELINE_HASH_SPEC_KEY8_EXT},
132 {"hash-spec-8-lru", e_APP_PIPELINE_HASH_SPEC_KEY8_LRU},
133 {"hash-spec-16-ext", e_APP_PIPELINE_HASH_SPEC_KEY16_EXT},
134 {"hash-spec-16-lru", e_APP_PIPELINE_HASH_SPEC_KEY16_LRU},
135 {"hash-spec-32-ext", e_APP_PIPELINE_HASH_SPEC_KEY32_EXT},
136 {"hash-spec-32-lru", e_APP_PIPELINE_HASH_SPEC_KEY32_LRU},
137 {"acl", e_APP_PIPELINE_ACL},
138 {"lpm", e_APP_PIPELINE_LPM},
139 {"lpm-ipv6", e_APP_PIPELINE_LPM_IPV6},
140 {"hash-cuckoo-8", e_APP_PIPELINE_HASH_CUCKOO_KEY8},
141 {"hash-cuckoo-16", e_APP_PIPELINE_HASH_CUCKOO_KEY16},
142 {"hash-cuckoo-32", e_APP_PIPELINE_HASH_CUCKOO_KEY32},
143 {"hash-cuckoo-48", e_APP_PIPELINE_HASH_CUCKOO_KEY48},
144 {"hash-cuckoo-64", e_APP_PIPELINE_HASH_CUCKOO_KEY64},
145 {"hash-cuckoo-80", e_APP_PIPELINE_HASH_CUCKOO_KEY80},
146 {"hash-cuckoo-96", e_APP_PIPELINE_HASH_CUCKOO_KEY96},
147 {"hash-cuckoo-112", e_APP_PIPELINE_HASH_CUCKOO_KEY112},
148 {"hash-cuckoo-128", e_APP_PIPELINE_HASH_CUCKOO_KEY128},
152 app_parse_args(int argc, char **argv)
157 char *prgname = argv[0];
158 static struct option lgopts[] = {
161 {"hash-8-ext", 0, 0, 0},
162 {"hash-8-lru", 0, 0, 0},
163 {"hash-16-ext", 0, 0, 0},
164 {"hash-16-lru", 0, 0, 0},
165 {"hash-32-ext", 0, 0, 0},
166 {"hash-32-lru", 0, 0, 0},
167 {"hash-spec-8-ext", 0, 0, 0},
168 {"hash-spec-8-lru", 0, 0, 0},
169 {"hash-spec-16-ext", 0, 0, 0},
170 {"hash-spec-16-lru", 0, 0, 0},
171 {"hash-spec-32-ext", 0, 0, 0},
172 {"hash-spec-32-lru", 0, 0, 0},
175 {"lpm-ipv6", 0, 0, 0},
176 {"hash-cuckoo-8", 0, 0, 0},
177 {"hash-cuckoo-16", 0, 0, 0},
178 {"hash-cuckoo-32", 0, 0, 0},
179 {"hash-cuckoo-48", 0, 0, 0},
180 {"hash-cuckoo-64", 0, 0, 0},
181 {"hash-cuckoo-80", 0, 0, 0},
182 {"hash-cuckoo-96", 0, 0, 0},
183 {"hash-cuckoo-112", 0, 0, 0},
184 {"hash-cuckoo-128", 0, 0, 0},
187 uint32_t lcores[3], n_lcores, lcore_id, pipeline_type_provided;
191 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
192 if (rte_lcore_is_enabled(lcore_id) == 0)
196 RTE_LOG(ERR, USER1, "Number of cores must be 3\n");
201 lcores[n_lcores] = lcore_id;
206 RTE_LOG(ERR, USER1, "Number of cores must be 3\n");
211 app.core_rx = lcores[0];
212 app.core_worker = lcores[1];
213 app.core_tx = lcores[2];
218 app.pipeline_type = e_APP_PIPELINE_HASH_KEY16_LRU;
219 pipeline_type_provided = 0;
221 while ((opt = getopt_long(argc, argvopt, "p:",
222 lgopts, &option_index)) != EOF) {
225 if (app_parse_port_mask(optarg) < 0) {
231 case 0: /* long options */
232 if (!pipeline_type_provided) {
235 for (i = 0; i < e_APP_PIPELINES; i++) {
236 if (!strcmp(lgopts[option_index].name,
237 app_args_table[i].name)) {
239 app_args_table[i].value;
240 pipeline_type_provided = 1;
257 argv[optind - 1] = prgname;
260 optind = 1; /* reset getopt lib */