4 * Copyright(c) 2010-2012 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.
45 #include <net/socket.h>
47 #include <netinet/in.h>
49 #include <sys/queue.h>
51 #include <rte_common.h>
52 #include <rte_byteorder.h>
54 #include <rte_debug.h>
55 #include <rte_cycles.h>
56 #include <rte_memory.h>
57 #include <rte_memzone.h>
58 #include <rte_launch.h>
59 #include <rte_tailq.h>
61 #include <rte_per_lcore.h>
62 #include <rte_lcore.h>
63 #include <rte_atomic.h>
64 #include <rte_branch_prediction.h>
66 #include <rte_mempool.h>
67 #include <rte_interrupts.h>
69 #include <rte_ether.h>
70 #include <rte_ethdev.h>
71 #include <rte_string_fns.h>
73 #include <cmdline_rdline.h>
74 #include <cmdline_parse.h>
75 #include <cmdline_parse_num.h>
76 #include <cmdline_parse_string.h>
77 #include <cmdline_parse_ipaddr.h>
78 #include <cmdline_parse_etheraddr.h>
79 #include <cmdline_socket.h>
84 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
87 struct cmd_help_result {
88 cmdline_fixed_string_t help;
91 static void cmd_help_parsed(__attribute__((unused)) void *parsed_result,
93 __attribute__((unused)) void *data)
100 "This commandline can be used to configure forwarding\n"
103 "Display informations:\n"
104 "---------------------\n"
105 "- show port info|stats|fdir|stat_qmap X|all\n"
106 " Diplays information or stats or stats queue mapping on port X, or all\n"
107 "- clear port stats X|all\n"
108 " Clear stats for port X, or all\n"
109 "- show config rxtx|cores|fwd\n"
110 " Displays the given configuration\n"
111 "- read reg port_id reg_off\n"
112 " Displays value of a port register\n"
113 "- read regfield port_id reg_off bit_x bit_y\n"
114 " Displays value of a port register bit field\n"
115 "- read regbit port_id reg_off bit_x\n"
116 " Displays value of a port register bit\n"
117 "- read rxd port_id queue_id rxd_id\n"
118 " Displays a RX descriptor of a port RX queue\n"
119 "- read txd port_id queue_id txd_id\n"
120 " Displays a TX descriptor of a port TX queue\n"
125 "Modifications are taken into account once "
126 "forwarding is restarted.\n"
128 " Set forwarding to default configuration\n"
129 "- set nbport|nbcore|burst|verbose X\n"
130 " Set number of ports, number of cores, number "
131 "of packets per burst,\n or verbose level to X\n"
132 "- set txpkts x[,y]*\n"
133 " Set the length of each segment of TXONLY packets\n"
134 "- set coremask|portmask X\n"
135 " Set the hexadecimal mask of forwarding cores / "
137 "- set corelist|portlist x[,y]*\n"
138 " Set the list of forwarding cores / forwarding "
140 "- vlan set strip|filter|qinq on/off port_id\n"
141 " Set the VLAN strip, filter, QinQ(extended) on a port"
142 "- rx_vlan add/rm vlan_id|all port_id\n"
143 " Set the VLAN filter table, add/remove vlan_id, or all "
144 "identifiers, to/from the set of VLAN Identifiers\n"
145 "filtered by port_id\n"
146 "- rx_vlan set tpid value port_id\n"
147 " Set Outer VLAN TPID for Packet Filtering on a port \n"
148 "- tx_vlan set vlan_id port_id\n"
149 " Set hardware insertion of VLAN ID in packets sent on a port\n"
150 "- tx_vlan reset port_id\n"
151 " Disable hardware insertion of a VLAN header in "
152 "packets sent on port_id\n"
153 "- tx_checksum set mask port_id\n"
154 " Enable hardware insertion of checksum offload with "
155 "the 4-bit mask (0~0xf)\n in packets sent on port_id\n"
156 " Please check the NIC datasheet for HW limits\n"
157 " bit 0 - insert ip checksum offload if set \n"
158 " bit 1 - insert udp checksum offload if set \n"
159 " bit 2 - insert tcp checksum offload if set\n"
160 " bit 3 - insert sctp checksum offload if set\n"
161 #ifdef RTE_LIBRTE_IEEE1588
162 "- set fwd io|mac|rxonly|txonly|csum|ieee1588\n"
163 " Set IO, MAC, RXONLY, TXONLY, CSUM or IEEE1588 "
164 "packet forwarding mode\n"
166 "- set fwd io|mac|rxonly|txonly|csum\n"
167 " Set IO, MAC, RXONLY, CSUM or TXONLY packet "
170 "- mac_addr add|remove X <xx:xx:xx:xx:xx:xx>\n"
171 " Add/Remove the MAC address <xx:xx:xx:xx:xx:xx> on port X\n"
172 "- set promisc|allmulti [all|X] on|off\n"
173 " Set/unset promisc|allmulti mode on port X, or all\n"
174 "- set flow_ctrl rx on|off tx on|off high_water low_water "
175 "pause_time send_xon port_id \n"
176 " Set the link flow control parameter on the port \n"
177 "- set pfc_ctrl rx on|off tx on|off high_water low_water "
178 "pause_time priority port_id \n"
179 " Set the priority flow control parameter on the port \n"
180 "- write reg port_id reg_off value\n"
181 " Set value of a port register\n"
182 "- write regfield port_id reg_off bit_x bit_y value\n"
183 " Set bit field value of a port register\n"
184 "- write regbit port_id reg_off bit_x value\n"
185 " Set bit value of a port register\n"
186 "- set stat_qmap tx|rx port_id queue_id qmapping\n"
187 " Set statistics mapping (qmapping 0..15) for tx|rx queue_id on port_id\n"
188 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2 on port 0 to mapping 5\n"
191 "Control forwarding:\n"
192 "-------------------\n"
194 " Start packet forwarding with current config\n"
196 " Start packet forwarding with current config"
197 " after sending one burst\n of packets\n"
199 " Stop packet forwarding, and displays accumulated"
203 "Flow director mode:\n"
204 "-------------------\n"
205 "- add_signature_filter port_id ip|udp|tcp|sctp src\n"
206 " ip_src_address port_src dst ip_dst_address port_dst\n"
207 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
208 "- upd_signature_filter port_id ip|udp|tcp|sctp src \n"
209 " ip_src_address port_src dst ip_dst_address port_dst\n"
210 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
211 "- rm_signature_filter port_id ip|udp|tcp|sctp src\n"
212 " ip_src_address port_src dst ip_dst_address port_dst\n"
213 " flexbytes flexbytes_values vlan vlan_id\n"
214 "- add_perfect_filter port_id ip|udp|tcp|sctp src\n"
215 " ip_src_address port_src dst ip_dst_address port_dst\n"
216 " flexbytes flexbytes_values vlan vlan_id queue \n"
217 " queue_id soft soft_id\n"
218 "- upd_perfect_filter port_id ip|udp|tcp|sctp src\n"
219 " ip_src_address port_src dst ip_dst_address port_dst\n"
220 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
221 "- rm_perfect_filter port_id ip|udp|tcp|sctp src\n"
222 " ip_src_address port_src dst ip_dst_address port_dst\n"
223 " flexbytes flexbytes_values vlan vlan_id soft soft_id\n"
224 "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
225 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
226 " port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
227 "- set_ipv6_masks_filter port_id only_ip_flow 0|1 src_mask\n"
228 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
229 " port_dst_mask flexbytes 0|1 vlan_id 0|1\n"
230 " vlan_prio 0|1 compare_dst 0|1\n"
235 "- port start|stop|close all|X\n"
236 " start/stop/close all ports or port X\n"
237 "- port config all|X speed 10|100|1000|10000|auto "
238 "duplex half|full|auto\n"
239 " set speed for all ports or port X\n"
240 "- port config all rxq|txq|rxd|txd value\n"
241 " set number for rxq/txq/rxd/txd\n"
242 "- port config all max-pkt-len value\n"
243 " set the max packet lenght\n"
244 "- port config all crc-strip|rx-cksum|hw-vlan|drop-en on|off\n"
245 " set crc-strip/rx-checksum/hardware-vlan/drop_en on or off"
247 "- port config all rss ip|udp|none\n"
249 "- port config port-id dcb vt on|off nb-tcs pfc on|off\n"
251 "- port config all burst value\n"
252 " set the number of packet per burst\n"
253 "- port config all txpt|txht|txwt|rxpt|rxht|rxwt value\n"
254 " set ring prefetch/host/writeback threshold for "
256 "- port config all txfreet|txrst|rxfreet value\n"
257 " set free threshold for rx/tx, or set tx rs bit "
264 " Quit to prompt in linux, and reboot on baremetal\n"
268 cmdline_parse_token_string_t cmd_help_help =
269 TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
271 cmdline_parse_inst_t cmd_help = {
272 .f = cmd_help_parsed,
274 .help_str = "show help",
276 (void *)&cmd_help_help,
281 /* *** start/stop/close all ports *** */
282 struct cmd_operate_port_result {
283 cmdline_fixed_string_t keyword;
284 cmdline_fixed_string_t name;
285 cmdline_fixed_string_t value;
288 static void cmd_operate_port_parsed(void *parsed_result,
289 __attribute__((unused)) struct cmdline *cl,
290 __attribute__((unused)) void *data)
292 struct cmd_operate_port_result *res = parsed_result;
294 if (!strcmp(res->name, "start"))
295 start_port(RTE_PORT_ALL);
296 else if (!strcmp(res->name, "stop"))
297 stop_port(RTE_PORT_ALL);
298 else if (!strcmp(res->name, "close"))
299 close_port(RTE_PORT_ALL);
301 printf("Unknown parameter\n");
304 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
305 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
307 cmdline_parse_token_string_t cmd_operate_port_all_port =
308 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
310 cmdline_parse_token_string_t cmd_operate_port_all_all =
311 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
313 cmdline_parse_inst_t cmd_operate_port = {
314 .f = cmd_operate_port_parsed,
316 .help_str = "port start|stop|close all: start/stop/close all ports",
318 (void *)&cmd_operate_port_all_cmd,
319 (void *)&cmd_operate_port_all_port,
320 (void *)&cmd_operate_port_all_all,
325 /* *** start/stop/close specific port *** */
326 struct cmd_operate_specific_port_result {
327 cmdline_fixed_string_t keyword;
328 cmdline_fixed_string_t name;
332 static void cmd_operate_specific_port_parsed(void *parsed_result,
333 __attribute__((unused)) struct cmdline *cl,
334 __attribute__((unused)) void *data)
336 struct cmd_operate_specific_port_result *res = parsed_result;
338 if (!strcmp(res->name, "start"))
339 start_port(res->value);
340 else if (!strcmp(res->name, "stop"))
341 stop_port(res->value);
342 else if (!strcmp(res->name, "close"))
343 close_port(res->value);
345 printf("Unknown parameter\n");
348 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
349 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
351 cmdline_parse_token_string_t cmd_operate_specific_port_port =
352 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
353 name, "start#stop#close");
354 cmdline_parse_token_num_t cmd_operate_specific_port_id =
355 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
358 cmdline_parse_inst_t cmd_operate_specific_port = {
359 .f = cmd_operate_specific_port_parsed,
361 .help_str = "port start|stop|close X: start/stop/close port X",
363 (void *)&cmd_operate_specific_port_cmd,
364 (void *)&cmd_operate_specific_port_port,
365 (void *)&cmd_operate_specific_port_id,
370 /* *** configure speed for all ports *** */
371 struct cmd_config_speed_all {
372 cmdline_fixed_string_t port;
373 cmdline_fixed_string_t keyword;
374 cmdline_fixed_string_t all;
375 cmdline_fixed_string_t item1;
376 cmdline_fixed_string_t item2;
377 cmdline_fixed_string_t value1;
378 cmdline_fixed_string_t value2;
382 cmd_config_speed_all_parsed(void *parsed_result,
383 __attribute__((unused)) struct cmdline *cl,
384 __attribute__((unused)) void *data)
386 struct cmd_config_speed_all *res = parsed_result;
387 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
388 uint16_t link_duplex = 0;
391 if (!all_ports_stopped()) {
392 printf("Please stop all ports first\n");
396 if (!strcmp(res->value1, "10"))
397 link_speed = ETH_LINK_SPEED_10;
398 else if (!strcmp(res->value1, "100"))
399 link_speed = ETH_LINK_SPEED_100;
400 else if (!strcmp(res->value1, "1000"))
401 link_speed = ETH_LINK_SPEED_1000;
402 else if (!strcmp(res->value1, "10000"))
403 link_speed = ETH_LINK_SPEED_10000;
404 else if (!strcmp(res->value1, "auto"))
405 link_speed = ETH_LINK_SPEED_AUTONEG;
407 printf("Unknown parameter\n");
411 if (!strcmp(res->value2, "half"))
412 link_duplex = ETH_LINK_HALF_DUPLEX;
413 else if (!strcmp(res->value2, "full"))
414 link_duplex = ETH_LINK_FULL_DUPLEX;
415 else if (!strcmp(res->value2, "auto"))
416 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
418 printf("Unknown parameter\n");
422 for (pid = 0; pid < nb_ports; pid++) {
423 ports[pid].dev_conf.link_speed = link_speed;
424 ports[pid].dev_conf.link_duplex = link_duplex;
427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
430 cmdline_parse_token_string_t cmd_config_speed_all_port =
431 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
432 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
435 cmdline_parse_token_string_t cmd_config_speed_all_all =
436 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
437 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
438 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
439 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
440 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
441 "10#100#1000#10000#auto");
442 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
443 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
444 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
445 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
448 cmdline_parse_inst_t cmd_config_speed_all = {
449 .f = cmd_config_speed_all_parsed,
451 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
454 (void *)&cmd_config_speed_all_port,
455 (void *)&cmd_config_speed_all_keyword,
456 (void *)&cmd_config_speed_all_all,
457 (void *)&cmd_config_speed_all_item1,
458 (void *)&cmd_config_speed_all_value1,
459 (void *)&cmd_config_speed_all_item2,
460 (void *)&cmd_config_speed_all_value2,
465 /* *** configure speed for specific port *** */
466 struct cmd_config_speed_specific {
467 cmdline_fixed_string_t port;
468 cmdline_fixed_string_t keyword;
470 cmdline_fixed_string_t item1;
471 cmdline_fixed_string_t item2;
472 cmdline_fixed_string_t value1;
473 cmdline_fixed_string_t value2;
477 cmd_config_speed_specific_parsed(void *parsed_result,
478 __attribute__((unused)) struct cmdline *cl,
479 __attribute__((unused)) void *data)
481 struct cmd_config_speed_specific *res = parsed_result;
482 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
483 uint16_t link_duplex = 0;
485 if (!all_ports_stopped()) {
486 printf("Please stop all ports first\n");
490 if (res->id >= nb_ports) {
491 printf("Port id %d must be less than %d\n", res->id, nb_ports);
495 if (!strcmp(res->value1, "10"))
496 link_speed = ETH_LINK_SPEED_10;
497 else if (!strcmp(res->value1, "100"))
498 link_speed = ETH_LINK_SPEED_100;
499 else if (!strcmp(res->value1, "1000"))
500 link_speed = ETH_LINK_SPEED_1000;
501 else if (!strcmp(res->value1, "10000"))
502 link_speed = ETH_LINK_SPEED_10000;
503 else if (!strcmp(res->value1, "auto"))
504 link_speed = ETH_LINK_SPEED_AUTONEG;
506 printf("Unknown parameter\n");
510 if (!strcmp(res->value2, "half"))
511 link_duplex = ETH_LINK_HALF_DUPLEX;
512 else if (!strcmp(res->value2, "full"))
513 link_duplex = ETH_LINK_FULL_DUPLEX;
514 else if (!strcmp(res->value2, "auto"))
515 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
517 printf("Unknown parameter\n");
521 ports[res->id].dev_conf.link_speed = link_speed;
522 ports[res->id].dev_conf.link_duplex = link_duplex;
524 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
528 cmdline_parse_token_string_t cmd_config_speed_specific_port =
529 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
531 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
532 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
534 cmdline_parse_token_num_t cmd_config_speed_specific_id =
535 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
536 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
537 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
539 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
540 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
541 "10#100#1000#10000#auto");
542 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
543 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
545 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
546 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
549 cmdline_parse_inst_t cmd_config_speed_specific = {
550 .f = cmd_config_speed_specific_parsed,
552 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
555 (void *)&cmd_config_speed_specific_port,
556 (void *)&cmd_config_speed_specific_keyword,
557 (void *)&cmd_config_speed_specific_id,
558 (void *)&cmd_config_speed_specific_item1,
559 (void *)&cmd_config_speed_specific_value1,
560 (void *)&cmd_config_speed_specific_item2,
561 (void *)&cmd_config_speed_specific_value2,
566 /* *** configure txq/rxq, txd/rxd *** */
567 struct cmd_config_rx_tx {
568 cmdline_fixed_string_t port;
569 cmdline_fixed_string_t keyword;
570 cmdline_fixed_string_t all;
571 cmdline_fixed_string_t name;
576 cmd_config_rx_tx_parsed(void *parsed_result,
577 __attribute__((unused)) struct cmdline *cl,
578 __attribute__((unused)) void *data)
580 struct cmd_config_rx_tx *res = parsed_result;
582 if (!all_ports_stopped()) {
583 printf("Please stop all ports first\n");
587 if (!strcmp(res->name, "rxq")) {
588 if (res->value <= 0) {
589 printf("rxq %d invalid - must be > 0\n", res->value);
594 else if (!strcmp(res->name, "txq")) {
595 if (res->value <= 0) {
596 printf("txq %d invalid - must be > 0\n", res->value);
601 else if (!strcmp(res->name, "rxd")) {
602 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
603 printf("rxd %d invalid - must be > 0 && <= %d\n",
604 res->value, RTE_TEST_RX_DESC_MAX);
608 } else if (!strcmp(res->name, "txd")) {
609 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
610 printf("txd %d invalid - must be > 0 && <= %d\n",
611 res->value, RTE_TEST_TX_DESC_MAX);
616 printf("Unknown parameter\n");
622 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
625 cmdline_parse_token_string_t cmd_config_rx_tx_port =
626 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
627 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
628 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
629 cmdline_parse_token_string_t cmd_config_rx_tx_all =
630 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
631 cmdline_parse_token_string_t cmd_config_rx_tx_name =
632 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
634 cmdline_parse_token_num_t cmd_config_rx_tx_value =
635 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
637 cmdline_parse_inst_t cmd_config_rx_tx = {
638 .f = cmd_config_rx_tx_parsed,
640 .help_str = "port config all rxq|txq|rxd|txd value",
642 (void *)&cmd_config_rx_tx_port,
643 (void *)&cmd_config_rx_tx_keyword,
644 (void *)&cmd_config_rx_tx_all,
645 (void *)&cmd_config_rx_tx_name,
646 (void *)&cmd_config_rx_tx_value,
651 /* *** config max packet length *** */
652 struct cmd_config_max_pkt_len_result {
653 cmdline_fixed_string_t port;
654 cmdline_fixed_string_t keyword;
655 cmdline_fixed_string_t all;
656 cmdline_fixed_string_t name;
661 cmd_config_max_pkt_len_parsed(void *parsed_result,
662 __attribute__((unused)) struct cmdline *cl,
663 __attribute__((unused)) void *data)
665 struct cmd_config_max_pkt_len_result *res = parsed_result;
667 if (!all_ports_stopped()) {
668 printf("Please stop all ports first\n");
672 if (!strcmp(res->name, "max-pkt-len")) {
673 if (res->value < ETHER_MIN_LEN) {
674 printf("max-pkt-len can not be less than %d\n",
678 if (res->value == rx_mode.max_rx_pkt_len)
681 rx_mode.max_rx_pkt_len = res->value;
682 if (res->value > ETHER_MAX_LEN)
683 rx_mode.jumbo_frame = 1;
685 rx_mode.jumbo_frame = 0;
687 printf("Unknown parameter\n");
693 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
696 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
697 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
699 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
700 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
702 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
703 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
705 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
706 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
708 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
709 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
712 cmdline_parse_inst_t cmd_config_max_pkt_len = {
713 .f = cmd_config_max_pkt_len_parsed,
715 .help_str = "port config all max-pkt-len value",
717 (void *)&cmd_config_max_pkt_len_port,
718 (void *)&cmd_config_max_pkt_len_keyword,
719 (void *)&cmd_config_max_pkt_len_all,
720 (void *)&cmd_config_max_pkt_len_name,
721 (void *)&cmd_config_max_pkt_len_value,
726 /* *** configure rx mode *** */
727 struct cmd_config_rx_mode_flag {
728 cmdline_fixed_string_t port;
729 cmdline_fixed_string_t keyword;
730 cmdline_fixed_string_t all;
731 cmdline_fixed_string_t name;
732 cmdline_fixed_string_t value;
736 cmd_config_rx_mode_flag_parsed(void *parsed_result,
737 __attribute__((unused)) struct cmdline *cl,
738 __attribute__((unused)) void *data)
740 struct cmd_config_rx_mode_flag *res = parsed_result;
742 if (!all_ports_stopped()) {
743 printf("Please stop all ports first\n");
747 if (!strcmp(res->name, "crc-strip")) {
748 if (!strcmp(res->value, "on"))
749 rx_mode.hw_strip_crc = 1;
750 else if (!strcmp(res->value, "off"))
751 rx_mode.hw_strip_crc = 0;
753 printf("Unknown parameter\n");
756 } else if (!strcmp(res->name, "rx-cksum")) {
757 if (!strcmp(res->value, "on"))
758 rx_mode.hw_ip_checksum = 1;
759 else if (!strcmp(res->value, "off"))
760 rx_mode.hw_ip_checksum = 0;
762 printf("Unknown parameter\n");
765 } else if (!strcmp(res->name, "hw-vlan")) {
766 if (!strcmp(res->value, "on")) {
767 rx_mode.hw_vlan_filter = 1;
768 rx_mode.hw_vlan_strip = 1;
770 else if (!strcmp(res->value, "off")) {
771 rx_mode.hw_vlan_filter = 0;
772 rx_mode.hw_vlan_strip = 0;
775 printf("Unknown parameter\n");
778 } else if (!strcmp(res->name, "drop-en")) {
779 if (!strcmp(res->value, "on"))
781 else if (!strcmp(res->value, "off"))
784 printf("Unknown parameter\n");
788 printf("Unknown parameter\n");
794 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
797 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
798 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
799 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
800 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
802 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
803 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
804 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
805 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
806 "crc-strip#rx-cksum#hw-vlan");
807 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
808 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
811 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
812 .f = cmd_config_rx_mode_flag_parsed,
814 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
816 (void *)&cmd_config_rx_mode_flag_port,
817 (void *)&cmd_config_rx_mode_flag_keyword,
818 (void *)&cmd_config_rx_mode_flag_all,
819 (void *)&cmd_config_rx_mode_flag_name,
820 (void *)&cmd_config_rx_mode_flag_value,
825 /* *** configure rss *** */
826 struct cmd_config_rss {
827 cmdline_fixed_string_t port;
828 cmdline_fixed_string_t keyword;
829 cmdline_fixed_string_t all;
830 cmdline_fixed_string_t name;
831 cmdline_fixed_string_t value;
835 cmd_config_rss_parsed(void *parsed_result,
836 __attribute__((unused)) struct cmdline *cl,
837 __attribute__((unused)) void *data)
839 struct cmd_config_rss *res = parsed_result;
841 if (!all_ports_stopped()) {
842 printf("Please stop all ports first\n");
846 if (!strcmp(res->value, "ip"))
847 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
848 else if (!strcmp(res->value, "udp"))
849 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
850 else if (!strcmp(res->value, "none"))
853 printf("Unknown parameter\n");
859 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
862 cmdline_parse_token_string_t cmd_config_rss_port =
863 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
864 cmdline_parse_token_string_t cmd_config_rss_keyword =
865 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
866 cmdline_parse_token_string_t cmd_config_rss_all =
867 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
868 cmdline_parse_token_string_t cmd_config_rss_name =
869 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
870 cmdline_parse_token_string_t cmd_config_rss_value =
871 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
873 cmdline_parse_inst_t cmd_config_rss = {
874 .f = cmd_config_rss_parsed,
876 .help_str = "port config all rss ip|udp|none",
878 (void *)&cmd_config_rss_port,
879 (void *)&cmd_config_rss_keyword,
880 (void *)&cmd_config_rss_all,
881 (void *)&cmd_config_rss_name,
882 (void *)&cmd_config_rss_value,
887 /* *** Configure DCB *** */
888 struct cmd_config_dcb {
889 cmdline_fixed_string_t port;
890 cmdline_fixed_string_t config;
892 cmdline_fixed_string_t dcb;
893 cmdline_fixed_string_t vt;
894 cmdline_fixed_string_t vt_en;
896 cmdline_fixed_string_t pfc;
897 cmdline_fixed_string_t pfc_en;
901 cmd_config_dcb_parsed(void *parsed_result,
902 __attribute__((unused)) struct cmdline *cl,
903 __attribute__((unused)) void *data)
905 struct cmd_config_dcb *res = parsed_result;
906 struct dcb_config dcb_conf;
907 portid_t port_id = res->port_id;
908 struct rte_port *port;
910 port = &ports[port_id];
911 /** Check if the port is not started **/
912 if (port->port_status != RTE_PORT_STOPPED) {
913 printf("Please stop port %d first\n",port_id);
917 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
918 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
919 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
924 if (!strncmp(res->vt_en, "on",2))
925 dcb_conf.dcb_mode = DCB_VT_ENABLED;
927 dcb_conf.dcb_mode = DCB_ENABLED;
929 if (!strncmp(res->pfc_en, "on",2)) {
935 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
936 printf("Cannot initialize network ports\n");
940 cmd_reconfig_device_queue(port_id, 1, 1);
943 cmdline_parse_token_string_t cmd_config_dcb_port =
944 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
945 cmdline_parse_token_string_t cmd_config_dcb_config =
946 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
947 cmdline_parse_token_num_t cmd_config_dcb_port_id =
948 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
949 cmdline_parse_token_string_t cmd_config_dcb_dcb =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
951 cmdline_parse_token_string_t cmd_config_dcb_vt =
952 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
953 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
954 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
955 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
956 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
957 cmdline_parse_token_string_t cmd_config_dcb_pfc=
958 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
959 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
960 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
962 cmdline_parse_inst_t cmd_config_dcb = {
963 .f = cmd_config_dcb_parsed,
965 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
967 (void *)&cmd_config_dcb_port,
968 (void *)&cmd_config_dcb_config,
969 (void *)&cmd_config_dcb_port_id,
970 (void *)&cmd_config_dcb_dcb,
971 (void *)&cmd_config_dcb_vt,
972 (void *)&cmd_config_dcb_vt_en,
973 (void *)&cmd_config_dcb_num_tcs,
974 (void *)&cmd_config_dcb_pfc,
975 (void *)&cmd_config_dcb_pfc_en,
980 /* *** configure number of packets per burst *** */
981 struct cmd_config_burst {
982 cmdline_fixed_string_t port;
983 cmdline_fixed_string_t keyword;
984 cmdline_fixed_string_t all;
985 cmdline_fixed_string_t name;
990 cmd_config_burst_parsed(void *parsed_result,
991 __attribute__((unused)) struct cmdline *cl,
992 __attribute__((unused)) void *data)
994 struct cmd_config_burst *res = parsed_result;
996 if (!all_ports_stopped()) {
997 printf("Please stop all ports first\n");
1001 if (!strcmp(res->name, "burst")) {
1002 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1003 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1006 nb_pkt_per_burst = res->value;
1008 printf("Unknown parameter\n");
1014 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1017 cmdline_parse_token_string_t cmd_config_burst_port =
1018 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1019 cmdline_parse_token_string_t cmd_config_burst_keyword =
1020 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1021 cmdline_parse_token_string_t cmd_config_burst_all =
1022 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1023 cmdline_parse_token_string_t cmd_config_burst_name =
1024 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1025 cmdline_parse_token_num_t cmd_config_burst_value =
1026 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1028 cmdline_parse_inst_t cmd_config_burst = {
1029 .f = cmd_config_burst_parsed,
1031 .help_str = "port config all burst value",
1033 (void *)&cmd_config_burst_port,
1034 (void *)&cmd_config_burst_keyword,
1035 (void *)&cmd_config_burst_all,
1036 (void *)&cmd_config_burst_name,
1037 (void *)&cmd_config_burst_value,
1042 /* *** configure rx/tx queues *** */
1043 struct cmd_config_thresh {
1044 cmdline_fixed_string_t port;
1045 cmdline_fixed_string_t keyword;
1046 cmdline_fixed_string_t all;
1047 cmdline_fixed_string_t name;
1052 cmd_config_thresh_parsed(void *parsed_result,
1053 __attribute__((unused)) struct cmdline *cl,
1054 __attribute__((unused)) void *data)
1056 struct cmd_config_thresh *res = parsed_result;
1058 if (!all_ports_stopped()) {
1059 printf("Please stop all ports first\n");
1063 if (!strcmp(res->name, "txpt"))
1064 tx_thresh.pthresh = res->value;
1065 else if(!strcmp(res->name, "txht"))
1066 tx_thresh.hthresh = res->value;
1067 else if(!strcmp(res->name, "txwt"))
1068 tx_thresh.wthresh = res->value;
1069 else if(!strcmp(res->name, "rxpt"))
1070 rx_thresh.pthresh = res->value;
1071 else if(!strcmp(res->name, "rxht"))
1072 rx_thresh.hthresh = res->value;
1073 else if(!strcmp(res->name, "rxwt"))
1074 rx_thresh.wthresh = res->value;
1076 printf("Unknown parameter\n");
1082 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1085 cmdline_parse_token_string_t cmd_config_thresh_port =
1086 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1087 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1088 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1089 cmdline_parse_token_string_t cmd_config_thresh_all =
1090 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1091 cmdline_parse_token_string_t cmd_config_thresh_name =
1092 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1093 "txpt#txht#txwt#rxpt#rxht#rxwt");
1094 cmdline_parse_token_num_t cmd_config_thresh_value =
1095 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1097 cmdline_parse_inst_t cmd_config_thresh = {
1098 .f = cmd_config_thresh_parsed,
1100 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1102 (void *)&cmd_config_thresh_port,
1103 (void *)&cmd_config_thresh_keyword,
1104 (void *)&cmd_config_thresh_all,
1105 (void *)&cmd_config_thresh_name,
1106 (void *)&cmd_config_thresh_value,
1111 /* *** configure free/rs threshold *** */
1112 struct cmd_config_threshold {
1113 cmdline_fixed_string_t port;
1114 cmdline_fixed_string_t keyword;
1115 cmdline_fixed_string_t all;
1116 cmdline_fixed_string_t name;
1121 cmd_config_threshold_parsed(void *parsed_result,
1122 __attribute__((unused)) struct cmdline *cl,
1123 __attribute__((unused)) void *data)
1125 struct cmd_config_threshold *res = parsed_result;
1127 if (!all_ports_stopped()) {
1128 printf("Please stop all ports first\n");
1132 if (!strcmp(res->name, "txfreet"))
1133 tx_free_thresh = res->value;
1134 else if (!strcmp(res->name, "txrst"))
1135 tx_rs_thresh = res->value;
1136 else if (!strcmp(res->name, "rxfreet"))
1137 rx_free_thresh = res->value;
1139 printf("Unknown parameter\n");
1145 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1148 cmdline_parse_token_string_t cmd_config_threshold_port =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1150 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1153 cmdline_parse_token_string_t cmd_config_threshold_all =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1155 cmdline_parse_token_string_t cmd_config_threshold_name =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1157 "txfreet#txrst#rxfreet");
1158 cmdline_parse_token_num_t cmd_config_threshold_value =
1159 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1161 cmdline_parse_inst_t cmd_config_threshold = {
1162 .f = cmd_config_threshold_parsed,
1164 .help_str = "port config all txfreet|txrst|rxfreet value",
1166 (void *)&cmd_config_threshold_port,
1167 (void *)&cmd_config_threshold_keyword,
1168 (void *)&cmd_config_threshold_all,
1169 (void *)&cmd_config_threshold_name,
1170 (void *)&cmd_config_threshold_value,
1176 struct cmd_stop_result {
1177 cmdline_fixed_string_t stop;
1180 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1181 __attribute__((unused)) struct cmdline *cl,
1182 __attribute__((unused)) void *data)
1184 stop_packet_forwarding();
1187 cmdline_parse_token_string_t cmd_stop_stop =
1188 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1190 cmdline_parse_inst_t cmd_stop = {
1191 .f = cmd_stop_parsed,
1193 .help_str = "stop - stop packet forwarding",
1195 (void *)&cmd_stop_stop,
1200 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1203 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1204 unsigned int *parsed_items, int check_unique_values)
1206 unsigned int nb_item;
1214 * First parse all items in the list and store their value.
1219 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1221 if ((c >= '0') && (c <= '9')) {
1222 value = (unsigned int) (value * 10 + (c - '0'));
1227 printf("character %c is not a decimal digit\n", c);
1231 printf("No valid value before comma\n");
1234 if (nb_item < max_items) {
1235 parsed_items[nb_item] = value;
1241 if (nb_item >= max_items) {
1242 printf("Number of %s = %u > %u (maximum items)\n",
1243 item_name, nb_item + 1, max_items);
1246 parsed_items[nb_item++] = value;
1247 if (! check_unique_values)
1251 * Then, check that all values in the list are differents.
1252 * No optimization here...
1254 for (i = 0; i < nb_item; i++) {
1255 for (j = i + 1; j < nb_item; j++) {
1256 if (parsed_items[j] == parsed_items[i]) {
1257 printf("duplicated %s %u at index %u and %u\n",
1258 item_name, parsed_items[i], i, j);
1266 struct cmd_set_list_result {
1267 cmdline_fixed_string_t cmd_keyword;
1268 cmdline_fixed_string_t list_name;
1269 cmdline_fixed_string_t list_of_items;
1272 static void cmd_set_list_parsed(void *parsed_result,
1273 __attribute__((unused)) struct cmdline *cl,
1274 __attribute__((unused)) void *data)
1276 struct cmd_set_list_result *res;
1278 unsigned int lcorelist[RTE_MAX_LCORE];
1279 unsigned int portlist[RTE_MAX_ETHPORTS];
1281 unsigned int nb_item;
1283 res = parsed_result;
1284 if (!strcmp(res->list_name, "corelist")) {
1285 nb_item = parse_item_list(res->list_of_items, "core",
1287 parsed_items.lcorelist, 1);
1289 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1292 if (!strcmp(res->list_name, "portlist")) {
1293 nb_item = parse_item_list(res->list_of_items, "port",
1295 parsed_items.portlist, 1);
1297 set_fwd_ports_list(parsed_items.portlist, nb_item);
1301 cmdline_parse_token_string_t cmd_set_list_keyword =
1302 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1304 cmdline_parse_token_string_t cmd_set_list_name =
1305 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1306 "corelist#portlist");
1307 cmdline_parse_token_string_t cmd_set_list_of_items =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1311 cmdline_parse_inst_t cmd_set_fwd_list = {
1312 .f = cmd_set_list_parsed,
1314 .help_str = "set corelist|portlist x[,y]*",
1316 (void *)&cmd_set_list_keyword,
1317 (void *)&cmd_set_list_name,
1318 (void *)&cmd_set_list_of_items,
1323 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1325 struct cmd_setmask_result {
1326 cmdline_fixed_string_t set;
1327 cmdline_fixed_string_t mask;
1331 static void cmd_set_mask_parsed(void *parsed_result,
1332 __attribute__((unused)) struct cmdline *cl,
1333 __attribute__((unused)) void *data)
1335 struct cmd_setmask_result *res = parsed_result;
1337 if (!strcmp(res->mask, "coremask"))
1338 set_fwd_lcores_mask(res->hexavalue);
1339 else if (!strcmp(res->mask, "portmask"))
1340 set_fwd_ports_mask(res->hexavalue);
1343 cmdline_parse_token_string_t cmd_setmask_set =
1344 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1345 cmdline_parse_token_string_t cmd_setmask_mask =
1346 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1347 "coremask#portmask");
1348 cmdline_parse_token_num_t cmd_setmask_value =
1349 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1351 cmdline_parse_inst_t cmd_set_fwd_mask = {
1352 .f = cmd_set_mask_parsed,
1354 .help_str = "set coremask|portmask hexadecimal value",
1356 (void *)&cmd_setmask_set,
1357 (void *)&cmd_setmask_mask,
1358 (void *)&cmd_setmask_value,
1364 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1366 struct cmd_set_result {
1367 cmdline_fixed_string_t set;
1368 cmdline_fixed_string_t what;
1372 static void cmd_set_parsed(void *parsed_result,
1373 __attribute__((unused)) struct cmdline *cl,
1374 __attribute__((unused)) void *data)
1376 struct cmd_set_result *res = parsed_result;
1377 if (!strcmp(res->what, "nbport"))
1378 set_fwd_ports_number(res->value);
1379 else if (!strcmp(res->what, "nbcore"))
1380 set_fwd_lcores_number(res->value);
1381 else if (!strcmp(res->what, "burst"))
1382 set_nb_pkt_per_burst(res->value);
1383 else if (!strcmp(res->what, "verbose"))
1384 set_verbose_level(res->value);
1387 cmdline_parse_token_string_t cmd_set_set =
1388 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1389 cmdline_parse_token_string_t cmd_set_what =
1390 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1391 "nbport#nbcore#burst#verbose");
1392 cmdline_parse_token_num_t cmd_set_value =
1393 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1395 cmdline_parse_inst_t cmd_set_numbers = {
1396 .f = cmd_set_parsed,
1398 .help_str = "set nbport|nbcore|burst|verbose value",
1400 (void *)&cmd_set_set,
1401 (void *)&cmd_set_what,
1402 (void *)&cmd_set_value,
1407 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1409 struct cmd_set_txpkts_result {
1410 cmdline_fixed_string_t cmd_keyword;
1411 cmdline_fixed_string_t txpkts;
1412 cmdline_fixed_string_t seg_lengths;
1416 cmd_set_txpkts_parsed(void *parsed_result,
1417 __attribute__((unused)) struct cmdline *cl,
1418 __attribute__((unused)) void *data)
1420 struct cmd_set_txpkts_result *res;
1421 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1422 unsigned int nb_segs;
1424 res = parsed_result;
1425 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1426 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1428 set_tx_pkt_segments(seg_lengths, nb_segs);
1431 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1433 cmd_keyword, "set");
1434 cmdline_parse_token_string_t cmd_set_txpkts_name =
1435 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1437 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1438 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1441 cmdline_parse_inst_t cmd_set_txpkts = {
1442 .f = cmd_set_txpkts_parsed,
1444 .help_str = "set txpkts x[,y]*",
1446 (void *)&cmd_set_txpkts_keyword,
1447 (void *)&cmd_set_txpkts_name,
1448 (void *)&cmd_set_txpkts_lengths,
1453 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1454 struct cmd_rx_vlan_filter_all_result {
1455 cmdline_fixed_string_t rx_vlan;
1456 cmdline_fixed_string_t what;
1457 cmdline_fixed_string_t all;
1462 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1468 if (!strcmp(res->what, "add"))
1469 rx_vlan_all_filter_set(res->port_id, 1);
1471 rx_vlan_all_filter_set(res->port_id, 0);
1474 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1475 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1476 rx_vlan, "rx_vlan");
1477 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1478 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1480 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1481 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1483 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1484 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1487 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1488 .f = cmd_rx_vlan_filter_all_parsed,
1490 .help_str = "add/remove all identifiers to/from the set of VLAN "
1491 "Identifiers filtered by a port",
1493 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1494 (void *)&cmd_rx_vlan_filter_all_what,
1495 (void *)&cmd_rx_vlan_filter_all_all,
1496 (void *)&cmd_rx_vlan_filter_all_portid,
1501 /* *** VLAN OFFLOAD SET ON A PORT *** */
1502 struct cmd_vlan_offload_result {
1503 cmdline_fixed_string_t vlan;
1504 cmdline_fixed_string_t set;
1505 cmdline_fixed_string_t what;
1506 cmdline_fixed_string_t on;
1507 cmdline_fixed_string_t port_id;
1511 cmd_vlan_offload_parsed(void *parsed_result,
1512 __attribute__((unused)) struct cmdline *cl,
1513 __attribute__((unused)) void *data)
1516 struct cmd_vlan_offload_result *res = parsed_result;
1519 portid_t port_id = 0;
1523 len = strnlen(str, STR_TOKEN_SIZE);
1525 /* Get port_id first */
1533 tmp = strtoul(str, NULL, 0);
1534 /* If port_id greater that what portid_t can represent, return */
1537 port_id = (portid_t)tmp;
1539 if (!strcmp(res->on, "on"))
1544 if (!strcmp(res->what, "strip"))
1545 rx_vlan_strip_set(port_id, on);
1546 else if(!strcmp(res->what, "stripq")){
1547 uint16_t queue_id = 0;
1549 /* No queue_id, return */
1552 tmp = strtoul(str + i + 1, NULL, 0);
1553 /* If queue_id greater that what 16-bits can represent, return */
1557 queue_id = (uint16_t)tmp;
1558 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1560 else if (!strcmp(res->what, "filter"))
1561 rx_vlan_filter_set(port_id, on);
1563 vlan_extend_set(port_id, on);
1568 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1569 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1571 cmdline_parse_token_string_t cmd_vlan_offload_set =
1572 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1574 cmdline_parse_token_string_t cmd_vlan_offload_what =
1575 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1576 what, "strip#filter#qinq#stripq");
1577 cmdline_parse_token_string_t cmd_vlan_offload_on =
1578 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1580 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1581 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1584 cmdline_parse_inst_t cmd_vlan_offload = {
1585 .f = cmd_vlan_offload_parsed,
1587 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1588 " qinq(extended) for both rx/tx sides ",
1590 (void *)&cmd_vlan_offload_vlan,
1591 (void *)&cmd_vlan_offload_set,
1592 (void *)&cmd_vlan_offload_what,
1593 (void *)&cmd_vlan_offload_on,
1594 (void *)&cmd_vlan_offload_portid,
1599 /* *** VLAN TPID SET ON A PORT *** */
1600 struct cmd_vlan_tpid_result {
1601 cmdline_fixed_string_t vlan;
1602 cmdline_fixed_string_t set;
1603 cmdline_fixed_string_t what;
1609 cmd_vlan_tpid_parsed(void *parsed_result,
1610 __attribute__((unused)) struct cmdline *cl,
1611 __attribute__((unused)) void *data)
1613 struct cmd_vlan_tpid_result *res = parsed_result;
1614 vlan_tpid_set(res->port_id, res->tp_id);
1618 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1619 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1621 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1622 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1624 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1625 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1627 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
1628 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1630 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
1631 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1634 cmdline_parse_inst_t cmd_vlan_tpid = {
1635 .f = cmd_vlan_tpid_parsed,
1637 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
1639 (void *)&cmd_vlan_tpid_vlan,
1640 (void *)&cmd_vlan_tpid_set,
1641 (void *)&cmd_vlan_tpid_what,
1642 (void *)&cmd_vlan_tpid_tpid,
1643 (void *)&cmd_vlan_tpid_portid,
1648 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
1649 struct cmd_rx_vlan_filter_result {
1650 cmdline_fixed_string_t rx_vlan;
1651 cmdline_fixed_string_t what;
1657 cmd_rx_vlan_filter_parsed(void *parsed_result,
1658 __attribute__((unused)) struct cmdline *cl,
1659 __attribute__((unused)) void *data)
1661 struct cmd_rx_vlan_filter_result *res = parsed_result;
1663 if (!strcmp(res->what, "add"))
1664 rx_vft_set(res->port_id, res->vlan_id, 1);
1666 rx_vft_set(res->port_id, res->vlan_id, 0);
1669 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
1670 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1671 rx_vlan, "rx_vlan");
1672 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
1673 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1675 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
1676 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1678 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
1679 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1682 cmdline_parse_inst_t cmd_rx_vlan_filter = {
1683 .f = cmd_rx_vlan_filter_parsed,
1685 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
1686 "Identifiers filtered by a port",
1688 (void *)&cmd_rx_vlan_filter_rx_vlan,
1689 (void *)&cmd_rx_vlan_filter_what,
1690 (void *)&cmd_rx_vlan_filter_vlanid,
1691 (void *)&cmd_rx_vlan_filter_portid,
1696 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1697 struct cmd_tx_vlan_set_result {
1698 cmdline_fixed_string_t tx_vlan;
1699 cmdline_fixed_string_t set;
1705 cmd_tx_vlan_set_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_tx_vlan_set_result *res = parsed_result;
1710 tx_vlan_set(res->port_id, res->vlan_id);
1713 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
1714 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1715 tx_vlan, "tx_vlan");
1716 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
1717 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1719 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
1720 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1722 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
1723 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1726 cmdline_parse_inst_t cmd_tx_vlan_set = {
1727 .f = cmd_tx_vlan_set_parsed,
1729 .help_str = "enable hardware insertion of a VLAN header with a given "
1730 "TAG Identifier in packets sent on a port",
1732 (void *)&cmd_tx_vlan_set_tx_vlan,
1733 (void *)&cmd_tx_vlan_set_set,
1734 (void *)&cmd_tx_vlan_set_vlanid,
1735 (void *)&cmd_tx_vlan_set_portid,
1740 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1741 struct cmd_tx_vlan_reset_result {
1742 cmdline_fixed_string_t tx_vlan;
1743 cmdline_fixed_string_t reset;
1748 cmd_tx_vlan_reset_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1752 struct cmd_tx_vlan_reset_result *res = parsed_result;
1754 tx_vlan_reset(res->port_id);
1757 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
1758 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1759 tx_vlan, "tx_vlan");
1760 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
1761 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1763 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
1764 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
1767 cmdline_parse_inst_t cmd_tx_vlan_reset = {
1768 .f = cmd_tx_vlan_reset_parsed,
1770 .help_str = "disable hardware insertion of a VLAN header in packets "
1773 (void *)&cmd_tx_vlan_reset_tx_vlan,
1774 (void *)&cmd_tx_vlan_reset_reset,
1775 (void *)&cmd_tx_vlan_reset_portid,
1781 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
1782 struct cmd_tx_cksum_set_result {
1783 cmdline_fixed_string_t tx_cksum;
1784 cmdline_fixed_string_t set;
1790 cmd_tx_cksum_set_parsed(void *parsed_result,
1791 __attribute__((unused)) struct cmdline *cl,
1792 __attribute__((unused)) void *data)
1794 struct cmd_tx_cksum_set_result *res = parsed_result;
1796 tx_cksum_set(res->port_id, res->cksum_mask);
1799 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
1800 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1801 tx_cksum, "tx_checksum");
1802 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
1803 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1805 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
1806 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1808 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
1809 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1812 cmdline_parse_inst_t cmd_tx_cksum_set = {
1813 .f = cmd_tx_cksum_set_parsed,
1815 .help_str = "enable hardware insertion of L3/L4checksum with a given "
1816 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
1817 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
1819 (void *)&cmd_tx_cksum_set_tx_cksum,
1820 (void *)&cmd_tx_cksum_set_set,
1821 (void *)&cmd_tx_cksum_set_cksum_mask,
1822 (void *)&cmd_tx_cksum_set_portid,
1827 /* *** SET FORWARDING MODE *** */
1828 struct cmd_set_fwd_mode_result {
1829 cmdline_fixed_string_t set;
1830 cmdline_fixed_string_t fwd;
1831 cmdline_fixed_string_t mode;
1834 static void cmd_set_fwd_mode_parsed(void *parsed_result,
1835 __attribute__((unused)) struct cmdline *cl,
1836 __attribute__((unused)) void *data)
1838 struct cmd_set_fwd_mode_result *res = parsed_result;
1840 set_pkt_forwarding_mode(res->mode);
1843 cmdline_parse_token_string_t cmd_setfwd_set =
1844 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
1845 cmdline_parse_token_string_t cmd_setfwd_fwd =
1846 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
1847 cmdline_parse_token_string_t cmd_setfwd_mode =
1848 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
1849 #ifdef RTE_LIBRTE_IEEE1588
1850 "io#mac#rxonly#txonly#csum#ieee1588");
1852 "io#mac#rxonly#txonly#csum");
1855 cmdline_parse_inst_t cmd_set_fwd_mode = {
1856 .f = cmd_set_fwd_mode_parsed,
1858 #ifdef RTE_LIBRTE_IEEE1588
1859 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
1860 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
1862 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
1863 " RXONLY, CSUM or TXONLY packet forwarding mode",
1866 (void *)&cmd_setfwd_set,
1867 (void *)&cmd_setfwd_fwd,
1868 (void *)&cmd_setfwd_mode,
1873 /* *** SET PROMISC MODE *** */
1874 struct cmd_set_promisc_mode_result {
1875 cmdline_fixed_string_t set;
1876 cmdline_fixed_string_t promisc;
1877 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1878 uint8_t port_num; /* valid if "allports" argument == 0 */
1879 cmdline_fixed_string_t mode;
1882 static void cmd_set_promisc_mode_parsed(void *parsed_result,
1883 __attribute__((unused)) struct cmdline *cl,
1886 struct cmd_set_promisc_mode_result *res = parsed_result;
1890 if (!strcmp(res->mode, "on"))
1897 for (i = 0; i < nb_ports; i++) {
1899 rte_eth_promiscuous_enable(i);
1901 rte_eth_promiscuous_disable(i);
1906 rte_eth_promiscuous_enable(res->port_num);
1908 rte_eth_promiscuous_disable(res->port_num);
1912 cmdline_parse_token_string_t cmd_setpromisc_set =
1913 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
1914 cmdline_parse_token_string_t cmd_setpromisc_promisc =
1915 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
1917 cmdline_parse_token_string_t cmd_setpromisc_portall =
1918 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
1920 cmdline_parse_token_num_t cmd_setpromisc_portnum =
1921 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
1923 cmdline_parse_token_string_t cmd_setpromisc_mode =
1924 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
1927 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
1928 .f = cmd_set_promisc_mode_parsed,
1930 .help_str = "set promisc all on|off: set promisc mode for all ports",
1932 (void *)&cmd_setpromisc_set,
1933 (void *)&cmd_setpromisc_promisc,
1934 (void *)&cmd_setpromisc_portall,
1935 (void *)&cmd_setpromisc_mode,
1940 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
1941 .f = cmd_set_promisc_mode_parsed,
1943 .help_str = "set promisc X on|off: set promisc mode on port X",
1945 (void *)&cmd_setpromisc_set,
1946 (void *)&cmd_setpromisc_promisc,
1947 (void *)&cmd_setpromisc_portnum,
1948 (void *)&cmd_setpromisc_mode,
1953 /* *** SET ALLMULTI MODE *** */
1954 struct cmd_set_allmulti_mode_result {
1955 cmdline_fixed_string_t set;
1956 cmdline_fixed_string_t allmulti;
1957 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1958 uint8_t port_num; /* valid if "allports" argument == 0 */
1959 cmdline_fixed_string_t mode;
1962 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
1963 __attribute__((unused)) struct cmdline *cl,
1966 struct cmd_set_allmulti_mode_result *res = parsed_result;
1970 if (!strcmp(res->mode, "on"))
1977 for (i = 0; i < nb_ports; i++) {
1979 rte_eth_allmulticast_enable(i);
1981 rte_eth_allmulticast_disable(i);
1986 rte_eth_allmulticast_enable(res->port_num);
1988 rte_eth_allmulticast_disable(res->port_num);
1992 cmdline_parse_token_string_t cmd_setallmulti_set =
1993 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
1994 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
1995 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
1997 cmdline_parse_token_string_t cmd_setallmulti_portall =
1998 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2000 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2001 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2003 cmdline_parse_token_string_t cmd_setallmulti_mode =
2004 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2007 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2008 .f = cmd_set_allmulti_mode_parsed,
2010 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2012 (void *)&cmd_setallmulti_set,
2013 (void *)&cmd_setallmulti_allmulti,
2014 (void *)&cmd_setallmulti_portall,
2015 (void *)&cmd_setallmulti_mode,
2020 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2021 .f = cmd_set_allmulti_mode_parsed,
2023 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2025 (void *)&cmd_setallmulti_set,
2026 (void *)&cmd_setallmulti_allmulti,
2027 (void *)&cmd_setallmulti_portnum,
2028 (void *)&cmd_setallmulti_mode,
2033 /* *** ADD/REMOVE A PKT FILTER *** */
2034 struct cmd_pkt_filter_result {
2035 cmdline_fixed_string_t pkt_filter;
2037 cmdline_fixed_string_t protocol;
2038 cmdline_fixed_string_t src;
2039 cmdline_ipaddr_t ip_src;
2041 cmdline_fixed_string_t dst;
2042 cmdline_ipaddr_t ip_dst;
2044 cmdline_fixed_string_t flexbytes;
2045 uint16_t flexbytes_value;
2046 cmdline_fixed_string_t vlan;
2048 cmdline_fixed_string_t queue;
2050 cmdline_fixed_string_t soft;
2055 cmd_pkt_filter_parsed(void *parsed_result,
2056 __attribute__((unused)) struct cmdline *cl,
2057 __attribute__((unused)) void *data)
2059 struct rte_fdir_filter fdir_filter;
2060 struct cmd_pkt_filter_result *res = parsed_result;
2062 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2064 if (res->ip_src.family == AF_INET)
2065 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2067 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2068 &(res->ip_src.addr.ipv6),
2069 sizeof(struct in6_addr));
2071 if (res->ip_dst.family == AF_INET)
2072 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2074 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2075 &(res->ip_dst.addr.ipv6),
2076 sizeof(struct in6_addr));
2078 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2079 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2081 if (!strcmp(res->protocol, "udp"))
2082 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2083 else if (!strcmp(res->protocol, "tcp"))
2084 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2085 else if (!strcmp(res->protocol, "sctp"))
2086 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2087 else /* default only IP */
2088 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2090 if (res->ip_dst.family == AF_INET6)
2091 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2093 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2095 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2096 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2098 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2099 fdir_add_signature_filter(res->port_id, res->queue_id,
2101 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2102 fdir_update_signature_filter(res->port_id, res->queue_id,
2104 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2105 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2106 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2107 fdir_add_perfect_filter(res->port_id, res->soft_id,
2109 (uint8_t) (res->queue_id < 0),
2111 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2112 fdir_update_perfect_filter(res->port_id, res->soft_id,
2114 (uint8_t) (res->queue_id < 0),
2116 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2117 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2123 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2124 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2126 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2127 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2128 protocol, "ip#tcp#udp#sctp");
2129 cmdline_parse_token_string_t cmd_pkt_filter_src =
2130 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2132 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2133 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2135 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2136 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2138 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2139 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2141 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2142 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2144 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2145 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2147 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2148 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2149 flexbytes, "flexbytes");
2150 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2151 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2152 flexbytes_value, UINT16);
2153 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2154 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2156 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2157 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2159 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2160 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2162 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2163 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2165 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2166 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2168 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2169 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2173 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2174 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2175 pkt_filter, "add_signature_filter");
2176 cmdline_parse_inst_t cmd_add_signature_filter = {
2177 .f = cmd_pkt_filter_parsed,
2179 .help_str = "add a signature filter",
2181 (void *)&cmd_pkt_filter_add_signature_filter,
2182 (void *)&cmd_pkt_filter_port_id,
2183 (void *)&cmd_pkt_filter_protocol,
2184 (void *)&cmd_pkt_filter_src,
2185 (void *)&cmd_pkt_filter_ip_src,
2186 (void *)&cmd_pkt_filter_port_src,
2187 (void *)&cmd_pkt_filter_dst,
2188 (void *)&cmd_pkt_filter_ip_dst,
2189 (void *)&cmd_pkt_filter_port_dst,
2190 (void *)&cmd_pkt_filter_flexbytes,
2191 (void *)&cmd_pkt_filter_flexbytes_value,
2192 (void *)&cmd_pkt_filter_vlan,
2193 (void *)&cmd_pkt_filter_vlan_id,
2194 (void *)&cmd_pkt_filter_queue,
2195 (void *)&cmd_pkt_filter_queue_id,
2201 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2202 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2203 pkt_filter, "upd_signature_filter");
2204 cmdline_parse_inst_t cmd_upd_signature_filter = {
2205 .f = cmd_pkt_filter_parsed,
2207 .help_str = "update a signature filter",
2209 (void *)&cmd_pkt_filter_upd_signature_filter,
2210 (void *)&cmd_pkt_filter_port_id,
2211 (void *)&cmd_pkt_filter_protocol,
2212 (void *)&cmd_pkt_filter_src,
2213 (void *)&cmd_pkt_filter_ip_src,
2214 (void *)&cmd_pkt_filter_port_src,
2215 (void *)&cmd_pkt_filter_dst,
2216 (void *)&cmd_pkt_filter_ip_dst,
2217 (void *)&cmd_pkt_filter_port_dst,
2218 (void *)&cmd_pkt_filter_flexbytes,
2219 (void *)&cmd_pkt_filter_flexbytes_value,
2220 (void *)&cmd_pkt_filter_vlan,
2221 (void *)&cmd_pkt_filter_vlan_id,
2222 (void *)&cmd_pkt_filter_queue,
2223 (void *)&cmd_pkt_filter_queue_id,
2229 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2230 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2231 pkt_filter, "rm_signature_filter");
2232 cmdline_parse_inst_t cmd_rm_signature_filter = {
2233 .f = cmd_pkt_filter_parsed,
2235 .help_str = "remove a signature filter",
2237 (void *)&cmd_pkt_filter_rm_signature_filter,
2238 (void *)&cmd_pkt_filter_port_id,
2239 (void *)&cmd_pkt_filter_protocol,
2240 (void *)&cmd_pkt_filter_src,
2241 (void *)&cmd_pkt_filter_ip_src,
2242 (void *)&cmd_pkt_filter_port_src,
2243 (void *)&cmd_pkt_filter_dst,
2244 (void *)&cmd_pkt_filter_ip_dst,
2245 (void *)&cmd_pkt_filter_port_dst,
2246 (void *)&cmd_pkt_filter_flexbytes,
2247 (void *)&cmd_pkt_filter_flexbytes_value,
2248 (void *)&cmd_pkt_filter_vlan,
2249 (void *)&cmd_pkt_filter_vlan_id,
2255 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2256 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2257 pkt_filter, "add_perfect_filter");
2258 cmdline_parse_inst_t cmd_add_perfect_filter = {
2259 .f = cmd_pkt_filter_parsed,
2261 .help_str = "add a perfect filter",
2263 (void *)&cmd_pkt_filter_add_perfect_filter,
2264 (void *)&cmd_pkt_filter_port_id,
2265 (void *)&cmd_pkt_filter_protocol,
2266 (void *)&cmd_pkt_filter_src,
2267 (void *)&cmd_pkt_filter_ip_src,
2268 (void *)&cmd_pkt_filter_port_src,
2269 (void *)&cmd_pkt_filter_dst,
2270 (void *)&cmd_pkt_filter_ip_dst,
2271 (void *)&cmd_pkt_filter_port_dst,
2272 (void *)&cmd_pkt_filter_flexbytes,
2273 (void *)&cmd_pkt_filter_flexbytes_value,
2274 (void *)&cmd_pkt_filter_vlan,
2275 (void *)&cmd_pkt_filter_vlan_id,
2276 (void *)&cmd_pkt_filter_queue,
2277 (void *)&cmd_pkt_filter_queue_id,
2278 (void *)&cmd_pkt_filter_soft,
2279 (void *)&cmd_pkt_filter_soft_id,
2285 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2286 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2287 pkt_filter, "upd_perfect_filter");
2288 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2289 .f = cmd_pkt_filter_parsed,
2291 .help_str = "update a perfect filter",
2293 (void *)&cmd_pkt_filter_upd_perfect_filter,
2294 (void *)&cmd_pkt_filter_port_id,
2295 (void *)&cmd_pkt_filter_protocol,
2296 (void *)&cmd_pkt_filter_src,
2297 (void *)&cmd_pkt_filter_ip_src,
2298 (void *)&cmd_pkt_filter_port_src,
2299 (void *)&cmd_pkt_filter_dst,
2300 (void *)&cmd_pkt_filter_ip_dst,
2301 (void *)&cmd_pkt_filter_port_dst,
2302 (void *)&cmd_pkt_filter_flexbytes,
2303 (void *)&cmd_pkt_filter_flexbytes_value,
2304 (void *)&cmd_pkt_filter_vlan,
2305 (void *)&cmd_pkt_filter_vlan_id,
2306 (void *)&cmd_pkt_filter_queue,
2307 (void *)&cmd_pkt_filter_queue_id,
2308 (void *)&cmd_pkt_filter_soft,
2309 (void *)&cmd_pkt_filter_soft_id,
2315 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2316 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2317 pkt_filter, "rm_perfect_filter");
2318 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2319 .f = cmd_pkt_filter_parsed,
2321 .help_str = "remove a perfect filter",
2323 (void *)&cmd_pkt_filter_rm_perfect_filter,
2324 (void *)&cmd_pkt_filter_port_id,
2325 (void *)&cmd_pkt_filter_protocol,
2326 (void *)&cmd_pkt_filter_src,
2327 (void *)&cmd_pkt_filter_ip_src,
2328 (void *)&cmd_pkt_filter_port_src,
2329 (void *)&cmd_pkt_filter_dst,
2330 (void *)&cmd_pkt_filter_ip_dst,
2331 (void *)&cmd_pkt_filter_port_dst,
2332 (void *)&cmd_pkt_filter_flexbytes,
2333 (void *)&cmd_pkt_filter_flexbytes_value,
2334 (void *)&cmd_pkt_filter_vlan,
2335 (void *)&cmd_pkt_filter_vlan_id,
2336 (void *)&cmd_pkt_filter_soft,
2337 (void *)&cmd_pkt_filter_soft_id,
2342 /* *** SETUP MASKS FILTER *** */
2343 struct cmd_pkt_filter_masks_result {
2344 cmdline_fixed_string_t filter_mask;
2346 cmdline_fixed_string_t src_mask;
2347 uint32_t ip_src_mask;
2348 uint16_t ipv6_src_mask;
2349 uint16_t port_src_mask;
2350 cmdline_fixed_string_t dst_mask;
2351 uint32_t ip_dst_mask;
2352 uint16_t ipv6_dst_mask;
2353 uint16_t port_dst_mask;
2354 cmdline_fixed_string_t flexbytes;
2355 uint8_t flexbytes_value;
2356 cmdline_fixed_string_t vlan_id;
2357 uint8_t vlan_id_value;
2358 cmdline_fixed_string_t vlan_prio;
2359 uint8_t vlan_prio_value;
2360 cmdline_fixed_string_t only_ip_flow;
2361 uint8_t only_ip_flow_value;
2362 cmdline_fixed_string_t comp_ipv6_dst;
2363 uint8_t comp_ipv6_dst_value;
2367 cmd_pkt_filter_masks_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2369 __attribute__((unused)) void *data)
2371 struct rte_fdir_masks fdir_masks;
2372 struct cmd_pkt_filter_masks_result *res = parsed_result;
2374 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2376 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2377 fdir_masks.vlan_id = res->vlan_id_value;
2378 fdir_masks.vlan_prio = res->vlan_prio_value;
2379 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2380 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2381 fdir_masks.src_port_mask = res->port_src_mask;
2382 fdir_masks.dst_port_mask = res->port_dst_mask;
2383 fdir_masks.flexbytes = res->flexbytes_value;
2385 fdir_set_masks(res->port_id, &fdir_masks);
2388 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2389 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2390 filter_mask, "set_masks_filter");
2391 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2392 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2394 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2395 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2396 only_ip_flow, "only_ip_flow");
2397 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2398 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2399 only_ip_flow_value, UINT8);
2400 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2401 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2402 src_mask, "src_mask");
2403 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2404 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2405 ip_src_mask, UINT32);
2406 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2407 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2408 port_src_mask, UINT16);
2409 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2410 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2411 dst_mask, "dst_mask");
2412 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2413 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2414 ip_dst_mask, UINT32);
2415 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2416 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2417 port_dst_mask, UINT16);
2418 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2419 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2420 flexbytes, "flexbytes");
2421 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2422 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2423 flexbytes_value, UINT8);
2424 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2425 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2426 vlan_id, "vlan_id");
2427 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2428 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2429 vlan_id_value, UINT8);
2430 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2431 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2432 vlan_prio, "vlan_prio");
2433 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2434 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2435 vlan_prio_value, UINT8);
2437 cmdline_parse_inst_t cmd_set_masks_filter = {
2438 .f = cmd_pkt_filter_masks_parsed,
2440 .help_str = "setup masks filter",
2442 (void *)&cmd_pkt_filter_masks_filter_mask,
2443 (void *)&cmd_pkt_filter_masks_port_id,
2444 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2445 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2446 (void *)&cmd_pkt_filter_masks_src_mask,
2447 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2448 (void *)&cmd_pkt_filter_masks_port_src_mask,
2449 (void *)&cmd_pkt_filter_masks_dst_mask,
2450 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2451 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2452 (void *)&cmd_pkt_filter_masks_flexbytes,
2453 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2454 (void *)&cmd_pkt_filter_masks_vlan_id,
2455 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2456 (void *)&cmd_pkt_filter_masks_vlan_prio,
2457 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2463 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2464 __attribute__((unused)) struct cmdline *cl,
2465 __attribute__((unused)) void *data)
2467 struct rte_fdir_masks fdir_masks;
2468 struct cmd_pkt_filter_masks_result *res = parsed_result;
2470 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2472 fdir_masks.set_ipv6_mask = 1;
2473 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2474 fdir_masks.vlan_id = res->vlan_id_value;
2475 fdir_masks.vlan_prio = res->vlan_prio_value;
2476 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2477 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2478 fdir_masks.src_port_mask = res->port_src_mask;
2479 fdir_masks.dst_port_mask = res->port_dst_mask;
2480 fdir_masks.flexbytes = res->flexbytes_value;
2481 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2483 fdir_set_masks(res->port_id, &fdir_masks);
2486 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2487 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2488 filter_mask, "set_ipv6_masks_filter");
2489 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2490 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2491 ipv6_src_mask, UINT16);
2492 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2493 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2494 ipv6_dst_mask, UINT16);
2496 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2497 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2498 comp_ipv6_dst, "compare_dst");
2499 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2500 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2501 comp_ipv6_dst_value, UINT8);
2503 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2504 .f = cmd_pkt_filter_masks_ipv6_parsed,
2506 .help_str = "setup ipv6 masks filter",
2508 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2509 (void *)&cmd_pkt_filter_masks_port_id,
2510 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2511 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2512 (void *)&cmd_pkt_filter_masks_src_mask,
2513 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2514 (void *)&cmd_pkt_filter_masks_port_src_mask,
2515 (void *)&cmd_pkt_filter_masks_dst_mask,
2516 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2517 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2518 (void *)&cmd_pkt_filter_masks_flexbytes,
2519 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2520 (void *)&cmd_pkt_filter_masks_vlan_id,
2521 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2522 (void *)&cmd_pkt_filter_masks_vlan_prio,
2523 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2524 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2525 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2530 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2531 struct cmd_link_flow_ctrl_set_result {
2532 cmdline_fixed_string_t set;
2533 cmdline_fixed_string_t flow_ctrl;
2534 cmdline_fixed_string_t rx;
2535 cmdline_fixed_string_t rx_lfc_mode;
2536 cmdline_fixed_string_t tx;
2537 cmdline_fixed_string_t tx_lfc_mode;
2538 uint32_t high_water;
2540 uint16_t pause_time;
2546 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2547 __attribute__((unused)) struct cmdline *cl,
2548 __attribute__((unused)) void *data)
2550 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2551 struct rte_eth_fc_conf fc_conf;
2552 int rx_fc_enable, tx_fc_enable;
2556 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2557 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2558 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2559 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2561 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2562 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2565 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2566 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2568 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2569 fc_conf.high_water = res->high_water;
2570 fc_conf.low_water = res->low_water;
2571 fc_conf.pause_time = res->pause_time;
2572 fc_conf.send_xon = res->send_xon;
2574 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2576 printf("bad flow contrl parameter, return code = %d \n", ret);
2579 cmdline_parse_token_string_t cmd_lfc_set_set =
2580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2582 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2584 flow_ctrl, "flow_ctrl");
2585 cmdline_parse_token_string_t cmd_lfc_set_rx =
2586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2588 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2589 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2590 rx_lfc_mode, "on#off");
2591 cmdline_parse_token_string_t cmd_lfc_set_tx =
2592 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2594 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2595 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2596 tx_lfc_mode, "on#off");
2597 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2598 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2599 high_water, UINT32);
2600 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2601 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2603 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2604 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2605 pause_time, UINT16);
2606 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2607 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2609 cmdline_parse_token_num_t cmd_lfc_set_portid =
2610 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2613 cmdline_parse_inst_t cmd_link_flow_control_set = {
2614 .f = cmd_link_flow_ctrl_set_parsed,
2616 .help_str = "Configure the Ethernet link flow control...",
2618 (void *)&cmd_lfc_set_set,
2619 (void *)&cmd_lfc_set_flow_ctrl,
2620 (void *)&cmd_lfc_set_rx,
2621 (void *)&cmd_lfc_set_rx_mode,
2622 (void *)&cmd_lfc_set_tx,
2623 (void *)&cmd_lfc_set_tx_mode,
2624 (void *)&cmd_lfc_set_high_water,
2625 (void *)&cmd_lfc_set_low_water,
2626 (void *)&cmd_lfc_set_pause_time,
2627 (void *)&cmd_lfc_set_send_xon,
2628 (void *)&cmd_lfc_set_portid,
2633 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
2634 struct cmd_priority_flow_ctrl_set_result {
2635 cmdline_fixed_string_t set;
2636 cmdline_fixed_string_t pfc_ctrl;
2637 cmdline_fixed_string_t rx;
2638 cmdline_fixed_string_t rx_pfc_mode;
2639 cmdline_fixed_string_t tx;
2640 cmdline_fixed_string_t tx_pfc_mode;
2641 uint32_t high_water;
2643 uint16_t pause_time;
2649 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
2650 __attribute__((unused)) struct cmdline *cl,
2651 __attribute__((unused)) void *data)
2653 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
2654 struct rte_eth_pfc_conf pfc_conf;
2655 int rx_fc_enable, tx_fc_enable;
2659 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2660 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2661 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2662 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2664 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
2665 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2668 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
2669 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
2670 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
2671 pfc_conf.fc.high_water = res->high_water;
2672 pfc_conf.fc.low_water = res->low_water;
2673 pfc_conf.fc.pause_time = res->pause_time;
2674 pfc_conf.priority = res->priority;
2676 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
2678 printf("bad priority flow contrl parameter, return code = %d \n", ret);
2681 cmdline_parse_token_string_t cmd_pfc_set_set =
2682 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2684 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
2685 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2686 pfc_ctrl, "pfc_ctrl");
2687 cmdline_parse_token_string_t cmd_pfc_set_rx =
2688 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2690 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
2691 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2692 rx_pfc_mode, "on#off");
2693 cmdline_parse_token_string_t cmd_pfc_set_tx =
2694 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2696 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
2697 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2698 tx_pfc_mode, "on#off");
2699 cmdline_parse_token_num_t cmd_pfc_set_high_water =
2700 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2701 high_water, UINT32);
2702 cmdline_parse_token_num_t cmd_pfc_set_low_water =
2703 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2705 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
2706 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2707 pause_time, UINT16);
2708 cmdline_parse_token_num_t cmd_pfc_set_priority =
2709 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2711 cmdline_parse_token_num_t cmd_pfc_set_portid =
2712 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2715 cmdline_parse_inst_t cmd_priority_flow_control_set = {
2716 .f = cmd_priority_flow_ctrl_set_parsed,
2718 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
2719 tx on|off high_water low_water pause_time priority port_id",
2721 (void *)&cmd_pfc_set_set,
2722 (void *)&cmd_pfc_set_flow_ctrl,
2723 (void *)&cmd_pfc_set_rx,
2724 (void *)&cmd_pfc_set_rx_mode,
2725 (void *)&cmd_pfc_set_tx,
2726 (void *)&cmd_pfc_set_tx_mode,
2727 (void *)&cmd_pfc_set_high_water,
2728 (void *)&cmd_pfc_set_low_water,
2729 (void *)&cmd_pfc_set_pause_time,
2730 (void *)&cmd_pfc_set_priority,
2731 (void *)&cmd_pfc_set_portid,
2736 /* *** RESET CONFIGURATION *** */
2737 struct cmd_reset_result {
2738 cmdline_fixed_string_t reset;
2739 cmdline_fixed_string_t def;
2742 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
2744 __attribute__((unused)) void *data)
2746 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
2747 set_def_fwd_config();
2750 cmdline_parse_token_string_t cmd_reset_set =
2751 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
2752 cmdline_parse_token_string_t cmd_reset_def =
2753 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
2756 cmdline_parse_inst_t cmd_reset = {
2757 .f = cmd_reset_parsed,
2759 .help_str = "set default: reset default forwarding configuration",
2761 (void *)&cmd_reset_set,
2762 (void *)&cmd_reset_def,
2767 /* *** START FORWARDING *** */
2768 struct cmd_start_result {
2769 cmdline_fixed_string_t start;
2772 cmdline_parse_token_string_t cmd_start_start =
2773 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
2775 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
2776 __attribute__((unused)) struct cmdline *cl,
2777 __attribute__((unused)) void *data)
2779 start_packet_forwarding(0);
2782 cmdline_parse_inst_t cmd_start = {
2783 .f = cmd_start_parsed,
2785 .help_str = "start packet forwarding",
2787 (void *)&cmd_start_start,
2792 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
2793 struct cmd_start_tx_first_result {
2794 cmdline_fixed_string_t start;
2795 cmdline_fixed_string_t tx_first;
2799 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
2800 __attribute__((unused)) struct cmdline *cl,
2801 __attribute__((unused)) void *data)
2803 start_packet_forwarding(1);
2806 cmdline_parse_token_string_t cmd_start_tx_first_start =
2807 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
2809 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
2810 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
2811 tx_first, "tx_first");
2813 cmdline_parse_inst_t cmd_start_tx_first = {
2814 .f = cmd_start_tx_first_parsed,
2816 .help_str = "start packet forwarding, after sending 1 burst of packets",
2818 (void *)&cmd_start_tx_first_start,
2819 (void *)&cmd_start_tx_first_tx_first,
2824 /* *** SHOW CFG *** */
2825 struct cmd_showcfg_result {
2826 cmdline_fixed_string_t show;
2827 cmdline_fixed_string_t cfg;
2828 cmdline_fixed_string_t what;
2831 static void cmd_showcfg_parsed(void *parsed_result,
2832 __attribute__((unused)) struct cmdline *cl,
2833 __attribute__((unused)) void *data)
2835 struct cmd_showcfg_result *res = parsed_result;
2836 if (!strcmp(res->what, "rxtx"))
2837 rxtx_config_display();
2838 else if (!strcmp(res->what, "cores"))
2839 fwd_lcores_config_display();
2840 else if (!strcmp(res->what, "fwd"))
2841 fwd_config_display();
2844 cmdline_parse_token_string_t cmd_showcfg_show =
2845 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
2846 cmdline_parse_token_string_t cmd_showcfg_port =
2847 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
2848 cmdline_parse_token_string_t cmd_showcfg_what =
2849 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
2852 cmdline_parse_inst_t cmd_showcfg = {
2853 .f = cmd_showcfg_parsed,
2855 .help_str = "show config rxtx|cores|fwd",
2857 (void *)&cmd_showcfg_show,
2858 (void *)&cmd_showcfg_port,
2859 (void *)&cmd_showcfg_what,
2864 /* *** SHOW ALL PORT INFO *** */
2865 struct cmd_showportall_result {
2866 cmdline_fixed_string_t show;
2867 cmdline_fixed_string_t port;
2868 cmdline_fixed_string_t what;
2869 cmdline_fixed_string_t all;
2872 static void cmd_showportall_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2878 struct cmd_showportall_result *res = parsed_result;
2879 if (!strcmp(res->show, "clear")) {
2880 if (!strcmp(res->what, "stats"))
2881 for (i = 0; i < nb_ports; i++)
2883 } else if (!strcmp(res->what, "info"))
2884 for (i = 0; i < nb_ports; i++)
2885 port_infos_display(i);
2886 else if (!strcmp(res->what, "stats"))
2887 for (i = 0; i < nb_ports; i++)
2888 nic_stats_display(i);
2889 else if (!strcmp(res->what, "fdir"))
2890 for (i = 0; i < nb_ports; i++)
2892 else if (!strcmp(res->what, "stat_qmap"))
2893 for (i = 0; i < nb_ports; i++)
2894 nic_stats_mapping_display(i);
2897 cmdline_parse_token_string_t cmd_showportall_show =
2898 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
2900 cmdline_parse_token_string_t cmd_showportall_port =
2901 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
2902 cmdline_parse_token_string_t cmd_showportall_what =
2903 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
2904 "info#stats#fdir#stat_qmap");
2905 cmdline_parse_token_string_t cmd_showportall_all =
2906 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
2907 cmdline_parse_inst_t cmd_showportall = {
2908 .f = cmd_showportall_parsed,
2910 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
2912 (void *)&cmd_showportall_show,
2913 (void *)&cmd_showportall_port,
2914 (void *)&cmd_showportall_what,
2915 (void *)&cmd_showportall_all,
2920 /* *** SHOW PORT INFO *** */
2921 struct cmd_showport_result {
2922 cmdline_fixed_string_t show;
2923 cmdline_fixed_string_t port;
2924 cmdline_fixed_string_t what;
2928 static void cmd_showport_parsed(void *parsed_result,
2929 __attribute__((unused)) struct cmdline *cl,
2930 __attribute__((unused)) void *data)
2932 struct cmd_showport_result *res = parsed_result;
2933 if (!strcmp(res->show, "clear")) {
2934 if (!strcmp(res->what, "stats"))
2935 nic_stats_clear(res->portnum);
2936 } else if (!strcmp(res->what, "info"))
2937 port_infos_display(res->portnum);
2938 else if (!strcmp(res->what, "stats"))
2939 nic_stats_display(res->portnum);
2940 else if (!strcmp(res->what, "fdir"))
2941 fdir_get_infos(res->portnum);
2942 else if (!strcmp(res->what, "stat_qmap"))
2943 nic_stats_mapping_display(res->portnum);
2946 cmdline_parse_token_string_t cmd_showport_show =
2947 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
2949 cmdline_parse_token_string_t cmd_showport_port =
2950 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
2951 cmdline_parse_token_string_t cmd_showport_what =
2952 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
2953 "info#stats#fdir#stat_qmap");
2954 cmdline_parse_token_num_t cmd_showport_portnum =
2955 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
2957 cmdline_parse_inst_t cmd_showport = {
2958 .f = cmd_showport_parsed,
2960 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
2962 (void *)&cmd_showport_show,
2963 (void *)&cmd_showport_port,
2964 (void *)&cmd_showport_what,
2965 (void *)&cmd_showport_portnum,
2970 /* *** READ PORT REGISTER *** */
2971 struct cmd_read_reg_result {
2972 cmdline_fixed_string_t read;
2973 cmdline_fixed_string_t reg;
2979 cmd_read_reg_parsed(void *parsed_result,
2980 __attribute__((unused)) struct cmdline *cl,
2981 __attribute__((unused)) void *data)
2983 struct cmd_read_reg_result *res = parsed_result;
2984 port_reg_display(res->port_id, res->reg_off);
2987 cmdline_parse_token_string_t cmd_read_reg_read =
2988 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
2989 cmdline_parse_token_string_t cmd_read_reg_reg =
2990 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
2991 cmdline_parse_token_num_t cmd_read_reg_port_id =
2992 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
2993 cmdline_parse_token_num_t cmd_read_reg_reg_off =
2994 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
2996 cmdline_parse_inst_t cmd_read_reg = {
2997 .f = cmd_read_reg_parsed,
2999 .help_str = "read reg port_id reg_off",
3001 (void *)&cmd_read_reg_read,
3002 (void *)&cmd_read_reg_reg,
3003 (void *)&cmd_read_reg_port_id,
3004 (void *)&cmd_read_reg_reg_off,
3009 /* *** READ PORT REGISTER BIT FIELD *** */
3010 struct cmd_read_reg_bit_field_result {
3011 cmdline_fixed_string_t read;
3012 cmdline_fixed_string_t regfield;
3020 cmd_read_reg_bit_field_parsed(void *parsed_result,
3021 __attribute__((unused)) struct cmdline *cl,
3022 __attribute__((unused)) void *data)
3024 struct cmd_read_reg_bit_field_result *res = parsed_result;
3025 port_reg_bit_field_display(res->port_id, res->reg_off,
3026 res->bit1_pos, res->bit2_pos);
3029 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3030 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3032 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3033 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3034 regfield, "regfield");
3035 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3036 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3038 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3039 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3041 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3042 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3044 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3045 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3048 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3049 .f = cmd_read_reg_bit_field_parsed,
3051 .help_str = "read regfield port_id reg_off bit_x bit_y "
3052 "(read register bit field between bit_x and bit_y included)",
3054 (void *)&cmd_read_reg_bit_field_read,
3055 (void *)&cmd_read_reg_bit_field_regfield,
3056 (void *)&cmd_read_reg_bit_field_port_id,
3057 (void *)&cmd_read_reg_bit_field_reg_off,
3058 (void *)&cmd_read_reg_bit_field_bit1_pos,
3059 (void *)&cmd_read_reg_bit_field_bit2_pos,
3064 /* *** READ PORT REGISTER BIT *** */
3065 struct cmd_read_reg_bit_result {
3066 cmdline_fixed_string_t read;
3067 cmdline_fixed_string_t regbit;
3074 cmd_read_reg_bit_parsed(void *parsed_result,
3075 __attribute__((unused)) struct cmdline *cl,
3076 __attribute__((unused)) void *data)
3078 struct cmd_read_reg_bit_result *res = parsed_result;
3079 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3082 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3083 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3084 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3085 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3087 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3088 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3089 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3090 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3091 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3092 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3094 cmdline_parse_inst_t cmd_read_reg_bit = {
3095 .f = cmd_read_reg_bit_parsed,
3097 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3099 (void *)&cmd_read_reg_bit_read,
3100 (void *)&cmd_read_reg_bit_regbit,
3101 (void *)&cmd_read_reg_bit_port_id,
3102 (void *)&cmd_read_reg_bit_reg_off,
3103 (void *)&cmd_read_reg_bit_bit_pos,
3108 /* *** WRITE PORT REGISTER *** */
3109 struct cmd_write_reg_result {
3110 cmdline_fixed_string_t write;
3111 cmdline_fixed_string_t reg;
3118 cmd_write_reg_parsed(void *parsed_result,
3119 __attribute__((unused)) struct cmdline *cl,
3120 __attribute__((unused)) void *data)
3122 struct cmd_write_reg_result *res = parsed_result;
3123 port_reg_set(res->port_id, res->reg_off, res->value);
3126 cmdline_parse_token_string_t cmd_write_reg_write =
3127 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3128 cmdline_parse_token_string_t cmd_write_reg_reg =
3129 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3130 cmdline_parse_token_num_t cmd_write_reg_port_id =
3131 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3132 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3134 cmdline_parse_token_num_t cmd_write_reg_value =
3135 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3137 cmdline_parse_inst_t cmd_write_reg = {
3138 .f = cmd_write_reg_parsed,
3140 .help_str = "write reg port_id reg_off reg_value",
3142 (void *)&cmd_write_reg_write,
3143 (void *)&cmd_write_reg_reg,
3144 (void *)&cmd_write_reg_port_id,
3145 (void *)&cmd_write_reg_reg_off,
3146 (void *)&cmd_write_reg_value,
3151 /* *** WRITE PORT REGISTER BIT FIELD *** */
3152 struct cmd_write_reg_bit_field_result {
3153 cmdline_fixed_string_t write;
3154 cmdline_fixed_string_t regfield;
3163 cmd_write_reg_bit_field_parsed(void *parsed_result,
3164 __attribute__((unused)) struct cmdline *cl,
3165 __attribute__((unused)) void *data)
3167 struct cmd_write_reg_bit_field_result *res = parsed_result;
3168 port_reg_bit_field_set(res->port_id, res->reg_off,
3169 res->bit1_pos, res->bit2_pos, res->value);
3172 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3173 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3175 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3176 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3177 regfield, "regfield");
3178 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3179 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3181 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3182 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3184 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3185 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3187 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3188 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3190 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3191 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3194 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3195 .f = cmd_write_reg_bit_field_parsed,
3197 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3198 "(set register bit field between bit_x and bit_y included)",
3200 (void *)&cmd_write_reg_bit_field_write,
3201 (void *)&cmd_write_reg_bit_field_regfield,
3202 (void *)&cmd_write_reg_bit_field_port_id,
3203 (void *)&cmd_write_reg_bit_field_reg_off,
3204 (void *)&cmd_write_reg_bit_field_bit1_pos,
3205 (void *)&cmd_write_reg_bit_field_bit2_pos,
3206 (void *)&cmd_write_reg_bit_field_value,
3211 /* *** WRITE PORT REGISTER BIT *** */
3212 struct cmd_write_reg_bit_result {
3213 cmdline_fixed_string_t write;
3214 cmdline_fixed_string_t regbit;
3222 cmd_write_reg_bit_parsed(void *parsed_result,
3223 __attribute__((unused)) struct cmdline *cl,
3224 __attribute__((unused)) void *data)
3226 struct cmd_write_reg_bit_result *res = parsed_result;
3227 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3230 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3231 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3233 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3236 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3237 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3238 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3239 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3240 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3241 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3242 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3243 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3245 cmdline_parse_inst_t cmd_write_reg_bit = {
3246 .f = cmd_write_reg_bit_parsed,
3248 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3250 (void *)&cmd_write_reg_bit_write,
3251 (void *)&cmd_write_reg_bit_regbit,
3252 (void *)&cmd_write_reg_bit_port_id,
3253 (void *)&cmd_write_reg_bit_reg_off,
3254 (void *)&cmd_write_reg_bit_bit_pos,
3255 (void *)&cmd_write_reg_bit_value,
3260 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3261 struct cmd_read_rxd_txd_result {
3262 cmdline_fixed_string_t read;
3263 cmdline_fixed_string_t rxd_txd;
3270 cmd_read_rxd_txd_parsed(void *parsed_result,
3271 __attribute__((unused)) struct cmdline *cl,
3272 __attribute__((unused)) void *data)
3274 struct cmd_read_rxd_txd_result *res = parsed_result;
3276 if (!strcmp(res->rxd_txd, "rxd"))
3277 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3278 else if (!strcmp(res->rxd_txd, "txd"))
3279 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3282 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3283 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3284 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3285 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3287 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3288 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3289 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3290 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3291 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3292 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3294 cmdline_parse_inst_t cmd_read_rxd_txd = {
3295 .f = cmd_read_rxd_txd_parsed,
3297 .help_str = "read rxd|txd port_id queue_id rxd_id",
3299 (void *)&cmd_read_rxd_txd_read,
3300 (void *)&cmd_read_rxd_txd_rxd_txd,
3301 (void *)&cmd_read_rxd_txd_port_id,
3302 (void *)&cmd_read_rxd_txd_queue_id,
3303 (void *)&cmd_read_rxd_txd_desc_id,
3309 struct cmd_quit_result {
3310 cmdline_fixed_string_t quit;
3313 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3315 __attribute__((unused)) void *data)
3321 cmdline_parse_token_string_t cmd_quit_quit =
3322 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3324 cmdline_parse_inst_t cmd_quit = {
3325 .f = cmd_quit_parsed,
3327 .help_str = "exit application",
3329 (void *)&cmd_quit_quit,
3334 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3335 struct cmd_mac_addr_result {
3336 cmdline_fixed_string_t mac_addr_cmd;
3337 cmdline_fixed_string_t what;
3339 struct ether_addr address;
3342 static void cmd_mac_addr_parsed(void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 struct cmd_mac_addr_result *res = parsed_result;
3349 if (strcmp(res->what, "add") == 0)
3350 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3352 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3354 /* check the return value and print it if is < 0 */
3356 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3360 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3361 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3363 cmdline_parse_token_string_t cmd_mac_addr_what =
3364 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3366 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3367 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3368 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3369 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3371 cmdline_parse_inst_t cmd_mac_addr = {
3372 .f = cmd_mac_addr_parsed,
3374 .help_str = "mac_addr add|remove X <address>: "
3375 "add/remove MAC address on port X",
3377 (void *)&cmd_mac_addr_cmd,
3378 (void *)&cmd_mac_addr_what,
3379 (void *)&cmd_mac_addr_portnum,
3380 (void *)&cmd_mac_addr_addr,
3386 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3387 struct cmd_set_qmap_result {
3388 cmdline_fixed_string_t set;
3389 cmdline_fixed_string_t qmap;
3390 cmdline_fixed_string_t what;
3397 cmd_set_qmap_parsed(void *parsed_result,
3398 __attribute__((unused)) struct cmdline *cl,
3399 __attribute__((unused)) void *data)
3401 struct cmd_set_qmap_result *res = parsed_result;
3402 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3404 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3407 cmdline_parse_token_string_t cmd_setqmap_set =
3408 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3410 cmdline_parse_token_string_t cmd_setqmap_qmap =
3411 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3413 cmdline_parse_token_string_t cmd_setqmap_what =
3414 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3416 cmdline_parse_token_num_t cmd_setqmap_portid =
3417 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3419 cmdline_parse_token_num_t cmd_setqmap_queueid =
3420 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3422 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3423 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3426 cmdline_parse_inst_t cmd_set_qmap = {
3427 .f = cmd_set_qmap_parsed,
3429 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3431 (void *)&cmd_setqmap_set,
3432 (void *)&cmd_setqmap_qmap,
3433 (void *)&cmd_setqmap_what,
3434 (void *)&cmd_setqmap_portid,
3435 (void *)&cmd_setqmap_queueid,
3436 (void *)&cmd_setqmap_mapvalue,
3441 /* ******************************************************************************** */
3443 /* list of instructions */
3444 cmdline_parse_ctx_t main_ctx[] = {
3445 (cmdline_parse_inst_t *)&cmd_help,
3446 (cmdline_parse_inst_t *)&cmd_quit,
3447 (cmdline_parse_inst_t *)&cmd_showport,
3448 (cmdline_parse_inst_t *)&cmd_showportall,
3449 (cmdline_parse_inst_t *)&cmd_showcfg,
3450 (cmdline_parse_inst_t *)&cmd_start,
3451 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3452 (cmdline_parse_inst_t *)&cmd_reset,
3453 (cmdline_parse_inst_t *)&cmd_set_numbers,
3454 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3455 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3456 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3457 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3458 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3459 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3460 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3461 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3462 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3463 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3464 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3465 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3466 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3467 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3468 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3470 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
3471 (cmdline_parse_inst_t *)&cmd_config_dcb,
3472 (cmdline_parse_inst_t *)&cmd_read_reg,
3473 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3474 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3475 (cmdline_parse_inst_t *)&cmd_write_reg,
3476 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3477 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3478 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3479 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3480 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3481 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3482 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3483 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3484 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3485 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3486 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3487 (cmdline_parse_inst_t *)&cmd_stop,
3488 (cmdline_parse_inst_t *)&cmd_mac_addr,
3489 (cmdline_parse_inst_t *)&cmd_set_qmap,
3490 (cmdline_parse_inst_t *)&cmd_operate_port,
3491 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3492 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3493 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3494 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3495 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3496 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3497 (cmdline_parse_inst_t *)&cmd_config_rss,
3498 (cmdline_parse_inst_t *)&cmd_config_burst,
3499 (cmdline_parse_inst_t *)&cmd_config_thresh,
3500 (cmdline_parse_inst_t *)&cmd_config_threshold,
3504 /* prompt function, called from main on MASTER lcore */
3510 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3514 cmdline_interact(cl);
3515 cmdline_stdin_exit(cl);
3519 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3521 if (id < nb_ports) {
3522 /* check if need_reconfig has been set to 1 */
3523 if (ports[id].need_reconfig == 0)
3524 ports[id].need_reconfig = dev;
3525 /* check if need_reconfig_queues has been set to 1 */
3526 if (ports[id].need_reconfig_queues == 0)
3527 ports[id].need_reconfig_queues = queue;
3531 for (pid = 0; pid < nb_ports; pid++) {
3532 /* check if need_reconfig has been set to 1 */
3533 if (ports[pid].need_reconfig == 0)
3534 ports[pid].need_reconfig = dev;
3535 /* check if need_reconfig_queues has been set to 1 */
3536 if (ports[pid].need_reconfig_queues == 0)
3537 ports[pid].need_reconfig_queues = queue;