1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation
11 #include <sys/queue.h>
16 #include <rte_common.h>
17 #include <rte_byteorder.h>
19 #include <rte_memory.h>
20 #include <rte_memcpy.h>
22 #include <rte_per_lcore.h>
23 #include <rte_launch.h>
24 #include <rte_atomic.h>
25 #include <rte_cycles.h>
26 #include <rte_prefetch.h>
27 #include <rte_lcore.h>
28 #include <rte_branch_prediction.h>
29 #include <rte_interrupts.h>
31 #include <rte_random.h>
32 #include <rte_debug.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_mempool.h>
41 #include <rte_string_fns.h>
45 struct app_params app;
47 static const char usage[] = "\n";
56 app_parse_port_mask(const char *arg)
65 port_mask = strtoul(arg, &end, 16);
66 if ((end == NULL) || (*end != '\0'))
73 for (i = 0; i < 64; i++) {
74 if ((port_mask & (1LLU << i)) == 0)
77 if (app.n_ports >= APP_MAX_PORTS)
80 app.ports[app.n_ports] = i;
84 if (!rte_is_power_of_2(app.n_ports))
93 } app_args_table[] = {
94 {"none", e_APP_PIPELINE_NONE},
95 {"stub", e_APP_PIPELINE_STUB},
96 {"hash-8-ext", e_APP_PIPELINE_HASH_KEY8_EXT},
97 {"hash-8-lru", e_APP_PIPELINE_HASH_KEY8_LRU},
98 {"hash-16-ext", e_APP_PIPELINE_HASH_KEY16_EXT},
99 {"hash-16-lru", e_APP_PIPELINE_HASH_KEY16_LRU},
100 {"hash-32-ext", e_APP_PIPELINE_HASH_KEY32_EXT},
101 {"hash-32-lru", e_APP_PIPELINE_HASH_KEY32_LRU},
102 {"hash-spec-8-ext", e_APP_PIPELINE_HASH_SPEC_KEY8_EXT},
103 {"hash-spec-8-lru", e_APP_PIPELINE_HASH_SPEC_KEY8_LRU},
104 {"hash-spec-16-ext", e_APP_PIPELINE_HASH_SPEC_KEY16_EXT},
105 {"hash-spec-16-lru", e_APP_PIPELINE_HASH_SPEC_KEY16_LRU},
106 {"hash-spec-32-ext", e_APP_PIPELINE_HASH_SPEC_KEY32_EXT},
107 {"hash-spec-32-lru", e_APP_PIPELINE_HASH_SPEC_KEY32_LRU},
108 {"acl", e_APP_PIPELINE_ACL},
109 {"lpm", e_APP_PIPELINE_LPM},
110 {"lpm-ipv6", e_APP_PIPELINE_LPM_IPV6},
111 {"hash-cuckoo-8", e_APP_PIPELINE_HASH_CUCKOO_KEY8},
112 {"hash-cuckoo-16", e_APP_PIPELINE_HASH_CUCKOO_KEY16},
113 {"hash-cuckoo-32", e_APP_PIPELINE_HASH_CUCKOO_KEY32},
114 {"hash-cuckoo-48", e_APP_PIPELINE_HASH_CUCKOO_KEY48},
115 {"hash-cuckoo-64", e_APP_PIPELINE_HASH_CUCKOO_KEY64},
116 {"hash-cuckoo-80", e_APP_PIPELINE_HASH_CUCKOO_KEY80},
117 {"hash-cuckoo-96", e_APP_PIPELINE_HASH_CUCKOO_KEY96},
118 {"hash-cuckoo-112", e_APP_PIPELINE_HASH_CUCKOO_KEY112},
119 {"hash-cuckoo-128", e_APP_PIPELINE_HASH_CUCKOO_KEY128},
123 app_parse_args(int argc, char **argv)
128 char *prgname = argv[0];
129 static struct option lgopts[] = {
132 {"hash-8-ext", 0, 0, 0},
133 {"hash-8-lru", 0, 0, 0},
134 {"hash-16-ext", 0, 0, 0},
135 {"hash-16-lru", 0, 0, 0},
136 {"hash-32-ext", 0, 0, 0},
137 {"hash-32-lru", 0, 0, 0},
138 {"hash-spec-8-ext", 0, 0, 0},
139 {"hash-spec-8-lru", 0, 0, 0},
140 {"hash-spec-16-ext", 0, 0, 0},
141 {"hash-spec-16-lru", 0, 0, 0},
142 {"hash-spec-32-ext", 0, 0, 0},
143 {"hash-spec-32-lru", 0, 0, 0},
146 {"lpm-ipv6", 0, 0, 0},
147 {"hash-cuckoo-8", 0, 0, 0},
148 {"hash-cuckoo-16", 0, 0, 0},
149 {"hash-cuckoo-32", 0, 0, 0},
150 {"hash-cuckoo-48", 0, 0, 0},
151 {"hash-cuckoo-64", 0, 0, 0},
152 {"hash-cuckoo-80", 0, 0, 0},
153 {"hash-cuckoo-96", 0, 0, 0},
154 {"hash-cuckoo-112", 0, 0, 0},
155 {"hash-cuckoo-128", 0, 0, 0},
158 uint32_t lcores[3], n_lcores, lcore_id, pipeline_type_provided;
162 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
163 if (rte_lcore_is_enabled(lcore_id) == 0)
167 RTE_LOG(ERR, USER1, "Number of cores must be 3\n");
172 lcores[n_lcores] = lcore_id;
177 RTE_LOG(ERR, USER1, "Number of cores must be 3\n");
182 app.core_rx = lcores[0];
183 app.core_worker = lcores[1];
184 app.core_tx = lcores[2];
189 app.pipeline_type = e_APP_PIPELINE_HASH_KEY16_LRU;
190 pipeline_type_provided = 0;
192 while ((opt = getopt_long(argc, argvopt, "p:",
193 lgopts, &option_index)) != EOF) {
196 if (app_parse_port_mask(optarg) < 0) {
202 case 0: /* long options */
203 if (!pipeline_type_provided) {
206 for (i = 0; i < e_APP_PIPELINES; i++) {
207 if (!strcmp(lgopts[option_index].name,
208 app_args_table[i].name)) {
210 app_args_table[i].value;
211 pipeline_type_provided = 1;
228 argv[optind - 1] = prgname;
231 optind = 1; /* reset getopt lib */