4 * Copyright(c) 2010-2013 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);
86 /* *** Help command with introduction. *** */
87 struct cmd_help_brief_result {
88 cmdline_fixed_string_t help;
91 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
93 __attribute__((unused)) void *data)
98 "Help is available for the following sections:\n\n"
99 " help control : Start and stop forwarding.\n"
100 " help display : Displaying port, stats and config "
102 " help config : Configuration information.\n"
103 " help ports : Configuring ports.\n"
104 " help flowdir : Flow Director filter help.\n"
105 " help registers : Reading and setting port registers.\n"
106 " help all : All of the above sections.\n\n"
111 cmdline_parse_token_string_t cmd_help_brief_help =
112 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
114 cmdline_parse_inst_t cmd_help_brief = {
115 .f = cmd_help_brief_parsed,
117 .help_str = "show help",
119 (void *)&cmd_help_brief_help,
124 /* *** Help command with help sections. *** */
125 struct cmd_help_long_result {
126 cmdline_fixed_string_t help;
127 cmdline_fixed_string_t section;
130 static void cmd_help_long_parsed(void *parsed_result,
132 __attribute__((unused)) void *data)
135 struct cmd_help_long_result *res = parsed_result;
137 if (!strcmp(res->section, "all"))
140 if (show_all || !strcmp(res->section, "control")) {
145 "Control forwarding:\n"
146 "-------------------\n\n"
149 " Start packet forwarding with current configuration.\n\n"
152 " Start packet forwarding with current config"
153 " after sending one burst of packets.\n\n"
156 " Stop packet forwarding, and display accumulated"
160 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
164 if (show_all || !strcmp(res->section, "display")) {
172 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
173 " Display information for port_id, or all.\n\n"
175 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
176 " Clear information for port_id, or all.\n\n"
178 "show config (rxtx|cores|fwd)\n"
179 " Display the given configuration.\n\n"
181 "read rxd (port_id) (queue_id) (rxd_id)\n"
182 " Display an RX descriptor of a port RX queue.\n\n"
184 "read txd (port_id) (queue_id) (txd_id)\n"
185 " Display a TX descriptor of a port TX queue.\n\n"
189 if (show_all || !strcmp(res->section, "config")) {
195 "Configuration changes only become active when"
196 " forwarding is started/restarted.\n\n"
199 " Reset forwarding to the default configuration.\n\n"
201 "set verbose (level)\n"
202 " Set the debug verbosity level X.\n\n"
205 " Set number of ports.\n\n"
208 " Set number of cores.\n\n"
210 "set coremask (mask)\n"
211 " Set the forwarding cores hexadecimal mask.\n\n"
213 "set portmask (mask)\n"
214 " Set the forwarding ports hexadecimal mask.\n\n"
217 " Set number of packets per burst.\n\n"
219 "set txpkts (x[,y]*)\n"
220 " Set the length of each segment of TXONLY"
223 "set corelist (x[,y]*)\n"
224 " Set the list of forwarding cores.\n\n"
226 "set portlist (x[,y]*)\n"
227 " Set the list of forwarding ports.\n\n"
229 "vlan set strip (on|off) (port_id)\n"
230 " Set the VLAN strip on a port.\n\n"
232 "vlan set filter (on|off) (port_id)\n"
233 " Set the VLAN filter on a port.\n\n"
235 "vlan set qinq (on|off) (port_id)\n"
236 " Set the VLAN QinQ (extended queue in queue)"
239 "vlan set tpid (value) (port_id)\n"
240 " Set the outer VLAN TPID for Packet Filtering on"
243 "rx_vlan add (vlan_id|all) (port_id)\n"
244 " Add a vlan_id, or all identifiers, to the set"
245 " of VLAN identifiers filtered by port_id.\n\n"
247 "rx_vlan rm (vlan_id|all) (port_id)\n"
248 " Remove a vlan_id, or all identifiers, from the set"
249 " of VLAN identifiers filtered by port_id.\n\n"
251 "tx_vlan set vlan_id (port_id)\n"
252 " Set hardware insertion of VLAN ID in packets sent"
255 "tx_vlan reset (port_id)\n"
256 " Disable hardware insertion of a VLAN header in"
257 " packets sent on a port.\n\n"
259 "tx_checksum set mask (port_id)\n"
260 " Enable hardware insertion of checksum offload with"
261 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
262 " bit 0 - insert ip checksum offload if set\n"
263 " bit 1 - insert udp checksum offload if set\n"
264 " bit 2 - insert tcp checksum offload if set\n"
265 " bit 3 - insert sctp checksum offload if set\n"
266 " Please check the NIC datasheet for HW limits.\n\n"
268 #ifdef RTE_LIBRTE_IEEE1588
269 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
270 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
271 " packet forwarding mode.\n\n"
274 "set fwd (io|mac|rxonly|txonly|csum)\n"
275 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
276 " forwarding mode.\n\n"
279 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
280 " Add a MAC address on port_id.\n\n"
282 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
283 " Remove a MAC address from port_id.\n\n"
285 "set promisc (port_id|all) (on|off)\n"
286 " Set the promiscuous mode on port_id, or all.\n\n"
288 "set allmulti (port_id|all) (on|off)\n"
289 " Set the allmulti mode on port_id, or all.\n\n"
291 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
292 " (low_water) (pause_time) (send_xon) (port_id)\n"
293 " Set the link flow control parameter on a port.\n\n"
295 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
296 " (low_water) (pause_time) (priority) (port_id)\n"
297 " Set the priority flow control parameter on a"
300 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
301 " Set statistics mapping (qmapping 0..15) for RX/TX"
303 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
304 " on port 0 to mapping 5.\n\n"
309 if (show_all || !strcmp(res->section, "flowdir")) {
314 "Flow director mode:\n"
315 "-------------------\n\n"
317 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
318 " src (src_ip_address) (src_port)"
319 " dst (dst_ip_address) (dst_port)"
320 " flexbytes (flexbytes_values) vlan (vlan_id)"
321 " queue (queue_id)\n"
322 " Add a signature filter.\n\n"
324 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
325 " src (src_ip_address) (src_port)"
326 " dst (dst_ip_address) (dst_port)"
327 " flexbytes (flexbytes_values) vlan (vlan_id)"
328 " queue (queue_id)\n"
329 " Update a signature filter.\n\n"
331 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
332 " src (src_ip_address) (src_port)"
333 " dst (dst_ip_address) (dst_port)"
334 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
335 " Remove a signature filter.\n\n"
337 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
338 " src (src_ip_address) (src_port)"
339 " dst (dst_ip_address) (dst_port)"
340 " flexbytes (flexbytes_values) vlan (vlan_id)"
341 " queue (queue_id) soft (soft_id)\n"
342 " Add a perfect filter.\n\n"
344 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
345 " src (src_ip_address) (src_port)"
346 " dst (dst_ip_address) (dst_port)"
347 " flexbytes (flexbytes_values) vlan (vlan_id)"
348 " queue (queue_id)\n"
349 " Update a perfect filter.\n\n"
351 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
352 " src (src_ip_address) (src_port)"
353 " dst (dst_ip_address) (dst_port)"
354 " flexbytes (flexbytes_values) vlan (vlan_id)"
356 " Remove a perfect filter.\n\n"
358 "set_masks_filter (port_id) only_ip_flow (0|1)"
359 " src_mask (ip_src_mask) (src_port_mask)"
360 " dst_mask (ip_dst_mask) (dst_port_mask)"
361 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
362 " Set IPv4 filter masks.\n\n"
364 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
365 " src_mask (ip_src_mask) (src_port_mask)"
366 " dst_mask (ip_dst_mask) (dst_port_mask)"
367 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
368 " compare_dst (0|1)\n"
369 " Set IPv6 filter masks.\n\n"
373 if (show_all || !strcmp(res->section, "ports")) {
379 "----------------\n\n"
381 "port start (port_id|all)\n"
382 " Start all ports or port_id.\n\n"
384 "port stop (port_id|all)\n"
385 " Stop all ports or port_id.\n\n"
387 "port close (port_id|all)\n"
388 " Close all ports or port_id.\n\n"
390 "port config (port_id|all) speed (10|100|1000|10000|auto)"
391 " duplex (half|full|auto)\n"
392 " Set speed and duplex for all ports or port_id\n\n"
394 "port config all (rxq|txq|rxd|txd) (value)\n"
395 " Set number for rxq/txq/rxd/txd.\n\n"
397 "port config all max-pkt-len (value)\n"
398 " Set the max packet length.\n\n"
400 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
402 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
405 "port config all rss (ip|udp|none)\n"
406 " Set the RSS mode.\n\n"
408 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
409 " Set the RSS redirection table.\n\n"
411 "port config (port_id) dcb vt (on|off) (traffic_class)"
413 " Set the DCB mode.\n\n"
415 "port config all burst (value)\n"
416 " Set the number of packets per burst.\n\n"
418 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
420 " Set the ring prefetch/host/writeback threshold"
421 " for tx/rx queue.\n\n"
423 "port config all (txfreet|txrst|rxfreet) (value)\n"
424 " Set free threshold for rx/tx, or set"
425 " tx rs bit threshold.\n\n"
429 if (show_all || !strcmp(res->section, "registers")) {
437 "read reg (port_id) (address)\n"
438 " Display value of a port register.\n\n"
440 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
441 " Display a port register bit field.\n\n"
443 "read regbit (port_id) (address) (bit_x)\n"
444 " Display a single port register bit.\n\n"
446 "write reg (port_id) (address) (value)\n"
447 " Set value of a port register.\n\n"
449 "write regfield (port_id) (address) (bit_x) (bit_y)"
451 " Set bit field of a port register.\n\n"
453 "write regbit (port_id) (address) (bit_x) (value)\n"
454 " Set single bit value of a port register.\n\n"
459 cmdline_parse_token_string_t cmd_help_long_help =
460 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
462 cmdline_parse_token_string_t cmd_help_long_section =
463 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
464 "all#control#display#config#flowdir#"
467 cmdline_parse_inst_t cmd_help_long = {
468 .f = cmd_help_long_parsed,
470 .help_str = "show help",
472 (void *)&cmd_help_long_help,
473 (void *)&cmd_help_long_section,
479 /* *** start/stop/close all ports *** */
480 struct cmd_operate_port_result {
481 cmdline_fixed_string_t keyword;
482 cmdline_fixed_string_t name;
483 cmdline_fixed_string_t value;
486 static void cmd_operate_port_parsed(void *parsed_result,
487 __attribute__((unused)) struct cmdline *cl,
488 __attribute__((unused)) void *data)
490 struct cmd_operate_port_result *res = parsed_result;
492 if (!strcmp(res->name, "start"))
493 start_port(RTE_PORT_ALL);
494 else if (!strcmp(res->name, "stop"))
495 stop_port(RTE_PORT_ALL);
496 else if (!strcmp(res->name, "close"))
497 close_port(RTE_PORT_ALL);
499 printf("Unknown parameter\n");
502 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
503 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
505 cmdline_parse_token_string_t cmd_operate_port_all_port =
506 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
508 cmdline_parse_token_string_t cmd_operate_port_all_all =
509 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
511 cmdline_parse_inst_t cmd_operate_port = {
512 .f = cmd_operate_port_parsed,
514 .help_str = "port start|stop|close all: start/stop/close all ports",
516 (void *)&cmd_operate_port_all_cmd,
517 (void *)&cmd_operate_port_all_port,
518 (void *)&cmd_operate_port_all_all,
523 /* *** start/stop/close specific port *** */
524 struct cmd_operate_specific_port_result {
525 cmdline_fixed_string_t keyword;
526 cmdline_fixed_string_t name;
530 static void cmd_operate_specific_port_parsed(void *parsed_result,
531 __attribute__((unused)) struct cmdline *cl,
532 __attribute__((unused)) void *data)
534 struct cmd_operate_specific_port_result *res = parsed_result;
536 if (!strcmp(res->name, "start"))
537 start_port(res->value);
538 else if (!strcmp(res->name, "stop"))
539 stop_port(res->value);
540 else if (!strcmp(res->name, "close"))
541 close_port(res->value);
543 printf("Unknown parameter\n");
546 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
547 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
549 cmdline_parse_token_string_t cmd_operate_specific_port_port =
550 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
551 name, "start#stop#close");
552 cmdline_parse_token_num_t cmd_operate_specific_port_id =
553 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
556 cmdline_parse_inst_t cmd_operate_specific_port = {
557 .f = cmd_operate_specific_port_parsed,
559 .help_str = "port start|stop|close X: start/stop/close port X",
561 (void *)&cmd_operate_specific_port_cmd,
562 (void *)&cmd_operate_specific_port_port,
563 (void *)&cmd_operate_specific_port_id,
568 /* *** configure speed for all ports *** */
569 struct cmd_config_speed_all {
570 cmdline_fixed_string_t port;
571 cmdline_fixed_string_t keyword;
572 cmdline_fixed_string_t all;
573 cmdline_fixed_string_t item1;
574 cmdline_fixed_string_t item2;
575 cmdline_fixed_string_t value1;
576 cmdline_fixed_string_t value2;
580 cmd_config_speed_all_parsed(void *parsed_result,
581 __attribute__((unused)) struct cmdline *cl,
582 __attribute__((unused)) void *data)
584 struct cmd_config_speed_all *res = parsed_result;
585 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
586 uint16_t link_duplex = 0;
589 if (!all_ports_stopped()) {
590 printf("Please stop all ports first\n");
594 if (!strcmp(res->value1, "10"))
595 link_speed = ETH_LINK_SPEED_10;
596 else if (!strcmp(res->value1, "100"))
597 link_speed = ETH_LINK_SPEED_100;
598 else if (!strcmp(res->value1, "1000"))
599 link_speed = ETH_LINK_SPEED_1000;
600 else if (!strcmp(res->value1, "10000"))
601 link_speed = ETH_LINK_SPEED_10000;
602 else if (!strcmp(res->value1, "auto"))
603 link_speed = ETH_LINK_SPEED_AUTONEG;
605 printf("Unknown parameter\n");
609 if (!strcmp(res->value2, "half"))
610 link_duplex = ETH_LINK_HALF_DUPLEX;
611 else if (!strcmp(res->value2, "full"))
612 link_duplex = ETH_LINK_FULL_DUPLEX;
613 else if (!strcmp(res->value2, "auto"))
614 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
616 printf("Unknown parameter\n");
620 for (pid = 0; pid < nb_ports; pid++) {
621 ports[pid].dev_conf.link_speed = link_speed;
622 ports[pid].dev_conf.link_duplex = link_duplex;
625 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
628 cmdline_parse_token_string_t cmd_config_speed_all_port =
629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
630 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
631 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
633 cmdline_parse_token_string_t cmd_config_speed_all_all =
634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
635 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
636 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
637 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
638 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
639 "10#100#1000#10000#auto");
640 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
642 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
646 cmdline_parse_inst_t cmd_config_speed_all = {
647 .f = cmd_config_speed_all_parsed,
649 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
652 (void *)&cmd_config_speed_all_port,
653 (void *)&cmd_config_speed_all_keyword,
654 (void *)&cmd_config_speed_all_all,
655 (void *)&cmd_config_speed_all_item1,
656 (void *)&cmd_config_speed_all_value1,
657 (void *)&cmd_config_speed_all_item2,
658 (void *)&cmd_config_speed_all_value2,
663 /* *** configure speed for specific port *** */
664 struct cmd_config_speed_specific {
665 cmdline_fixed_string_t port;
666 cmdline_fixed_string_t keyword;
668 cmdline_fixed_string_t item1;
669 cmdline_fixed_string_t item2;
670 cmdline_fixed_string_t value1;
671 cmdline_fixed_string_t value2;
675 cmd_config_speed_specific_parsed(void *parsed_result,
676 __attribute__((unused)) struct cmdline *cl,
677 __attribute__((unused)) void *data)
679 struct cmd_config_speed_specific *res = parsed_result;
680 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
681 uint16_t link_duplex = 0;
683 if (!all_ports_stopped()) {
684 printf("Please stop all ports first\n");
688 if (res->id >= nb_ports) {
689 printf("Port id %d must be less than %d\n", res->id, nb_ports);
693 if (!strcmp(res->value1, "10"))
694 link_speed = ETH_LINK_SPEED_10;
695 else if (!strcmp(res->value1, "100"))
696 link_speed = ETH_LINK_SPEED_100;
697 else if (!strcmp(res->value1, "1000"))
698 link_speed = ETH_LINK_SPEED_1000;
699 else if (!strcmp(res->value1, "10000"))
700 link_speed = ETH_LINK_SPEED_10000;
701 else if (!strcmp(res->value1, "auto"))
702 link_speed = ETH_LINK_SPEED_AUTONEG;
704 printf("Unknown parameter\n");
708 if (!strcmp(res->value2, "half"))
709 link_duplex = ETH_LINK_HALF_DUPLEX;
710 else if (!strcmp(res->value2, "full"))
711 link_duplex = ETH_LINK_FULL_DUPLEX;
712 else if (!strcmp(res->value2, "auto"))
713 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
715 printf("Unknown parameter\n");
719 ports[res->id].dev_conf.link_speed = link_speed;
720 ports[res->id].dev_conf.link_duplex = link_duplex;
722 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
726 cmdline_parse_token_string_t cmd_config_speed_specific_port =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
729 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
732 cmdline_parse_token_num_t cmd_config_speed_specific_id =
733 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
734 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
737 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
739 "10#100#1000#10000#auto");
740 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
743 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
744 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
747 cmdline_parse_inst_t cmd_config_speed_specific = {
748 .f = cmd_config_speed_specific_parsed,
750 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
753 (void *)&cmd_config_speed_specific_port,
754 (void *)&cmd_config_speed_specific_keyword,
755 (void *)&cmd_config_speed_specific_id,
756 (void *)&cmd_config_speed_specific_item1,
757 (void *)&cmd_config_speed_specific_value1,
758 (void *)&cmd_config_speed_specific_item2,
759 (void *)&cmd_config_speed_specific_value2,
764 /* *** configure txq/rxq, txd/rxd *** */
765 struct cmd_config_rx_tx {
766 cmdline_fixed_string_t port;
767 cmdline_fixed_string_t keyword;
768 cmdline_fixed_string_t all;
769 cmdline_fixed_string_t name;
774 cmd_config_rx_tx_parsed(void *parsed_result,
775 __attribute__((unused)) struct cmdline *cl,
776 __attribute__((unused)) void *data)
778 struct cmd_config_rx_tx *res = parsed_result;
780 if (!all_ports_stopped()) {
781 printf("Please stop all ports first\n");
785 if (!strcmp(res->name, "rxq")) {
786 if (res->value <= 0) {
787 printf("rxq %d invalid - must be > 0\n", res->value);
792 else if (!strcmp(res->name, "txq")) {
793 if (res->value <= 0) {
794 printf("txq %d invalid - must be > 0\n", res->value);
799 else if (!strcmp(res->name, "rxd")) {
800 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
801 printf("rxd %d invalid - must be > 0 && <= %d\n",
802 res->value, RTE_TEST_RX_DESC_MAX);
806 } else if (!strcmp(res->name, "txd")) {
807 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
808 printf("txd %d invalid - must be > 0 && <= %d\n",
809 res->value, RTE_TEST_TX_DESC_MAX);
814 printf("Unknown parameter\n");
820 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
823 cmdline_parse_token_string_t cmd_config_rx_tx_port =
824 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
825 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
826 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
827 cmdline_parse_token_string_t cmd_config_rx_tx_all =
828 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
829 cmdline_parse_token_string_t cmd_config_rx_tx_name =
830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
832 cmdline_parse_token_num_t cmd_config_rx_tx_value =
833 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
835 cmdline_parse_inst_t cmd_config_rx_tx = {
836 .f = cmd_config_rx_tx_parsed,
838 .help_str = "port config all rxq|txq|rxd|txd value",
840 (void *)&cmd_config_rx_tx_port,
841 (void *)&cmd_config_rx_tx_keyword,
842 (void *)&cmd_config_rx_tx_all,
843 (void *)&cmd_config_rx_tx_name,
844 (void *)&cmd_config_rx_tx_value,
849 /* *** config max packet length *** */
850 struct cmd_config_max_pkt_len_result {
851 cmdline_fixed_string_t port;
852 cmdline_fixed_string_t keyword;
853 cmdline_fixed_string_t all;
854 cmdline_fixed_string_t name;
859 cmd_config_max_pkt_len_parsed(void *parsed_result,
860 __attribute__((unused)) struct cmdline *cl,
861 __attribute__((unused)) void *data)
863 struct cmd_config_max_pkt_len_result *res = parsed_result;
865 if (!all_ports_stopped()) {
866 printf("Please stop all ports first\n");
870 if (!strcmp(res->name, "max-pkt-len")) {
871 if (res->value < ETHER_MIN_LEN) {
872 printf("max-pkt-len can not be less than %d\n",
876 if (res->value == rx_mode.max_rx_pkt_len)
879 rx_mode.max_rx_pkt_len = res->value;
880 if (res->value > ETHER_MAX_LEN)
881 rx_mode.jumbo_frame = 1;
883 rx_mode.jumbo_frame = 0;
885 printf("Unknown parameter\n");
891 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
894 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
895 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
897 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
898 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
900 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
901 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
903 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
904 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
906 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
907 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
910 cmdline_parse_inst_t cmd_config_max_pkt_len = {
911 .f = cmd_config_max_pkt_len_parsed,
913 .help_str = "port config all max-pkt-len value",
915 (void *)&cmd_config_max_pkt_len_port,
916 (void *)&cmd_config_max_pkt_len_keyword,
917 (void *)&cmd_config_max_pkt_len_all,
918 (void *)&cmd_config_max_pkt_len_name,
919 (void *)&cmd_config_max_pkt_len_value,
924 /* *** configure rx mode *** */
925 struct cmd_config_rx_mode_flag {
926 cmdline_fixed_string_t port;
927 cmdline_fixed_string_t keyword;
928 cmdline_fixed_string_t all;
929 cmdline_fixed_string_t name;
930 cmdline_fixed_string_t value;
934 cmd_config_rx_mode_flag_parsed(void *parsed_result,
935 __attribute__((unused)) struct cmdline *cl,
936 __attribute__((unused)) void *data)
938 struct cmd_config_rx_mode_flag *res = parsed_result;
940 if (!all_ports_stopped()) {
941 printf("Please stop all ports first\n");
945 if (!strcmp(res->name, "crc-strip")) {
946 if (!strcmp(res->value, "on"))
947 rx_mode.hw_strip_crc = 1;
948 else if (!strcmp(res->value, "off"))
949 rx_mode.hw_strip_crc = 0;
951 printf("Unknown parameter\n");
954 } else if (!strcmp(res->name, "rx-cksum")) {
955 if (!strcmp(res->value, "on"))
956 rx_mode.hw_ip_checksum = 1;
957 else if (!strcmp(res->value, "off"))
958 rx_mode.hw_ip_checksum = 0;
960 printf("Unknown parameter\n");
963 } else if (!strcmp(res->name, "hw-vlan")) {
964 if (!strcmp(res->value, "on")) {
965 rx_mode.hw_vlan_filter = 1;
966 rx_mode.hw_vlan_strip = 1;
968 else if (!strcmp(res->value, "off")) {
969 rx_mode.hw_vlan_filter = 0;
970 rx_mode.hw_vlan_strip = 0;
973 printf("Unknown parameter\n");
976 } else if (!strcmp(res->name, "drop-en")) {
977 if (!strcmp(res->value, "on"))
979 else if (!strcmp(res->value, "off"))
982 printf("Unknown parameter\n");
986 printf("Unknown parameter\n");
992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
995 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
996 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
997 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1000 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1001 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1002 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1004 "crc-strip#rx-cksum#hw-vlan");
1005 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1006 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1009 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1010 .f = cmd_config_rx_mode_flag_parsed,
1012 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1014 (void *)&cmd_config_rx_mode_flag_port,
1015 (void *)&cmd_config_rx_mode_flag_keyword,
1016 (void *)&cmd_config_rx_mode_flag_all,
1017 (void *)&cmd_config_rx_mode_flag_name,
1018 (void *)&cmd_config_rx_mode_flag_value,
1023 /* *** configure rss *** */
1024 struct cmd_config_rss {
1025 cmdline_fixed_string_t port;
1026 cmdline_fixed_string_t keyword;
1027 cmdline_fixed_string_t all;
1028 cmdline_fixed_string_t name;
1029 cmdline_fixed_string_t value;
1033 cmd_config_rss_parsed(void *parsed_result,
1034 __attribute__((unused)) struct cmdline *cl,
1035 __attribute__((unused)) void *data)
1037 struct cmd_config_rss *res = parsed_result;
1039 if (!all_ports_stopped()) {
1040 printf("Please stop all ports first\n");
1044 if (!strcmp(res->value, "ip"))
1045 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1046 else if (!strcmp(res->value, "udp"))
1047 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1048 else if (!strcmp(res->value, "none"))
1051 printf("Unknown parameter\n");
1057 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1060 cmdline_parse_token_string_t cmd_config_rss_port =
1061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1062 cmdline_parse_token_string_t cmd_config_rss_keyword =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1064 cmdline_parse_token_string_t cmd_config_rss_all =
1065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1066 cmdline_parse_token_string_t cmd_config_rss_name =
1067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1068 cmdline_parse_token_string_t cmd_config_rss_value =
1069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1071 cmdline_parse_inst_t cmd_config_rss = {
1072 .f = cmd_config_rss_parsed,
1074 .help_str = "port config all rss ip|udp|none",
1076 (void *)&cmd_config_rss_port,
1077 (void *)&cmd_config_rss_keyword,
1078 (void *)&cmd_config_rss_all,
1079 (void *)&cmd_config_rss_name,
1080 (void *)&cmd_config_rss_value,
1085 /* *** Configure RSS RETA *** */
1086 struct cmd_config_rss_reta {
1087 cmdline_fixed_string_t port;
1088 cmdline_fixed_string_t keyword;
1090 cmdline_fixed_string_t name;
1091 cmdline_fixed_string_t list_name;
1092 cmdline_fixed_string_t list_of_items;
1096 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1103 const char *p, *p0 = str;
1110 unsigned long int_fld[_NUM_FLD];
1111 char *str_fld[_NUM_FLD];
1113 while ((p = strchr(p0,'(')) != NULL) {
1115 if((p0 = strchr(p,')')) == NULL)
1119 if(size >= sizeof(s))
1122 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1123 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1125 for (i = 0; i < _NUM_FLD; i++) {
1127 int_fld[i] = strtoul(str_fld[i], &end, 0);
1128 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1132 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1133 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1135 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1136 printf("Invalid RETA hash index=%d",hash_index);
1140 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1141 reta_conf->mask_lo |= (1ULL << hash_index);
1143 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1145 reta_conf->reta[hash_index] = nb_queue;
1152 cmd_set_rss_reta_parsed(void *parsed_result,
1153 __attribute__((unused)) struct cmdline *cl,
1154 __attribute__((unused)) void *data)
1157 struct rte_eth_rss_reta reta_conf;
1158 struct cmd_config_rss_reta *res = parsed_result;
1160 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1161 if (!strcmp(res->list_name, "reta")) {
1162 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1163 printf("Invalid RSS Redirection Table config entered\n");
1166 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1168 printf("Bad redirection table parameter, return code = %d \n",ret);
1172 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1173 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1174 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1175 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1176 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1177 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1178 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1179 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1180 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1181 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1182 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1185 cmdline_parse_inst_t cmd_config_rss_reta = {
1186 .f = cmd_set_rss_reta_parsed,
1188 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1190 (void *)&cmd_config_rss_reta_port,
1191 (void *)&cmd_config_rss_reta_keyword,
1192 (void *)&cmd_config_rss_reta_port_id,
1193 (void *)&cmd_config_rss_reta_name,
1194 (void *)&cmd_config_rss_reta_list_name,
1195 (void *)&cmd_config_rss_reta_list_of_items,
1200 /* *** SHOW PORT INFO *** */
1201 struct cmd_showport_reta {
1202 cmdline_fixed_string_t show;
1203 cmdline_fixed_string_t port;
1205 cmdline_fixed_string_t rss;
1206 cmdline_fixed_string_t reta;
1211 static void cmd_showport_reta_parsed(void *parsed_result,
1212 __attribute__((unused)) struct cmdline *cl,
1213 __attribute__((unused)) void *data)
1215 struct cmd_showport_reta *res = parsed_result;
1216 struct rte_eth_rss_reta reta_conf;
1218 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1219 printf("Invalid RSS Redirection Table config entered\n");
1223 reta_conf.mask_lo = res->mask_lo;
1224 reta_conf.mask_hi = res->mask_hi;
1226 port_rss_reta_info(res->port_id,&reta_conf);
1229 cmdline_parse_token_string_t cmd_showport_reta_show =
1230 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1231 cmdline_parse_token_string_t cmd_showport_reta_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1233 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1234 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1235 cmdline_parse_token_string_t cmd_showport_reta_rss =
1236 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1237 cmdline_parse_token_string_t cmd_showport_reta_reta =
1238 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1239 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1240 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1241 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1242 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1244 cmdline_parse_inst_t cmd_showport_reta = {
1245 .f = cmd_showport_reta_parsed,
1247 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1248 (mask_lo and mask_hi is UINT64)",
1250 (void *)&cmd_showport_reta_show,
1251 (void *)&cmd_showport_reta_port,
1252 (void *)&cmd_showport_reta_port_id,
1253 (void *)&cmd_showport_reta_rss,
1254 (void *)&cmd_showport_reta_reta,
1255 (void *)&cmd_showport_reta_mask_lo,
1256 (void *)&cmd_showport_reta_mask_hi,
1261 /* *** Configure DCB *** */
1262 struct cmd_config_dcb {
1263 cmdline_fixed_string_t port;
1264 cmdline_fixed_string_t config;
1266 cmdline_fixed_string_t dcb;
1267 cmdline_fixed_string_t vt;
1268 cmdline_fixed_string_t vt_en;
1270 cmdline_fixed_string_t pfc;
1271 cmdline_fixed_string_t pfc_en;
1275 cmd_config_dcb_parsed(void *parsed_result,
1276 __attribute__((unused)) struct cmdline *cl,
1277 __attribute__((unused)) void *data)
1279 struct cmd_config_dcb *res = parsed_result;
1280 struct dcb_config dcb_conf;
1281 portid_t port_id = res->port_id;
1282 struct rte_port *port;
1284 port = &ports[port_id];
1285 /** Check if the port is not started **/
1286 if (port->port_status != RTE_PORT_STOPPED) {
1287 printf("Please stop port %d first\n",port_id);
1291 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1292 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1293 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1297 /* DCB in VT mode */
1298 if (!strncmp(res->vt_en, "on",2))
1299 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1301 dcb_conf.dcb_mode = DCB_ENABLED;
1303 if (!strncmp(res->pfc_en, "on",2)) {
1304 dcb_conf.pfc_en = 1;
1307 dcb_conf.pfc_en = 0;
1309 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1310 printf("Cannot initialize network ports\n");
1314 cmd_reconfig_device_queue(port_id, 1, 1);
1317 cmdline_parse_token_string_t cmd_config_dcb_port =
1318 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1319 cmdline_parse_token_string_t cmd_config_dcb_config =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1321 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1322 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1323 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1325 cmdline_parse_token_string_t cmd_config_dcb_vt =
1326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1327 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1329 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1330 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1331 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1333 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1336 cmdline_parse_inst_t cmd_config_dcb = {
1337 .f = cmd_config_dcb_parsed,
1339 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1341 (void *)&cmd_config_dcb_port,
1342 (void *)&cmd_config_dcb_config,
1343 (void *)&cmd_config_dcb_port_id,
1344 (void *)&cmd_config_dcb_dcb,
1345 (void *)&cmd_config_dcb_vt,
1346 (void *)&cmd_config_dcb_vt_en,
1347 (void *)&cmd_config_dcb_num_tcs,
1348 (void *)&cmd_config_dcb_pfc,
1349 (void *)&cmd_config_dcb_pfc_en,
1354 /* *** configure number of packets per burst *** */
1355 struct cmd_config_burst {
1356 cmdline_fixed_string_t port;
1357 cmdline_fixed_string_t keyword;
1358 cmdline_fixed_string_t all;
1359 cmdline_fixed_string_t name;
1364 cmd_config_burst_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_config_burst *res = parsed_result;
1370 if (!all_ports_stopped()) {
1371 printf("Please stop all ports first\n");
1375 if (!strcmp(res->name, "burst")) {
1376 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1377 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1380 nb_pkt_per_burst = res->value;
1382 printf("Unknown parameter\n");
1388 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1391 cmdline_parse_token_string_t cmd_config_burst_port =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1393 cmdline_parse_token_string_t cmd_config_burst_keyword =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1395 cmdline_parse_token_string_t cmd_config_burst_all =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1397 cmdline_parse_token_string_t cmd_config_burst_name =
1398 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1399 cmdline_parse_token_num_t cmd_config_burst_value =
1400 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1402 cmdline_parse_inst_t cmd_config_burst = {
1403 .f = cmd_config_burst_parsed,
1405 .help_str = "port config all burst value",
1407 (void *)&cmd_config_burst_port,
1408 (void *)&cmd_config_burst_keyword,
1409 (void *)&cmd_config_burst_all,
1410 (void *)&cmd_config_burst_name,
1411 (void *)&cmd_config_burst_value,
1416 /* *** configure rx/tx queues *** */
1417 struct cmd_config_thresh {
1418 cmdline_fixed_string_t port;
1419 cmdline_fixed_string_t keyword;
1420 cmdline_fixed_string_t all;
1421 cmdline_fixed_string_t name;
1426 cmd_config_thresh_parsed(void *parsed_result,
1427 __attribute__((unused)) struct cmdline *cl,
1428 __attribute__((unused)) void *data)
1430 struct cmd_config_thresh *res = parsed_result;
1432 if (!all_ports_stopped()) {
1433 printf("Please stop all ports first\n");
1437 if (!strcmp(res->name, "txpt"))
1438 tx_thresh.pthresh = res->value;
1439 else if(!strcmp(res->name, "txht"))
1440 tx_thresh.hthresh = res->value;
1441 else if(!strcmp(res->name, "txwt"))
1442 tx_thresh.wthresh = res->value;
1443 else if(!strcmp(res->name, "rxpt"))
1444 rx_thresh.pthresh = res->value;
1445 else if(!strcmp(res->name, "rxht"))
1446 rx_thresh.hthresh = res->value;
1447 else if(!strcmp(res->name, "rxwt"))
1448 rx_thresh.wthresh = res->value;
1450 printf("Unknown parameter\n");
1456 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1459 cmdline_parse_token_string_t cmd_config_thresh_port =
1460 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1461 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1462 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1463 cmdline_parse_token_string_t cmd_config_thresh_all =
1464 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1465 cmdline_parse_token_string_t cmd_config_thresh_name =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1467 "txpt#txht#txwt#rxpt#rxht#rxwt");
1468 cmdline_parse_token_num_t cmd_config_thresh_value =
1469 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1471 cmdline_parse_inst_t cmd_config_thresh = {
1472 .f = cmd_config_thresh_parsed,
1474 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1476 (void *)&cmd_config_thresh_port,
1477 (void *)&cmd_config_thresh_keyword,
1478 (void *)&cmd_config_thresh_all,
1479 (void *)&cmd_config_thresh_name,
1480 (void *)&cmd_config_thresh_value,
1485 /* *** configure free/rs threshold *** */
1486 struct cmd_config_threshold {
1487 cmdline_fixed_string_t port;
1488 cmdline_fixed_string_t keyword;
1489 cmdline_fixed_string_t all;
1490 cmdline_fixed_string_t name;
1495 cmd_config_threshold_parsed(void *parsed_result,
1496 __attribute__((unused)) struct cmdline *cl,
1497 __attribute__((unused)) void *data)
1499 struct cmd_config_threshold *res = parsed_result;
1501 if (!all_ports_stopped()) {
1502 printf("Please stop all ports first\n");
1506 if (!strcmp(res->name, "txfreet"))
1507 tx_free_thresh = res->value;
1508 else if (!strcmp(res->name, "txrst"))
1509 tx_rs_thresh = res->value;
1510 else if (!strcmp(res->name, "rxfreet"))
1511 rx_free_thresh = res->value;
1513 printf("Unknown parameter\n");
1519 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1522 cmdline_parse_token_string_t cmd_config_threshold_port =
1523 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1524 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1525 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1527 cmdline_parse_token_string_t cmd_config_threshold_all =
1528 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1529 cmdline_parse_token_string_t cmd_config_threshold_name =
1530 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1531 "txfreet#txrst#rxfreet");
1532 cmdline_parse_token_num_t cmd_config_threshold_value =
1533 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1535 cmdline_parse_inst_t cmd_config_threshold = {
1536 .f = cmd_config_threshold_parsed,
1538 .help_str = "port config all txfreet|txrst|rxfreet value",
1540 (void *)&cmd_config_threshold_port,
1541 (void *)&cmd_config_threshold_keyword,
1542 (void *)&cmd_config_threshold_all,
1543 (void *)&cmd_config_threshold_name,
1544 (void *)&cmd_config_threshold_value,
1550 struct cmd_stop_result {
1551 cmdline_fixed_string_t stop;
1554 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1555 __attribute__((unused)) struct cmdline *cl,
1556 __attribute__((unused)) void *data)
1558 stop_packet_forwarding();
1561 cmdline_parse_token_string_t cmd_stop_stop =
1562 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1564 cmdline_parse_inst_t cmd_stop = {
1565 .f = cmd_stop_parsed,
1567 .help_str = "stop - stop packet forwarding",
1569 (void *)&cmd_stop_stop,
1574 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1577 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1578 unsigned int *parsed_items, int check_unique_values)
1580 unsigned int nb_item;
1588 * First parse all items in the list and store their value.
1593 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1595 if ((c >= '0') && (c <= '9')) {
1596 value = (unsigned int) (value * 10 + (c - '0'));
1601 printf("character %c is not a decimal digit\n", c);
1605 printf("No valid value before comma\n");
1608 if (nb_item < max_items) {
1609 parsed_items[nb_item] = value;
1615 if (nb_item >= max_items) {
1616 printf("Number of %s = %u > %u (maximum items)\n",
1617 item_name, nb_item + 1, max_items);
1620 parsed_items[nb_item++] = value;
1621 if (! check_unique_values)
1625 * Then, check that all values in the list are differents.
1626 * No optimization here...
1628 for (i = 0; i < nb_item; i++) {
1629 for (j = i + 1; j < nb_item; j++) {
1630 if (parsed_items[j] == parsed_items[i]) {
1631 printf("duplicated %s %u at index %u and %u\n",
1632 item_name, parsed_items[i], i, j);
1640 struct cmd_set_list_result {
1641 cmdline_fixed_string_t cmd_keyword;
1642 cmdline_fixed_string_t list_name;
1643 cmdline_fixed_string_t list_of_items;
1646 static void cmd_set_list_parsed(void *parsed_result,
1647 __attribute__((unused)) struct cmdline *cl,
1648 __attribute__((unused)) void *data)
1650 struct cmd_set_list_result *res;
1652 unsigned int lcorelist[RTE_MAX_LCORE];
1653 unsigned int portlist[RTE_MAX_ETHPORTS];
1655 unsigned int nb_item;
1657 res = parsed_result;
1658 if (!strcmp(res->list_name, "corelist")) {
1659 nb_item = parse_item_list(res->list_of_items, "core",
1661 parsed_items.lcorelist, 1);
1663 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1666 if (!strcmp(res->list_name, "portlist")) {
1667 nb_item = parse_item_list(res->list_of_items, "port",
1669 parsed_items.portlist, 1);
1671 set_fwd_ports_list(parsed_items.portlist, nb_item);
1675 cmdline_parse_token_string_t cmd_set_list_keyword =
1676 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1678 cmdline_parse_token_string_t cmd_set_list_name =
1679 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1680 "corelist#portlist");
1681 cmdline_parse_token_string_t cmd_set_list_of_items =
1682 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1685 cmdline_parse_inst_t cmd_set_fwd_list = {
1686 .f = cmd_set_list_parsed,
1688 .help_str = "set corelist|portlist x[,y]*",
1690 (void *)&cmd_set_list_keyword,
1691 (void *)&cmd_set_list_name,
1692 (void *)&cmd_set_list_of_items,
1697 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1699 struct cmd_setmask_result {
1700 cmdline_fixed_string_t set;
1701 cmdline_fixed_string_t mask;
1705 static void cmd_set_mask_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_setmask_result *res = parsed_result;
1711 if (!strcmp(res->mask, "coremask"))
1712 set_fwd_lcores_mask(res->hexavalue);
1713 else if (!strcmp(res->mask, "portmask"))
1714 set_fwd_ports_mask(res->hexavalue);
1717 cmdline_parse_token_string_t cmd_setmask_set =
1718 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1719 cmdline_parse_token_string_t cmd_setmask_mask =
1720 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1721 "coremask#portmask");
1722 cmdline_parse_token_num_t cmd_setmask_value =
1723 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1725 cmdline_parse_inst_t cmd_set_fwd_mask = {
1726 .f = cmd_set_mask_parsed,
1728 .help_str = "set coremask|portmask hexadecimal value",
1730 (void *)&cmd_setmask_set,
1731 (void *)&cmd_setmask_mask,
1732 (void *)&cmd_setmask_value,
1738 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1740 struct cmd_set_result {
1741 cmdline_fixed_string_t set;
1742 cmdline_fixed_string_t what;
1746 static void cmd_set_parsed(void *parsed_result,
1747 __attribute__((unused)) struct cmdline *cl,
1748 __attribute__((unused)) void *data)
1750 struct cmd_set_result *res = parsed_result;
1751 if (!strcmp(res->what, "nbport"))
1752 set_fwd_ports_number(res->value);
1753 else if (!strcmp(res->what, "nbcore"))
1754 set_fwd_lcores_number(res->value);
1755 else if (!strcmp(res->what, "burst"))
1756 set_nb_pkt_per_burst(res->value);
1757 else if (!strcmp(res->what, "verbose"))
1758 set_verbose_level(res->value);
1761 cmdline_parse_token_string_t cmd_set_set =
1762 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1763 cmdline_parse_token_string_t cmd_set_what =
1764 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1765 "nbport#nbcore#burst#verbose");
1766 cmdline_parse_token_num_t cmd_set_value =
1767 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1769 cmdline_parse_inst_t cmd_set_numbers = {
1770 .f = cmd_set_parsed,
1772 .help_str = "set nbport|nbcore|burst|verbose value",
1774 (void *)&cmd_set_set,
1775 (void *)&cmd_set_what,
1776 (void *)&cmd_set_value,
1781 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1783 struct cmd_set_txpkts_result {
1784 cmdline_fixed_string_t cmd_keyword;
1785 cmdline_fixed_string_t txpkts;
1786 cmdline_fixed_string_t seg_lengths;
1790 cmd_set_txpkts_parsed(void *parsed_result,
1791 __attribute__((unused)) struct cmdline *cl,
1792 __attribute__((unused)) void *data)
1794 struct cmd_set_txpkts_result *res;
1795 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1796 unsigned int nb_segs;
1798 res = parsed_result;
1799 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1800 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1802 set_tx_pkt_segments(seg_lengths, nb_segs);
1805 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1806 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1807 cmd_keyword, "set");
1808 cmdline_parse_token_string_t cmd_set_txpkts_name =
1809 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1811 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1812 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1815 cmdline_parse_inst_t cmd_set_txpkts = {
1816 .f = cmd_set_txpkts_parsed,
1818 .help_str = "set txpkts x[,y]*",
1820 (void *)&cmd_set_txpkts_keyword,
1821 (void *)&cmd_set_txpkts_name,
1822 (void *)&cmd_set_txpkts_lengths,
1827 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1828 struct cmd_rx_vlan_filter_all_result {
1829 cmdline_fixed_string_t rx_vlan;
1830 cmdline_fixed_string_t what;
1831 cmdline_fixed_string_t all;
1836 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1837 __attribute__((unused)) struct cmdline *cl,
1838 __attribute__((unused)) void *data)
1840 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1842 if (!strcmp(res->what, "add"))
1843 rx_vlan_all_filter_set(res->port_id, 1);
1845 rx_vlan_all_filter_set(res->port_id, 0);
1848 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1849 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1850 rx_vlan, "rx_vlan");
1851 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1852 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1854 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1855 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1857 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1858 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1861 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1862 .f = cmd_rx_vlan_filter_all_parsed,
1864 .help_str = "add/remove all identifiers to/from the set of VLAN "
1865 "Identifiers filtered by a port",
1867 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1868 (void *)&cmd_rx_vlan_filter_all_what,
1869 (void *)&cmd_rx_vlan_filter_all_all,
1870 (void *)&cmd_rx_vlan_filter_all_portid,
1875 /* *** VLAN OFFLOAD SET ON A PORT *** */
1876 struct cmd_vlan_offload_result {
1877 cmdline_fixed_string_t vlan;
1878 cmdline_fixed_string_t set;
1879 cmdline_fixed_string_t what;
1880 cmdline_fixed_string_t on;
1881 cmdline_fixed_string_t port_id;
1885 cmd_vlan_offload_parsed(void *parsed_result,
1886 __attribute__((unused)) struct cmdline *cl,
1887 __attribute__((unused)) void *data)
1890 struct cmd_vlan_offload_result *res = parsed_result;
1893 portid_t port_id = 0;
1897 len = strnlen(str, STR_TOKEN_SIZE);
1899 /* Get port_id first */
1907 tmp = strtoul(str, NULL, 0);
1908 /* If port_id greater that what portid_t can represent, return */
1909 if(tmp >= RTE_MAX_ETHPORTS)
1911 port_id = (portid_t)tmp;
1913 if (!strcmp(res->on, "on"))
1918 if (!strcmp(res->what, "strip"))
1919 rx_vlan_strip_set(port_id, on);
1920 else if(!strcmp(res->what, "stripq")){
1921 uint16_t queue_id = 0;
1923 /* No queue_id, return */
1926 tmp = strtoul(str + i + 1, NULL, 0);
1927 /* If queue_id greater that what 16-bits can represent, return */
1931 queue_id = (uint16_t)tmp;
1932 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1934 else if (!strcmp(res->what, "filter"))
1935 rx_vlan_filter_set(port_id, on);
1937 vlan_extend_set(port_id, on);
1942 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1943 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1945 cmdline_parse_token_string_t cmd_vlan_offload_set =
1946 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1948 cmdline_parse_token_string_t cmd_vlan_offload_what =
1949 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1950 what, "strip#filter#qinq#stripq");
1951 cmdline_parse_token_string_t cmd_vlan_offload_on =
1952 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1954 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1955 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1958 cmdline_parse_inst_t cmd_vlan_offload = {
1959 .f = cmd_vlan_offload_parsed,
1961 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1962 " qinq(extended) for both rx/tx sides ",
1964 (void *)&cmd_vlan_offload_vlan,
1965 (void *)&cmd_vlan_offload_set,
1966 (void *)&cmd_vlan_offload_what,
1967 (void *)&cmd_vlan_offload_on,
1968 (void *)&cmd_vlan_offload_portid,
1973 /* *** VLAN TPID SET ON A PORT *** */
1974 struct cmd_vlan_tpid_result {
1975 cmdline_fixed_string_t vlan;
1976 cmdline_fixed_string_t set;
1977 cmdline_fixed_string_t what;
1983 cmd_vlan_tpid_parsed(void *parsed_result,
1984 __attribute__((unused)) struct cmdline *cl,
1985 __attribute__((unused)) void *data)
1987 struct cmd_vlan_tpid_result *res = parsed_result;
1988 vlan_tpid_set(res->port_id, res->tp_id);
1992 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1993 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1995 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1996 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1998 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1999 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2001 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2002 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2004 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2005 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2008 cmdline_parse_inst_t cmd_vlan_tpid = {
2009 .f = cmd_vlan_tpid_parsed,
2011 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2013 (void *)&cmd_vlan_tpid_vlan,
2014 (void *)&cmd_vlan_tpid_set,
2015 (void *)&cmd_vlan_tpid_what,
2016 (void *)&cmd_vlan_tpid_tpid,
2017 (void *)&cmd_vlan_tpid_portid,
2022 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2023 struct cmd_rx_vlan_filter_result {
2024 cmdline_fixed_string_t rx_vlan;
2025 cmdline_fixed_string_t what;
2031 cmd_rx_vlan_filter_parsed(void *parsed_result,
2032 __attribute__((unused)) struct cmdline *cl,
2033 __attribute__((unused)) void *data)
2035 struct cmd_rx_vlan_filter_result *res = parsed_result;
2037 if (!strcmp(res->what, "add"))
2038 rx_vft_set(res->port_id, res->vlan_id, 1);
2040 rx_vft_set(res->port_id, res->vlan_id, 0);
2043 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2044 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2045 rx_vlan, "rx_vlan");
2046 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2049 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2050 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2052 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2053 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2056 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2057 .f = cmd_rx_vlan_filter_parsed,
2059 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2060 "Identifiers filtered by a port",
2062 (void *)&cmd_rx_vlan_filter_rx_vlan,
2063 (void *)&cmd_rx_vlan_filter_what,
2064 (void *)&cmd_rx_vlan_filter_vlanid,
2065 (void *)&cmd_rx_vlan_filter_portid,
2070 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2071 struct cmd_tx_vlan_set_result {
2072 cmdline_fixed_string_t tx_vlan;
2073 cmdline_fixed_string_t set;
2079 cmd_tx_vlan_set_parsed(void *parsed_result,
2080 __attribute__((unused)) struct cmdline *cl,
2081 __attribute__((unused)) void *data)
2083 struct cmd_tx_vlan_set_result *res = parsed_result;
2084 tx_vlan_set(res->port_id, res->vlan_id);
2087 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2088 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2089 tx_vlan, "tx_vlan");
2090 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2091 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2093 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2094 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2096 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2097 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2100 cmdline_parse_inst_t cmd_tx_vlan_set = {
2101 .f = cmd_tx_vlan_set_parsed,
2103 .help_str = "enable hardware insertion of a VLAN header with a given "
2104 "TAG Identifier in packets sent on a port",
2106 (void *)&cmd_tx_vlan_set_tx_vlan,
2107 (void *)&cmd_tx_vlan_set_set,
2108 (void *)&cmd_tx_vlan_set_vlanid,
2109 (void *)&cmd_tx_vlan_set_portid,
2114 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2115 struct cmd_tx_vlan_reset_result {
2116 cmdline_fixed_string_t tx_vlan;
2117 cmdline_fixed_string_t reset;
2122 cmd_tx_vlan_reset_parsed(void *parsed_result,
2123 __attribute__((unused)) struct cmdline *cl,
2124 __attribute__((unused)) void *data)
2126 struct cmd_tx_vlan_reset_result *res = parsed_result;
2128 tx_vlan_reset(res->port_id);
2131 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2132 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2133 tx_vlan, "tx_vlan");
2134 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2135 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2137 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2141 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2142 .f = cmd_tx_vlan_reset_parsed,
2144 .help_str = "disable hardware insertion of a VLAN header in packets "
2147 (void *)&cmd_tx_vlan_reset_tx_vlan,
2148 (void *)&cmd_tx_vlan_reset_reset,
2149 (void *)&cmd_tx_vlan_reset_portid,
2155 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2156 struct cmd_tx_cksum_set_result {
2157 cmdline_fixed_string_t tx_cksum;
2158 cmdline_fixed_string_t set;
2164 cmd_tx_cksum_set_parsed(void *parsed_result,
2165 __attribute__((unused)) struct cmdline *cl,
2166 __attribute__((unused)) void *data)
2168 struct cmd_tx_cksum_set_result *res = parsed_result;
2170 tx_cksum_set(res->port_id, res->cksum_mask);
2173 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2174 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2175 tx_cksum, "tx_checksum");
2176 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2177 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2179 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2180 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2182 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2183 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2186 cmdline_parse_inst_t cmd_tx_cksum_set = {
2187 .f = cmd_tx_cksum_set_parsed,
2189 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2190 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2191 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2193 (void *)&cmd_tx_cksum_set_tx_cksum,
2194 (void *)&cmd_tx_cksum_set_set,
2195 (void *)&cmd_tx_cksum_set_cksum_mask,
2196 (void *)&cmd_tx_cksum_set_portid,
2201 /* *** SET FORWARDING MODE *** */
2202 struct cmd_set_fwd_mode_result {
2203 cmdline_fixed_string_t set;
2204 cmdline_fixed_string_t fwd;
2205 cmdline_fixed_string_t mode;
2208 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2209 __attribute__((unused)) struct cmdline *cl,
2210 __attribute__((unused)) void *data)
2212 struct cmd_set_fwd_mode_result *res = parsed_result;
2214 set_pkt_forwarding_mode(res->mode);
2217 cmdline_parse_token_string_t cmd_setfwd_set =
2218 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2219 cmdline_parse_token_string_t cmd_setfwd_fwd =
2220 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2221 cmdline_parse_token_string_t cmd_setfwd_mode =
2222 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2223 #ifdef RTE_LIBRTE_IEEE1588
2224 "io#mac#rxonly#txonly#csum#ieee1588");
2226 "io#mac#rxonly#txonly#csum");
2229 cmdline_parse_inst_t cmd_set_fwd_mode = {
2230 .f = cmd_set_fwd_mode_parsed,
2232 #ifdef RTE_LIBRTE_IEEE1588
2233 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2234 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2236 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2237 " RXONLY, CSUM or TXONLY packet forwarding mode",
2240 (void *)&cmd_setfwd_set,
2241 (void *)&cmd_setfwd_fwd,
2242 (void *)&cmd_setfwd_mode,
2247 /* *** SET PROMISC MODE *** */
2248 struct cmd_set_promisc_mode_result {
2249 cmdline_fixed_string_t set;
2250 cmdline_fixed_string_t promisc;
2251 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2252 uint8_t port_num; /* valid if "allports" argument == 0 */
2253 cmdline_fixed_string_t mode;
2256 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2257 __attribute__((unused)) struct cmdline *cl,
2260 struct cmd_set_promisc_mode_result *res = parsed_result;
2264 if (!strcmp(res->mode, "on"))
2271 for (i = 0; i < nb_ports; i++) {
2273 rte_eth_promiscuous_enable(i);
2275 rte_eth_promiscuous_disable(i);
2280 rte_eth_promiscuous_enable(res->port_num);
2282 rte_eth_promiscuous_disable(res->port_num);
2286 cmdline_parse_token_string_t cmd_setpromisc_set =
2287 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2288 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2289 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2291 cmdline_parse_token_string_t cmd_setpromisc_portall =
2292 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2294 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2295 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2297 cmdline_parse_token_string_t cmd_setpromisc_mode =
2298 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2301 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2302 .f = cmd_set_promisc_mode_parsed,
2304 .help_str = "set promisc all on|off: set promisc mode for all ports",
2306 (void *)&cmd_setpromisc_set,
2307 (void *)&cmd_setpromisc_promisc,
2308 (void *)&cmd_setpromisc_portall,
2309 (void *)&cmd_setpromisc_mode,
2314 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2315 .f = cmd_set_promisc_mode_parsed,
2317 .help_str = "set promisc X on|off: set promisc mode on port X",
2319 (void *)&cmd_setpromisc_set,
2320 (void *)&cmd_setpromisc_promisc,
2321 (void *)&cmd_setpromisc_portnum,
2322 (void *)&cmd_setpromisc_mode,
2327 /* *** SET ALLMULTI MODE *** */
2328 struct cmd_set_allmulti_mode_result {
2329 cmdline_fixed_string_t set;
2330 cmdline_fixed_string_t allmulti;
2331 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2332 uint8_t port_num; /* valid if "allports" argument == 0 */
2333 cmdline_fixed_string_t mode;
2336 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2337 __attribute__((unused)) struct cmdline *cl,
2340 struct cmd_set_allmulti_mode_result *res = parsed_result;
2344 if (!strcmp(res->mode, "on"))
2351 for (i = 0; i < nb_ports; i++) {
2353 rte_eth_allmulticast_enable(i);
2355 rte_eth_allmulticast_disable(i);
2360 rte_eth_allmulticast_enable(res->port_num);
2362 rte_eth_allmulticast_disable(res->port_num);
2366 cmdline_parse_token_string_t cmd_setallmulti_set =
2367 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2368 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2369 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2371 cmdline_parse_token_string_t cmd_setallmulti_portall =
2372 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2374 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2375 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2377 cmdline_parse_token_string_t cmd_setallmulti_mode =
2378 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2381 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2382 .f = cmd_set_allmulti_mode_parsed,
2384 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2386 (void *)&cmd_setallmulti_set,
2387 (void *)&cmd_setallmulti_allmulti,
2388 (void *)&cmd_setallmulti_portall,
2389 (void *)&cmd_setallmulti_mode,
2394 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2395 .f = cmd_set_allmulti_mode_parsed,
2397 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2399 (void *)&cmd_setallmulti_set,
2400 (void *)&cmd_setallmulti_allmulti,
2401 (void *)&cmd_setallmulti_portnum,
2402 (void *)&cmd_setallmulti_mode,
2407 /* *** ADD/REMOVE A PKT FILTER *** */
2408 struct cmd_pkt_filter_result {
2409 cmdline_fixed_string_t pkt_filter;
2411 cmdline_fixed_string_t protocol;
2412 cmdline_fixed_string_t src;
2413 cmdline_ipaddr_t ip_src;
2415 cmdline_fixed_string_t dst;
2416 cmdline_ipaddr_t ip_dst;
2418 cmdline_fixed_string_t flexbytes;
2419 uint16_t flexbytes_value;
2420 cmdline_fixed_string_t vlan;
2422 cmdline_fixed_string_t queue;
2424 cmdline_fixed_string_t soft;
2429 cmd_pkt_filter_parsed(void *parsed_result,
2430 __attribute__((unused)) struct cmdline *cl,
2431 __attribute__((unused)) void *data)
2433 struct rte_fdir_filter fdir_filter;
2434 struct cmd_pkt_filter_result *res = parsed_result;
2436 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2438 if (res->ip_src.family == AF_INET)
2439 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2441 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2442 &(res->ip_src.addr.ipv6),
2443 sizeof(struct in6_addr));
2445 if (res->ip_dst.family == AF_INET)
2446 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2448 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2449 &(res->ip_dst.addr.ipv6),
2450 sizeof(struct in6_addr));
2452 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2453 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2455 if (!strcmp(res->protocol, "udp"))
2456 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2457 else if (!strcmp(res->protocol, "tcp"))
2458 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2459 else if (!strcmp(res->protocol, "sctp"))
2460 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2461 else /* default only IP */
2462 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2464 if (res->ip_dst.family == AF_INET6)
2465 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2467 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2469 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2470 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2472 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2473 fdir_add_signature_filter(res->port_id, res->queue_id,
2475 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2476 fdir_update_signature_filter(res->port_id, res->queue_id,
2478 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2479 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2480 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2481 fdir_add_perfect_filter(res->port_id, res->soft_id,
2483 (uint8_t) (res->queue_id < 0),
2485 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2486 fdir_update_perfect_filter(res->port_id, res->soft_id,
2488 (uint8_t) (res->queue_id < 0),
2490 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2491 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2497 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2498 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2500 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2501 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2502 protocol, "ip#tcp#udp#sctp");
2503 cmdline_parse_token_string_t cmd_pkt_filter_src =
2504 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2506 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2507 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2509 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2510 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2512 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2513 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2515 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2516 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2518 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2519 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2521 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2522 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2523 flexbytes, "flexbytes");
2524 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2525 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2526 flexbytes_value, UINT16);
2527 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2528 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2530 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2531 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2533 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2534 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2536 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2537 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2539 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2540 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2542 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2543 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2547 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2548 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2549 pkt_filter, "add_signature_filter");
2550 cmdline_parse_inst_t cmd_add_signature_filter = {
2551 .f = cmd_pkt_filter_parsed,
2553 .help_str = "add a signature filter",
2555 (void *)&cmd_pkt_filter_add_signature_filter,
2556 (void *)&cmd_pkt_filter_port_id,
2557 (void *)&cmd_pkt_filter_protocol,
2558 (void *)&cmd_pkt_filter_src,
2559 (void *)&cmd_pkt_filter_ip_src,
2560 (void *)&cmd_pkt_filter_port_src,
2561 (void *)&cmd_pkt_filter_dst,
2562 (void *)&cmd_pkt_filter_ip_dst,
2563 (void *)&cmd_pkt_filter_port_dst,
2564 (void *)&cmd_pkt_filter_flexbytes,
2565 (void *)&cmd_pkt_filter_flexbytes_value,
2566 (void *)&cmd_pkt_filter_vlan,
2567 (void *)&cmd_pkt_filter_vlan_id,
2568 (void *)&cmd_pkt_filter_queue,
2569 (void *)&cmd_pkt_filter_queue_id,
2575 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2576 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2577 pkt_filter, "upd_signature_filter");
2578 cmdline_parse_inst_t cmd_upd_signature_filter = {
2579 .f = cmd_pkt_filter_parsed,
2581 .help_str = "update a signature filter",
2583 (void *)&cmd_pkt_filter_upd_signature_filter,
2584 (void *)&cmd_pkt_filter_port_id,
2585 (void *)&cmd_pkt_filter_protocol,
2586 (void *)&cmd_pkt_filter_src,
2587 (void *)&cmd_pkt_filter_ip_src,
2588 (void *)&cmd_pkt_filter_port_src,
2589 (void *)&cmd_pkt_filter_dst,
2590 (void *)&cmd_pkt_filter_ip_dst,
2591 (void *)&cmd_pkt_filter_port_dst,
2592 (void *)&cmd_pkt_filter_flexbytes,
2593 (void *)&cmd_pkt_filter_flexbytes_value,
2594 (void *)&cmd_pkt_filter_vlan,
2595 (void *)&cmd_pkt_filter_vlan_id,
2596 (void *)&cmd_pkt_filter_queue,
2597 (void *)&cmd_pkt_filter_queue_id,
2603 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2604 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2605 pkt_filter, "rm_signature_filter");
2606 cmdline_parse_inst_t cmd_rm_signature_filter = {
2607 .f = cmd_pkt_filter_parsed,
2609 .help_str = "remove a signature filter",
2611 (void *)&cmd_pkt_filter_rm_signature_filter,
2612 (void *)&cmd_pkt_filter_port_id,
2613 (void *)&cmd_pkt_filter_protocol,
2614 (void *)&cmd_pkt_filter_src,
2615 (void *)&cmd_pkt_filter_ip_src,
2616 (void *)&cmd_pkt_filter_port_src,
2617 (void *)&cmd_pkt_filter_dst,
2618 (void *)&cmd_pkt_filter_ip_dst,
2619 (void *)&cmd_pkt_filter_port_dst,
2620 (void *)&cmd_pkt_filter_flexbytes,
2621 (void *)&cmd_pkt_filter_flexbytes_value,
2622 (void *)&cmd_pkt_filter_vlan,
2623 (void *)&cmd_pkt_filter_vlan_id,
2629 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2630 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2631 pkt_filter, "add_perfect_filter");
2632 cmdline_parse_inst_t cmd_add_perfect_filter = {
2633 .f = cmd_pkt_filter_parsed,
2635 .help_str = "add a perfect filter",
2637 (void *)&cmd_pkt_filter_add_perfect_filter,
2638 (void *)&cmd_pkt_filter_port_id,
2639 (void *)&cmd_pkt_filter_protocol,
2640 (void *)&cmd_pkt_filter_src,
2641 (void *)&cmd_pkt_filter_ip_src,
2642 (void *)&cmd_pkt_filter_port_src,
2643 (void *)&cmd_pkt_filter_dst,
2644 (void *)&cmd_pkt_filter_ip_dst,
2645 (void *)&cmd_pkt_filter_port_dst,
2646 (void *)&cmd_pkt_filter_flexbytes,
2647 (void *)&cmd_pkt_filter_flexbytes_value,
2648 (void *)&cmd_pkt_filter_vlan,
2649 (void *)&cmd_pkt_filter_vlan_id,
2650 (void *)&cmd_pkt_filter_queue,
2651 (void *)&cmd_pkt_filter_queue_id,
2652 (void *)&cmd_pkt_filter_soft,
2653 (void *)&cmd_pkt_filter_soft_id,
2659 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2660 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2661 pkt_filter, "upd_perfect_filter");
2662 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2663 .f = cmd_pkt_filter_parsed,
2665 .help_str = "update a perfect filter",
2667 (void *)&cmd_pkt_filter_upd_perfect_filter,
2668 (void *)&cmd_pkt_filter_port_id,
2669 (void *)&cmd_pkt_filter_protocol,
2670 (void *)&cmd_pkt_filter_src,
2671 (void *)&cmd_pkt_filter_ip_src,
2672 (void *)&cmd_pkt_filter_port_src,
2673 (void *)&cmd_pkt_filter_dst,
2674 (void *)&cmd_pkt_filter_ip_dst,
2675 (void *)&cmd_pkt_filter_port_dst,
2676 (void *)&cmd_pkt_filter_flexbytes,
2677 (void *)&cmd_pkt_filter_flexbytes_value,
2678 (void *)&cmd_pkt_filter_vlan,
2679 (void *)&cmd_pkt_filter_vlan_id,
2680 (void *)&cmd_pkt_filter_queue,
2681 (void *)&cmd_pkt_filter_queue_id,
2682 (void *)&cmd_pkt_filter_soft,
2683 (void *)&cmd_pkt_filter_soft_id,
2689 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2690 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2691 pkt_filter, "rm_perfect_filter");
2692 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2693 .f = cmd_pkt_filter_parsed,
2695 .help_str = "remove a perfect filter",
2697 (void *)&cmd_pkt_filter_rm_perfect_filter,
2698 (void *)&cmd_pkt_filter_port_id,
2699 (void *)&cmd_pkt_filter_protocol,
2700 (void *)&cmd_pkt_filter_src,
2701 (void *)&cmd_pkt_filter_ip_src,
2702 (void *)&cmd_pkt_filter_port_src,
2703 (void *)&cmd_pkt_filter_dst,
2704 (void *)&cmd_pkt_filter_ip_dst,
2705 (void *)&cmd_pkt_filter_port_dst,
2706 (void *)&cmd_pkt_filter_flexbytes,
2707 (void *)&cmd_pkt_filter_flexbytes_value,
2708 (void *)&cmd_pkt_filter_vlan,
2709 (void *)&cmd_pkt_filter_vlan_id,
2710 (void *)&cmd_pkt_filter_soft,
2711 (void *)&cmd_pkt_filter_soft_id,
2716 /* *** SETUP MASKS FILTER *** */
2717 struct cmd_pkt_filter_masks_result {
2718 cmdline_fixed_string_t filter_mask;
2720 cmdline_fixed_string_t src_mask;
2721 uint32_t ip_src_mask;
2722 uint16_t ipv6_src_mask;
2723 uint16_t port_src_mask;
2724 cmdline_fixed_string_t dst_mask;
2725 uint32_t ip_dst_mask;
2726 uint16_t ipv6_dst_mask;
2727 uint16_t port_dst_mask;
2728 cmdline_fixed_string_t flexbytes;
2729 uint8_t flexbytes_value;
2730 cmdline_fixed_string_t vlan_id;
2731 uint8_t vlan_id_value;
2732 cmdline_fixed_string_t vlan_prio;
2733 uint8_t vlan_prio_value;
2734 cmdline_fixed_string_t only_ip_flow;
2735 uint8_t only_ip_flow_value;
2736 cmdline_fixed_string_t comp_ipv6_dst;
2737 uint8_t comp_ipv6_dst_value;
2741 cmd_pkt_filter_masks_parsed(void *parsed_result,
2742 __attribute__((unused)) struct cmdline *cl,
2743 __attribute__((unused)) void *data)
2745 struct rte_fdir_masks fdir_masks;
2746 struct cmd_pkt_filter_masks_result *res = parsed_result;
2748 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2750 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2751 fdir_masks.vlan_id = res->vlan_id_value;
2752 fdir_masks.vlan_prio = res->vlan_prio_value;
2753 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2754 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2755 fdir_masks.src_port_mask = res->port_src_mask;
2756 fdir_masks.dst_port_mask = res->port_dst_mask;
2757 fdir_masks.flexbytes = res->flexbytes_value;
2759 fdir_set_masks(res->port_id, &fdir_masks);
2762 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2763 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2764 filter_mask, "set_masks_filter");
2765 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2766 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2768 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2769 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2770 only_ip_flow, "only_ip_flow");
2771 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2772 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2773 only_ip_flow_value, UINT8);
2774 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2775 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2776 src_mask, "src_mask");
2777 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2778 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2779 ip_src_mask, UINT32);
2780 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2781 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2782 port_src_mask, UINT16);
2783 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2784 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2785 dst_mask, "dst_mask");
2786 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2787 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2788 ip_dst_mask, UINT32);
2789 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2790 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2791 port_dst_mask, UINT16);
2792 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2793 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2794 flexbytes, "flexbytes");
2795 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2796 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2797 flexbytes_value, UINT8);
2798 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2799 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2800 vlan_id, "vlan_id");
2801 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2802 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2803 vlan_id_value, UINT8);
2804 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2805 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2806 vlan_prio, "vlan_prio");
2807 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2808 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2809 vlan_prio_value, UINT8);
2811 cmdline_parse_inst_t cmd_set_masks_filter = {
2812 .f = cmd_pkt_filter_masks_parsed,
2814 .help_str = "setup masks filter",
2816 (void *)&cmd_pkt_filter_masks_filter_mask,
2817 (void *)&cmd_pkt_filter_masks_port_id,
2818 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2819 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2820 (void *)&cmd_pkt_filter_masks_src_mask,
2821 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2822 (void *)&cmd_pkt_filter_masks_port_src_mask,
2823 (void *)&cmd_pkt_filter_masks_dst_mask,
2824 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2825 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2826 (void *)&cmd_pkt_filter_masks_flexbytes,
2827 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2828 (void *)&cmd_pkt_filter_masks_vlan_id,
2829 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2830 (void *)&cmd_pkt_filter_masks_vlan_prio,
2831 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2837 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2838 __attribute__((unused)) struct cmdline *cl,
2839 __attribute__((unused)) void *data)
2841 struct rte_fdir_masks fdir_masks;
2842 struct cmd_pkt_filter_masks_result *res = parsed_result;
2844 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2846 fdir_masks.set_ipv6_mask = 1;
2847 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2848 fdir_masks.vlan_id = res->vlan_id_value;
2849 fdir_masks.vlan_prio = res->vlan_prio_value;
2850 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2851 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2852 fdir_masks.src_port_mask = res->port_src_mask;
2853 fdir_masks.dst_port_mask = res->port_dst_mask;
2854 fdir_masks.flexbytes = res->flexbytes_value;
2855 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2857 fdir_set_masks(res->port_id, &fdir_masks);
2860 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2861 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2862 filter_mask, "set_ipv6_masks_filter");
2863 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2864 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2865 ipv6_src_mask, UINT16);
2866 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2867 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2868 ipv6_dst_mask, UINT16);
2870 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2871 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2872 comp_ipv6_dst, "compare_dst");
2873 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2874 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2875 comp_ipv6_dst_value, UINT8);
2877 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2878 .f = cmd_pkt_filter_masks_ipv6_parsed,
2880 .help_str = "setup ipv6 masks filter",
2882 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2883 (void *)&cmd_pkt_filter_masks_port_id,
2884 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2885 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2886 (void *)&cmd_pkt_filter_masks_src_mask,
2887 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2888 (void *)&cmd_pkt_filter_masks_port_src_mask,
2889 (void *)&cmd_pkt_filter_masks_dst_mask,
2890 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2891 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2892 (void *)&cmd_pkt_filter_masks_flexbytes,
2893 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2894 (void *)&cmd_pkt_filter_masks_vlan_id,
2895 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2896 (void *)&cmd_pkt_filter_masks_vlan_prio,
2897 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2898 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2899 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2904 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2905 struct cmd_link_flow_ctrl_set_result {
2906 cmdline_fixed_string_t set;
2907 cmdline_fixed_string_t flow_ctrl;
2908 cmdline_fixed_string_t rx;
2909 cmdline_fixed_string_t rx_lfc_mode;
2910 cmdline_fixed_string_t tx;
2911 cmdline_fixed_string_t tx_lfc_mode;
2912 uint32_t high_water;
2914 uint16_t pause_time;
2920 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2921 __attribute__((unused)) struct cmdline *cl,
2922 __attribute__((unused)) void *data)
2924 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2925 struct rte_eth_fc_conf fc_conf;
2926 int rx_fc_enable, tx_fc_enable;
2930 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2931 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2932 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2933 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2935 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2936 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2939 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2940 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2942 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2943 fc_conf.high_water = res->high_water;
2944 fc_conf.low_water = res->low_water;
2945 fc_conf.pause_time = res->pause_time;
2946 fc_conf.send_xon = res->send_xon;
2948 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2950 printf("bad flow contrl parameter, return code = %d \n", ret);
2953 cmdline_parse_token_string_t cmd_lfc_set_set =
2954 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2956 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2957 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2958 flow_ctrl, "flow_ctrl");
2959 cmdline_parse_token_string_t cmd_lfc_set_rx =
2960 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2962 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2964 rx_lfc_mode, "on#off");
2965 cmdline_parse_token_string_t cmd_lfc_set_tx =
2966 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2968 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2970 tx_lfc_mode, "on#off");
2971 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2972 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2973 high_water, UINT32);
2974 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2975 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2977 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2978 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2979 pause_time, UINT16);
2980 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2981 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2983 cmdline_parse_token_num_t cmd_lfc_set_portid =
2984 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2987 cmdline_parse_inst_t cmd_link_flow_control_set = {
2988 .f = cmd_link_flow_ctrl_set_parsed,
2990 .help_str = "Configure the Ethernet link flow control...",
2992 (void *)&cmd_lfc_set_set,
2993 (void *)&cmd_lfc_set_flow_ctrl,
2994 (void *)&cmd_lfc_set_rx,
2995 (void *)&cmd_lfc_set_rx_mode,
2996 (void *)&cmd_lfc_set_tx,
2997 (void *)&cmd_lfc_set_tx_mode,
2998 (void *)&cmd_lfc_set_high_water,
2999 (void *)&cmd_lfc_set_low_water,
3000 (void *)&cmd_lfc_set_pause_time,
3001 (void *)&cmd_lfc_set_send_xon,
3002 (void *)&cmd_lfc_set_portid,
3007 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3008 struct cmd_priority_flow_ctrl_set_result {
3009 cmdline_fixed_string_t set;
3010 cmdline_fixed_string_t pfc_ctrl;
3011 cmdline_fixed_string_t rx;
3012 cmdline_fixed_string_t rx_pfc_mode;
3013 cmdline_fixed_string_t tx;
3014 cmdline_fixed_string_t tx_pfc_mode;
3015 uint32_t high_water;
3017 uint16_t pause_time;
3023 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3024 __attribute__((unused)) struct cmdline *cl,
3025 __attribute__((unused)) void *data)
3027 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3028 struct rte_eth_pfc_conf pfc_conf;
3029 int rx_fc_enable, tx_fc_enable;
3033 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3034 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3035 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3036 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3038 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3039 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3042 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3043 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3044 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3045 pfc_conf.fc.high_water = res->high_water;
3046 pfc_conf.fc.low_water = res->low_water;
3047 pfc_conf.fc.pause_time = res->pause_time;
3048 pfc_conf.priority = res->priority;
3050 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3052 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3055 cmdline_parse_token_string_t cmd_pfc_set_set =
3056 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3058 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3059 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3060 pfc_ctrl, "pfc_ctrl");
3061 cmdline_parse_token_string_t cmd_pfc_set_rx =
3062 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3064 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3065 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3066 rx_pfc_mode, "on#off");
3067 cmdline_parse_token_string_t cmd_pfc_set_tx =
3068 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3070 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3071 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3072 tx_pfc_mode, "on#off");
3073 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3074 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3075 high_water, UINT32);
3076 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3077 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3079 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3080 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3081 pause_time, UINT16);
3082 cmdline_parse_token_num_t cmd_pfc_set_priority =
3083 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3085 cmdline_parse_token_num_t cmd_pfc_set_portid =
3086 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3089 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3090 .f = cmd_priority_flow_ctrl_set_parsed,
3092 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3093 tx on|off high_water low_water pause_time priority port_id",
3095 (void *)&cmd_pfc_set_set,
3096 (void *)&cmd_pfc_set_flow_ctrl,
3097 (void *)&cmd_pfc_set_rx,
3098 (void *)&cmd_pfc_set_rx_mode,
3099 (void *)&cmd_pfc_set_tx,
3100 (void *)&cmd_pfc_set_tx_mode,
3101 (void *)&cmd_pfc_set_high_water,
3102 (void *)&cmd_pfc_set_low_water,
3103 (void *)&cmd_pfc_set_pause_time,
3104 (void *)&cmd_pfc_set_priority,
3105 (void *)&cmd_pfc_set_portid,
3110 /* *** RESET CONFIGURATION *** */
3111 struct cmd_reset_result {
3112 cmdline_fixed_string_t reset;
3113 cmdline_fixed_string_t def;
3116 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3118 __attribute__((unused)) void *data)
3120 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3121 set_def_fwd_config();
3124 cmdline_parse_token_string_t cmd_reset_set =
3125 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3126 cmdline_parse_token_string_t cmd_reset_def =
3127 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3130 cmdline_parse_inst_t cmd_reset = {
3131 .f = cmd_reset_parsed,
3133 .help_str = "set default: reset default forwarding configuration",
3135 (void *)&cmd_reset_set,
3136 (void *)&cmd_reset_def,
3141 /* *** START FORWARDING *** */
3142 struct cmd_start_result {
3143 cmdline_fixed_string_t start;
3146 cmdline_parse_token_string_t cmd_start_start =
3147 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3149 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3150 __attribute__((unused)) struct cmdline *cl,
3151 __attribute__((unused)) void *data)
3153 start_packet_forwarding(0);
3156 cmdline_parse_inst_t cmd_start = {
3157 .f = cmd_start_parsed,
3159 .help_str = "start packet forwarding",
3161 (void *)&cmd_start_start,
3166 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3167 struct cmd_start_tx_first_result {
3168 cmdline_fixed_string_t start;
3169 cmdline_fixed_string_t tx_first;
3173 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3174 __attribute__((unused)) struct cmdline *cl,
3175 __attribute__((unused)) void *data)
3177 start_packet_forwarding(1);
3180 cmdline_parse_token_string_t cmd_start_tx_first_start =
3181 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3183 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3184 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3185 tx_first, "tx_first");
3187 cmdline_parse_inst_t cmd_start_tx_first = {
3188 .f = cmd_start_tx_first_parsed,
3190 .help_str = "start packet forwarding, after sending 1 burst of packets",
3192 (void *)&cmd_start_tx_first_start,
3193 (void *)&cmd_start_tx_first_tx_first,
3198 /* *** SHOW CFG *** */
3199 struct cmd_showcfg_result {
3200 cmdline_fixed_string_t show;
3201 cmdline_fixed_string_t cfg;
3202 cmdline_fixed_string_t what;
3205 static void cmd_showcfg_parsed(void *parsed_result,
3206 __attribute__((unused)) struct cmdline *cl,
3207 __attribute__((unused)) void *data)
3209 struct cmd_showcfg_result *res = parsed_result;
3210 if (!strcmp(res->what, "rxtx"))
3211 rxtx_config_display();
3212 else if (!strcmp(res->what, "cores"))
3213 fwd_lcores_config_display();
3214 else if (!strcmp(res->what, "fwd"))
3215 fwd_config_display();
3218 cmdline_parse_token_string_t cmd_showcfg_show =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3220 cmdline_parse_token_string_t cmd_showcfg_port =
3221 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3222 cmdline_parse_token_string_t cmd_showcfg_what =
3223 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3226 cmdline_parse_inst_t cmd_showcfg = {
3227 .f = cmd_showcfg_parsed,
3229 .help_str = "show config rxtx|cores|fwd",
3231 (void *)&cmd_showcfg_show,
3232 (void *)&cmd_showcfg_port,
3233 (void *)&cmd_showcfg_what,
3238 /* *** SHOW ALL PORT INFO *** */
3239 struct cmd_showportall_result {
3240 cmdline_fixed_string_t show;
3241 cmdline_fixed_string_t port;
3242 cmdline_fixed_string_t what;
3243 cmdline_fixed_string_t all;
3246 static void cmd_showportall_parsed(void *parsed_result,
3247 __attribute__((unused)) struct cmdline *cl,
3248 __attribute__((unused)) void *data)
3252 struct cmd_showportall_result *res = parsed_result;
3253 if (!strcmp(res->show, "clear")) {
3254 if (!strcmp(res->what, "stats"))
3255 for (i = 0; i < nb_ports; i++)
3257 } else if (!strcmp(res->what, "info"))
3258 for (i = 0; i < nb_ports; i++)
3259 port_infos_display(i);
3260 else if (!strcmp(res->what, "stats"))
3261 for (i = 0; i < nb_ports; i++)
3262 nic_stats_display(i);
3263 else if (!strcmp(res->what, "fdir"))
3264 for (i = 0; i < nb_ports; i++)
3266 else if (!strcmp(res->what, "stat_qmap"))
3267 for (i = 0; i < nb_ports; i++)
3268 nic_stats_mapping_display(i);
3271 cmdline_parse_token_string_t cmd_showportall_show =
3272 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3274 cmdline_parse_token_string_t cmd_showportall_port =
3275 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3276 cmdline_parse_token_string_t cmd_showportall_what =
3277 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3278 "info#stats#fdir#stat_qmap");
3279 cmdline_parse_token_string_t cmd_showportall_all =
3280 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3281 cmdline_parse_inst_t cmd_showportall = {
3282 .f = cmd_showportall_parsed,
3284 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3286 (void *)&cmd_showportall_show,
3287 (void *)&cmd_showportall_port,
3288 (void *)&cmd_showportall_what,
3289 (void *)&cmd_showportall_all,
3294 /* *** SHOW PORT INFO *** */
3295 struct cmd_showport_result {
3296 cmdline_fixed_string_t show;
3297 cmdline_fixed_string_t port;
3298 cmdline_fixed_string_t what;
3302 static void cmd_showport_parsed(void *parsed_result,
3303 __attribute__((unused)) struct cmdline *cl,
3304 __attribute__((unused)) void *data)
3306 struct cmd_showport_result *res = parsed_result;
3307 if (!strcmp(res->show, "clear")) {
3308 if (!strcmp(res->what, "stats"))
3309 nic_stats_clear(res->portnum);
3310 } else if (!strcmp(res->what, "info"))
3311 port_infos_display(res->portnum);
3312 else if (!strcmp(res->what, "stats"))
3313 nic_stats_display(res->portnum);
3314 else if (!strcmp(res->what, "fdir"))
3315 fdir_get_infos(res->portnum);
3316 else if (!strcmp(res->what, "stat_qmap"))
3317 nic_stats_mapping_display(res->portnum);
3320 cmdline_parse_token_string_t cmd_showport_show =
3321 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3323 cmdline_parse_token_string_t cmd_showport_port =
3324 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3325 cmdline_parse_token_string_t cmd_showport_what =
3326 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3327 "info#stats#fdir#stat_qmap");
3328 cmdline_parse_token_num_t cmd_showport_portnum =
3329 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3331 cmdline_parse_inst_t cmd_showport = {
3332 .f = cmd_showport_parsed,
3334 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3336 (void *)&cmd_showport_show,
3337 (void *)&cmd_showport_port,
3338 (void *)&cmd_showport_what,
3339 (void *)&cmd_showport_portnum,
3344 /* *** READ PORT REGISTER *** */
3345 struct cmd_read_reg_result {
3346 cmdline_fixed_string_t read;
3347 cmdline_fixed_string_t reg;
3353 cmd_read_reg_parsed(void *parsed_result,
3354 __attribute__((unused)) struct cmdline *cl,
3355 __attribute__((unused)) void *data)
3357 struct cmd_read_reg_result *res = parsed_result;
3358 port_reg_display(res->port_id, res->reg_off);
3361 cmdline_parse_token_string_t cmd_read_reg_read =
3362 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3363 cmdline_parse_token_string_t cmd_read_reg_reg =
3364 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3365 cmdline_parse_token_num_t cmd_read_reg_port_id =
3366 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3367 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3368 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3370 cmdline_parse_inst_t cmd_read_reg = {
3371 .f = cmd_read_reg_parsed,
3373 .help_str = "read reg port_id reg_off",
3375 (void *)&cmd_read_reg_read,
3376 (void *)&cmd_read_reg_reg,
3377 (void *)&cmd_read_reg_port_id,
3378 (void *)&cmd_read_reg_reg_off,
3383 /* *** READ PORT REGISTER BIT FIELD *** */
3384 struct cmd_read_reg_bit_field_result {
3385 cmdline_fixed_string_t read;
3386 cmdline_fixed_string_t regfield;
3394 cmd_read_reg_bit_field_parsed(void *parsed_result,
3395 __attribute__((unused)) struct cmdline *cl,
3396 __attribute__((unused)) void *data)
3398 struct cmd_read_reg_bit_field_result *res = parsed_result;
3399 port_reg_bit_field_display(res->port_id, res->reg_off,
3400 res->bit1_pos, res->bit2_pos);
3403 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3404 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3406 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3407 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3408 regfield, "regfield");
3409 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3410 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3412 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3415 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3416 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3418 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3419 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3422 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3423 .f = cmd_read_reg_bit_field_parsed,
3425 .help_str = "read regfield port_id reg_off bit_x bit_y "
3426 "(read register bit field between bit_x and bit_y included)",
3428 (void *)&cmd_read_reg_bit_field_read,
3429 (void *)&cmd_read_reg_bit_field_regfield,
3430 (void *)&cmd_read_reg_bit_field_port_id,
3431 (void *)&cmd_read_reg_bit_field_reg_off,
3432 (void *)&cmd_read_reg_bit_field_bit1_pos,
3433 (void *)&cmd_read_reg_bit_field_bit2_pos,
3438 /* *** READ PORT REGISTER BIT *** */
3439 struct cmd_read_reg_bit_result {
3440 cmdline_fixed_string_t read;
3441 cmdline_fixed_string_t regbit;
3448 cmd_read_reg_bit_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_read_reg_bit_result *res = parsed_result;
3453 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3456 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3458 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3459 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3461 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3462 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3463 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3464 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3465 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3468 cmdline_parse_inst_t cmd_read_reg_bit = {
3469 .f = cmd_read_reg_bit_parsed,
3471 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3473 (void *)&cmd_read_reg_bit_read,
3474 (void *)&cmd_read_reg_bit_regbit,
3475 (void *)&cmd_read_reg_bit_port_id,
3476 (void *)&cmd_read_reg_bit_reg_off,
3477 (void *)&cmd_read_reg_bit_bit_pos,
3482 /* *** WRITE PORT REGISTER *** */
3483 struct cmd_write_reg_result {
3484 cmdline_fixed_string_t write;
3485 cmdline_fixed_string_t reg;
3492 cmd_write_reg_parsed(void *parsed_result,
3493 __attribute__((unused)) struct cmdline *cl,
3494 __attribute__((unused)) void *data)
3496 struct cmd_write_reg_result *res = parsed_result;
3497 port_reg_set(res->port_id, res->reg_off, res->value);
3500 cmdline_parse_token_string_t cmd_write_reg_write =
3501 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3502 cmdline_parse_token_string_t cmd_write_reg_reg =
3503 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3504 cmdline_parse_token_num_t cmd_write_reg_port_id =
3505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3506 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3507 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3508 cmdline_parse_token_num_t cmd_write_reg_value =
3509 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3511 cmdline_parse_inst_t cmd_write_reg = {
3512 .f = cmd_write_reg_parsed,
3514 .help_str = "write reg port_id reg_off reg_value",
3516 (void *)&cmd_write_reg_write,
3517 (void *)&cmd_write_reg_reg,
3518 (void *)&cmd_write_reg_port_id,
3519 (void *)&cmd_write_reg_reg_off,
3520 (void *)&cmd_write_reg_value,
3525 /* *** WRITE PORT REGISTER BIT FIELD *** */
3526 struct cmd_write_reg_bit_field_result {
3527 cmdline_fixed_string_t write;
3528 cmdline_fixed_string_t regfield;
3537 cmd_write_reg_bit_field_parsed(void *parsed_result,
3538 __attribute__((unused)) struct cmdline *cl,
3539 __attribute__((unused)) void *data)
3541 struct cmd_write_reg_bit_field_result *res = parsed_result;
3542 port_reg_bit_field_set(res->port_id, res->reg_off,
3543 res->bit1_pos, res->bit2_pos, res->value);
3546 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3547 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3549 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3550 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3551 regfield, "regfield");
3552 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3553 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3555 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3556 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3558 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3559 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3561 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3562 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3564 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3565 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3568 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3569 .f = cmd_write_reg_bit_field_parsed,
3571 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3572 "(set register bit field between bit_x and bit_y included)",
3574 (void *)&cmd_write_reg_bit_field_write,
3575 (void *)&cmd_write_reg_bit_field_regfield,
3576 (void *)&cmd_write_reg_bit_field_port_id,
3577 (void *)&cmd_write_reg_bit_field_reg_off,
3578 (void *)&cmd_write_reg_bit_field_bit1_pos,
3579 (void *)&cmd_write_reg_bit_field_bit2_pos,
3580 (void *)&cmd_write_reg_bit_field_value,
3585 /* *** WRITE PORT REGISTER BIT *** */
3586 struct cmd_write_reg_bit_result {
3587 cmdline_fixed_string_t write;
3588 cmdline_fixed_string_t regbit;
3596 cmd_write_reg_bit_parsed(void *parsed_result,
3597 __attribute__((unused)) struct cmdline *cl,
3598 __attribute__((unused)) void *data)
3600 struct cmd_write_reg_bit_result *res = parsed_result;
3601 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3604 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3605 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3607 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3608 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3610 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3611 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3612 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3613 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3614 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3616 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3617 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3619 cmdline_parse_inst_t cmd_write_reg_bit = {
3620 .f = cmd_write_reg_bit_parsed,
3622 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3624 (void *)&cmd_write_reg_bit_write,
3625 (void *)&cmd_write_reg_bit_regbit,
3626 (void *)&cmd_write_reg_bit_port_id,
3627 (void *)&cmd_write_reg_bit_reg_off,
3628 (void *)&cmd_write_reg_bit_bit_pos,
3629 (void *)&cmd_write_reg_bit_value,
3634 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3635 struct cmd_read_rxd_txd_result {
3636 cmdline_fixed_string_t read;
3637 cmdline_fixed_string_t rxd_txd;
3644 cmd_read_rxd_txd_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3648 struct cmd_read_rxd_txd_result *res = parsed_result;
3650 if (!strcmp(res->rxd_txd, "rxd"))
3651 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3652 else if (!strcmp(res->rxd_txd, "txd"))
3653 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3656 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3657 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3658 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3659 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3661 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3662 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3663 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3664 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3665 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3666 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3668 cmdline_parse_inst_t cmd_read_rxd_txd = {
3669 .f = cmd_read_rxd_txd_parsed,
3671 .help_str = "read rxd|txd port_id queue_id rxd_id",
3673 (void *)&cmd_read_rxd_txd_read,
3674 (void *)&cmd_read_rxd_txd_rxd_txd,
3675 (void *)&cmd_read_rxd_txd_port_id,
3676 (void *)&cmd_read_rxd_txd_queue_id,
3677 (void *)&cmd_read_rxd_txd_desc_id,
3683 struct cmd_quit_result {
3684 cmdline_fixed_string_t quit;
3687 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3689 __attribute__((unused)) void *data)
3695 cmdline_parse_token_string_t cmd_quit_quit =
3696 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3698 cmdline_parse_inst_t cmd_quit = {
3699 .f = cmd_quit_parsed,
3701 .help_str = "exit application",
3703 (void *)&cmd_quit_quit,
3708 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3709 struct cmd_mac_addr_result {
3710 cmdline_fixed_string_t mac_addr_cmd;
3711 cmdline_fixed_string_t what;
3713 struct ether_addr address;
3716 static void cmd_mac_addr_parsed(void *parsed_result,
3717 __attribute__((unused)) struct cmdline *cl,
3718 __attribute__((unused)) void *data)
3720 struct cmd_mac_addr_result *res = parsed_result;
3723 if (strcmp(res->what, "add") == 0)
3724 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3726 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3728 /* check the return value and print it if is < 0 */
3730 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3734 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3735 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3737 cmdline_parse_token_string_t cmd_mac_addr_what =
3738 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3740 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3741 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3742 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3745 cmdline_parse_inst_t cmd_mac_addr = {
3746 .f = cmd_mac_addr_parsed,
3748 .help_str = "mac_addr add|remove X <address>: "
3749 "add/remove MAC address on port X",
3751 (void *)&cmd_mac_addr_cmd,
3752 (void *)&cmd_mac_addr_what,
3753 (void *)&cmd_mac_addr_portnum,
3754 (void *)&cmd_mac_addr_addr,
3760 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3761 struct cmd_set_qmap_result {
3762 cmdline_fixed_string_t set;
3763 cmdline_fixed_string_t qmap;
3764 cmdline_fixed_string_t what;
3771 cmd_set_qmap_parsed(void *parsed_result,
3772 __attribute__((unused)) struct cmdline *cl,
3773 __attribute__((unused)) void *data)
3775 struct cmd_set_qmap_result *res = parsed_result;
3776 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3778 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3781 cmdline_parse_token_string_t cmd_setqmap_set =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3784 cmdline_parse_token_string_t cmd_setqmap_qmap =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3787 cmdline_parse_token_string_t cmd_setqmap_what =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3790 cmdline_parse_token_num_t cmd_setqmap_portid =
3791 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3793 cmdline_parse_token_num_t cmd_setqmap_queueid =
3794 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3796 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3797 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3800 cmdline_parse_inst_t cmd_set_qmap = {
3801 .f = cmd_set_qmap_parsed,
3803 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3805 (void *)&cmd_setqmap_set,
3806 (void *)&cmd_setqmap_qmap,
3807 (void *)&cmd_setqmap_what,
3808 (void *)&cmd_setqmap_portid,
3809 (void *)&cmd_setqmap_queueid,
3810 (void *)&cmd_setqmap_mapvalue,
3815 /* ******************************************************************************** */
3817 /* list of instructions */
3818 cmdline_parse_ctx_t main_ctx[] = {
3819 (cmdline_parse_inst_t *)&cmd_help_brief,
3820 (cmdline_parse_inst_t *)&cmd_help_long,
3821 (cmdline_parse_inst_t *)&cmd_quit,
3822 (cmdline_parse_inst_t *)&cmd_showport,
3823 (cmdline_parse_inst_t *)&cmd_showportall,
3824 (cmdline_parse_inst_t *)&cmd_showcfg,
3825 (cmdline_parse_inst_t *)&cmd_start,
3826 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3827 (cmdline_parse_inst_t *)&cmd_reset,
3828 (cmdline_parse_inst_t *)&cmd_set_numbers,
3829 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3830 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3831 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3832 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3833 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3834 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3835 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3836 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3837 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3838 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3839 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3840 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3841 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3842 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3843 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3844 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3845 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
3846 (cmdline_parse_inst_t *)&cmd_config_dcb,
3847 (cmdline_parse_inst_t *)&cmd_read_reg,
3848 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3849 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3850 (cmdline_parse_inst_t *)&cmd_write_reg,
3851 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3852 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3853 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3854 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3855 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3856 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3857 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3858 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3859 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3860 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3861 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3862 (cmdline_parse_inst_t *)&cmd_stop,
3863 (cmdline_parse_inst_t *)&cmd_mac_addr,
3864 (cmdline_parse_inst_t *)&cmd_set_qmap,
3865 (cmdline_parse_inst_t *)&cmd_operate_port,
3866 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3867 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3868 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3869 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3870 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3871 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3872 (cmdline_parse_inst_t *)&cmd_config_rss,
3873 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
3874 (cmdline_parse_inst_t *)&cmd_showport_reta,
3875 (cmdline_parse_inst_t *)&cmd_config_burst,
3876 (cmdline_parse_inst_t *)&cmd_config_thresh,
3877 (cmdline_parse_inst_t *)&cmd_config_threshold,
3881 /* prompt function, called from main on MASTER lcore */
3887 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3891 cmdline_interact(cl);
3892 cmdline_stdin_exit(cl);
3896 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3898 if (id < nb_ports) {
3899 /* check if need_reconfig has been set to 1 */
3900 if (ports[id].need_reconfig == 0)
3901 ports[id].need_reconfig = dev;
3902 /* check if need_reconfig_queues has been set to 1 */
3903 if (ports[id].need_reconfig_queues == 0)
3904 ports[id].need_reconfig_queues = queue;
3908 for (pid = 0; pid < nb_ports; pid++) {
3909 /* check if need_reconfig has been set to 1 */
3910 if (ports[pid].need_reconfig == 0)
3911 ports[pid].need_reconfig = dev;
3912 /* check if need_reconfig_queues has been set to 1 */
3913 if (ports[pid].need_reconfig_queues == 0)
3914 ports[pid].need_reconfig_queues = queue;