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 "- write reg port_id reg_off value\n"
178 " Set value of a port register\n"
179 "- write regfield port_id reg_off bit_x bit_y value\n"
180 " Set bit field value of a port register\n"
181 "- write regbit port_id reg_off bit_x value\n"
182 " Set bit value of a port register\n"
183 "- set stat_qmap tx|rx port_id queue_id qmapping\n"
184 " Set statistics mapping (qmapping 0..15) for tx|rx queue_id on port_id\n"
185 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2 on port 0 to mapping 5\n"
188 "Control forwarding:\n"
189 "-------------------\n"
191 " Start packet forwarding with current config\n"
193 " Start packet forwarding with current config"
194 " after sending one burst\n of packets\n"
196 " Stop packet forwarding, and displays accumulated"
200 "Flow director mode:\n"
201 "-------------------\n"
202 "- add_signature_filter port_id ip|udp|tcp|sctp src\n"
203 " ip_src_address port_src dst ip_dst_address port_dst\n"
204 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
205 "- upd_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 "- rm_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\n"
211 "- add_perfect_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 queue \n"
214 " queue_id soft soft_id\n"
215 "- upd_perfect_filter port_id ip|udp|tcp|sctp src\n"
216 " ip_src_address port_src dst ip_dst_address port_dst\n"
217 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
218 "- rm_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 soft soft_id\n"
221 "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
222 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
223 " port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
224 "- set_ipv6_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\n"
227 " vlan_prio 0|1 compare_dst 0|1\n"
232 "- port start|stop|close all|X\n"
233 " start/stop/close all ports or port X\n"
234 "- port config all|X speed 10|100|1000|10000|auto "
235 "duplex half|full|auto\n"
236 " set speed for all ports or port X\n"
237 "- port config all rxq|txq|rxd|txd value\n"
238 " set number for rxq/txq/rxd/txd\n"
239 "- port config all max-pkt-len value\n"
240 " set the max packet lenght\n"
241 "- port config all crc-strip|rx-cksum|hw-vlan|drop-en on|off\n"
242 " set crc-strip/rx-checksum/hardware-vlan/drop_en on or off"
244 "- port config all rss ip|udp|none\n"
246 "- port config all burst value\n"
247 " set the number of packet per burst\n"
248 "- port config all txpt|txht|txwt|rxpt|rxht|rxwt value\n"
249 " set ring prefetch/host/writeback threshold for "
251 "- port config all txfreet|txrst|rxfreet value\n"
252 " set free threshold for rx/tx, or set tx rs bit "
259 " Quit to prompt in linux, and reboot on baremetal\n"
263 cmdline_parse_token_string_t cmd_help_help =
264 TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
266 cmdline_parse_inst_t cmd_help = {
267 .f = cmd_help_parsed,
269 .help_str = "show help",
271 (void *)&cmd_help_help,
276 /* *** start/stop/close all ports *** */
277 struct cmd_operate_port_result {
278 cmdline_fixed_string_t keyword;
279 cmdline_fixed_string_t name;
280 cmdline_fixed_string_t value;
283 static void cmd_operate_port_parsed(void *parsed_result,
284 __attribute__((unused)) struct cmdline *cl,
285 __attribute__((unused)) void *data)
287 struct cmd_operate_port_result *res = parsed_result;
289 if (!strcmp(res->name, "start"))
290 start_port(RTE_PORT_ALL);
291 else if (!strcmp(res->name, "stop"))
292 stop_port(RTE_PORT_ALL);
293 else if (!strcmp(res->name, "close"))
294 close_port(RTE_PORT_ALL);
296 printf("Unknown parameter\n");
299 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
300 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
302 cmdline_parse_token_string_t cmd_operate_port_all_port =
303 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
305 cmdline_parse_token_string_t cmd_operate_port_all_all =
306 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
308 cmdline_parse_inst_t cmd_operate_port = {
309 .f = cmd_operate_port_parsed,
311 .help_str = "port start|stop|close all: start/stop/close all ports",
313 (void *)&cmd_operate_port_all_cmd,
314 (void *)&cmd_operate_port_all_port,
315 (void *)&cmd_operate_port_all_all,
320 /* *** start/stop/close specific port *** */
321 struct cmd_operate_specific_port_result {
322 cmdline_fixed_string_t keyword;
323 cmdline_fixed_string_t name;
327 static void cmd_operate_specific_port_parsed(void *parsed_result,
328 __attribute__((unused)) struct cmdline *cl,
329 __attribute__((unused)) void *data)
331 struct cmd_operate_specific_port_result *res = parsed_result;
333 if (!strcmp(res->name, "start"))
334 start_port(res->value);
335 else if (!strcmp(res->name, "stop"))
336 stop_port(res->value);
337 else if (!strcmp(res->name, "close"))
338 close_port(res->value);
340 printf("Unknown parameter\n");
343 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
344 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
346 cmdline_parse_token_string_t cmd_operate_specific_port_port =
347 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
348 name, "start#stop#close");
349 cmdline_parse_token_num_t cmd_operate_specific_port_id =
350 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
353 cmdline_parse_inst_t cmd_operate_specific_port = {
354 .f = cmd_operate_specific_port_parsed,
356 .help_str = "port start|stop|close X: start/stop/close port X",
358 (void *)&cmd_operate_specific_port_cmd,
359 (void *)&cmd_operate_specific_port_port,
360 (void *)&cmd_operate_specific_port_id,
365 /* *** configure speed for all ports *** */
366 struct cmd_config_speed_all {
367 cmdline_fixed_string_t port;
368 cmdline_fixed_string_t keyword;
369 cmdline_fixed_string_t all;
370 cmdline_fixed_string_t item1;
371 cmdline_fixed_string_t item2;
372 cmdline_fixed_string_t value1;
373 cmdline_fixed_string_t value2;
377 cmd_config_speed_all_parsed(void *parsed_result,
378 __attribute__((unused)) struct cmdline *cl,
379 __attribute__((unused)) void *data)
381 struct cmd_config_speed_all *res = parsed_result;
382 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
383 uint16_t link_duplex = 0;
386 if (!all_ports_stopped()) {
387 printf("Please stop all ports first\n");
391 if (!strcmp(res->value1, "10"))
392 link_speed = ETH_LINK_SPEED_10;
393 else if (!strcmp(res->value1, "100"))
394 link_speed = ETH_LINK_SPEED_100;
395 else if (!strcmp(res->value1, "1000"))
396 link_speed = ETH_LINK_SPEED_1000;
397 else if (!strcmp(res->value1, "10000"))
398 link_speed = ETH_LINK_SPEED_10000;
399 else if (!strcmp(res->value1, "auto"))
400 link_speed = ETH_LINK_SPEED_AUTONEG;
402 printf("Unknown parameter\n");
406 if (!strcmp(res->value2, "half"))
407 link_duplex = ETH_LINK_HALF_DUPLEX;
408 else if (!strcmp(res->value2, "full"))
409 link_duplex = ETH_LINK_FULL_DUPLEX;
410 else if (!strcmp(res->value2, "auto"))
411 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
413 printf("Unknown parameter\n");
417 for (pid = 0; pid < nb_ports; pid++) {
418 ports[pid].dev_conf.link_speed = link_speed;
419 ports[pid].dev_conf.link_duplex = link_duplex;
422 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
425 cmdline_parse_token_string_t cmd_config_speed_all_port =
426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
427 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
428 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
430 cmdline_parse_token_string_t cmd_config_speed_all_all =
431 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
432 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
434 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
435 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
436 "10#100#1000#10000#auto");
437 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
438 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
439 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
440 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
443 cmdline_parse_inst_t cmd_config_speed_all = {
444 .f = cmd_config_speed_all_parsed,
446 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
449 (void *)&cmd_config_speed_all_port,
450 (void *)&cmd_config_speed_all_keyword,
451 (void *)&cmd_config_speed_all_all,
452 (void *)&cmd_config_speed_all_item1,
453 (void *)&cmd_config_speed_all_value1,
454 (void *)&cmd_config_speed_all_item2,
455 (void *)&cmd_config_speed_all_value2,
460 /* *** configure speed for specific port *** */
461 struct cmd_config_speed_specific {
462 cmdline_fixed_string_t port;
463 cmdline_fixed_string_t keyword;
465 cmdline_fixed_string_t item1;
466 cmdline_fixed_string_t item2;
467 cmdline_fixed_string_t value1;
468 cmdline_fixed_string_t value2;
472 cmd_config_speed_specific_parsed(void *parsed_result,
473 __attribute__((unused)) struct cmdline *cl,
474 __attribute__((unused)) void *data)
476 struct cmd_config_speed_specific *res = parsed_result;
477 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
478 uint16_t link_duplex = 0;
480 if (!all_ports_stopped()) {
481 printf("Please stop all ports first\n");
485 if (res->id >= nb_ports) {
486 printf("Port id %d must be less than %d\n", res->id, nb_ports);
490 if (!strcmp(res->value1, "10"))
491 link_speed = ETH_LINK_SPEED_10;
492 else if (!strcmp(res->value1, "100"))
493 link_speed = ETH_LINK_SPEED_100;
494 else if (!strcmp(res->value1, "1000"))
495 link_speed = ETH_LINK_SPEED_1000;
496 else if (!strcmp(res->value1, "10000"))
497 link_speed = ETH_LINK_SPEED_10000;
498 else if (!strcmp(res->value1, "auto"))
499 link_speed = ETH_LINK_SPEED_AUTONEG;
501 printf("Unknown parameter\n");
505 if (!strcmp(res->value2, "half"))
506 link_duplex = ETH_LINK_HALF_DUPLEX;
507 else if (!strcmp(res->value2, "full"))
508 link_duplex = ETH_LINK_FULL_DUPLEX;
509 else if (!strcmp(res->value2, "auto"))
510 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
512 printf("Unknown parameter\n");
516 ports[res->id].dev_conf.link_speed = link_speed;
517 ports[res->id].dev_conf.link_duplex = link_duplex;
519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
523 cmdline_parse_token_string_t cmd_config_speed_specific_port =
524 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
526 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
527 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
529 cmdline_parse_token_num_t cmd_config_speed_specific_id =
530 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
531 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
532 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
534 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
535 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
536 "10#100#1000#10000#auto");
537 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
538 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
540 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
541 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
544 cmdline_parse_inst_t cmd_config_speed_specific = {
545 .f = cmd_config_speed_specific_parsed,
547 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
550 (void *)&cmd_config_speed_specific_port,
551 (void *)&cmd_config_speed_specific_keyword,
552 (void *)&cmd_config_speed_specific_id,
553 (void *)&cmd_config_speed_specific_item1,
554 (void *)&cmd_config_speed_specific_value1,
555 (void *)&cmd_config_speed_specific_item2,
556 (void *)&cmd_config_speed_specific_value2,
561 /* *** configure txq/rxq, txd/rxd *** */
562 struct cmd_config_rx_tx {
563 cmdline_fixed_string_t port;
564 cmdline_fixed_string_t keyword;
565 cmdline_fixed_string_t all;
566 cmdline_fixed_string_t name;
571 cmd_config_rx_tx_parsed(void *parsed_result,
572 __attribute__((unused)) struct cmdline *cl,
573 __attribute__((unused)) void *data)
575 struct cmd_config_rx_tx *res = parsed_result;
577 if (!all_ports_stopped()) {
578 printf("Please stop all ports first\n");
582 if (!strcmp(res->name, "rxq")) {
583 if (res->value <= 0) {
584 printf("rxq %d invalid - must be > 0\n", res->value);
589 else if (!strcmp(res->name, "txq")) {
590 if (res->value <= 0) {
591 printf("txq %d invalid - must be > 0\n", res->value);
596 else if (!strcmp(res->name, "rxd")) {
597 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
598 printf("rxd %d invalid - must be > 0 && <= %d\n",
599 res->value, RTE_TEST_RX_DESC_MAX);
603 } else if (!strcmp(res->name, "txd")) {
604 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
605 printf("txd %d invalid - must be > 0 && <= %d\n",
606 res->value, RTE_TEST_TX_DESC_MAX);
611 printf("Unknown parameter\n");
617 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
620 cmdline_parse_token_string_t cmd_config_rx_tx_port =
621 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
622 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
623 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
624 cmdline_parse_token_string_t cmd_config_rx_tx_all =
625 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
626 cmdline_parse_token_string_t cmd_config_rx_tx_name =
627 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
629 cmdline_parse_token_num_t cmd_config_rx_tx_value =
630 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
632 cmdline_parse_inst_t cmd_config_rx_tx = {
633 .f = cmd_config_rx_tx_parsed,
635 .help_str = "port config all rxq|txq|rxd|txd value",
637 (void *)&cmd_config_rx_tx_port,
638 (void *)&cmd_config_rx_tx_keyword,
639 (void *)&cmd_config_rx_tx_all,
640 (void *)&cmd_config_rx_tx_name,
641 (void *)&cmd_config_rx_tx_value,
646 /* *** config max packet length *** */
647 struct cmd_config_max_pkt_len_result {
648 cmdline_fixed_string_t port;
649 cmdline_fixed_string_t keyword;
650 cmdline_fixed_string_t all;
651 cmdline_fixed_string_t name;
656 cmd_config_max_pkt_len_parsed(void *parsed_result,
657 __attribute__((unused)) struct cmdline *cl,
658 __attribute__((unused)) void *data)
660 struct cmd_config_max_pkt_len_result *res = parsed_result;
662 if (!all_ports_stopped()) {
663 printf("Please stop all ports first\n");
667 if (!strcmp(res->name, "max-pkt-len")) {
668 if (res->value < ETHER_MIN_LEN) {
669 printf("max-pkt-len can not be less than %d\n",
673 if (res->value == rx_mode.max_rx_pkt_len)
676 rx_mode.max_rx_pkt_len = res->value;
677 if (res->value > ETHER_MAX_LEN)
678 rx_mode.jumbo_frame = 1;
680 rx_mode.jumbo_frame = 0;
682 printf("Unknown parameter\n");
688 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
691 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
692 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
694 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
695 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
697 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
698 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
700 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
701 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
703 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
704 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
707 cmdline_parse_inst_t cmd_config_max_pkt_len = {
708 .f = cmd_config_max_pkt_len_parsed,
710 .help_str = "port config all max-pkt-len value",
712 (void *)&cmd_config_max_pkt_len_port,
713 (void *)&cmd_config_max_pkt_len_keyword,
714 (void *)&cmd_config_max_pkt_len_all,
715 (void *)&cmd_config_max_pkt_len_name,
716 (void *)&cmd_config_max_pkt_len_value,
721 /* *** configure rx mode *** */
722 struct cmd_config_rx_mode_flag {
723 cmdline_fixed_string_t port;
724 cmdline_fixed_string_t keyword;
725 cmdline_fixed_string_t all;
726 cmdline_fixed_string_t name;
727 cmdline_fixed_string_t value;
731 cmd_config_rx_mode_flag_parsed(void *parsed_result,
732 __attribute__((unused)) struct cmdline *cl,
733 __attribute__((unused)) void *data)
735 struct cmd_config_rx_mode_flag *res = parsed_result;
737 if (!all_ports_stopped()) {
738 printf("Please stop all ports first\n");
742 if (!strcmp(res->name, "crc-strip")) {
743 if (!strcmp(res->value, "on"))
744 rx_mode.hw_strip_crc = 1;
745 else if (!strcmp(res->value, "off"))
746 rx_mode.hw_strip_crc = 0;
748 printf("Unknown parameter\n");
751 } else if (!strcmp(res->name, "rx-cksum")) {
752 if (!strcmp(res->value, "on"))
753 rx_mode.hw_ip_checksum = 1;
754 else if (!strcmp(res->value, "off"))
755 rx_mode.hw_ip_checksum = 0;
757 printf("Unknown parameter\n");
760 } else if (!strcmp(res->name, "hw-vlan")) {
761 if (!strcmp(res->value, "on")) {
762 rx_mode.hw_vlan_filter = 1;
763 rx_mode.hw_vlan_strip = 1;
765 else if (!strcmp(res->value, "off")) {
766 rx_mode.hw_vlan_filter = 0;
767 rx_mode.hw_vlan_strip = 0;
770 printf("Unknown parameter\n");
773 } else if (!strcmp(res->name, "drop-en")) {
774 if (!strcmp(res->value, "on"))
776 else if (!strcmp(res->value, "off"))
779 printf("Unknown parameter\n");
783 printf("Unknown parameter\n");
789 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
792 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
793 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
794 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
795 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
797 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
798 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
799 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
800 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
801 "crc-strip#rx-cksum#hw-vlan");
802 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
803 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
806 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
807 .f = cmd_config_rx_mode_flag_parsed,
809 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
811 (void *)&cmd_config_rx_mode_flag_port,
812 (void *)&cmd_config_rx_mode_flag_keyword,
813 (void *)&cmd_config_rx_mode_flag_all,
814 (void *)&cmd_config_rx_mode_flag_name,
815 (void *)&cmd_config_rx_mode_flag_value,
820 /* *** configure rss *** */
821 struct cmd_config_rss {
822 cmdline_fixed_string_t port;
823 cmdline_fixed_string_t keyword;
824 cmdline_fixed_string_t all;
825 cmdline_fixed_string_t name;
826 cmdline_fixed_string_t value;
830 cmd_config_rss_parsed(void *parsed_result,
831 __attribute__((unused)) struct cmdline *cl,
832 __attribute__((unused)) void *data)
834 struct cmd_config_rss *res = parsed_result;
836 if (!all_ports_stopped()) {
837 printf("Please stop all ports first\n");
841 if (!strcmp(res->value, "ip"))
842 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
843 else if (!strcmp(res->value, "udp"))
844 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
845 else if (!strcmp(res->value, "none"))
848 printf("Unknown parameter\n");
854 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
857 cmdline_parse_token_string_t cmd_config_rss_port =
858 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
859 cmdline_parse_token_string_t cmd_config_rss_keyword =
860 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
861 cmdline_parse_token_string_t cmd_config_rss_all =
862 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
863 cmdline_parse_token_string_t cmd_config_rss_name =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
865 cmdline_parse_token_string_t cmd_config_rss_value =
866 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
868 cmdline_parse_inst_t cmd_config_rss = {
869 .f = cmd_config_rss_parsed,
871 .help_str = "port config all rss ip|udp|none",
873 (void *)&cmd_config_rss_port,
874 (void *)&cmd_config_rss_keyword,
875 (void *)&cmd_config_rss_all,
876 (void *)&cmd_config_rss_name,
877 (void *)&cmd_config_rss_value,
882 /* *** configure number of packets per burst *** */
883 struct cmd_config_burst {
884 cmdline_fixed_string_t port;
885 cmdline_fixed_string_t keyword;
886 cmdline_fixed_string_t all;
887 cmdline_fixed_string_t name;
892 cmd_config_burst_parsed(void *parsed_result,
893 __attribute__((unused)) struct cmdline *cl,
894 __attribute__((unused)) void *data)
896 struct cmd_config_burst *res = parsed_result;
898 if (!all_ports_stopped()) {
899 printf("Please stop all ports first\n");
903 if (!strcmp(res->name, "burst")) {
904 if (res->value < 1 || res->value > MAX_PKT_BURST) {
905 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
908 nb_pkt_per_burst = res->value;
910 printf("Unknown parameter\n");
916 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
919 cmdline_parse_token_string_t cmd_config_burst_port =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
921 cmdline_parse_token_string_t cmd_config_burst_keyword =
922 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
923 cmdline_parse_token_string_t cmd_config_burst_all =
924 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
925 cmdline_parse_token_string_t cmd_config_burst_name =
926 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
927 cmdline_parse_token_num_t cmd_config_burst_value =
928 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
930 cmdline_parse_inst_t cmd_config_burst = {
931 .f = cmd_config_burst_parsed,
933 .help_str = "port config all burst value",
935 (void *)&cmd_config_burst_port,
936 (void *)&cmd_config_burst_keyword,
937 (void *)&cmd_config_burst_all,
938 (void *)&cmd_config_burst_name,
939 (void *)&cmd_config_burst_value,
944 /* *** configure rx/tx queues *** */
945 struct cmd_config_thresh {
946 cmdline_fixed_string_t port;
947 cmdline_fixed_string_t keyword;
948 cmdline_fixed_string_t all;
949 cmdline_fixed_string_t name;
954 cmd_config_thresh_parsed(void *parsed_result,
955 __attribute__((unused)) struct cmdline *cl,
956 __attribute__((unused)) void *data)
958 struct cmd_config_thresh *res = parsed_result;
960 if (!all_ports_stopped()) {
961 printf("Please stop all ports first\n");
965 if (!strcmp(res->name, "txpt"))
966 tx_thresh.pthresh = res->value;
967 else if(!strcmp(res->name, "txht"))
968 tx_thresh.hthresh = res->value;
969 else if(!strcmp(res->name, "txwt"))
970 tx_thresh.wthresh = res->value;
971 else if(!strcmp(res->name, "rxpt"))
972 rx_thresh.pthresh = res->value;
973 else if(!strcmp(res->name, "rxht"))
974 rx_thresh.hthresh = res->value;
975 else if(!strcmp(res->name, "rxwt"))
976 rx_thresh.wthresh = res->value;
978 printf("Unknown parameter\n");
984 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
987 cmdline_parse_token_string_t cmd_config_thresh_port =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
989 cmdline_parse_token_string_t cmd_config_thresh_keyword =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
991 cmdline_parse_token_string_t cmd_config_thresh_all =
992 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
993 cmdline_parse_token_string_t cmd_config_thresh_name =
994 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
995 "txpt#txht#txwt#rxpt#rxht#rxwt");
996 cmdline_parse_token_num_t cmd_config_thresh_value =
997 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
999 cmdline_parse_inst_t cmd_config_thresh = {
1000 .f = cmd_config_thresh_parsed,
1002 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1004 (void *)&cmd_config_thresh_port,
1005 (void *)&cmd_config_thresh_keyword,
1006 (void *)&cmd_config_thresh_all,
1007 (void *)&cmd_config_thresh_name,
1008 (void *)&cmd_config_thresh_value,
1013 /* *** configure free/rs threshold *** */
1014 struct cmd_config_threshold {
1015 cmdline_fixed_string_t port;
1016 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t all;
1018 cmdline_fixed_string_t name;
1023 cmd_config_threshold_parsed(void *parsed_result,
1024 __attribute__((unused)) struct cmdline *cl,
1025 __attribute__((unused)) void *data)
1027 struct cmd_config_threshold *res = parsed_result;
1029 if (!all_ports_stopped()) {
1030 printf("Please stop all ports first\n");
1034 if (!strcmp(res->name, "txfreet"))
1035 tx_free_thresh = res->value;
1036 else if (!strcmp(res->name, "txrst"))
1037 tx_rs_thresh = res->value;
1038 else if (!strcmp(res->name, "rxfreet"))
1039 rx_free_thresh = res->value;
1041 printf("Unknown parameter\n");
1047 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1050 cmdline_parse_token_string_t cmd_config_threshold_port =
1051 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1052 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1053 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1055 cmdline_parse_token_string_t cmd_config_threshold_all =
1056 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1057 cmdline_parse_token_string_t cmd_config_threshold_name =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1059 "txfreet#txrst#rxfreet");
1060 cmdline_parse_token_num_t cmd_config_threshold_value =
1061 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1063 cmdline_parse_inst_t cmd_config_threshold = {
1064 .f = cmd_config_threshold_parsed,
1066 .help_str = "port config all txfreet|txrst|rxfreet value",
1068 (void *)&cmd_config_threshold_port,
1069 (void *)&cmd_config_threshold_keyword,
1070 (void *)&cmd_config_threshold_all,
1071 (void *)&cmd_config_threshold_name,
1072 (void *)&cmd_config_threshold_value,
1078 struct cmd_stop_result {
1079 cmdline_fixed_string_t stop;
1082 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1083 __attribute__((unused)) struct cmdline *cl,
1084 __attribute__((unused)) void *data)
1086 stop_packet_forwarding();
1089 cmdline_parse_token_string_t cmd_stop_stop =
1090 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1092 cmdline_parse_inst_t cmd_stop = {
1093 .f = cmd_stop_parsed,
1095 .help_str = "stop - stop packet forwarding",
1097 (void *)&cmd_stop_stop,
1102 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1105 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1106 unsigned int *parsed_items, int check_unique_values)
1108 unsigned int nb_item;
1116 * First parse all items in the list and store their value.
1121 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1123 if ((c >= '0') && (c <= '9')) {
1124 value = (unsigned int) (value * 10 + (c - '0'));
1129 printf("character %c is not a decimal digit\n", c);
1133 printf("No valid value before comma\n");
1136 if (nb_item < max_items) {
1137 parsed_items[nb_item] = value;
1143 if (nb_item >= max_items) {
1144 printf("Number of %s = %u > %u (maximum items)\n",
1145 item_name, nb_item + 1, max_items);
1148 parsed_items[nb_item++] = value;
1149 if (! check_unique_values)
1153 * Then, check that all values in the list are differents.
1154 * No optimization here...
1156 for (i = 0; i < nb_item; i++) {
1157 for (j = i + 1; j < nb_item; j++) {
1158 if (parsed_items[j] == parsed_items[i]) {
1159 printf("duplicated %s %u at index %u and %u\n",
1160 item_name, parsed_items[i], i, j);
1168 struct cmd_set_list_result {
1169 cmdline_fixed_string_t cmd_keyword;
1170 cmdline_fixed_string_t list_name;
1171 cmdline_fixed_string_t list_of_items;
1174 static void cmd_set_list_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_set_list_result *res;
1180 unsigned int lcorelist[RTE_MAX_LCORE];
1181 unsigned int portlist[RTE_MAX_ETHPORTS];
1183 unsigned int nb_item;
1185 res = parsed_result;
1186 if (!strcmp(res->list_name, "corelist")) {
1187 nb_item = parse_item_list(res->list_of_items, "core",
1189 parsed_items.lcorelist, 1);
1191 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1194 if (!strcmp(res->list_name, "portlist")) {
1195 nb_item = parse_item_list(res->list_of_items, "port",
1197 parsed_items.portlist, 1);
1199 set_fwd_ports_list(parsed_items.portlist, nb_item);
1203 cmdline_parse_token_string_t cmd_set_list_keyword =
1204 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1206 cmdline_parse_token_string_t cmd_set_list_name =
1207 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1208 "corelist#portlist");
1209 cmdline_parse_token_string_t cmd_set_list_of_items =
1210 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1213 cmdline_parse_inst_t cmd_set_fwd_list = {
1214 .f = cmd_set_list_parsed,
1216 .help_str = "set corelist|portlist x[,y]*",
1218 (void *)&cmd_set_list_keyword,
1219 (void *)&cmd_set_list_name,
1220 (void *)&cmd_set_list_of_items,
1225 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1227 struct cmd_setmask_result {
1228 cmdline_fixed_string_t set;
1229 cmdline_fixed_string_t mask;
1233 static void cmd_set_mask_parsed(void *parsed_result,
1234 __attribute__((unused)) struct cmdline *cl,
1235 __attribute__((unused)) void *data)
1237 struct cmd_setmask_result *res = parsed_result;
1239 if (!strcmp(res->mask, "coremask"))
1240 set_fwd_lcores_mask(res->hexavalue);
1241 else if (!strcmp(res->mask, "portmask"))
1242 set_fwd_ports_mask(res->hexavalue);
1245 cmdline_parse_token_string_t cmd_setmask_set =
1246 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1247 cmdline_parse_token_string_t cmd_setmask_mask =
1248 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1249 "coremask#portmask");
1250 cmdline_parse_token_num_t cmd_setmask_value =
1251 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1253 cmdline_parse_inst_t cmd_set_fwd_mask = {
1254 .f = cmd_set_mask_parsed,
1256 .help_str = "set coremask|portmask hexadecimal value",
1258 (void *)&cmd_setmask_set,
1259 (void *)&cmd_setmask_mask,
1260 (void *)&cmd_setmask_value,
1266 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1268 struct cmd_set_result {
1269 cmdline_fixed_string_t set;
1270 cmdline_fixed_string_t what;
1274 static void cmd_set_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_set_result *res = parsed_result;
1279 if (!strcmp(res->what, "nbport"))
1280 set_fwd_ports_number(res->value);
1281 else if (!strcmp(res->what, "nbcore"))
1282 set_fwd_lcores_number(res->value);
1283 else if (!strcmp(res->what, "burst"))
1284 set_nb_pkt_per_burst(res->value);
1285 else if (!strcmp(res->what, "verbose"))
1286 set_verbose_level(res->value);
1289 cmdline_parse_token_string_t cmd_set_set =
1290 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1291 cmdline_parse_token_string_t cmd_set_what =
1292 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1293 "nbport#nbcore#burst#verbose");
1294 cmdline_parse_token_num_t cmd_set_value =
1295 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1297 cmdline_parse_inst_t cmd_set_numbers = {
1298 .f = cmd_set_parsed,
1300 .help_str = "set nbport|nbcore|burst|verbose value",
1302 (void *)&cmd_set_set,
1303 (void *)&cmd_set_what,
1304 (void *)&cmd_set_value,
1309 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1311 struct cmd_set_txpkts_result {
1312 cmdline_fixed_string_t cmd_keyword;
1313 cmdline_fixed_string_t txpkts;
1314 cmdline_fixed_string_t seg_lengths;
1318 cmd_set_txpkts_parsed(void *parsed_result,
1319 __attribute__((unused)) struct cmdline *cl,
1320 __attribute__((unused)) void *data)
1322 struct cmd_set_txpkts_result *res;
1323 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1324 unsigned int nb_segs;
1326 res = parsed_result;
1327 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1328 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1330 set_tx_pkt_segments(seg_lengths, nb_segs);
1333 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1334 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1335 cmd_keyword, "set");
1336 cmdline_parse_token_string_t cmd_set_txpkts_name =
1337 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1339 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1340 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1343 cmdline_parse_inst_t cmd_set_txpkts = {
1344 .f = cmd_set_txpkts_parsed,
1346 .help_str = "set txpkts x[,y]*",
1348 (void *)&cmd_set_txpkts_keyword,
1349 (void *)&cmd_set_txpkts_name,
1350 (void *)&cmd_set_txpkts_lengths,
1355 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1356 struct cmd_rx_vlan_filter_all_result {
1357 cmdline_fixed_string_t rx_vlan;
1358 cmdline_fixed_string_t what;
1359 cmdline_fixed_string_t all;
1364 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1370 if (!strcmp(res->what, "add"))
1371 rx_vlan_all_filter_set(res->port_id, 1);
1373 rx_vlan_all_filter_set(res->port_id, 0);
1376 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1377 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1378 rx_vlan, "rx_vlan");
1379 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1380 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1382 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1383 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1385 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1386 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1389 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1390 .f = cmd_rx_vlan_filter_all_parsed,
1392 .help_str = "add/remove all identifiers to/from the set of VLAN "
1393 "Identifiers filtered by a port",
1395 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1396 (void *)&cmd_rx_vlan_filter_all_what,
1397 (void *)&cmd_rx_vlan_filter_all_all,
1398 (void *)&cmd_rx_vlan_filter_all_portid,
1403 /* *** VLAN OFFLOAD SET ON A PORT *** */
1404 struct cmd_vlan_offload_result {
1405 cmdline_fixed_string_t vlan;
1406 cmdline_fixed_string_t set;
1407 cmdline_fixed_string_t what;
1408 cmdline_fixed_string_t on;
1409 cmdline_fixed_string_t port_id;
1413 cmd_vlan_offload_parsed(void *parsed_result,
1414 __attribute__((unused)) struct cmdline *cl,
1415 __attribute__((unused)) void *data)
1418 struct cmd_vlan_offload_result *res = parsed_result;
1421 portid_t port_id = 0;
1425 len = strnlen(str, STR_TOKEN_SIZE);
1427 /* Get port_id first */
1435 tmp = strtoul(str, NULL, 0);
1436 /* If port_id greater that what portid_t can represent, return */
1439 port_id = (portid_t)tmp;
1441 if (!strcmp(res->on, "on"))
1446 if (!strcmp(res->what, "strip"))
1447 rx_vlan_strip_set(port_id, on);
1448 else if(!strcmp(res->what, "stripq")){
1449 uint16_t queue_id = 0;
1451 /* No queue_id, return */
1454 tmp = strtoul(str + i + 1, NULL, 0);
1455 /* If queue_id greater that what 16-bits can represent, return */
1459 queue_id = (uint16_t)tmp;
1460 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1462 else if (!strcmp(res->what, "filter"))
1463 rx_vlan_filter_set(port_id, on);
1465 vlan_extend_set(port_id, on);
1470 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1471 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1473 cmdline_parse_token_string_t cmd_vlan_offload_set =
1474 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1476 cmdline_parse_token_string_t cmd_vlan_offload_what =
1477 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1478 what, "strip#filter#qinq#stripq");
1479 cmdline_parse_token_string_t cmd_vlan_offload_on =
1480 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1482 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1483 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1486 cmdline_parse_inst_t cmd_vlan_offload = {
1487 .f = cmd_vlan_offload_parsed,
1489 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1490 " qinq(extended) for both rx/tx sides ",
1492 (void *)&cmd_vlan_offload_vlan,
1493 (void *)&cmd_vlan_offload_set,
1494 (void *)&cmd_vlan_offload_what,
1495 (void *)&cmd_vlan_offload_on,
1496 (void *)&cmd_vlan_offload_portid,
1501 /* *** VLAN TPID SET ON A PORT *** */
1502 struct cmd_vlan_tpid_result {
1503 cmdline_fixed_string_t vlan;
1504 cmdline_fixed_string_t set;
1505 cmdline_fixed_string_t what;
1511 cmd_vlan_tpid_parsed(void *parsed_result,
1512 __attribute__((unused)) struct cmdline *cl,
1513 __attribute__((unused)) void *data)
1515 struct cmd_vlan_tpid_result *res = parsed_result;
1516 vlan_tpid_set(res->port_id, res->tp_id);
1520 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1521 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1523 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1524 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1526 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1527 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1529 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
1530 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1532 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
1533 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1536 cmdline_parse_inst_t cmd_vlan_tpid = {
1537 .f = cmd_vlan_tpid_parsed,
1539 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
1541 (void *)&cmd_vlan_tpid_vlan,
1542 (void *)&cmd_vlan_tpid_set,
1543 (void *)&cmd_vlan_tpid_what,
1544 (void *)&cmd_vlan_tpid_tpid,
1545 (void *)&cmd_vlan_tpid_portid,
1550 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
1551 struct cmd_rx_vlan_filter_result {
1552 cmdline_fixed_string_t rx_vlan;
1553 cmdline_fixed_string_t what;
1559 cmd_rx_vlan_filter_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_rx_vlan_filter_result *res = parsed_result;
1565 if (!strcmp(res->what, "add"))
1566 rx_vft_set(res->port_id, res->vlan_id, 1);
1568 rx_vft_set(res->port_id, res->vlan_id, 0);
1571 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
1572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1573 rx_vlan, "rx_vlan");
1574 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
1575 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1577 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
1578 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1580 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
1581 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1584 cmdline_parse_inst_t cmd_rx_vlan_filter = {
1585 .f = cmd_rx_vlan_filter_parsed,
1587 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
1588 "Identifiers filtered by a port",
1590 (void *)&cmd_rx_vlan_filter_rx_vlan,
1591 (void *)&cmd_rx_vlan_filter_what,
1592 (void *)&cmd_rx_vlan_filter_vlanid,
1593 (void *)&cmd_rx_vlan_filter_portid,
1598 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1599 struct cmd_tx_vlan_set_result {
1600 cmdline_fixed_string_t tx_vlan;
1601 cmdline_fixed_string_t set;
1607 cmd_tx_vlan_set_parsed(void *parsed_result,
1608 __attribute__((unused)) struct cmdline *cl,
1609 __attribute__((unused)) void *data)
1611 struct cmd_tx_vlan_set_result *res = parsed_result;
1612 tx_vlan_set(res->port_id, res->vlan_id);
1615 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
1616 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1617 tx_vlan, "tx_vlan");
1618 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
1619 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1621 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
1622 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1624 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
1625 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1628 cmdline_parse_inst_t cmd_tx_vlan_set = {
1629 .f = cmd_tx_vlan_set_parsed,
1631 .help_str = "enable hardware insertion of a VLAN header with a given "
1632 "TAG Identifier in packets sent on a port",
1634 (void *)&cmd_tx_vlan_set_tx_vlan,
1635 (void *)&cmd_tx_vlan_set_set,
1636 (void *)&cmd_tx_vlan_set_vlanid,
1637 (void *)&cmd_tx_vlan_set_portid,
1642 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1643 struct cmd_tx_vlan_reset_result {
1644 cmdline_fixed_string_t tx_vlan;
1645 cmdline_fixed_string_t reset;
1650 cmd_tx_vlan_reset_parsed(void *parsed_result,
1651 __attribute__((unused)) struct cmdline *cl,
1652 __attribute__((unused)) void *data)
1654 struct cmd_tx_vlan_reset_result *res = parsed_result;
1656 tx_vlan_reset(res->port_id);
1659 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
1660 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1661 tx_vlan, "tx_vlan");
1662 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
1663 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1665 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
1666 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
1669 cmdline_parse_inst_t cmd_tx_vlan_reset = {
1670 .f = cmd_tx_vlan_reset_parsed,
1672 .help_str = "disable hardware insertion of a VLAN header in packets "
1675 (void *)&cmd_tx_vlan_reset_tx_vlan,
1676 (void *)&cmd_tx_vlan_reset_reset,
1677 (void *)&cmd_tx_vlan_reset_portid,
1683 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
1684 struct cmd_tx_cksum_set_result {
1685 cmdline_fixed_string_t tx_cksum;
1686 cmdline_fixed_string_t set;
1692 cmd_tx_cksum_set_parsed(void *parsed_result,
1693 __attribute__((unused)) struct cmdline *cl,
1694 __attribute__((unused)) void *data)
1696 struct cmd_tx_cksum_set_result *res = parsed_result;
1698 tx_cksum_set(res->port_id, res->cksum_mask);
1701 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
1702 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1703 tx_cksum, "tx_checksum");
1704 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
1705 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1707 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
1708 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1710 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
1711 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1714 cmdline_parse_inst_t cmd_tx_cksum_set = {
1715 .f = cmd_tx_cksum_set_parsed,
1717 .help_str = "enable hardware insertion of L3/L4checksum with a given "
1718 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
1719 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
1721 (void *)&cmd_tx_cksum_set_tx_cksum,
1722 (void *)&cmd_tx_cksum_set_set,
1723 (void *)&cmd_tx_cksum_set_cksum_mask,
1724 (void *)&cmd_tx_cksum_set_portid,
1729 /* *** SET FORWARDING MODE *** */
1730 struct cmd_set_fwd_mode_result {
1731 cmdline_fixed_string_t set;
1732 cmdline_fixed_string_t fwd;
1733 cmdline_fixed_string_t mode;
1736 static void cmd_set_fwd_mode_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_set_fwd_mode_result *res = parsed_result;
1742 set_pkt_forwarding_mode(res->mode);
1745 cmdline_parse_token_string_t cmd_setfwd_set =
1746 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
1747 cmdline_parse_token_string_t cmd_setfwd_fwd =
1748 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
1749 cmdline_parse_token_string_t cmd_setfwd_mode =
1750 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
1751 #ifdef RTE_LIBRTE_IEEE1588
1752 "io#mac#rxonly#txonly#csum#ieee1588");
1754 "io#mac#rxonly#txonly#csum");
1757 cmdline_parse_inst_t cmd_set_fwd_mode = {
1758 .f = cmd_set_fwd_mode_parsed,
1760 #ifdef RTE_LIBRTE_IEEE1588
1761 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
1762 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
1764 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
1765 " RXONLY, CSUM or TXONLY packet forwarding mode",
1768 (void *)&cmd_setfwd_set,
1769 (void *)&cmd_setfwd_fwd,
1770 (void *)&cmd_setfwd_mode,
1775 /* *** SET PROMISC MODE *** */
1776 struct cmd_set_promisc_mode_result {
1777 cmdline_fixed_string_t set;
1778 cmdline_fixed_string_t promisc;
1779 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1780 uint8_t port_num; /* valid if "allports" argument == 0 */
1781 cmdline_fixed_string_t mode;
1784 static void cmd_set_promisc_mode_parsed(void *parsed_result,
1785 __attribute__((unused)) struct cmdline *cl,
1788 struct cmd_set_promisc_mode_result *res = parsed_result;
1792 if (!strcmp(res->mode, "on"))
1799 for (i = 0; i < nb_ports; i++) {
1801 rte_eth_promiscuous_enable(i);
1803 rte_eth_promiscuous_disable(i);
1808 rte_eth_promiscuous_enable(res->port_num);
1810 rte_eth_promiscuous_disable(res->port_num);
1814 cmdline_parse_token_string_t cmd_setpromisc_set =
1815 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
1816 cmdline_parse_token_string_t cmd_setpromisc_promisc =
1817 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
1819 cmdline_parse_token_string_t cmd_setpromisc_portall =
1820 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
1822 cmdline_parse_token_num_t cmd_setpromisc_portnum =
1823 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
1825 cmdline_parse_token_string_t cmd_setpromisc_mode =
1826 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
1829 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
1830 .f = cmd_set_promisc_mode_parsed,
1832 .help_str = "set promisc all on|off: set promisc mode for all ports",
1834 (void *)&cmd_setpromisc_set,
1835 (void *)&cmd_setpromisc_promisc,
1836 (void *)&cmd_setpromisc_portall,
1837 (void *)&cmd_setpromisc_mode,
1842 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
1843 .f = cmd_set_promisc_mode_parsed,
1845 .help_str = "set promisc X on|off: set promisc mode on port X",
1847 (void *)&cmd_setpromisc_set,
1848 (void *)&cmd_setpromisc_promisc,
1849 (void *)&cmd_setpromisc_portnum,
1850 (void *)&cmd_setpromisc_mode,
1855 /* *** SET ALLMULTI MODE *** */
1856 struct cmd_set_allmulti_mode_result {
1857 cmdline_fixed_string_t set;
1858 cmdline_fixed_string_t allmulti;
1859 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1860 uint8_t port_num; /* valid if "allports" argument == 0 */
1861 cmdline_fixed_string_t mode;
1864 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
1865 __attribute__((unused)) struct cmdline *cl,
1868 struct cmd_set_allmulti_mode_result *res = parsed_result;
1872 if (!strcmp(res->mode, "on"))
1879 for (i = 0; i < nb_ports; i++) {
1881 rte_eth_allmulticast_enable(i);
1883 rte_eth_allmulticast_disable(i);
1888 rte_eth_allmulticast_enable(res->port_num);
1890 rte_eth_allmulticast_disable(res->port_num);
1894 cmdline_parse_token_string_t cmd_setallmulti_set =
1895 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
1896 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
1897 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
1899 cmdline_parse_token_string_t cmd_setallmulti_portall =
1900 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
1902 cmdline_parse_token_num_t cmd_setallmulti_portnum =
1903 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
1905 cmdline_parse_token_string_t cmd_setallmulti_mode =
1906 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
1909 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
1910 .f = cmd_set_allmulti_mode_parsed,
1912 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
1914 (void *)&cmd_setallmulti_set,
1915 (void *)&cmd_setallmulti_allmulti,
1916 (void *)&cmd_setallmulti_portall,
1917 (void *)&cmd_setallmulti_mode,
1922 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
1923 .f = cmd_set_allmulti_mode_parsed,
1925 .help_str = "set allmulti X on|off: set allmulti mode on port X",
1927 (void *)&cmd_setallmulti_set,
1928 (void *)&cmd_setallmulti_allmulti,
1929 (void *)&cmd_setallmulti_portnum,
1930 (void *)&cmd_setallmulti_mode,
1935 /* *** ADD/REMOVE A PKT FILTER *** */
1936 struct cmd_pkt_filter_result {
1937 cmdline_fixed_string_t pkt_filter;
1939 cmdline_fixed_string_t protocol;
1940 cmdline_fixed_string_t src;
1941 cmdline_ipaddr_t ip_src;
1943 cmdline_fixed_string_t dst;
1944 cmdline_ipaddr_t ip_dst;
1946 cmdline_fixed_string_t flexbytes;
1947 uint16_t flexbytes_value;
1948 cmdline_fixed_string_t vlan;
1950 cmdline_fixed_string_t queue;
1952 cmdline_fixed_string_t soft;
1957 cmd_pkt_filter_parsed(void *parsed_result,
1958 __attribute__((unused)) struct cmdline *cl,
1959 __attribute__((unused)) void *data)
1961 struct rte_fdir_filter fdir_filter;
1962 struct cmd_pkt_filter_result *res = parsed_result;
1964 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
1966 if (res->ip_src.family == AF_INET)
1967 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
1969 memcpy(&(fdir_filter.ip_src.ipv6_addr),
1970 &(res->ip_src.addr.ipv6),
1971 sizeof(struct in6_addr));
1973 if (res->ip_dst.family == AF_INET)
1974 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
1976 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
1977 &(res->ip_dst.addr.ipv6),
1978 sizeof(struct in6_addr));
1980 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
1981 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
1983 if (!strcmp(res->protocol, "udp"))
1984 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
1985 else if (!strcmp(res->protocol, "tcp"))
1986 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
1987 else if (!strcmp(res->protocol, "sctp"))
1988 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
1989 else /* default only IP */
1990 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
1992 if (res->ip_dst.family == AF_INET6)
1993 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
1995 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
1997 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
1998 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2000 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2001 fdir_add_signature_filter(res->port_id, res->queue_id,
2003 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2004 fdir_update_signature_filter(res->port_id, res->queue_id,
2006 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2007 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2008 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2009 fdir_add_perfect_filter(res->port_id, res->soft_id,
2011 (uint8_t) (res->queue_id < 0),
2013 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2014 fdir_update_perfect_filter(res->port_id, res->soft_id,
2016 (uint8_t) (res->queue_id < 0),
2018 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2019 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2025 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2026 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2028 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2029 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2030 protocol, "ip#tcp#udp#sctp");
2031 cmdline_parse_token_string_t cmd_pkt_filter_src =
2032 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2034 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2035 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2037 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2038 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2040 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2041 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2043 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2044 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2046 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2047 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2049 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2050 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2051 flexbytes, "flexbytes");
2052 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2053 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2054 flexbytes_value, UINT16);
2055 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2056 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2058 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2059 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2061 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2062 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2064 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2065 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2067 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2068 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2070 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2071 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2075 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2076 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2077 pkt_filter, "add_signature_filter");
2078 cmdline_parse_inst_t cmd_add_signature_filter = {
2079 .f = cmd_pkt_filter_parsed,
2081 .help_str = "add a signature filter",
2083 (void *)&cmd_pkt_filter_add_signature_filter,
2084 (void *)&cmd_pkt_filter_port_id,
2085 (void *)&cmd_pkt_filter_protocol,
2086 (void *)&cmd_pkt_filter_src,
2087 (void *)&cmd_pkt_filter_ip_src,
2088 (void *)&cmd_pkt_filter_port_src,
2089 (void *)&cmd_pkt_filter_dst,
2090 (void *)&cmd_pkt_filter_ip_dst,
2091 (void *)&cmd_pkt_filter_port_dst,
2092 (void *)&cmd_pkt_filter_flexbytes,
2093 (void *)&cmd_pkt_filter_flexbytes_value,
2094 (void *)&cmd_pkt_filter_vlan,
2095 (void *)&cmd_pkt_filter_vlan_id,
2096 (void *)&cmd_pkt_filter_queue,
2097 (void *)&cmd_pkt_filter_queue_id,
2103 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2104 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2105 pkt_filter, "upd_signature_filter");
2106 cmdline_parse_inst_t cmd_upd_signature_filter = {
2107 .f = cmd_pkt_filter_parsed,
2109 .help_str = "update a signature filter",
2111 (void *)&cmd_pkt_filter_upd_signature_filter,
2112 (void *)&cmd_pkt_filter_port_id,
2113 (void *)&cmd_pkt_filter_protocol,
2114 (void *)&cmd_pkt_filter_src,
2115 (void *)&cmd_pkt_filter_ip_src,
2116 (void *)&cmd_pkt_filter_port_src,
2117 (void *)&cmd_pkt_filter_dst,
2118 (void *)&cmd_pkt_filter_ip_dst,
2119 (void *)&cmd_pkt_filter_port_dst,
2120 (void *)&cmd_pkt_filter_flexbytes,
2121 (void *)&cmd_pkt_filter_flexbytes_value,
2122 (void *)&cmd_pkt_filter_vlan,
2123 (void *)&cmd_pkt_filter_vlan_id,
2124 (void *)&cmd_pkt_filter_queue,
2125 (void *)&cmd_pkt_filter_queue_id,
2131 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2132 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2133 pkt_filter, "rm_signature_filter");
2134 cmdline_parse_inst_t cmd_rm_signature_filter = {
2135 .f = cmd_pkt_filter_parsed,
2137 .help_str = "remove a signature filter",
2139 (void *)&cmd_pkt_filter_rm_signature_filter,
2140 (void *)&cmd_pkt_filter_port_id,
2141 (void *)&cmd_pkt_filter_protocol,
2142 (void *)&cmd_pkt_filter_src,
2143 (void *)&cmd_pkt_filter_ip_src,
2144 (void *)&cmd_pkt_filter_port_src,
2145 (void *)&cmd_pkt_filter_dst,
2146 (void *)&cmd_pkt_filter_ip_dst,
2147 (void *)&cmd_pkt_filter_port_dst,
2148 (void *)&cmd_pkt_filter_flexbytes,
2149 (void *)&cmd_pkt_filter_flexbytes_value,
2150 (void *)&cmd_pkt_filter_vlan,
2151 (void *)&cmd_pkt_filter_vlan_id,
2157 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2158 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2159 pkt_filter, "add_perfect_filter");
2160 cmdline_parse_inst_t cmd_add_perfect_filter = {
2161 .f = cmd_pkt_filter_parsed,
2163 .help_str = "add a perfect filter",
2165 (void *)&cmd_pkt_filter_add_perfect_filter,
2166 (void *)&cmd_pkt_filter_port_id,
2167 (void *)&cmd_pkt_filter_protocol,
2168 (void *)&cmd_pkt_filter_src,
2169 (void *)&cmd_pkt_filter_ip_src,
2170 (void *)&cmd_pkt_filter_port_src,
2171 (void *)&cmd_pkt_filter_dst,
2172 (void *)&cmd_pkt_filter_ip_dst,
2173 (void *)&cmd_pkt_filter_port_dst,
2174 (void *)&cmd_pkt_filter_flexbytes,
2175 (void *)&cmd_pkt_filter_flexbytes_value,
2176 (void *)&cmd_pkt_filter_vlan,
2177 (void *)&cmd_pkt_filter_vlan_id,
2178 (void *)&cmd_pkt_filter_queue,
2179 (void *)&cmd_pkt_filter_queue_id,
2180 (void *)&cmd_pkt_filter_soft,
2181 (void *)&cmd_pkt_filter_soft_id,
2187 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2188 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2189 pkt_filter, "upd_perfect_filter");
2190 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2191 .f = cmd_pkt_filter_parsed,
2193 .help_str = "update a perfect filter",
2195 (void *)&cmd_pkt_filter_upd_perfect_filter,
2196 (void *)&cmd_pkt_filter_port_id,
2197 (void *)&cmd_pkt_filter_protocol,
2198 (void *)&cmd_pkt_filter_src,
2199 (void *)&cmd_pkt_filter_ip_src,
2200 (void *)&cmd_pkt_filter_port_src,
2201 (void *)&cmd_pkt_filter_dst,
2202 (void *)&cmd_pkt_filter_ip_dst,
2203 (void *)&cmd_pkt_filter_port_dst,
2204 (void *)&cmd_pkt_filter_flexbytes,
2205 (void *)&cmd_pkt_filter_flexbytes_value,
2206 (void *)&cmd_pkt_filter_vlan,
2207 (void *)&cmd_pkt_filter_vlan_id,
2208 (void *)&cmd_pkt_filter_queue,
2209 (void *)&cmd_pkt_filter_queue_id,
2210 (void *)&cmd_pkt_filter_soft,
2211 (void *)&cmd_pkt_filter_soft_id,
2217 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2218 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2219 pkt_filter, "rm_perfect_filter");
2220 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2221 .f = cmd_pkt_filter_parsed,
2223 .help_str = "remove a perfect filter",
2225 (void *)&cmd_pkt_filter_rm_perfect_filter,
2226 (void *)&cmd_pkt_filter_port_id,
2227 (void *)&cmd_pkt_filter_protocol,
2228 (void *)&cmd_pkt_filter_src,
2229 (void *)&cmd_pkt_filter_ip_src,
2230 (void *)&cmd_pkt_filter_port_src,
2231 (void *)&cmd_pkt_filter_dst,
2232 (void *)&cmd_pkt_filter_ip_dst,
2233 (void *)&cmd_pkt_filter_port_dst,
2234 (void *)&cmd_pkt_filter_flexbytes,
2235 (void *)&cmd_pkt_filter_flexbytes_value,
2236 (void *)&cmd_pkt_filter_vlan,
2237 (void *)&cmd_pkt_filter_vlan_id,
2238 (void *)&cmd_pkt_filter_soft,
2239 (void *)&cmd_pkt_filter_soft_id,
2244 /* *** SETUP MASKS FILTER *** */
2245 struct cmd_pkt_filter_masks_result {
2246 cmdline_fixed_string_t filter_mask;
2248 cmdline_fixed_string_t src_mask;
2249 uint32_t ip_src_mask;
2250 uint16_t ipv6_src_mask;
2251 uint16_t port_src_mask;
2252 cmdline_fixed_string_t dst_mask;
2253 uint32_t ip_dst_mask;
2254 uint16_t ipv6_dst_mask;
2255 uint16_t port_dst_mask;
2256 cmdline_fixed_string_t flexbytes;
2257 uint8_t flexbytes_value;
2258 cmdline_fixed_string_t vlan_id;
2259 uint8_t vlan_id_value;
2260 cmdline_fixed_string_t vlan_prio;
2261 uint8_t vlan_prio_value;
2262 cmdline_fixed_string_t only_ip_flow;
2263 uint8_t only_ip_flow_value;
2264 cmdline_fixed_string_t comp_ipv6_dst;
2265 uint8_t comp_ipv6_dst_value;
2269 cmd_pkt_filter_masks_parsed(void *parsed_result,
2270 __attribute__((unused)) struct cmdline *cl,
2271 __attribute__((unused)) void *data)
2273 struct rte_fdir_masks fdir_masks;
2274 struct cmd_pkt_filter_masks_result *res = parsed_result;
2276 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2278 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2279 fdir_masks.vlan_id = res->vlan_id_value;
2280 fdir_masks.vlan_prio = res->vlan_prio_value;
2281 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2282 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2283 fdir_masks.src_port_mask = res->port_src_mask;
2284 fdir_masks.dst_port_mask = res->port_dst_mask;
2285 fdir_masks.flexbytes = res->flexbytes_value;
2287 fdir_set_masks(res->port_id, &fdir_masks);
2290 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2291 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2292 filter_mask, "set_masks_filter");
2293 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2294 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2296 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2297 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2298 only_ip_flow, "only_ip_flow");
2299 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2300 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2301 only_ip_flow_value, UINT8);
2302 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2303 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2304 src_mask, "src_mask");
2305 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2306 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2307 ip_src_mask, UINT32);
2308 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2309 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2310 port_src_mask, UINT16);
2311 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2312 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2313 dst_mask, "dst_mask");
2314 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2315 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2316 ip_dst_mask, UINT32);
2317 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2318 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2319 port_dst_mask, UINT16);
2320 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2321 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2322 flexbytes, "flexbytes");
2323 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2324 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2325 flexbytes_value, UINT8);
2326 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2327 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2328 vlan_id, "vlan_id");
2329 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2330 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2331 vlan_id_value, UINT8);
2332 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2333 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2334 vlan_prio, "vlan_prio");
2335 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2336 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2337 vlan_prio_value, UINT8);
2339 cmdline_parse_inst_t cmd_set_masks_filter = {
2340 .f = cmd_pkt_filter_masks_parsed,
2342 .help_str = "setup masks filter",
2344 (void *)&cmd_pkt_filter_masks_filter_mask,
2345 (void *)&cmd_pkt_filter_masks_port_id,
2346 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2347 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2348 (void *)&cmd_pkt_filter_masks_src_mask,
2349 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2350 (void *)&cmd_pkt_filter_masks_port_src_mask,
2351 (void *)&cmd_pkt_filter_masks_dst_mask,
2352 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2353 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2354 (void *)&cmd_pkt_filter_masks_flexbytes,
2355 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2356 (void *)&cmd_pkt_filter_masks_vlan_id,
2357 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2358 (void *)&cmd_pkt_filter_masks_vlan_prio,
2359 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2365 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2366 __attribute__((unused)) struct cmdline *cl,
2367 __attribute__((unused)) void *data)
2369 struct rte_fdir_masks fdir_masks;
2370 struct cmd_pkt_filter_masks_result *res = parsed_result;
2372 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2374 fdir_masks.set_ipv6_mask = 1;
2375 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2376 fdir_masks.vlan_id = res->vlan_id_value;
2377 fdir_masks.vlan_prio = res->vlan_prio_value;
2378 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2379 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2380 fdir_masks.src_port_mask = res->port_src_mask;
2381 fdir_masks.dst_port_mask = res->port_dst_mask;
2382 fdir_masks.flexbytes = res->flexbytes_value;
2383 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2385 fdir_set_masks(res->port_id, &fdir_masks);
2388 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2389 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2390 filter_mask, "set_ipv6_masks_filter");
2391 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2392 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2393 ipv6_src_mask, UINT16);
2394 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2395 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2396 ipv6_dst_mask, UINT16);
2398 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2399 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2400 comp_ipv6_dst, "compare_dst");
2401 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2402 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2403 comp_ipv6_dst_value, UINT8);
2405 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2406 .f = cmd_pkt_filter_masks_ipv6_parsed,
2408 .help_str = "setup ipv6 masks filter",
2410 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2411 (void *)&cmd_pkt_filter_masks_port_id,
2412 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2413 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2414 (void *)&cmd_pkt_filter_masks_src_mask,
2415 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2416 (void *)&cmd_pkt_filter_masks_port_src_mask,
2417 (void *)&cmd_pkt_filter_masks_dst_mask,
2418 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2419 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2420 (void *)&cmd_pkt_filter_masks_flexbytes,
2421 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2422 (void *)&cmd_pkt_filter_masks_vlan_id,
2423 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2424 (void *)&cmd_pkt_filter_masks_vlan_prio,
2425 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2426 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2427 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2432 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2433 struct cmd_link_flow_ctrl_set_result {
2434 cmdline_fixed_string_t set;
2435 cmdline_fixed_string_t flow_ctrl;
2436 cmdline_fixed_string_t rx;
2437 cmdline_fixed_string_t rx_lfc_mode;
2438 cmdline_fixed_string_t tx;
2439 cmdline_fixed_string_t tx_lfc_mode;
2440 uint32_t high_water;
2442 uint16_t pause_time;
2448 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2449 __attribute__((unused)) struct cmdline *cl,
2450 __attribute__((unused)) void *data)
2452 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2453 struct rte_eth_fc_conf fc_conf;
2454 int rx_fc_enable, tx_fc_enable;
2458 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2459 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2460 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2461 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2463 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2464 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2467 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2468 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2470 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2471 fc_conf.high_water = res->high_water;
2472 fc_conf.low_water = res->low_water;
2473 fc_conf.pause_time = res->pause_time;
2474 fc_conf.send_xon = res->send_xon;
2476 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2478 printf("bad flow contrl parameter, return code = %d \n", ret);
2481 cmdline_parse_token_string_t cmd_lfc_set_set =
2482 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2484 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2485 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2486 flow_ctrl, "flow_ctrl");
2487 cmdline_parse_token_string_t cmd_lfc_set_rx =
2488 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2490 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2491 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2492 rx_lfc_mode, "on#off");
2493 cmdline_parse_token_string_t cmd_lfc_set_tx =
2494 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2496 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2497 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2498 tx_lfc_mode, "on#off");
2499 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2500 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2501 high_water, UINT32);
2502 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2503 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2505 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2506 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2507 pause_time, UINT16);
2508 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2509 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2511 cmdline_parse_token_num_t cmd_lfc_set_portid =
2512 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2515 cmdline_parse_inst_t cmd_link_flow_control_set = {
2516 .f = cmd_link_flow_ctrl_set_parsed,
2518 .help_str = "Configure the Ethernet link flow control...",
2520 (void *)&cmd_lfc_set_set,
2521 (void *)&cmd_lfc_set_flow_ctrl,
2522 (void *)&cmd_lfc_set_rx,
2523 (void *)&cmd_lfc_set_rx_mode,
2524 (void *)&cmd_lfc_set_tx,
2525 (void *)&cmd_lfc_set_tx_mode,
2526 (void *)&cmd_lfc_set_high_water,
2527 (void *)&cmd_lfc_set_low_water,
2528 (void *)&cmd_lfc_set_pause_time,
2529 (void *)&cmd_lfc_set_send_xon,
2530 (void *)&cmd_lfc_set_portid,
2535 /* *** RESET CONFIGURATION *** */
2536 struct cmd_reset_result {
2537 cmdline_fixed_string_t reset;
2538 cmdline_fixed_string_t def;
2541 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
2543 __attribute__((unused)) void *data)
2545 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
2546 set_def_fwd_config();
2549 cmdline_parse_token_string_t cmd_reset_set =
2550 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
2551 cmdline_parse_token_string_t cmd_reset_def =
2552 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
2555 cmdline_parse_inst_t cmd_reset = {
2556 .f = cmd_reset_parsed,
2558 .help_str = "set default: reset default forwarding configuration",
2560 (void *)&cmd_reset_set,
2561 (void *)&cmd_reset_def,
2566 /* *** START FORWARDING *** */
2567 struct cmd_start_result {
2568 cmdline_fixed_string_t start;
2571 cmdline_parse_token_string_t cmd_start_start =
2572 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
2574 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
2575 __attribute__((unused)) struct cmdline *cl,
2576 __attribute__((unused)) void *data)
2578 start_packet_forwarding(0);
2581 cmdline_parse_inst_t cmd_start = {
2582 .f = cmd_start_parsed,
2584 .help_str = "start packet forwarding",
2586 (void *)&cmd_start_start,
2591 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
2592 struct cmd_start_tx_first_result {
2593 cmdline_fixed_string_t start;
2594 cmdline_fixed_string_t tx_first;
2598 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
2599 __attribute__((unused)) struct cmdline *cl,
2600 __attribute__((unused)) void *data)
2602 start_packet_forwarding(1);
2605 cmdline_parse_token_string_t cmd_start_tx_first_start =
2606 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
2608 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
2609 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
2610 tx_first, "tx_first");
2612 cmdline_parse_inst_t cmd_start_tx_first = {
2613 .f = cmd_start_tx_first_parsed,
2615 .help_str = "start packet forwarding, after sending 1 burst of packets",
2617 (void *)&cmd_start_tx_first_start,
2618 (void *)&cmd_start_tx_first_tx_first,
2623 /* *** SHOW CFG *** */
2624 struct cmd_showcfg_result {
2625 cmdline_fixed_string_t show;
2626 cmdline_fixed_string_t cfg;
2627 cmdline_fixed_string_t what;
2630 static void cmd_showcfg_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_showcfg_result *res = parsed_result;
2635 if (!strcmp(res->what, "rxtx"))
2636 rxtx_config_display();
2637 else if (!strcmp(res->what, "cores"))
2638 fwd_lcores_config_display();
2639 else if (!strcmp(res->what, "fwd"))
2640 fwd_config_display();
2643 cmdline_parse_token_string_t cmd_showcfg_show =
2644 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
2645 cmdline_parse_token_string_t cmd_showcfg_port =
2646 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
2647 cmdline_parse_token_string_t cmd_showcfg_what =
2648 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
2651 cmdline_parse_inst_t cmd_showcfg = {
2652 .f = cmd_showcfg_parsed,
2654 .help_str = "show config rxtx|cores|fwd",
2656 (void *)&cmd_showcfg_show,
2657 (void *)&cmd_showcfg_port,
2658 (void *)&cmd_showcfg_what,
2663 /* *** SHOW ALL PORT INFO *** */
2664 struct cmd_showportall_result {
2665 cmdline_fixed_string_t show;
2666 cmdline_fixed_string_t port;
2667 cmdline_fixed_string_t what;
2668 cmdline_fixed_string_t all;
2671 static void cmd_showportall_parsed(void *parsed_result,
2672 __attribute__((unused)) struct cmdline *cl,
2673 __attribute__((unused)) void *data)
2677 struct cmd_showportall_result *res = parsed_result;
2678 if (!strcmp(res->show, "clear")) {
2679 if (!strcmp(res->what, "stats"))
2680 for (i = 0; i < nb_ports; i++)
2682 } else if (!strcmp(res->what, "info"))
2683 for (i = 0; i < nb_ports; i++)
2684 port_infos_display(i);
2685 else if (!strcmp(res->what, "stats"))
2686 for (i = 0; i < nb_ports; i++)
2687 nic_stats_display(i);
2688 else if (!strcmp(res->what, "fdir"))
2689 for (i = 0; i < nb_ports; i++)
2691 else if (!strcmp(res->what, "stat_qmap"))
2692 for (i = 0; i < nb_ports; i++)
2693 nic_stats_mapping_display(i);
2696 cmdline_parse_token_string_t cmd_showportall_show =
2697 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
2699 cmdline_parse_token_string_t cmd_showportall_port =
2700 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
2701 cmdline_parse_token_string_t cmd_showportall_what =
2702 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
2703 "info#stats#fdir#stat_qmap");
2704 cmdline_parse_token_string_t cmd_showportall_all =
2705 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
2706 cmdline_parse_inst_t cmd_showportall = {
2707 .f = cmd_showportall_parsed,
2709 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
2711 (void *)&cmd_showportall_show,
2712 (void *)&cmd_showportall_port,
2713 (void *)&cmd_showportall_what,
2714 (void *)&cmd_showportall_all,
2719 /* *** SHOW PORT INFO *** */
2720 struct cmd_showport_result {
2721 cmdline_fixed_string_t show;
2722 cmdline_fixed_string_t port;
2723 cmdline_fixed_string_t what;
2727 static void cmd_showport_parsed(void *parsed_result,
2728 __attribute__((unused)) struct cmdline *cl,
2729 __attribute__((unused)) void *data)
2731 struct cmd_showport_result *res = parsed_result;
2732 if (!strcmp(res->show, "clear")) {
2733 if (!strcmp(res->what, "stats"))
2734 nic_stats_clear(res->portnum);
2735 } else if (!strcmp(res->what, "info"))
2736 port_infos_display(res->portnum);
2737 else if (!strcmp(res->what, "stats"))
2738 nic_stats_display(res->portnum);
2739 else if (!strcmp(res->what, "fdir"))
2740 fdir_get_infos(res->portnum);
2741 else if (!strcmp(res->what, "stat_qmap"))
2742 nic_stats_mapping_display(res->portnum);
2745 cmdline_parse_token_string_t cmd_showport_show =
2746 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
2748 cmdline_parse_token_string_t cmd_showport_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
2750 cmdline_parse_token_string_t cmd_showport_what =
2751 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
2752 "info#stats#fdir#stat_qmap");
2753 cmdline_parse_token_num_t cmd_showport_portnum =
2754 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
2756 cmdline_parse_inst_t cmd_showport = {
2757 .f = cmd_showport_parsed,
2759 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
2761 (void *)&cmd_showport_show,
2762 (void *)&cmd_showport_port,
2763 (void *)&cmd_showport_what,
2764 (void *)&cmd_showport_portnum,
2769 /* *** READ PORT REGISTER *** */
2770 struct cmd_read_reg_result {
2771 cmdline_fixed_string_t read;
2772 cmdline_fixed_string_t reg;
2778 cmd_read_reg_parsed(void *parsed_result,
2779 __attribute__((unused)) struct cmdline *cl,
2780 __attribute__((unused)) void *data)
2782 struct cmd_read_reg_result *res = parsed_result;
2783 port_reg_display(res->port_id, res->reg_off);
2786 cmdline_parse_token_string_t cmd_read_reg_read =
2787 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
2788 cmdline_parse_token_string_t cmd_read_reg_reg =
2789 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
2790 cmdline_parse_token_num_t cmd_read_reg_port_id =
2791 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
2792 cmdline_parse_token_num_t cmd_read_reg_reg_off =
2793 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
2795 cmdline_parse_inst_t cmd_read_reg = {
2796 .f = cmd_read_reg_parsed,
2798 .help_str = "read reg port_id reg_off",
2800 (void *)&cmd_read_reg_read,
2801 (void *)&cmd_read_reg_reg,
2802 (void *)&cmd_read_reg_port_id,
2803 (void *)&cmd_read_reg_reg_off,
2808 /* *** READ PORT REGISTER BIT FIELD *** */
2809 struct cmd_read_reg_bit_field_result {
2810 cmdline_fixed_string_t read;
2811 cmdline_fixed_string_t regfield;
2819 cmd_read_reg_bit_field_parsed(void *parsed_result,
2820 __attribute__((unused)) struct cmdline *cl,
2821 __attribute__((unused)) void *data)
2823 struct cmd_read_reg_bit_field_result *res = parsed_result;
2824 port_reg_bit_field_display(res->port_id, res->reg_off,
2825 res->bit1_pos, res->bit2_pos);
2828 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
2829 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
2831 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
2832 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
2833 regfield, "regfield");
2834 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
2835 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
2837 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
2838 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
2840 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
2841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
2843 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
2844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
2847 cmdline_parse_inst_t cmd_read_reg_bit_field = {
2848 .f = cmd_read_reg_bit_field_parsed,
2850 .help_str = "read regfield port_id reg_off bit_x bit_y "
2851 "(read register bit field between bit_x and bit_y included)",
2853 (void *)&cmd_read_reg_bit_field_read,
2854 (void *)&cmd_read_reg_bit_field_regfield,
2855 (void *)&cmd_read_reg_bit_field_port_id,
2856 (void *)&cmd_read_reg_bit_field_reg_off,
2857 (void *)&cmd_read_reg_bit_field_bit1_pos,
2858 (void *)&cmd_read_reg_bit_field_bit2_pos,
2863 /* *** READ PORT REGISTER BIT *** */
2864 struct cmd_read_reg_bit_result {
2865 cmdline_fixed_string_t read;
2866 cmdline_fixed_string_t regbit;
2873 cmd_read_reg_bit_parsed(void *parsed_result,
2874 __attribute__((unused)) struct cmdline *cl,
2875 __attribute__((unused)) void *data)
2877 struct cmd_read_reg_bit_result *res = parsed_result;
2878 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
2881 cmdline_parse_token_string_t cmd_read_reg_bit_read =
2882 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
2883 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
2884 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
2886 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
2887 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
2888 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
2889 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
2890 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
2891 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
2893 cmdline_parse_inst_t cmd_read_reg_bit = {
2894 .f = cmd_read_reg_bit_parsed,
2896 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
2898 (void *)&cmd_read_reg_bit_read,
2899 (void *)&cmd_read_reg_bit_regbit,
2900 (void *)&cmd_read_reg_bit_port_id,
2901 (void *)&cmd_read_reg_bit_reg_off,
2902 (void *)&cmd_read_reg_bit_bit_pos,
2907 /* *** WRITE PORT REGISTER *** */
2908 struct cmd_write_reg_result {
2909 cmdline_fixed_string_t write;
2910 cmdline_fixed_string_t reg;
2917 cmd_write_reg_parsed(void *parsed_result,
2918 __attribute__((unused)) struct cmdline *cl,
2919 __attribute__((unused)) void *data)
2921 struct cmd_write_reg_result *res = parsed_result;
2922 port_reg_set(res->port_id, res->reg_off, res->value);
2925 cmdline_parse_token_string_t cmd_write_reg_write =
2926 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
2927 cmdline_parse_token_string_t cmd_write_reg_reg =
2928 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
2929 cmdline_parse_token_num_t cmd_write_reg_port_id =
2930 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
2931 cmdline_parse_token_num_t cmd_write_reg_reg_off =
2932 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
2933 cmdline_parse_token_num_t cmd_write_reg_value =
2934 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
2936 cmdline_parse_inst_t cmd_write_reg = {
2937 .f = cmd_write_reg_parsed,
2939 .help_str = "write reg port_id reg_off reg_value",
2941 (void *)&cmd_write_reg_write,
2942 (void *)&cmd_write_reg_reg,
2943 (void *)&cmd_write_reg_port_id,
2944 (void *)&cmd_write_reg_reg_off,
2945 (void *)&cmd_write_reg_value,
2950 /* *** WRITE PORT REGISTER BIT FIELD *** */
2951 struct cmd_write_reg_bit_field_result {
2952 cmdline_fixed_string_t write;
2953 cmdline_fixed_string_t regfield;
2962 cmd_write_reg_bit_field_parsed(void *parsed_result,
2963 __attribute__((unused)) struct cmdline *cl,
2964 __attribute__((unused)) void *data)
2966 struct cmd_write_reg_bit_field_result *res = parsed_result;
2967 port_reg_bit_field_set(res->port_id, res->reg_off,
2968 res->bit1_pos, res->bit2_pos, res->value);
2971 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
2972 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
2974 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
2975 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
2976 regfield, "regfield");
2977 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
2978 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
2980 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
2981 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
2983 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
2984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
2986 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
2987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
2989 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
2990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
2993 cmdline_parse_inst_t cmd_write_reg_bit_field = {
2994 .f = cmd_write_reg_bit_field_parsed,
2996 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
2997 "(set register bit field between bit_x and bit_y included)",
2999 (void *)&cmd_write_reg_bit_field_write,
3000 (void *)&cmd_write_reg_bit_field_regfield,
3001 (void *)&cmd_write_reg_bit_field_port_id,
3002 (void *)&cmd_write_reg_bit_field_reg_off,
3003 (void *)&cmd_write_reg_bit_field_bit1_pos,
3004 (void *)&cmd_write_reg_bit_field_bit2_pos,
3005 (void *)&cmd_write_reg_bit_field_value,
3010 /* *** WRITE PORT REGISTER BIT *** */
3011 struct cmd_write_reg_bit_result {
3012 cmdline_fixed_string_t write;
3013 cmdline_fixed_string_t regbit;
3021 cmd_write_reg_bit_parsed(void *parsed_result,
3022 __attribute__((unused)) struct cmdline *cl,
3023 __attribute__((unused)) void *data)
3025 struct cmd_write_reg_bit_result *res = parsed_result;
3026 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3029 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3030 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3032 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3033 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3035 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3036 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3037 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3038 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3039 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3040 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3041 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3042 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3044 cmdline_parse_inst_t cmd_write_reg_bit = {
3045 .f = cmd_write_reg_bit_parsed,
3047 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3049 (void *)&cmd_write_reg_bit_write,
3050 (void *)&cmd_write_reg_bit_regbit,
3051 (void *)&cmd_write_reg_bit_port_id,
3052 (void *)&cmd_write_reg_bit_reg_off,
3053 (void *)&cmd_write_reg_bit_bit_pos,
3054 (void *)&cmd_write_reg_bit_value,
3059 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3060 struct cmd_read_rxd_txd_result {
3061 cmdline_fixed_string_t read;
3062 cmdline_fixed_string_t rxd_txd;
3069 cmd_read_rxd_txd_parsed(void *parsed_result,
3070 __attribute__((unused)) struct cmdline *cl,
3071 __attribute__((unused)) void *data)
3073 struct cmd_read_rxd_txd_result *res = parsed_result;
3075 if (!strcmp(res->rxd_txd, "rxd"))
3076 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3077 else if (!strcmp(res->rxd_txd, "txd"))
3078 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3081 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3082 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3083 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3084 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3086 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3087 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3088 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3089 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3090 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3091 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3093 cmdline_parse_inst_t cmd_read_rxd_txd = {
3094 .f = cmd_read_rxd_txd_parsed,
3096 .help_str = "read rxd|txd port_id queue_id rxd_id",
3098 (void *)&cmd_read_rxd_txd_read,
3099 (void *)&cmd_read_rxd_txd_rxd_txd,
3100 (void *)&cmd_read_rxd_txd_port_id,
3101 (void *)&cmd_read_rxd_txd_queue_id,
3102 (void *)&cmd_read_rxd_txd_desc_id,
3108 struct cmd_quit_result {
3109 cmdline_fixed_string_t quit;
3112 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3114 __attribute__((unused)) void *data)
3120 cmdline_parse_token_string_t cmd_quit_quit =
3121 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3123 cmdline_parse_inst_t cmd_quit = {
3124 .f = cmd_quit_parsed,
3126 .help_str = "exit application",
3128 (void *)&cmd_quit_quit,
3133 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3134 struct cmd_mac_addr_result {
3135 cmdline_fixed_string_t mac_addr_cmd;
3136 cmdline_fixed_string_t what;
3138 struct ether_addr address;
3141 static void cmd_mac_addr_parsed(void *parsed_result,
3142 __attribute__((unused)) struct cmdline *cl,
3143 __attribute__((unused)) void *data)
3145 struct cmd_mac_addr_result *res = parsed_result;
3148 if (strcmp(res->what, "add") == 0)
3149 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3151 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3153 /* check the return value and print it if is < 0 */
3155 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3159 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3160 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3162 cmdline_parse_token_string_t cmd_mac_addr_what =
3163 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3165 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3166 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3167 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3170 cmdline_parse_inst_t cmd_mac_addr = {
3171 .f = cmd_mac_addr_parsed,
3173 .help_str = "mac_addr add|remove X <address>: "
3174 "add/remove MAC address on port X",
3176 (void *)&cmd_mac_addr_cmd,
3177 (void *)&cmd_mac_addr_what,
3178 (void *)&cmd_mac_addr_portnum,
3179 (void *)&cmd_mac_addr_addr,
3185 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3186 struct cmd_set_qmap_result {
3187 cmdline_fixed_string_t set;
3188 cmdline_fixed_string_t qmap;
3189 cmdline_fixed_string_t what;
3196 cmd_set_qmap_parsed(void *parsed_result,
3197 __attribute__((unused)) struct cmdline *cl,
3198 __attribute__((unused)) void *data)
3200 struct cmd_set_qmap_result *res = parsed_result;
3201 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3203 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3206 cmdline_parse_token_string_t cmd_setqmap_set =
3207 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3209 cmdline_parse_token_string_t cmd_setqmap_qmap =
3210 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3212 cmdline_parse_token_string_t cmd_setqmap_what =
3213 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3215 cmdline_parse_token_num_t cmd_setqmap_portid =
3216 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3218 cmdline_parse_token_num_t cmd_setqmap_queueid =
3219 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3221 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3222 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3225 cmdline_parse_inst_t cmd_set_qmap = {
3226 .f = cmd_set_qmap_parsed,
3228 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3230 (void *)&cmd_setqmap_set,
3231 (void *)&cmd_setqmap_qmap,
3232 (void *)&cmd_setqmap_what,
3233 (void *)&cmd_setqmap_portid,
3234 (void *)&cmd_setqmap_queueid,
3235 (void *)&cmd_setqmap_mapvalue,
3240 /* ******************************************************************************** */
3242 /* list of instructions */
3243 cmdline_parse_ctx_t main_ctx[] = {
3244 (cmdline_parse_inst_t *)&cmd_help,
3245 (cmdline_parse_inst_t *)&cmd_quit,
3246 (cmdline_parse_inst_t *)&cmd_showport,
3247 (cmdline_parse_inst_t *)&cmd_showportall,
3248 (cmdline_parse_inst_t *)&cmd_showcfg,
3249 (cmdline_parse_inst_t *)&cmd_start,
3250 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3251 (cmdline_parse_inst_t *)&cmd_reset,
3252 (cmdline_parse_inst_t *)&cmd_set_numbers,
3253 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3254 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3255 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3256 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3257 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3258 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3259 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3260 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3261 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3262 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3263 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3264 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3265 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3266 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3267 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3268 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3269 (cmdline_parse_inst_t *)&cmd_read_reg,
3270 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3271 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3272 (cmdline_parse_inst_t *)&cmd_write_reg,
3273 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3274 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3275 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3276 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3277 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3278 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3279 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3280 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3281 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3282 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3283 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3284 (cmdline_parse_inst_t *)&cmd_stop,
3285 (cmdline_parse_inst_t *)&cmd_mac_addr,
3286 (cmdline_parse_inst_t *)&cmd_set_qmap,
3287 (cmdline_parse_inst_t *)&cmd_operate_port,
3288 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3289 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3290 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3291 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3292 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3293 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3294 (cmdline_parse_inst_t *)&cmd_config_rss,
3295 (cmdline_parse_inst_t *)&cmd_config_burst,
3296 (cmdline_parse_inst_t *)&cmd_config_thresh,
3297 (cmdline_parse_inst_t *)&cmd_config_threshold,
3301 /* prompt function, called from main on MASTER lcore */
3307 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3311 cmdline_interact(cl);
3312 cmdline_stdin_exit(cl);
3316 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3318 if (id < nb_ports) {
3319 /* check if need_reconfig has been set to 1 */
3320 if (ports[id].need_reconfig == 0)
3321 ports[id].need_reconfig = dev;
3322 /* check if need_reconfig_queues has been set to 1 */
3323 if (ports[id].need_reconfig_queues == 0)
3324 ports[id].need_reconfig_queues = queue;
3328 for (pid = 0; pid < nb_ports; pid++) {
3329 /* check if need_reconfig has been set to 1 */
3330 if (ports[pid].need_reconfig == 0)
3331 ports[pid].need_reconfig = dev;
3332 /* check if need_reconfig_queues has been set to 1 */
3333 if (ports[pid].need_reconfig_queues == 0)
3334 ports[pid].need_reconfig_queues = queue;