4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
90 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
93 uint8_t bypass_is_supported(portid_t port_id);
96 /* *** Help command with introduction. *** */
97 struct cmd_help_brief_result {
98 cmdline_fixed_string_t help;
101 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
103 __attribute__((unused)) void *data)
108 "Help is available for the following sections:\n\n"
109 " help control : Start and stop forwarding.\n"
110 " help display : Displaying port, stats and config "
112 " help config : Configuration information.\n"
113 " help ports : Configuring ports.\n"
114 " help flowdir : Flow Director filter help.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help all : All of the above sections.\n\n"
121 cmdline_parse_token_string_t cmd_help_brief_help =
122 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
124 cmdline_parse_inst_t cmd_help_brief = {
125 .f = cmd_help_brief_parsed,
127 .help_str = "show help",
129 (void *)&cmd_help_brief_help,
134 /* *** Help command with help sections. *** */
135 struct cmd_help_long_result {
136 cmdline_fixed_string_t help;
137 cmdline_fixed_string_t section;
140 static void cmd_help_long_parsed(void *parsed_result,
142 __attribute__((unused)) void *data)
145 struct cmd_help_long_result *res = parsed_result;
147 if (!strcmp(res->section, "all"))
150 if (show_all || !strcmp(res->section, "control")) {
155 "Control forwarding:\n"
156 "-------------------\n\n"
159 " Start packet forwarding with current configuration.\n\n"
162 " Start packet forwarding with current config"
163 " after sending one burst of packets.\n\n"
166 " Stop packet forwarding, and display accumulated"
170 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
174 if (show_all || !strcmp(res->section, "display")) {
182 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
183 " Display information for port_id, or all.\n\n"
185 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
186 " Clear information for port_id, or all.\n\n"
188 "show config (rxtx|cores|fwd)\n"
189 " Display the given configuration.\n\n"
191 "read rxd (port_id) (queue_id) (rxd_id)\n"
192 " Display an RX descriptor of a port RX queue.\n\n"
194 "read txd (port_id) (queue_id) (txd_id)\n"
195 " Display a TX descriptor of a port TX queue.\n\n"
199 if (show_all || !strcmp(res->section, "config")) {
205 "Configuration changes only become active when"
206 " forwarding is started/restarted.\n\n"
209 " Reset forwarding to the default configuration.\n\n"
211 "set verbose (level)\n"
212 " Set the debug verbosity level X.\n\n"
215 " Set number of ports.\n\n"
218 " Set number of cores.\n\n"
220 "set coremask (mask)\n"
221 " Set the forwarding cores hexadecimal mask.\n\n"
223 "set portmask (mask)\n"
224 " Set the forwarding ports hexadecimal mask.\n\n"
227 " Set number of packets per burst.\n\n"
229 "set burst tx delay (microseconds) retry (num)\n"
230 " Set the transmit delay time and number of retries"
231 " in mac_retry forwarding mode.\n\n"
233 "set txpkts (x[,y]*)\n"
234 " Set the length of each segment of TXONLY"
237 "set corelist (x[,y]*)\n"
238 " Set the list of forwarding cores.\n\n"
240 "set portlist (x[,y]*)\n"
241 " Set the list of forwarding ports.\n\n"
243 "vlan set strip (on|off) (port_id)\n"
244 " Set the VLAN strip on a port.\n\n"
246 "vlan set stripq (on|off) (port_id,queue_id)\n"
247 " Set the VLAN strip for a queue on a port.\n\n"
249 "vlan set filter (on|off) (port_id)\n"
250 " Set the VLAN filter on a port.\n\n"
252 "vlan set qinq (on|off) (port_id)\n"
253 " Set the VLAN QinQ (extended queue in queue)"
256 "vlan set tpid (value) (port_id)\n"
257 " Set the outer VLAN TPID for Packet Filtering on"
260 "rx_vlan add (vlan_id|all) (port_id)\n"
261 " Add a vlan_id, or all identifiers, to the set"
262 " of VLAN identifiers filtered by port_id.\n\n"
264 "rx_vlan rm (vlan_id|all) (port_id)\n"
265 " Remove a vlan_id, or all identifiers, from the set"
266 " of VLAN identifiers filtered by port_id.\n\n"
268 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
269 " Add a vlan_id, to the set of VLAN identifiers"
270 "filtered for VF(s) from port_id.\n\n"
272 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
273 " Remove a vlan_id, to the set of VLAN identifiers"
274 "filtered for VF(s) from port_id.\n\n"
276 "rx_vlan set tpid (value) (port_id)\n"
277 " Set the outer VLAN TPID for Packet Filtering on"
280 "tx_vlan set vlan_id (port_id)\n"
281 " Set hardware insertion of VLAN ID in packets sent"
284 "tx_vlan reset (port_id)\n"
285 " Disable hardware insertion of a VLAN header in"
286 " packets sent on a port.\n\n"
288 "tx_checksum set mask (port_id)\n"
289 " Enable hardware insertion of checksum offload with"
290 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
291 " bit 0 - insert ip checksum offload if set\n"
292 " bit 1 - insert udp checksum offload if set\n"
293 " bit 2 - insert tcp checksum offload if set\n"
294 " bit 3 - insert sctp checksum offload if set\n"
295 " Please check the NIC datasheet for HW limits.\n\n"
297 #ifdef RTE_LIBRTE_IEEE1588
298 "set fwd (io|mac|mac_retry|rxonly|txonly|csum|ieee1588)\n"
299 " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY or ieee1588"
300 " packet forwarding mode.\n\n"
303 "set fwd (io|mac|mac_retry|rxonly|txonly|csum)\n"
304 " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY packet"
305 " forwarding mode.\n\n"
308 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
309 " Add a MAC address on port_id.\n\n"
311 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Remove a MAC address from port_id.\n\n"
314 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
315 " Add a MAC address for a VF on the port.\n\n"
317 "set port (port_id) uta (mac_address|all) (on|off)\n"
318 " Add/Remove a or all unicast hash filter(s)"
321 "set promisc (port_id|all) (on|off)\n"
322 " Set the promiscuous mode on port_id, or all.\n\n"
324 "set allmulti (port_id|all) (on|off)\n"
325 " Set the allmulti mode on port_id, or all.\n\n"
327 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
328 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
329 " (on|off) (port_id)\n"
330 " Set the link flow control parameter on a port.\n\n"
332 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
333 " (low_water) (pause_time) (priority) (port_id)\n"
334 " Set the priority flow control parameter on a"
337 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
338 " Set statistics mapping (qmapping 0..15) for RX/TX"
340 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
341 " on port 0 to mapping 5.\n\n"
343 "set port (port_id) vf (vf_id) rx|tx on|off \n"
344 " Enable/Disable a VF receive/tranmit from a port\n\n"
346 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
348 " AUPE:accepts untagged VLAN;"
349 "ROPE:accept unicast hash\n\n"
350 " BAM:accepts broadcast packets;"
351 "MPE:accepts all multicast packets\n\n"
352 " Enable/Disable a VF receive mode of a port\n\n"
354 "set port (port_id) mirror-rule (rule_id)"
355 "(pool-mirror|vlan-mirror)\n"
356 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
357 " Set pool or vlan type mirror rule on a port.\n"
358 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
359 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
362 "set port (port_id) mirror-rule (rule_id)"
363 " (uplink-mirror|downlink-mirror) dst-pool"
364 " (pool_id) (on|off)\n"
365 " Set uplink or downlink type mirror rule on a port.\n"
366 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
367 " 0 on' enable mirror income traffic to pool 0.\n\n"
369 "reset port (port_id) mirror-rule (rule_id)\n"
370 " Reset a mirror rule.\n\n"
372 "set flush_rx (on|off)\n"
373 " Flush (default) or don't flush RX streams before"
374 " forwarding. Mainly used with PCAP drivers.\n\n"
376 #ifdef RTE_NIC_BYPASS
377 "set bypass mode (normal|bypass|isolate) (port_id)\n"
378 " Set the bypass mode for the lowest port on bypass enabled"
381 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
382 "mode (normal|bypass|isolate) (port_id)\n"
383 " Set the event required to initiate specified bypass mode for"
384 " the lowest port on a bypass enabled NIC where:\n"
385 " timeout = enable bypass after watchdog timeout.\n"
386 " os_on = enable bypass when OS/board is powered on.\n"
387 " os_off = enable bypass when OS/board is powered off.\n"
388 " power_on = enable bypass when power supply is turned on.\n"
389 " power_off = enable bypass when power supply is turned off."
392 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
393 " Set the bypass watchdog timeout to 'n' seconds"
394 " where 0 = instant.\n\n"
396 "show bypass config (port_id)\n"
397 " Show the bypass configuration for a bypass enabled NIC"
398 " using the lowest port on the NIC.\n\n"
405 if (show_all || !strcmp(res->section, "flowdir")) {
410 "Flow director mode:\n"
411 "-------------------\n\n"
413 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
414 " src (src_ip_address) (src_port)"
415 " dst (dst_ip_address) (dst_port)"
416 " flexbytes (flexbytes_values) vlan (vlan_id)"
417 " queue (queue_id)\n"
418 " Add a signature filter.\n\n"
420 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
421 " src (src_ip_address) (src_port)"
422 " dst (dst_ip_address) (dst_port)"
423 " flexbytes (flexbytes_values) vlan (vlan_id)"
424 " queue (queue_id)\n"
425 " Update a signature filter.\n\n"
427 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
428 " src (src_ip_address) (src_port)"
429 " dst (dst_ip_address) (dst_port)"
430 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
431 " Remove a signature filter.\n\n"
433 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
434 " src (src_ip_address) (src_port)"
435 " dst (dst_ip_address) (dst_port)"
436 " flexbytes (flexbytes_values) vlan (vlan_id)"
437 " queue (queue_id) soft (soft_id)\n"
438 " Add a perfect filter.\n\n"
440 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
441 " src (src_ip_address) (src_port)"
442 " dst (dst_ip_address) (dst_port)"
443 " flexbytes (flexbytes_values) vlan (vlan_id)"
444 " queue (queue_id)\n"
445 " Update a perfect filter.\n\n"
447 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
448 " src (src_ip_address) (src_port)"
449 " dst (dst_ip_address) (dst_port)"
450 " flexbytes (flexbytes_values) vlan (vlan_id)"
452 " Remove a perfect filter.\n\n"
454 "set_masks_filter (port_id) only_ip_flow (0|1)"
455 " src_mask (ip_src_mask) (src_port_mask)"
456 " dst_mask (ip_dst_mask) (dst_port_mask)"
457 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
458 " Set IPv4 filter masks.\n\n"
460 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
461 " src_mask (ip_src_mask) (src_port_mask)"
462 " dst_mask (ip_dst_mask) (dst_port_mask)"
463 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
464 " compare_dst (0|1)\n"
465 " Set IPv6 filter masks.\n\n"
469 if (show_all || !strcmp(res->section, "ports")) {
475 "----------------\n\n"
477 "port start (port_id|all)\n"
478 " Start all ports or port_id.\n\n"
480 "port stop (port_id|all)\n"
481 " Stop all ports or port_id.\n\n"
483 "port close (port_id|all)\n"
484 " Close all ports or port_id.\n\n"
486 "port config (port_id|all) speed (10|100|1000|10000|auto)"
487 " duplex (half|full|auto)\n"
488 " Set speed and duplex for all ports or port_id\n\n"
490 "port config all (rxq|txq|rxd|txd) (value)\n"
491 " Set number for rxq/txq/rxd/txd.\n\n"
493 "port config all max-pkt-len (value)\n"
494 " Set the max packet length.\n\n"
496 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
498 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
501 "port config all rss (ip|udp|none)\n"
502 " Set the RSS mode.\n\n"
504 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
505 " Set the RSS redirection table.\n\n"
507 "port config (port_id) dcb vt (on|off) (traffic_class)"
509 " Set the DCB mode.\n\n"
511 "port config all burst (value)\n"
512 " Set the number of packets per burst.\n\n"
514 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
516 " Set the ring prefetch/host/writeback threshold"
517 " for tx/rx queue.\n\n"
519 "port config all (txfreet|txrst|rxfreet) (value)\n"
520 " Set free threshold for rx/tx, or set"
521 " tx rs bit threshold.\n\n"
525 if (show_all || !strcmp(res->section, "registers")) {
533 "read reg (port_id) (address)\n"
534 " Display value of a port register.\n\n"
536 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
537 " Display a port register bit field.\n\n"
539 "read regbit (port_id) (address) (bit_x)\n"
540 " Display a single port register bit.\n\n"
542 "write reg (port_id) (address) (value)\n"
543 " Set value of a port register.\n\n"
545 "write regfield (port_id) (address) (bit_x) (bit_y)"
547 " Set bit field of a port register.\n\n"
549 "write regbit (port_id) (address) (bit_x) (value)\n"
550 " Set single bit value of a port register.\n\n"
555 cmdline_parse_token_string_t cmd_help_long_help =
556 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
558 cmdline_parse_token_string_t cmd_help_long_section =
559 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
560 "all#control#display#config#flowdir#"
563 cmdline_parse_inst_t cmd_help_long = {
564 .f = cmd_help_long_parsed,
566 .help_str = "show help",
568 (void *)&cmd_help_long_help,
569 (void *)&cmd_help_long_section,
575 /* *** start/stop/close all ports *** */
576 struct cmd_operate_port_result {
577 cmdline_fixed_string_t keyword;
578 cmdline_fixed_string_t name;
579 cmdline_fixed_string_t value;
582 static void cmd_operate_port_parsed(void *parsed_result,
583 __attribute__((unused)) struct cmdline *cl,
584 __attribute__((unused)) void *data)
586 struct cmd_operate_port_result *res = parsed_result;
588 if (!strcmp(res->name, "start"))
589 start_port(RTE_PORT_ALL);
590 else if (!strcmp(res->name, "stop"))
591 stop_port(RTE_PORT_ALL);
592 else if (!strcmp(res->name, "close"))
593 close_port(RTE_PORT_ALL);
595 printf("Unknown parameter\n");
598 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
599 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
601 cmdline_parse_token_string_t cmd_operate_port_all_port =
602 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
604 cmdline_parse_token_string_t cmd_operate_port_all_all =
605 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
607 cmdline_parse_inst_t cmd_operate_port = {
608 .f = cmd_operate_port_parsed,
610 .help_str = "port start|stop|close all: start/stop/close all ports",
612 (void *)&cmd_operate_port_all_cmd,
613 (void *)&cmd_operate_port_all_port,
614 (void *)&cmd_operate_port_all_all,
619 /* *** start/stop/close specific port *** */
620 struct cmd_operate_specific_port_result {
621 cmdline_fixed_string_t keyword;
622 cmdline_fixed_string_t name;
626 static void cmd_operate_specific_port_parsed(void *parsed_result,
627 __attribute__((unused)) struct cmdline *cl,
628 __attribute__((unused)) void *data)
630 struct cmd_operate_specific_port_result *res = parsed_result;
632 if (!strcmp(res->name, "start"))
633 start_port(res->value);
634 else if (!strcmp(res->name, "stop"))
635 stop_port(res->value);
636 else if (!strcmp(res->name, "close"))
637 close_port(res->value);
639 printf("Unknown parameter\n");
642 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
643 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
645 cmdline_parse_token_string_t cmd_operate_specific_port_port =
646 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
647 name, "start#stop#close");
648 cmdline_parse_token_num_t cmd_operate_specific_port_id =
649 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
652 cmdline_parse_inst_t cmd_operate_specific_port = {
653 .f = cmd_operate_specific_port_parsed,
655 .help_str = "port start|stop|close X: start/stop/close port X",
657 (void *)&cmd_operate_specific_port_cmd,
658 (void *)&cmd_operate_specific_port_port,
659 (void *)&cmd_operate_specific_port_id,
664 /* *** configure speed for all ports *** */
665 struct cmd_config_speed_all {
666 cmdline_fixed_string_t port;
667 cmdline_fixed_string_t keyword;
668 cmdline_fixed_string_t all;
669 cmdline_fixed_string_t item1;
670 cmdline_fixed_string_t item2;
671 cmdline_fixed_string_t value1;
672 cmdline_fixed_string_t value2;
676 cmd_config_speed_all_parsed(void *parsed_result,
677 __attribute__((unused)) struct cmdline *cl,
678 __attribute__((unused)) void *data)
680 struct cmd_config_speed_all *res = parsed_result;
681 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
682 uint16_t link_duplex = 0;
685 if (!all_ports_stopped()) {
686 printf("Please stop all ports first\n");
690 if (!strcmp(res->value1, "10"))
691 link_speed = ETH_LINK_SPEED_10;
692 else if (!strcmp(res->value1, "100"))
693 link_speed = ETH_LINK_SPEED_100;
694 else if (!strcmp(res->value1, "1000"))
695 link_speed = ETH_LINK_SPEED_1000;
696 else if (!strcmp(res->value1, "10000"))
697 link_speed = ETH_LINK_SPEED_10000;
698 else if (!strcmp(res->value1, "auto"))
699 link_speed = ETH_LINK_SPEED_AUTONEG;
701 printf("Unknown parameter\n");
705 if (!strcmp(res->value2, "half"))
706 link_duplex = ETH_LINK_HALF_DUPLEX;
707 else if (!strcmp(res->value2, "full"))
708 link_duplex = ETH_LINK_FULL_DUPLEX;
709 else if (!strcmp(res->value2, "auto"))
710 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
712 printf("Unknown parameter\n");
716 for (pid = 0; pid < nb_ports; pid++) {
717 ports[pid].dev_conf.link_speed = link_speed;
718 ports[pid].dev_conf.link_duplex = link_duplex;
721 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
724 cmdline_parse_token_string_t cmd_config_speed_all_port =
725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
726 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
729 cmdline_parse_token_string_t cmd_config_speed_all_all =
730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
731 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
733 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
735 "10#100#1000#10000#auto");
736 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
738 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
739 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
742 cmdline_parse_inst_t cmd_config_speed_all = {
743 .f = cmd_config_speed_all_parsed,
745 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
748 (void *)&cmd_config_speed_all_port,
749 (void *)&cmd_config_speed_all_keyword,
750 (void *)&cmd_config_speed_all_all,
751 (void *)&cmd_config_speed_all_item1,
752 (void *)&cmd_config_speed_all_value1,
753 (void *)&cmd_config_speed_all_item2,
754 (void *)&cmd_config_speed_all_value2,
759 /* *** configure speed for specific port *** */
760 struct cmd_config_speed_specific {
761 cmdline_fixed_string_t port;
762 cmdline_fixed_string_t keyword;
764 cmdline_fixed_string_t item1;
765 cmdline_fixed_string_t item2;
766 cmdline_fixed_string_t value1;
767 cmdline_fixed_string_t value2;
771 cmd_config_speed_specific_parsed(void *parsed_result,
772 __attribute__((unused)) struct cmdline *cl,
773 __attribute__((unused)) void *data)
775 struct cmd_config_speed_specific *res = parsed_result;
776 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
777 uint16_t link_duplex = 0;
779 if (!all_ports_stopped()) {
780 printf("Please stop all ports first\n");
784 if (res->id >= nb_ports) {
785 printf("Port id %d must be less than %d\n", res->id, nb_ports);
789 if (!strcmp(res->value1, "10"))
790 link_speed = ETH_LINK_SPEED_10;
791 else if (!strcmp(res->value1, "100"))
792 link_speed = ETH_LINK_SPEED_100;
793 else if (!strcmp(res->value1, "1000"))
794 link_speed = ETH_LINK_SPEED_1000;
795 else if (!strcmp(res->value1, "10000"))
796 link_speed = ETH_LINK_SPEED_10000;
797 else if (!strcmp(res->value1, "auto"))
798 link_speed = ETH_LINK_SPEED_AUTONEG;
800 printf("Unknown parameter\n");
804 if (!strcmp(res->value2, "half"))
805 link_duplex = ETH_LINK_HALF_DUPLEX;
806 else if (!strcmp(res->value2, "full"))
807 link_duplex = ETH_LINK_FULL_DUPLEX;
808 else if (!strcmp(res->value2, "auto"))
809 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
811 printf("Unknown parameter\n");
815 ports[res->id].dev_conf.link_speed = link_speed;
816 ports[res->id].dev_conf.link_duplex = link_duplex;
818 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
822 cmdline_parse_token_string_t cmd_config_speed_specific_port =
823 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
825 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
826 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
828 cmdline_parse_token_num_t cmd_config_speed_specific_id =
829 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
830 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
831 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
833 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
834 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
835 "10#100#1000#10000#auto");
836 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
837 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
839 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
840 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
843 cmdline_parse_inst_t cmd_config_speed_specific = {
844 .f = cmd_config_speed_specific_parsed,
846 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
849 (void *)&cmd_config_speed_specific_port,
850 (void *)&cmd_config_speed_specific_keyword,
851 (void *)&cmd_config_speed_specific_id,
852 (void *)&cmd_config_speed_specific_item1,
853 (void *)&cmd_config_speed_specific_value1,
854 (void *)&cmd_config_speed_specific_item2,
855 (void *)&cmd_config_speed_specific_value2,
860 /* *** configure txq/rxq, txd/rxd *** */
861 struct cmd_config_rx_tx {
862 cmdline_fixed_string_t port;
863 cmdline_fixed_string_t keyword;
864 cmdline_fixed_string_t all;
865 cmdline_fixed_string_t name;
870 cmd_config_rx_tx_parsed(void *parsed_result,
871 __attribute__((unused)) struct cmdline *cl,
872 __attribute__((unused)) void *data)
874 struct cmd_config_rx_tx *res = parsed_result;
876 if (!all_ports_stopped()) {
877 printf("Please stop all ports first\n");
881 if (!strcmp(res->name, "rxq")) {
882 if (res->value <= 0) {
883 printf("rxq %d invalid - must be > 0\n", res->value);
888 else if (!strcmp(res->name, "txq")) {
889 if (res->value <= 0) {
890 printf("txq %d invalid - must be > 0\n", res->value);
895 else if (!strcmp(res->name, "rxd")) {
896 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
897 printf("rxd %d invalid - must be > 0 && <= %d\n",
898 res->value, RTE_TEST_RX_DESC_MAX);
902 } else if (!strcmp(res->name, "txd")) {
903 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
904 printf("txd %d invalid - must be > 0 && <= %d\n",
905 res->value, RTE_TEST_TX_DESC_MAX);
910 printf("Unknown parameter\n");
916 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
919 cmdline_parse_token_string_t cmd_config_rx_tx_port =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
921 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
922 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
923 cmdline_parse_token_string_t cmd_config_rx_tx_all =
924 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
925 cmdline_parse_token_string_t cmd_config_rx_tx_name =
926 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
928 cmdline_parse_token_num_t cmd_config_rx_tx_value =
929 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
931 cmdline_parse_inst_t cmd_config_rx_tx = {
932 .f = cmd_config_rx_tx_parsed,
934 .help_str = "port config all rxq|txq|rxd|txd value",
936 (void *)&cmd_config_rx_tx_port,
937 (void *)&cmd_config_rx_tx_keyword,
938 (void *)&cmd_config_rx_tx_all,
939 (void *)&cmd_config_rx_tx_name,
940 (void *)&cmd_config_rx_tx_value,
945 /* *** config max packet length *** */
946 struct cmd_config_max_pkt_len_result {
947 cmdline_fixed_string_t port;
948 cmdline_fixed_string_t keyword;
949 cmdline_fixed_string_t all;
950 cmdline_fixed_string_t name;
955 cmd_config_max_pkt_len_parsed(void *parsed_result,
956 __attribute__((unused)) struct cmdline *cl,
957 __attribute__((unused)) void *data)
959 struct cmd_config_max_pkt_len_result *res = parsed_result;
961 if (!all_ports_stopped()) {
962 printf("Please stop all ports first\n");
966 if (!strcmp(res->name, "max-pkt-len")) {
967 if (res->value < ETHER_MIN_LEN) {
968 printf("max-pkt-len can not be less than %d\n",
972 if (res->value == rx_mode.max_rx_pkt_len)
975 rx_mode.max_rx_pkt_len = res->value;
976 if (res->value > ETHER_MAX_LEN)
977 rx_mode.jumbo_frame = 1;
979 rx_mode.jumbo_frame = 0;
981 printf("Unknown parameter\n");
987 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
990 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
991 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
993 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
994 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
996 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
997 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
999 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1000 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1002 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1003 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1006 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1007 .f = cmd_config_max_pkt_len_parsed,
1009 .help_str = "port config all max-pkt-len value",
1011 (void *)&cmd_config_max_pkt_len_port,
1012 (void *)&cmd_config_max_pkt_len_keyword,
1013 (void *)&cmd_config_max_pkt_len_all,
1014 (void *)&cmd_config_max_pkt_len_name,
1015 (void *)&cmd_config_max_pkt_len_value,
1020 /* *** configure rx mode *** */
1021 struct cmd_config_rx_mode_flag {
1022 cmdline_fixed_string_t port;
1023 cmdline_fixed_string_t keyword;
1024 cmdline_fixed_string_t all;
1025 cmdline_fixed_string_t name;
1026 cmdline_fixed_string_t value;
1030 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1031 __attribute__((unused)) struct cmdline *cl,
1032 __attribute__((unused)) void *data)
1034 struct cmd_config_rx_mode_flag *res = parsed_result;
1036 if (!all_ports_stopped()) {
1037 printf("Please stop all ports first\n");
1041 if (!strcmp(res->name, "crc-strip")) {
1042 if (!strcmp(res->value, "on"))
1043 rx_mode.hw_strip_crc = 1;
1044 else if (!strcmp(res->value, "off"))
1045 rx_mode.hw_strip_crc = 0;
1047 printf("Unknown parameter\n");
1050 } else if (!strcmp(res->name, "rx-cksum")) {
1051 if (!strcmp(res->value, "on"))
1052 rx_mode.hw_ip_checksum = 1;
1053 else if (!strcmp(res->value, "off"))
1054 rx_mode.hw_ip_checksum = 0;
1056 printf("Unknown parameter\n");
1059 } else if (!strcmp(res->name, "hw-vlan")) {
1060 if (!strcmp(res->value, "on")) {
1061 rx_mode.hw_vlan_filter = 1;
1062 rx_mode.hw_vlan_strip = 1;
1064 else if (!strcmp(res->value, "off")) {
1065 rx_mode.hw_vlan_filter = 0;
1066 rx_mode.hw_vlan_strip = 0;
1069 printf("Unknown parameter\n");
1072 } else if (!strcmp(res->name, "drop-en")) {
1073 if (!strcmp(res->value, "on"))
1075 else if (!strcmp(res->value, "off"))
1078 printf("Unknown parameter\n");
1082 printf("Unknown parameter\n");
1088 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1091 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1092 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1093 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1094 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1096 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1097 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1098 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1099 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1100 "crc-strip#rx-cksum#hw-vlan");
1101 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1102 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1105 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1106 .f = cmd_config_rx_mode_flag_parsed,
1108 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1110 (void *)&cmd_config_rx_mode_flag_port,
1111 (void *)&cmd_config_rx_mode_flag_keyword,
1112 (void *)&cmd_config_rx_mode_flag_all,
1113 (void *)&cmd_config_rx_mode_flag_name,
1114 (void *)&cmd_config_rx_mode_flag_value,
1119 /* *** configure rss *** */
1120 struct cmd_config_rss {
1121 cmdline_fixed_string_t port;
1122 cmdline_fixed_string_t keyword;
1123 cmdline_fixed_string_t all;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1129 cmd_config_rss_parsed(void *parsed_result,
1130 __attribute__((unused)) struct cmdline *cl,
1131 __attribute__((unused)) void *data)
1133 struct cmd_config_rss *res = parsed_result;
1135 if (!all_ports_stopped()) {
1136 printf("Please stop all ports first\n");
1140 if (!strcmp(res->value, "ip"))
1141 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1142 else if (!strcmp(res->value, "udp"))
1143 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1144 else if (!strcmp(res->value, "none"))
1147 printf("Unknown parameter\n");
1153 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1156 cmdline_parse_token_string_t cmd_config_rss_port =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1158 cmdline_parse_token_string_t cmd_config_rss_keyword =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1160 cmdline_parse_token_string_t cmd_config_rss_all =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1162 cmdline_parse_token_string_t cmd_config_rss_name =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1164 cmdline_parse_token_string_t cmd_config_rss_value =
1165 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1167 cmdline_parse_inst_t cmd_config_rss = {
1168 .f = cmd_config_rss_parsed,
1170 .help_str = "port config all rss ip|udp|none",
1172 (void *)&cmd_config_rss_port,
1173 (void *)&cmd_config_rss_keyword,
1174 (void *)&cmd_config_rss_all,
1175 (void *)&cmd_config_rss_name,
1176 (void *)&cmd_config_rss_value,
1181 /* *** Configure RSS RETA *** */
1182 struct cmd_config_rss_reta {
1183 cmdline_fixed_string_t port;
1184 cmdline_fixed_string_t keyword;
1186 cmdline_fixed_string_t name;
1187 cmdline_fixed_string_t list_name;
1188 cmdline_fixed_string_t list_of_items;
1192 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1199 const char *p, *p0 = str;
1206 unsigned long int_fld[_NUM_FLD];
1207 char *str_fld[_NUM_FLD];
1209 while ((p = strchr(p0,'(')) != NULL) {
1211 if((p0 = strchr(p,')')) == NULL)
1215 if(size >= sizeof(s))
1218 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1219 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1221 for (i = 0; i < _NUM_FLD; i++) {
1223 int_fld[i] = strtoul(str_fld[i], &end, 0);
1224 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1228 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1229 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1231 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1232 printf("Invalid RETA hash index=%d",hash_index);
1236 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1237 reta_conf->mask_lo |= (1ULL << hash_index);
1239 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1241 reta_conf->reta[hash_index] = nb_queue;
1248 cmd_set_rss_reta_parsed(void *parsed_result,
1249 __attribute__((unused)) struct cmdline *cl,
1250 __attribute__((unused)) void *data)
1253 struct rte_eth_rss_reta reta_conf;
1254 struct cmd_config_rss_reta *res = parsed_result;
1256 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1257 if (!strcmp(res->list_name, "reta")) {
1258 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1259 printf("Invalid RSS Redirection Table config entered\n");
1262 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1264 printf("Bad redirection table parameter, return code = %d \n",ret);
1268 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1270 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1272 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1273 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1274 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1276 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1278 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1281 cmdline_parse_inst_t cmd_config_rss_reta = {
1282 .f = cmd_set_rss_reta_parsed,
1284 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1286 (void *)&cmd_config_rss_reta_port,
1287 (void *)&cmd_config_rss_reta_keyword,
1288 (void *)&cmd_config_rss_reta_port_id,
1289 (void *)&cmd_config_rss_reta_name,
1290 (void *)&cmd_config_rss_reta_list_name,
1291 (void *)&cmd_config_rss_reta_list_of_items,
1296 /* *** SHOW PORT RETA INFO *** */
1297 struct cmd_showport_reta {
1298 cmdline_fixed_string_t show;
1299 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t rss;
1302 cmdline_fixed_string_t reta;
1307 static void cmd_showport_reta_parsed(void *parsed_result,
1308 __attribute__((unused)) struct cmdline *cl,
1309 __attribute__((unused)) void *data)
1311 struct cmd_showport_reta *res = parsed_result;
1312 struct rte_eth_rss_reta reta_conf;
1314 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1315 printf("Invalid RSS Redirection Table config entered\n");
1319 reta_conf.mask_lo = res->mask_lo;
1320 reta_conf.mask_hi = res->mask_hi;
1322 port_rss_reta_info(res->port_id,&reta_conf);
1325 cmdline_parse_token_string_t cmd_showport_reta_show =
1326 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1327 cmdline_parse_token_string_t cmd_showport_reta_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1329 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1330 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1331 cmdline_parse_token_string_t cmd_showport_reta_rss =
1332 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1333 cmdline_parse_token_string_t cmd_showport_reta_reta =
1334 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1335 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1336 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1337 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1338 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1340 cmdline_parse_inst_t cmd_showport_reta = {
1341 .f = cmd_showport_reta_parsed,
1343 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1344 (mask_lo and mask_hi is UINT64)",
1346 (void *)&cmd_showport_reta_show,
1347 (void *)&cmd_showport_reta_port,
1348 (void *)&cmd_showport_reta_port_id,
1349 (void *)&cmd_showport_reta_rss,
1350 (void *)&cmd_showport_reta_reta,
1351 (void *)&cmd_showport_reta_mask_lo,
1352 (void *)&cmd_showport_reta_mask_hi,
1357 /* *** Configure DCB *** */
1358 struct cmd_config_dcb {
1359 cmdline_fixed_string_t port;
1360 cmdline_fixed_string_t config;
1362 cmdline_fixed_string_t dcb;
1363 cmdline_fixed_string_t vt;
1364 cmdline_fixed_string_t vt_en;
1366 cmdline_fixed_string_t pfc;
1367 cmdline_fixed_string_t pfc_en;
1371 cmd_config_dcb_parsed(void *parsed_result,
1372 __attribute__((unused)) struct cmdline *cl,
1373 __attribute__((unused)) void *data)
1375 struct cmd_config_dcb *res = parsed_result;
1376 struct dcb_config dcb_conf;
1377 portid_t port_id = res->port_id;
1378 struct rte_port *port;
1380 port = &ports[port_id];
1381 /** Check if the port is not started **/
1382 if (port->port_status != RTE_PORT_STOPPED) {
1383 printf("Please stop port %d first\n",port_id);
1387 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1388 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1389 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1393 /* DCB in VT mode */
1394 if (!strncmp(res->vt_en, "on",2))
1395 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1397 dcb_conf.dcb_mode = DCB_ENABLED;
1399 if (!strncmp(res->pfc_en, "on",2)) {
1400 dcb_conf.pfc_en = 1;
1403 dcb_conf.pfc_en = 0;
1405 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1406 printf("Cannot initialize network ports\n");
1410 cmd_reconfig_device_queue(port_id, 1, 1);
1413 cmdline_parse_token_string_t cmd_config_dcb_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1415 cmdline_parse_token_string_t cmd_config_dcb_config =
1416 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1417 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1418 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1419 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1421 cmdline_parse_token_string_t cmd_config_dcb_vt =
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1423 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1425 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1426 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1427 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1429 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1432 cmdline_parse_inst_t cmd_config_dcb = {
1433 .f = cmd_config_dcb_parsed,
1435 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1437 (void *)&cmd_config_dcb_port,
1438 (void *)&cmd_config_dcb_config,
1439 (void *)&cmd_config_dcb_port_id,
1440 (void *)&cmd_config_dcb_dcb,
1441 (void *)&cmd_config_dcb_vt,
1442 (void *)&cmd_config_dcb_vt_en,
1443 (void *)&cmd_config_dcb_num_tcs,
1444 (void *)&cmd_config_dcb_pfc,
1445 (void *)&cmd_config_dcb_pfc_en,
1450 /* *** configure number of packets per burst *** */
1451 struct cmd_config_burst {
1452 cmdline_fixed_string_t port;
1453 cmdline_fixed_string_t keyword;
1454 cmdline_fixed_string_t all;
1455 cmdline_fixed_string_t name;
1460 cmd_config_burst_parsed(void *parsed_result,
1461 __attribute__((unused)) struct cmdline *cl,
1462 __attribute__((unused)) void *data)
1464 struct cmd_config_burst *res = parsed_result;
1466 if (!all_ports_stopped()) {
1467 printf("Please stop all ports first\n");
1471 if (!strcmp(res->name, "burst")) {
1472 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1473 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1476 nb_pkt_per_burst = res->value;
1478 printf("Unknown parameter\n");
1484 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1487 cmdline_parse_token_string_t cmd_config_burst_port =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1489 cmdline_parse_token_string_t cmd_config_burst_keyword =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1491 cmdline_parse_token_string_t cmd_config_burst_all =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1493 cmdline_parse_token_string_t cmd_config_burst_name =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1495 cmdline_parse_token_num_t cmd_config_burst_value =
1496 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1498 cmdline_parse_inst_t cmd_config_burst = {
1499 .f = cmd_config_burst_parsed,
1501 .help_str = "port config all burst value",
1503 (void *)&cmd_config_burst_port,
1504 (void *)&cmd_config_burst_keyword,
1505 (void *)&cmd_config_burst_all,
1506 (void *)&cmd_config_burst_name,
1507 (void *)&cmd_config_burst_value,
1512 /* *** configure rx/tx queues *** */
1513 struct cmd_config_thresh {
1514 cmdline_fixed_string_t port;
1515 cmdline_fixed_string_t keyword;
1516 cmdline_fixed_string_t all;
1517 cmdline_fixed_string_t name;
1522 cmd_config_thresh_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_config_thresh *res = parsed_result;
1528 if (!all_ports_stopped()) {
1529 printf("Please stop all ports first\n");
1533 if (!strcmp(res->name, "txpt"))
1534 tx_thresh.pthresh = res->value;
1535 else if(!strcmp(res->name, "txht"))
1536 tx_thresh.hthresh = res->value;
1537 else if(!strcmp(res->name, "txwt"))
1538 tx_thresh.wthresh = res->value;
1539 else if(!strcmp(res->name, "rxpt"))
1540 rx_thresh.pthresh = res->value;
1541 else if(!strcmp(res->name, "rxht"))
1542 rx_thresh.hthresh = res->value;
1543 else if(!strcmp(res->name, "rxwt"))
1544 rx_thresh.wthresh = res->value;
1546 printf("Unknown parameter\n");
1552 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1555 cmdline_parse_token_string_t cmd_config_thresh_port =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1557 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1559 cmdline_parse_token_string_t cmd_config_thresh_all =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1561 cmdline_parse_token_string_t cmd_config_thresh_name =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1563 "txpt#txht#txwt#rxpt#rxht#rxwt");
1564 cmdline_parse_token_num_t cmd_config_thresh_value =
1565 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1567 cmdline_parse_inst_t cmd_config_thresh = {
1568 .f = cmd_config_thresh_parsed,
1570 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1572 (void *)&cmd_config_thresh_port,
1573 (void *)&cmd_config_thresh_keyword,
1574 (void *)&cmd_config_thresh_all,
1575 (void *)&cmd_config_thresh_name,
1576 (void *)&cmd_config_thresh_value,
1581 /* *** configure free/rs threshold *** */
1582 struct cmd_config_threshold {
1583 cmdline_fixed_string_t port;
1584 cmdline_fixed_string_t keyword;
1585 cmdline_fixed_string_t all;
1586 cmdline_fixed_string_t name;
1591 cmd_config_threshold_parsed(void *parsed_result,
1592 __attribute__((unused)) struct cmdline *cl,
1593 __attribute__((unused)) void *data)
1595 struct cmd_config_threshold *res = parsed_result;
1597 if (!all_ports_stopped()) {
1598 printf("Please stop all ports first\n");
1602 if (!strcmp(res->name, "txfreet"))
1603 tx_free_thresh = res->value;
1604 else if (!strcmp(res->name, "txrst"))
1605 tx_rs_thresh = res->value;
1606 else if (!strcmp(res->name, "rxfreet"))
1607 rx_free_thresh = res->value;
1609 printf("Unknown parameter\n");
1615 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1618 cmdline_parse_token_string_t cmd_config_threshold_port =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1620 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1623 cmdline_parse_token_string_t cmd_config_threshold_all =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1625 cmdline_parse_token_string_t cmd_config_threshold_name =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1627 "txfreet#txrst#rxfreet");
1628 cmdline_parse_token_num_t cmd_config_threshold_value =
1629 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1631 cmdline_parse_inst_t cmd_config_threshold = {
1632 .f = cmd_config_threshold_parsed,
1634 .help_str = "port config all txfreet|txrst|rxfreet value",
1636 (void *)&cmd_config_threshold_port,
1637 (void *)&cmd_config_threshold_keyword,
1638 (void *)&cmd_config_threshold_all,
1639 (void *)&cmd_config_threshold_name,
1640 (void *)&cmd_config_threshold_value,
1646 struct cmd_stop_result {
1647 cmdline_fixed_string_t stop;
1650 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1651 __attribute__((unused)) struct cmdline *cl,
1652 __attribute__((unused)) void *data)
1654 stop_packet_forwarding();
1657 cmdline_parse_token_string_t cmd_stop_stop =
1658 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1660 cmdline_parse_inst_t cmd_stop = {
1661 .f = cmd_stop_parsed,
1663 .help_str = "stop - stop packet forwarding",
1665 (void *)&cmd_stop_stop,
1670 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1673 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1674 unsigned int *parsed_items, int check_unique_values)
1676 unsigned int nb_item;
1684 * First parse all items in the list and store their value.
1689 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1691 if ((c >= '0') && (c <= '9')) {
1692 value = (unsigned int) (value * 10 + (c - '0'));
1697 printf("character %c is not a decimal digit\n", c);
1701 printf("No valid value before comma\n");
1704 if (nb_item < max_items) {
1705 parsed_items[nb_item] = value;
1711 if (nb_item >= max_items) {
1712 printf("Number of %s = %u > %u (maximum items)\n",
1713 item_name, nb_item + 1, max_items);
1716 parsed_items[nb_item++] = value;
1717 if (! check_unique_values)
1721 * Then, check that all values in the list are differents.
1722 * No optimization here...
1724 for (i = 0; i < nb_item; i++) {
1725 for (j = i + 1; j < nb_item; j++) {
1726 if (parsed_items[j] == parsed_items[i]) {
1727 printf("duplicated %s %u at index %u and %u\n",
1728 item_name, parsed_items[i], i, j);
1736 struct cmd_set_list_result {
1737 cmdline_fixed_string_t cmd_keyword;
1738 cmdline_fixed_string_t list_name;
1739 cmdline_fixed_string_t list_of_items;
1742 static void cmd_set_list_parsed(void *parsed_result,
1743 __attribute__((unused)) struct cmdline *cl,
1744 __attribute__((unused)) void *data)
1746 struct cmd_set_list_result *res;
1748 unsigned int lcorelist[RTE_MAX_LCORE];
1749 unsigned int portlist[RTE_MAX_ETHPORTS];
1751 unsigned int nb_item;
1753 res = parsed_result;
1754 if (!strcmp(res->list_name, "corelist")) {
1755 nb_item = parse_item_list(res->list_of_items, "core",
1757 parsed_items.lcorelist, 1);
1759 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1762 if (!strcmp(res->list_name, "portlist")) {
1763 nb_item = parse_item_list(res->list_of_items, "port",
1765 parsed_items.portlist, 1);
1767 set_fwd_ports_list(parsed_items.portlist, nb_item);
1771 cmdline_parse_token_string_t cmd_set_list_keyword =
1772 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1774 cmdline_parse_token_string_t cmd_set_list_name =
1775 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1776 "corelist#portlist");
1777 cmdline_parse_token_string_t cmd_set_list_of_items =
1778 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1781 cmdline_parse_inst_t cmd_set_fwd_list = {
1782 .f = cmd_set_list_parsed,
1784 .help_str = "set corelist|portlist x[,y]*",
1786 (void *)&cmd_set_list_keyword,
1787 (void *)&cmd_set_list_name,
1788 (void *)&cmd_set_list_of_items,
1793 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1795 struct cmd_setmask_result {
1796 cmdline_fixed_string_t set;
1797 cmdline_fixed_string_t mask;
1801 static void cmd_set_mask_parsed(void *parsed_result,
1802 __attribute__((unused)) struct cmdline *cl,
1803 __attribute__((unused)) void *data)
1805 struct cmd_setmask_result *res = parsed_result;
1807 if (!strcmp(res->mask, "coremask"))
1808 set_fwd_lcores_mask(res->hexavalue);
1809 else if (!strcmp(res->mask, "portmask"))
1810 set_fwd_ports_mask(res->hexavalue);
1813 cmdline_parse_token_string_t cmd_setmask_set =
1814 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1815 cmdline_parse_token_string_t cmd_setmask_mask =
1816 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1817 "coremask#portmask");
1818 cmdline_parse_token_num_t cmd_setmask_value =
1819 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1821 cmdline_parse_inst_t cmd_set_fwd_mask = {
1822 .f = cmd_set_mask_parsed,
1824 .help_str = "set coremask|portmask hexadecimal value",
1826 (void *)&cmd_setmask_set,
1827 (void *)&cmd_setmask_mask,
1828 (void *)&cmd_setmask_value,
1834 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1836 struct cmd_set_result {
1837 cmdline_fixed_string_t set;
1838 cmdline_fixed_string_t what;
1842 static void cmd_set_parsed(void *parsed_result,
1843 __attribute__((unused)) struct cmdline *cl,
1844 __attribute__((unused)) void *data)
1846 struct cmd_set_result *res = parsed_result;
1847 if (!strcmp(res->what, "nbport"))
1848 set_fwd_ports_number(res->value);
1849 else if (!strcmp(res->what, "nbcore"))
1850 set_fwd_lcores_number(res->value);
1851 else if (!strcmp(res->what, "burst"))
1852 set_nb_pkt_per_burst(res->value);
1853 else if (!strcmp(res->what, "verbose"))
1854 set_verbose_level(res->value);
1857 cmdline_parse_token_string_t cmd_set_set =
1858 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1859 cmdline_parse_token_string_t cmd_set_what =
1860 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1861 "nbport#nbcore#burst#verbose");
1862 cmdline_parse_token_num_t cmd_set_value =
1863 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1865 cmdline_parse_inst_t cmd_set_numbers = {
1866 .f = cmd_set_parsed,
1868 .help_str = "set nbport|nbcore|burst|verbose value",
1870 (void *)&cmd_set_set,
1871 (void *)&cmd_set_what,
1872 (void *)&cmd_set_value,
1877 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1879 struct cmd_set_txpkts_result {
1880 cmdline_fixed_string_t cmd_keyword;
1881 cmdline_fixed_string_t txpkts;
1882 cmdline_fixed_string_t seg_lengths;
1886 cmd_set_txpkts_parsed(void *parsed_result,
1887 __attribute__((unused)) struct cmdline *cl,
1888 __attribute__((unused)) void *data)
1890 struct cmd_set_txpkts_result *res;
1891 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1892 unsigned int nb_segs;
1894 res = parsed_result;
1895 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1896 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1898 set_tx_pkt_segments(seg_lengths, nb_segs);
1901 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1902 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1903 cmd_keyword, "set");
1904 cmdline_parse_token_string_t cmd_set_txpkts_name =
1905 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1907 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1908 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1911 cmdline_parse_inst_t cmd_set_txpkts = {
1912 .f = cmd_set_txpkts_parsed,
1914 .help_str = "set txpkts x[,y]*",
1916 (void *)&cmd_set_txpkts_keyword,
1917 (void *)&cmd_set_txpkts_name,
1918 (void *)&cmd_set_txpkts_lengths,
1923 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1924 struct cmd_rx_vlan_filter_all_result {
1925 cmdline_fixed_string_t rx_vlan;
1926 cmdline_fixed_string_t what;
1927 cmdline_fixed_string_t all;
1932 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1933 __attribute__((unused)) struct cmdline *cl,
1934 __attribute__((unused)) void *data)
1936 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1938 if (!strcmp(res->what, "add"))
1939 rx_vlan_all_filter_set(res->port_id, 1);
1941 rx_vlan_all_filter_set(res->port_id, 0);
1944 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1945 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1946 rx_vlan, "rx_vlan");
1947 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1948 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1950 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1951 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1953 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1954 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1957 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1958 .f = cmd_rx_vlan_filter_all_parsed,
1960 .help_str = "add/remove all identifiers to/from the set of VLAN "
1961 "Identifiers filtered by a port",
1963 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1964 (void *)&cmd_rx_vlan_filter_all_what,
1965 (void *)&cmd_rx_vlan_filter_all_all,
1966 (void *)&cmd_rx_vlan_filter_all_portid,
1971 /* *** VLAN OFFLOAD SET ON A PORT *** */
1972 struct cmd_vlan_offload_result {
1973 cmdline_fixed_string_t vlan;
1974 cmdline_fixed_string_t set;
1975 cmdline_fixed_string_t what;
1976 cmdline_fixed_string_t on;
1977 cmdline_fixed_string_t port_id;
1981 cmd_vlan_offload_parsed(void *parsed_result,
1982 __attribute__((unused)) struct cmdline *cl,
1983 __attribute__((unused)) void *data)
1986 struct cmd_vlan_offload_result *res = parsed_result;
1989 portid_t port_id = 0;
1993 len = strnlen(str, STR_TOKEN_SIZE);
1995 /* Get port_id first */
2003 tmp = strtoul(str, NULL, 0);
2004 /* If port_id greater that what portid_t can represent, return */
2005 if(tmp >= RTE_MAX_ETHPORTS)
2007 port_id = (portid_t)tmp;
2009 if (!strcmp(res->on, "on"))
2014 if (!strcmp(res->what, "strip"))
2015 rx_vlan_strip_set(port_id, on);
2016 else if(!strcmp(res->what, "stripq")){
2017 uint16_t queue_id = 0;
2019 /* No queue_id, return */
2021 printf("must specify (port,queue_id)\n");
2024 tmp = strtoul(str + i + 1, NULL, 0);
2025 /* If queue_id greater that what 16-bits can represent, return */
2029 queue_id = (uint16_t)tmp;
2030 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2032 else if (!strcmp(res->what, "filter"))
2033 rx_vlan_filter_set(port_id, on);
2035 vlan_extend_set(port_id, on);
2040 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2041 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2043 cmdline_parse_token_string_t cmd_vlan_offload_set =
2044 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2046 cmdline_parse_token_string_t cmd_vlan_offload_what =
2047 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2048 what, "strip#filter#qinq#stripq");
2049 cmdline_parse_token_string_t cmd_vlan_offload_on =
2050 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2052 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2053 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2056 cmdline_parse_inst_t cmd_vlan_offload = {
2057 .f = cmd_vlan_offload_parsed,
2059 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2060 " qinq(extended) for both rx/tx sides ",
2062 (void *)&cmd_vlan_offload_vlan,
2063 (void *)&cmd_vlan_offload_set,
2064 (void *)&cmd_vlan_offload_what,
2065 (void *)&cmd_vlan_offload_on,
2066 (void *)&cmd_vlan_offload_portid,
2071 /* *** VLAN TPID SET ON A PORT *** */
2072 struct cmd_vlan_tpid_result {
2073 cmdline_fixed_string_t vlan;
2074 cmdline_fixed_string_t set;
2075 cmdline_fixed_string_t what;
2081 cmd_vlan_tpid_parsed(void *parsed_result,
2082 __attribute__((unused)) struct cmdline *cl,
2083 __attribute__((unused)) void *data)
2085 struct cmd_vlan_tpid_result *res = parsed_result;
2086 vlan_tpid_set(res->port_id, res->tp_id);
2090 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2093 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2096 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2099 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2100 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2102 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2103 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2106 cmdline_parse_inst_t cmd_vlan_tpid = {
2107 .f = cmd_vlan_tpid_parsed,
2109 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2111 (void *)&cmd_vlan_tpid_vlan,
2112 (void *)&cmd_vlan_tpid_set,
2113 (void *)&cmd_vlan_tpid_what,
2114 (void *)&cmd_vlan_tpid_tpid,
2115 (void *)&cmd_vlan_tpid_portid,
2120 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2121 struct cmd_rx_vlan_filter_result {
2122 cmdline_fixed_string_t rx_vlan;
2123 cmdline_fixed_string_t what;
2129 cmd_rx_vlan_filter_parsed(void *parsed_result,
2130 __attribute__((unused)) struct cmdline *cl,
2131 __attribute__((unused)) void *data)
2133 struct cmd_rx_vlan_filter_result *res = parsed_result;
2135 if (!strcmp(res->what, "add"))
2136 rx_vft_set(res->port_id, res->vlan_id, 1);
2138 rx_vft_set(res->port_id, res->vlan_id, 0);
2141 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2142 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2143 rx_vlan, "rx_vlan");
2144 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2145 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2147 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2148 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2150 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2151 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2154 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2155 .f = cmd_rx_vlan_filter_parsed,
2157 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2158 "Identifiers filtered by a port",
2160 (void *)&cmd_rx_vlan_filter_rx_vlan,
2161 (void *)&cmd_rx_vlan_filter_what,
2162 (void *)&cmd_rx_vlan_filter_vlanid,
2163 (void *)&cmd_rx_vlan_filter_portid,
2168 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2169 struct cmd_tx_vlan_set_result {
2170 cmdline_fixed_string_t tx_vlan;
2171 cmdline_fixed_string_t set;
2177 cmd_tx_vlan_set_parsed(void *parsed_result,
2178 __attribute__((unused)) struct cmdline *cl,
2179 __attribute__((unused)) void *data)
2181 struct cmd_tx_vlan_set_result *res = parsed_result;
2182 tx_vlan_set(res->port_id, res->vlan_id);
2185 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2186 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2187 tx_vlan, "tx_vlan");
2188 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2189 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2191 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2192 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2194 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2195 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2198 cmdline_parse_inst_t cmd_tx_vlan_set = {
2199 .f = cmd_tx_vlan_set_parsed,
2201 .help_str = "enable hardware insertion of a VLAN header with a given "
2202 "TAG Identifier in packets sent on a port",
2204 (void *)&cmd_tx_vlan_set_tx_vlan,
2205 (void *)&cmd_tx_vlan_set_set,
2206 (void *)&cmd_tx_vlan_set_vlanid,
2207 (void *)&cmd_tx_vlan_set_portid,
2212 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2213 struct cmd_tx_vlan_reset_result {
2214 cmdline_fixed_string_t tx_vlan;
2215 cmdline_fixed_string_t reset;
2220 cmd_tx_vlan_reset_parsed(void *parsed_result,
2221 __attribute__((unused)) struct cmdline *cl,
2222 __attribute__((unused)) void *data)
2224 struct cmd_tx_vlan_reset_result *res = parsed_result;
2226 tx_vlan_reset(res->port_id);
2229 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2231 tx_vlan, "tx_vlan");
2232 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2233 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2235 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2236 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2239 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2240 .f = cmd_tx_vlan_reset_parsed,
2242 .help_str = "disable hardware insertion of a VLAN header in packets "
2245 (void *)&cmd_tx_vlan_reset_tx_vlan,
2246 (void *)&cmd_tx_vlan_reset_reset,
2247 (void *)&cmd_tx_vlan_reset_portid,
2253 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2254 struct cmd_tx_cksum_set_result {
2255 cmdline_fixed_string_t tx_cksum;
2256 cmdline_fixed_string_t set;
2262 cmd_tx_cksum_set_parsed(void *parsed_result,
2263 __attribute__((unused)) struct cmdline *cl,
2264 __attribute__((unused)) void *data)
2266 struct cmd_tx_cksum_set_result *res = parsed_result;
2268 tx_cksum_set(res->port_id, res->cksum_mask);
2271 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2272 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2273 tx_cksum, "tx_checksum");
2274 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2275 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2277 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2278 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2280 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2281 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2284 cmdline_parse_inst_t cmd_tx_cksum_set = {
2285 .f = cmd_tx_cksum_set_parsed,
2287 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2288 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2289 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2291 (void *)&cmd_tx_cksum_set_tx_cksum,
2292 (void *)&cmd_tx_cksum_set_set,
2293 (void *)&cmd_tx_cksum_set_cksum_mask,
2294 (void *)&cmd_tx_cksum_set_portid,
2299 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2300 struct cmd_set_flush_rx {
2301 cmdline_fixed_string_t set;
2302 cmdline_fixed_string_t flush_rx;
2303 cmdline_fixed_string_t mode;
2307 cmd_set_flush_rx_parsed(void *parsed_result,
2308 __attribute__((unused)) struct cmdline *cl,
2309 __attribute__((unused)) void *data)
2311 struct cmd_set_flush_rx *res = parsed_result;
2312 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2315 cmdline_parse_token_string_t cmd_setflushrx_set =
2316 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2318 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2319 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2320 flush_rx, "flush_rx");
2321 cmdline_parse_token_string_t cmd_setflushrx_mode =
2322 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2326 cmdline_parse_inst_t cmd_set_flush_rx = {
2327 .f = cmd_set_flush_rx_parsed,
2328 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2331 (void *)&cmd_setflushrx_set,
2332 (void *)&cmd_setflushrx_flush_rx,
2333 (void *)&cmd_setflushrx_mode,
2338 #ifdef RTE_NIC_BYPASS
2339 /* *** SET NIC BYPASS MODE *** */
2340 struct cmd_set_bypass_mode_result {
2341 cmdline_fixed_string_t set;
2342 cmdline_fixed_string_t bypass;
2343 cmdline_fixed_string_t mode;
2344 cmdline_fixed_string_t value;
2349 cmd_set_bypass_mode_parsed(void *parsed_result,
2350 __attribute__((unused)) struct cmdline *cl,
2351 __attribute__((unused)) void *data)
2353 struct cmd_set_bypass_mode_result *res = parsed_result;
2354 portid_t port_id = res->port_id;
2355 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2357 if (!bypass_is_supported(port_id))
2360 if (!strcmp(res->value, "bypass"))
2361 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2362 else if (!strcmp(res->value, "isolate"))
2363 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2365 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2367 /* Set the bypass mode for the relevant port. */
2368 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2369 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2373 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2374 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2376 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2377 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2379 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2380 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2382 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2383 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2384 value, "normal#bypass#isolate");
2385 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2386 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2389 cmdline_parse_inst_t cmd_set_bypass_mode = {
2390 .f = cmd_set_bypass_mode_parsed,
2391 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2392 "Set the NIC bypass mode for port_id",
2395 (void *)&cmd_setbypass_mode_set,
2396 (void *)&cmd_setbypass_mode_bypass,
2397 (void *)&cmd_setbypass_mode_mode,
2398 (void *)&cmd_setbypass_mode_value,
2399 (void *)&cmd_setbypass_mode_port,
2404 /* *** SET NIC BYPASS EVENT *** */
2405 struct cmd_set_bypass_event_result {
2406 cmdline_fixed_string_t set;
2407 cmdline_fixed_string_t bypass;
2408 cmdline_fixed_string_t event;
2409 cmdline_fixed_string_t event_value;
2410 cmdline_fixed_string_t mode;
2411 cmdline_fixed_string_t mode_value;
2416 cmd_set_bypass_event_parsed(void *parsed_result,
2417 __attribute__((unused)) struct cmdline *cl,
2418 __attribute__((unused)) void *data)
2421 struct cmd_set_bypass_event_result *res = parsed_result;
2422 portid_t port_id = res->port_id;
2423 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2424 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2426 if (!bypass_is_supported(port_id))
2429 if (!strcmp(res->event_value, "timeout"))
2430 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2431 else if (!strcmp(res->event_value, "os_on"))
2432 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2433 else if (!strcmp(res->event_value, "os_off"))
2434 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2435 else if (!strcmp(res->event_value, "power_on"))
2436 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2437 else if (!strcmp(res->event_value, "power_off"))
2438 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2440 bypass_event = RTE_BYPASS_EVENT_NONE;
2442 if (!strcmp(res->mode_value, "bypass"))
2443 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2444 else if (!strcmp(res->mode_value, "isolate"))
2445 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2447 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2449 /* Set the watchdog timeout. */
2450 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2453 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2454 (rc = rte_eth_dev_wd_timeout_store(port_id,
2455 bypass_timeout)) != 0) {
2456 printf("Failed to set timeout value %u "
2457 "for port %d, errto code: %d.\n",
2458 bypass_timeout, port_id, rc);
2462 /* Set the bypass event to transition to bypass mode. */
2463 if (0 != rte_eth_dev_bypass_event_store(port_id,
2464 bypass_event, bypass_mode)) {
2465 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2470 cmdline_parse_token_string_t cmd_setbypass_event_set =
2471 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2473 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2474 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2476 cmdline_parse_token_string_t cmd_setbypass_event_event =
2477 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2479 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2480 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2481 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2482 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2483 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2485 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2486 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2487 mode_value, "normal#bypass#isolate");
2488 cmdline_parse_token_num_t cmd_setbypass_event_port =
2489 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2492 cmdline_parse_inst_t cmd_set_bypass_event = {
2493 .f = cmd_set_bypass_event_parsed,
2494 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2495 "mode (normal|bypass|isolate) (port_id): "
2496 "Set the NIC bypass event mode for port_id",
2499 (void *)&cmd_setbypass_event_set,
2500 (void *)&cmd_setbypass_event_bypass,
2501 (void *)&cmd_setbypass_event_event,
2502 (void *)&cmd_setbypass_event_event_value,
2503 (void *)&cmd_setbypass_event_mode,
2504 (void *)&cmd_setbypass_event_mode_value,
2505 (void *)&cmd_setbypass_event_port,
2511 /* *** SET NIC BYPASS TIMEOUT *** */
2512 struct cmd_set_bypass_timeout_result {
2513 cmdline_fixed_string_t set;
2514 cmdline_fixed_string_t bypass;
2515 cmdline_fixed_string_t timeout;
2516 cmdline_fixed_string_t value;
2520 cmd_set_bypass_timeout_parsed(void *parsed_result,
2521 __attribute__((unused)) struct cmdline *cl,
2522 __attribute__((unused)) void *data)
2524 struct cmd_set_bypass_timeout_result *res = parsed_result;
2526 if (!strcmp(res->value, "1.5"))
2527 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2528 else if (!strcmp(res->value, "2"))
2529 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2530 else if (!strcmp(res->value, "3"))
2531 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2532 else if (!strcmp(res->value, "4"))
2533 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2534 else if (!strcmp(res->value, "8"))
2535 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2536 else if (!strcmp(res->value, "16"))
2537 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2538 else if (!strcmp(res->value, "32"))
2539 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2541 bypass_timeout = RTE_BYPASS_TMT_OFF;
2544 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2545 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2547 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2550 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2552 timeout, "timeout");
2553 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2555 value, "0#1.5#2#3#4#8#16#32");
2557 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2558 .f = cmd_set_bypass_timeout_parsed,
2559 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2560 "Set the NIC bypass watchdog timeout",
2563 (void *)&cmd_setbypass_timeout_set,
2564 (void *)&cmd_setbypass_timeout_bypass,
2565 (void *)&cmd_setbypass_timeout_timeout,
2566 (void *)&cmd_setbypass_timeout_value,
2571 /* *** SHOW NIC BYPASS MODE *** */
2572 struct cmd_show_bypass_config_result {
2573 cmdline_fixed_string_t show;
2574 cmdline_fixed_string_t bypass;
2575 cmdline_fixed_string_t config;
2580 cmd_show_bypass_config_parsed(void *parsed_result,
2581 __attribute__((unused)) struct cmdline *cl,
2582 __attribute__((unused)) void *data)
2584 struct cmd_show_bypass_config_result *res = parsed_result;
2585 uint32_t event_mode;
2586 uint32_t bypass_mode;
2587 portid_t port_id = res->port_id;
2588 uint32_t timeout = bypass_timeout;
2591 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2592 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2593 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2594 {"UNKNOWN", "normal", "bypass", "isolate"};
2595 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2602 int num_events = (sizeof events) / (sizeof events[0]);
2604 if (!bypass_is_supported(port_id))
2607 /* Display the bypass mode.*/
2608 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2609 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2613 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2614 bypass_mode = RTE_BYPASS_MODE_NONE;
2616 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2619 /* Display the bypass timeout.*/
2620 if (!RTE_BYPASS_TMT_VALID(timeout))
2621 timeout = RTE_BYPASS_TMT_OFF;
2623 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2625 /* Display the bypass events and associated modes. */
2626 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2628 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2629 printf("\tFailed to get bypass mode for event = %s\n",
2632 if (!RTE_BYPASS_MODE_VALID(event_mode))
2633 event_mode = RTE_BYPASS_MODE_NONE;
2635 printf("\tbypass event: %-16s = %s\n", events[i],
2641 cmdline_parse_token_string_t cmd_showbypass_config_show =
2642 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2644 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2645 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2647 cmdline_parse_token_string_t cmd_showbypass_config_config =
2648 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2650 cmdline_parse_token_num_t cmd_showbypass_config_port =
2651 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2654 cmdline_parse_inst_t cmd_show_bypass_config = {
2655 .f = cmd_show_bypass_config_parsed,
2656 .help_str = "show bypass config (port_id): "
2657 "Show the NIC bypass config for port_id",
2660 (void *)&cmd_showbypass_config_show,
2661 (void *)&cmd_showbypass_config_bypass,
2662 (void *)&cmd_showbypass_config_config,
2663 (void *)&cmd_showbypass_config_port,
2669 /* *** SET FORWARDING MODE *** */
2670 struct cmd_set_fwd_mode_result {
2671 cmdline_fixed_string_t set;
2672 cmdline_fixed_string_t fwd;
2673 cmdline_fixed_string_t mode;
2676 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2677 __attribute__((unused)) struct cmdline *cl,
2678 __attribute__((unused)) void *data)
2680 struct cmd_set_fwd_mode_result *res = parsed_result;
2682 set_pkt_forwarding_mode(res->mode);
2685 cmdline_parse_token_string_t cmd_setfwd_set =
2686 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2687 cmdline_parse_token_string_t cmd_setfwd_fwd =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2689 cmdline_parse_token_string_t cmd_setfwd_mode =
2690 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2691 #ifdef RTE_LIBRTE_IEEE1588
2692 "io#mac#mac_retry#rxonly#txonly#csum#ieee1588");
2694 "io#mac#mac_retry#rxonly#txonly#csum");
2697 cmdline_parse_inst_t cmd_set_fwd_mode = {
2698 .f = cmd_set_fwd_mode_parsed,
2700 #ifdef RTE_LIBRTE_IEEE1588
2701 .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2702 " MAC_RETRY, RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2704 .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum - set IO, MAC,"
2705 " MAC_RETRY, RXONLY, CSUM or TXONLY packet forwarding mode",
2708 (void *)&cmd_setfwd_set,
2709 (void *)&cmd_setfwd_fwd,
2710 (void *)&cmd_setfwd_mode,
2715 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2716 struct cmd_set_burst_tx_retry_result {
2717 cmdline_fixed_string_t set;
2718 cmdline_fixed_string_t burst;
2719 cmdline_fixed_string_t tx;
2720 cmdline_fixed_string_t delay;
2722 cmdline_fixed_string_t retry;
2726 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2727 __attribute__((unused)) struct cmdline *cl,
2728 __attribute__((unused)) void *data)
2730 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2732 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2733 && !strcmp(res->tx, "tx")) {
2734 if (!strcmp(res->delay, "delay"))
2735 burst_tx_delay_time = res->time;
2736 if (!strcmp(res->retry, "retry"))
2737 burst_tx_retry_num = res->retry_num;
2742 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2743 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2744 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2747 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2749 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2751 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2752 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2753 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2754 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2755 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2756 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2758 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2759 .f = cmd_set_burst_tx_retry_parsed,
2760 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2762 (void *)&cmd_set_burst_tx_retry_set,
2763 (void *)&cmd_set_burst_tx_retry_burst,
2764 (void *)&cmd_set_burst_tx_retry_tx,
2765 (void *)&cmd_set_burst_tx_retry_delay,
2766 (void *)&cmd_set_burst_tx_retry_time,
2767 (void *)&cmd_set_burst_tx_retry_retry,
2768 (void *)&cmd_set_burst_tx_retry_retry_num,
2773 /* *** SET PROMISC MODE *** */
2774 struct cmd_set_promisc_mode_result {
2775 cmdline_fixed_string_t set;
2776 cmdline_fixed_string_t promisc;
2777 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2778 uint8_t port_num; /* valid if "allports" argument == 0 */
2779 cmdline_fixed_string_t mode;
2782 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2783 __attribute__((unused)) struct cmdline *cl,
2786 struct cmd_set_promisc_mode_result *res = parsed_result;
2790 if (!strcmp(res->mode, "on"))
2797 for (i = 0; i < nb_ports; i++) {
2799 rte_eth_promiscuous_enable(i);
2801 rte_eth_promiscuous_disable(i);
2806 rte_eth_promiscuous_enable(res->port_num);
2808 rte_eth_promiscuous_disable(res->port_num);
2812 cmdline_parse_token_string_t cmd_setpromisc_set =
2813 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2814 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2815 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2817 cmdline_parse_token_string_t cmd_setpromisc_portall =
2818 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2820 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2821 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2823 cmdline_parse_token_string_t cmd_setpromisc_mode =
2824 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2827 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2828 .f = cmd_set_promisc_mode_parsed,
2830 .help_str = "set promisc all on|off: set promisc mode for all ports",
2832 (void *)&cmd_setpromisc_set,
2833 (void *)&cmd_setpromisc_promisc,
2834 (void *)&cmd_setpromisc_portall,
2835 (void *)&cmd_setpromisc_mode,
2840 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2841 .f = cmd_set_promisc_mode_parsed,
2843 .help_str = "set promisc X on|off: set promisc mode on port X",
2845 (void *)&cmd_setpromisc_set,
2846 (void *)&cmd_setpromisc_promisc,
2847 (void *)&cmd_setpromisc_portnum,
2848 (void *)&cmd_setpromisc_mode,
2853 /* *** SET ALLMULTI MODE *** */
2854 struct cmd_set_allmulti_mode_result {
2855 cmdline_fixed_string_t set;
2856 cmdline_fixed_string_t allmulti;
2857 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2858 uint8_t port_num; /* valid if "allports" argument == 0 */
2859 cmdline_fixed_string_t mode;
2862 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2863 __attribute__((unused)) struct cmdline *cl,
2866 struct cmd_set_allmulti_mode_result *res = parsed_result;
2870 if (!strcmp(res->mode, "on"))
2877 for (i = 0; i < nb_ports; i++) {
2879 rte_eth_allmulticast_enable(i);
2881 rte_eth_allmulticast_disable(i);
2886 rte_eth_allmulticast_enable(res->port_num);
2888 rte_eth_allmulticast_disable(res->port_num);
2892 cmdline_parse_token_string_t cmd_setallmulti_set =
2893 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2894 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2895 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2897 cmdline_parse_token_string_t cmd_setallmulti_portall =
2898 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2900 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2901 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2903 cmdline_parse_token_string_t cmd_setallmulti_mode =
2904 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2907 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2908 .f = cmd_set_allmulti_mode_parsed,
2910 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2912 (void *)&cmd_setallmulti_set,
2913 (void *)&cmd_setallmulti_allmulti,
2914 (void *)&cmd_setallmulti_portall,
2915 (void *)&cmd_setallmulti_mode,
2920 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2921 .f = cmd_set_allmulti_mode_parsed,
2923 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2925 (void *)&cmd_setallmulti_set,
2926 (void *)&cmd_setallmulti_allmulti,
2927 (void *)&cmd_setallmulti_portnum,
2928 (void *)&cmd_setallmulti_mode,
2933 /* *** ADD/REMOVE A PKT FILTER *** */
2934 struct cmd_pkt_filter_result {
2935 cmdline_fixed_string_t pkt_filter;
2937 cmdline_fixed_string_t protocol;
2938 cmdline_fixed_string_t src;
2939 cmdline_ipaddr_t ip_src;
2941 cmdline_fixed_string_t dst;
2942 cmdline_ipaddr_t ip_dst;
2944 cmdline_fixed_string_t flexbytes;
2945 uint16_t flexbytes_value;
2946 cmdline_fixed_string_t vlan;
2948 cmdline_fixed_string_t queue;
2950 cmdline_fixed_string_t soft;
2955 cmd_pkt_filter_parsed(void *parsed_result,
2956 __attribute__((unused)) struct cmdline *cl,
2957 __attribute__((unused)) void *data)
2959 struct rte_fdir_filter fdir_filter;
2960 struct cmd_pkt_filter_result *res = parsed_result;
2962 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2964 if (res->ip_src.family == AF_INET)
2965 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2967 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2968 &(res->ip_src.addr.ipv6),
2969 sizeof(struct in6_addr));
2971 if (res->ip_dst.family == AF_INET)
2972 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2974 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2975 &(res->ip_dst.addr.ipv6),
2976 sizeof(struct in6_addr));
2978 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2979 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2981 if (!strcmp(res->protocol, "udp"))
2982 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2983 else if (!strcmp(res->protocol, "tcp"))
2984 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2985 else if (!strcmp(res->protocol, "sctp"))
2986 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2987 else /* default only IP */
2988 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2990 if (res->ip_dst.family == AF_INET6)
2991 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2993 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2995 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2996 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2998 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2999 fdir_add_signature_filter(res->port_id, res->queue_id,
3001 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3002 fdir_update_signature_filter(res->port_id, res->queue_id,
3004 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3005 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3006 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3007 fdir_add_perfect_filter(res->port_id, res->soft_id,
3009 (uint8_t) (res->queue_id < 0),
3011 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3012 fdir_update_perfect_filter(res->port_id, res->soft_id,
3014 (uint8_t) (res->queue_id < 0),
3016 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3017 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3023 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3024 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3026 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3027 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3028 protocol, "ip#tcp#udp#sctp");
3029 cmdline_parse_token_string_t cmd_pkt_filter_src =
3030 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3032 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3033 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3035 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3036 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3038 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3039 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3041 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3042 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3044 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3045 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3047 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3048 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3049 flexbytes, "flexbytes");
3050 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3051 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3052 flexbytes_value, UINT16);
3053 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3054 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3056 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3057 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3059 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3060 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3062 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3063 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3065 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3066 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3068 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3069 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3073 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3074 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3075 pkt_filter, "add_signature_filter");
3076 cmdline_parse_inst_t cmd_add_signature_filter = {
3077 .f = cmd_pkt_filter_parsed,
3079 .help_str = "add a signature filter",
3081 (void *)&cmd_pkt_filter_add_signature_filter,
3082 (void *)&cmd_pkt_filter_port_id,
3083 (void *)&cmd_pkt_filter_protocol,
3084 (void *)&cmd_pkt_filter_src,
3085 (void *)&cmd_pkt_filter_ip_src,
3086 (void *)&cmd_pkt_filter_port_src,
3087 (void *)&cmd_pkt_filter_dst,
3088 (void *)&cmd_pkt_filter_ip_dst,
3089 (void *)&cmd_pkt_filter_port_dst,
3090 (void *)&cmd_pkt_filter_flexbytes,
3091 (void *)&cmd_pkt_filter_flexbytes_value,
3092 (void *)&cmd_pkt_filter_vlan,
3093 (void *)&cmd_pkt_filter_vlan_id,
3094 (void *)&cmd_pkt_filter_queue,
3095 (void *)&cmd_pkt_filter_queue_id,
3101 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3102 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3103 pkt_filter, "upd_signature_filter");
3104 cmdline_parse_inst_t cmd_upd_signature_filter = {
3105 .f = cmd_pkt_filter_parsed,
3107 .help_str = "update a signature filter",
3109 (void *)&cmd_pkt_filter_upd_signature_filter,
3110 (void *)&cmd_pkt_filter_port_id,
3111 (void *)&cmd_pkt_filter_protocol,
3112 (void *)&cmd_pkt_filter_src,
3113 (void *)&cmd_pkt_filter_ip_src,
3114 (void *)&cmd_pkt_filter_port_src,
3115 (void *)&cmd_pkt_filter_dst,
3116 (void *)&cmd_pkt_filter_ip_dst,
3117 (void *)&cmd_pkt_filter_port_dst,
3118 (void *)&cmd_pkt_filter_flexbytes,
3119 (void *)&cmd_pkt_filter_flexbytes_value,
3120 (void *)&cmd_pkt_filter_vlan,
3121 (void *)&cmd_pkt_filter_vlan_id,
3122 (void *)&cmd_pkt_filter_queue,
3123 (void *)&cmd_pkt_filter_queue_id,
3129 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3130 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3131 pkt_filter, "rm_signature_filter");
3132 cmdline_parse_inst_t cmd_rm_signature_filter = {
3133 .f = cmd_pkt_filter_parsed,
3135 .help_str = "remove a signature filter",
3137 (void *)&cmd_pkt_filter_rm_signature_filter,
3138 (void *)&cmd_pkt_filter_port_id,
3139 (void *)&cmd_pkt_filter_protocol,
3140 (void *)&cmd_pkt_filter_src,
3141 (void *)&cmd_pkt_filter_ip_src,
3142 (void *)&cmd_pkt_filter_port_src,
3143 (void *)&cmd_pkt_filter_dst,
3144 (void *)&cmd_pkt_filter_ip_dst,
3145 (void *)&cmd_pkt_filter_port_dst,
3146 (void *)&cmd_pkt_filter_flexbytes,
3147 (void *)&cmd_pkt_filter_flexbytes_value,
3148 (void *)&cmd_pkt_filter_vlan,
3149 (void *)&cmd_pkt_filter_vlan_id,
3155 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3156 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3157 pkt_filter, "add_perfect_filter");
3158 cmdline_parse_inst_t cmd_add_perfect_filter = {
3159 .f = cmd_pkt_filter_parsed,
3161 .help_str = "add a perfect filter",
3163 (void *)&cmd_pkt_filter_add_perfect_filter,
3164 (void *)&cmd_pkt_filter_port_id,
3165 (void *)&cmd_pkt_filter_protocol,
3166 (void *)&cmd_pkt_filter_src,
3167 (void *)&cmd_pkt_filter_ip_src,
3168 (void *)&cmd_pkt_filter_port_src,
3169 (void *)&cmd_pkt_filter_dst,
3170 (void *)&cmd_pkt_filter_ip_dst,
3171 (void *)&cmd_pkt_filter_port_dst,
3172 (void *)&cmd_pkt_filter_flexbytes,
3173 (void *)&cmd_pkt_filter_flexbytes_value,
3174 (void *)&cmd_pkt_filter_vlan,
3175 (void *)&cmd_pkt_filter_vlan_id,
3176 (void *)&cmd_pkt_filter_queue,
3177 (void *)&cmd_pkt_filter_queue_id,
3178 (void *)&cmd_pkt_filter_soft,
3179 (void *)&cmd_pkt_filter_soft_id,
3185 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3186 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3187 pkt_filter, "upd_perfect_filter");
3188 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3189 .f = cmd_pkt_filter_parsed,
3191 .help_str = "update a perfect filter",
3193 (void *)&cmd_pkt_filter_upd_perfect_filter,
3194 (void *)&cmd_pkt_filter_port_id,
3195 (void *)&cmd_pkt_filter_protocol,
3196 (void *)&cmd_pkt_filter_src,
3197 (void *)&cmd_pkt_filter_ip_src,
3198 (void *)&cmd_pkt_filter_port_src,
3199 (void *)&cmd_pkt_filter_dst,
3200 (void *)&cmd_pkt_filter_ip_dst,
3201 (void *)&cmd_pkt_filter_port_dst,
3202 (void *)&cmd_pkt_filter_flexbytes,
3203 (void *)&cmd_pkt_filter_flexbytes_value,
3204 (void *)&cmd_pkt_filter_vlan,
3205 (void *)&cmd_pkt_filter_vlan_id,
3206 (void *)&cmd_pkt_filter_queue,
3207 (void *)&cmd_pkt_filter_queue_id,
3208 (void *)&cmd_pkt_filter_soft,
3209 (void *)&cmd_pkt_filter_soft_id,
3215 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3216 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3217 pkt_filter, "rm_perfect_filter");
3218 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3219 .f = cmd_pkt_filter_parsed,
3221 .help_str = "remove a perfect filter",
3223 (void *)&cmd_pkt_filter_rm_perfect_filter,
3224 (void *)&cmd_pkt_filter_port_id,
3225 (void *)&cmd_pkt_filter_protocol,
3226 (void *)&cmd_pkt_filter_src,
3227 (void *)&cmd_pkt_filter_ip_src,
3228 (void *)&cmd_pkt_filter_port_src,
3229 (void *)&cmd_pkt_filter_dst,
3230 (void *)&cmd_pkt_filter_ip_dst,
3231 (void *)&cmd_pkt_filter_port_dst,
3232 (void *)&cmd_pkt_filter_flexbytes,
3233 (void *)&cmd_pkt_filter_flexbytes_value,
3234 (void *)&cmd_pkt_filter_vlan,
3235 (void *)&cmd_pkt_filter_vlan_id,
3236 (void *)&cmd_pkt_filter_soft,
3237 (void *)&cmd_pkt_filter_soft_id,
3242 /* *** SETUP MASKS FILTER *** */
3243 struct cmd_pkt_filter_masks_result {
3244 cmdline_fixed_string_t filter_mask;
3246 cmdline_fixed_string_t src_mask;
3247 uint32_t ip_src_mask;
3248 uint16_t ipv6_src_mask;
3249 uint16_t port_src_mask;
3250 cmdline_fixed_string_t dst_mask;
3251 uint32_t ip_dst_mask;
3252 uint16_t ipv6_dst_mask;
3253 uint16_t port_dst_mask;
3254 cmdline_fixed_string_t flexbytes;
3255 uint8_t flexbytes_value;
3256 cmdline_fixed_string_t vlan_id;
3257 uint8_t vlan_id_value;
3258 cmdline_fixed_string_t vlan_prio;
3259 uint8_t vlan_prio_value;
3260 cmdline_fixed_string_t only_ip_flow;
3261 uint8_t only_ip_flow_value;
3262 cmdline_fixed_string_t comp_ipv6_dst;
3263 uint8_t comp_ipv6_dst_value;
3267 cmd_pkt_filter_masks_parsed(void *parsed_result,
3268 __attribute__((unused)) struct cmdline *cl,
3269 __attribute__((unused)) void *data)
3271 struct rte_fdir_masks fdir_masks;
3272 struct cmd_pkt_filter_masks_result *res = parsed_result;
3274 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3276 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3277 fdir_masks.vlan_id = res->vlan_id_value;
3278 fdir_masks.vlan_prio = res->vlan_prio_value;
3279 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3280 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3281 fdir_masks.src_port_mask = res->port_src_mask;
3282 fdir_masks.dst_port_mask = res->port_dst_mask;
3283 fdir_masks.flexbytes = res->flexbytes_value;
3285 fdir_set_masks(res->port_id, &fdir_masks);
3288 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3289 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3290 filter_mask, "set_masks_filter");
3291 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3292 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3294 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3295 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3296 only_ip_flow, "only_ip_flow");
3297 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3298 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3299 only_ip_flow_value, UINT8);
3300 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3301 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3302 src_mask, "src_mask");
3303 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3304 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3305 ip_src_mask, UINT32);
3306 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3307 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3308 port_src_mask, UINT16);
3309 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3310 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3311 dst_mask, "dst_mask");
3312 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3313 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3314 ip_dst_mask, UINT32);
3315 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3316 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3317 port_dst_mask, UINT16);
3318 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3319 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3320 flexbytes, "flexbytes");
3321 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3322 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3323 flexbytes_value, UINT8);
3324 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3325 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3326 vlan_id, "vlan_id");
3327 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3328 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3329 vlan_id_value, UINT8);
3330 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3331 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3332 vlan_prio, "vlan_prio");
3333 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3334 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3335 vlan_prio_value, UINT8);
3337 cmdline_parse_inst_t cmd_set_masks_filter = {
3338 .f = cmd_pkt_filter_masks_parsed,
3340 .help_str = "setup masks filter",
3342 (void *)&cmd_pkt_filter_masks_filter_mask,
3343 (void *)&cmd_pkt_filter_masks_port_id,
3344 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3345 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3346 (void *)&cmd_pkt_filter_masks_src_mask,
3347 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3348 (void *)&cmd_pkt_filter_masks_port_src_mask,
3349 (void *)&cmd_pkt_filter_masks_dst_mask,
3350 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3351 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3352 (void *)&cmd_pkt_filter_masks_flexbytes,
3353 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3354 (void *)&cmd_pkt_filter_masks_vlan_id,
3355 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3356 (void *)&cmd_pkt_filter_masks_vlan_prio,
3357 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3363 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct rte_fdir_masks fdir_masks;
3368 struct cmd_pkt_filter_masks_result *res = parsed_result;
3370 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3372 fdir_masks.set_ipv6_mask = 1;
3373 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3374 fdir_masks.vlan_id = res->vlan_id_value;
3375 fdir_masks.vlan_prio = res->vlan_prio_value;
3376 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3377 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3378 fdir_masks.src_port_mask = res->port_src_mask;
3379 fdir_masks.dst_port_mask = res->port_dst_mask;
3380 fdir_masks.flexbytes = res->flexbytes_value;
3381 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3383 fdir_set_masks(res->port_id, &fdir_masks);
3386 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3387 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3388 filter_mask, "set_ipv6_masks_filter");
3389 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3390 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3391 ipv6_src_mask, UINT16);
3392 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3393 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3394 ipv6_dst_mask, UINT16);
3396 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3397 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3398 comp_ipv6_dst, "compare_dst");
3399 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3400 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3401 comp_ipv6_dst_value, UINT8);
3403 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3404 .f = cmd_pkt_filter_masks_ipv6_parsed,
3406 .help_str = "setup ipv6 masks filter",
3408 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3409 (void *)&cmd_pkt_filter_masks_port_id,
3410 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3411 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3412 (void *)&cmd_pkt_filter_masks_src_mask,
3413 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3414 (void *)&cmd_pkt_filter_masks_port_src_mask,
3415 (void *)&cmd_pkt_filter_masks_dst_mask,
3416 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3417 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3418 (void *)&cmd_pkt_filter_masks_flexbytes,
3419 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3420 (void *)&cmd_pkt_filter_masks_vlan_id,
3421 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3422 (void *)&cmd_pkt_filter_masks_vlan_prio,
3423 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3424 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3425 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3430 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3431 struct cmd_link_flow_ctrl_set_result {
3432 cmdline_fixed_string_t set;
3433 cmdline_fixed_string_t flow_ctrl;
3434 cmdline_fixed_string_t rx;
3435 cmdline_fixed_string_t rx_lfc_mode;
3436 cmdline_fixed_string_t tx;
3437 cmdline_fixed_string_t tx_lfc_mode;
3438 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3439 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3440 uint32_t high_water;
3442 uint16_t pause_time;
3448 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3453 struct rte_eth_fc_conf fc_conf;
3454 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3458 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3459 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3460 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3461 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3463 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3464 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3467 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3468 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3469 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3471 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3472 fc_conf.high_water = res->high_water;
3473 fc_conf.low_water = res->low_water;
3474 fc_conf.pause_time = res->pause_time;
3475 fc_conf.send_xon = res->send_xon;
3476 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3478 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3480 printf("bad flow contrl parameter, return code = %d \n", ret);
3483 cmdline_parse_token_string_t cmd_lfc_set_set =
3484 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3486 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3487 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3488 flow_ctrl, "flow_ctrl");
3489 cmdline_parse_token_string_t cmd_lfc_set_rx =
3490 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3492 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3493 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3494 rx_lfc_mode, "on#off");
3495 cmdline_parse_token_string_t cmd_lfc_set_tx =
3496 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3498 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3499 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3500 tx_lfc_mode, "on#off");
3501 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3502 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3503 high_water, UINT32);
3504 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3505 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3507 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3508 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3509 pause_time, UINT16);
3510 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3511 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3513 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3514 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3515 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3516 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3517 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3518 mac_ctrl_frame_fwd_mode, "on#off");
3519 cmdline_parse_token_num_t cmd_lfc_set_portid =
3520 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3523 cmdline_parse_inst_t cmd_link_flow_control_set = {
3524 .f = cmd_link_flow_ctrl_set_parsed,
3526 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3527 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3530 (void *)&cmd_lfc_set_set,
3531 (void *)&cmd_lfc_set_flow_ctrl,
3532 (void *)&cmd_lfc_set_rx,
3533 (void *)&cmd_lfc_set_rx_mode,
3534 (void *)&cmd_lfc_set_tx,
3535 (void *)&cmd_lfc_set_tx_mode,
3536 (void *)&cmd_lfc_set_high_water,
3537 (void *)&cmd_lfc_set_low_water,
3538 (void *)&cmd_lfc_set_pause_time,
3539 (void *)&cmd_lfc_set_send_xon,
3540 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3541 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3542 (void *)&cmd_lfc_set_portid,
3547 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3548 struct cmd_priority_flow_ctrl_set_result {
3549 cmdline_fixed_string_t set;
3550 cmdline_fixed_string_t pfc_ctrl;
3551 cmdline_fixed_string_t rx;
3552 cmdline_fixed_string_t rx_pfc_mode;
3553 cmdline_fixed_string_t tx;
3554 cmdline_fixed_string_t tx_pfc_mode;
3555 uint32_t high_water;
3557 uint16_t pause_time;
3563 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3564 __attribute__((unused)) struct cmdline *cl,
3565 __attribute__((unused)) void *data)
3567 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3568 struct rte_eth_pfc_conf pfc_conf;
3569 int rx_fc_enable, tx_fc_enable;
3573 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3574 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3575 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3576 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3578 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3579 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3582 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3583 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3584 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3585 pfc_conf.fc.high_water = res->high_water;
3586 pfc_conf.fc.low_water = res->low_water;
3587 pfc_conf.fc.pause_time = res->pause_time;
3588 pfc_conf.priority = res->priority;
3590 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3592 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3595 cmdline_parse_token_string_t cmd_pfc_set_set =
3596 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3598 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3599 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3600 pfc_ctrl, "pfc_ctrl");
3601 cmdline_parse_token_string_t cmd_pfc_set_rx =
3602 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3604 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3605 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3606 rx_pfc_mode, "on#off");
3607 cmdline_parse_token_string_t cmd_pfc_set_tx =
3608 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3610 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3611 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3612 tx_pfc_mode, "on#off");
3613 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3614 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3615 high_water, UINT32);
3616 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3617 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3619 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3620 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3621 pause_time, UINT16);
3622 cmdline_parse_token_num_t cmd_pfc_set_priority =
3623 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3625 cmdline_parse_token_num_t cmd_pfc_set_portid =
3626 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3629 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3630 .f = cmd_priority_flow_ctrl_set_parsed,
3632 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3633 tx on|off high_water low_water pause_time priority port_id",
3635 (void *)&cmd_pfc_set_set,
3636 (void *)&cmd_pfc_set_flow_ctrl,
3637 (void *)&cmd_pfc_set_rx,
3638 (void *)&cmd_pfc_set_rx_mode,
3639 (void *)&cmd_pfc_set_tx,
3640 (void *)&cmd_pfc_set_tx_mode,
3641 (void *)&cmd_pfc_set_high_water,
3642 (void *)&cmd_pfc_set_low_water,
3643 (void *)&cmd_pfc_set_pause_time,
3644 (void *)&cmd_pfc_set_priority,
3645 (void *)&cmd_pfc_set_portid,
3650 /* *** RESET CONFIGURATION *** */
3651 struct cmd_reset_result {
3652 cmdline_fixed_string_t reset;
3653 cmdline_fixed_string_t def;
3656 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3658 __attribute__((unused)) void *data)
3660 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3661 set_def_fwd_config();
3664 cmdline_parse_token_string_t cmd_reset_set =
3665 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3666 cmdline_parse_token_string_t cmd_reset_def =
3667 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3670 cmdline_parse_inst_t cmd_reset = {
3671 .f = cmd_reset_parsed,
3673 .help_str = "set default: reset default forwarding configuration",
3675 (void *)&cmd_reset_set,
3676 (void *)&cmd_reset_def,
3681 /* *** START FORWARDING *** */
3682 struct cmd_start_result {
3683 cmdline_fixed_string_t start;
3686 cmdline_parse_token_string_t cmd_start_start =
3687 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3689 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3690 __attribute__((unused)) struct cmdline *cl,
3691 __attribute__((unused)) void *data)
3693 start_packet_forwarding(0);
3696 cmdline_parse_inst_t cmd_start = {
3697 .f = cmd_start_parsed,
3699 .help_str = "start packet forwarding",
3701 (void *)&cmd_start_start,
3706 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3707 struct cmd_start_tx_first_result {
3708 cmdline_fixed_string_t start;
3709 cmdline_fixed_string_t tx_first;
3713 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3714 __attribute__((unused)) struct cmdline *cl,
3715 __attribute__((unused)) void *data)
3717 start_packet_forwarding(1);
3720 cmdline_parse_token_string_t cmd_start_tx_first_start =
3721 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3723 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3724 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3725 tx_first, "tx_first");
3727 cmdline_parse_inst_t cmd_start_tx_first = {
3728 .f = cmd_start_tx_first_parsed,
3730 .help_str = "start packet forwarding, after sending 1 burst of packets",
3732 (void *)&cmd_start_tx_first_start,
3733 (void *)&cmd_start_tx_first_tx_first,
3738 /* *** SHOW CFG *** */
3739 struct cmd_showcfg_result {
3740 cmdline_fixed_string_t show;
3741 cmdline_fixed_string_t cfg;
3742 cmdline_fixed_string_t what;
3745 static void cmd_showcfg_parsed(void *parsed_result,
3746 __attribute__((unused)) struct cmdline *cl,
3747 __attribute__((unused)) void *data)
3749 struct cmd_showcfg_result *res = parsed_result;
3750 if (!strcmp(res->what, "rxtx"))
3751 rxtx_config_display();
3752 else if (!strcmp(res->what, "cores"))
3753 fwd_lcores_config_display();
3754 else if (!strcmp(res->what, "fwd"))
3755 fwd_config_display();
3758 cmdline_parse_token_string_t cmd_showcfg_show =
3759 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3760 cmdline_parse_token_string_t cmd_showcfg_port =
3761 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3762 cmdline_parse_token_string_t cmd_showcfg_what =
3763 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3766 cmdline_parse_inst_t cmd_showcfg = {
3767 .f = cmd_showcfg_parsed,
3769 .help_str = "show config rxtx|cores|fwd",
3771 (void *)&cmd_showcfg_show,
3772 (void *)&cmd_showcfg_port,
3773 (void *)&cmd_showcfg_what,
3778 /* *** SHOW ALL PORT INFO *** */
3779 struct cmd_showportall_result {
3780 cmdline_fixed_string_t show;
3781 cmdline_fixed_string_t port;
3782 cmdline_fixed_string_t what;
3783 cmdline_fixed_string_t all;
3786 static void cmd_showportall_parsed(void *parsed_result,
3787 __attribute__((unused)) struct cmdline *cl,
3788 __attribute__((unused)) void *data)
3792 struct cmd_showportall_result *res = parsed_result;
3793 if (!strcmp(res->show, "clear")) {
3794 if (!strcmp(res->what, "stats"))
3795 for (i = 0; i < nb_ports; i++)
3797 } else if (!strcmp(res->what, "info"))
3798 for (i = 0; i < nb_ports; i++)
3799 port_infos_display(i);
3800 else if (!strcmp(res->what, "stats"))
3801 for (i = 0; i < nb_ports; i++)
3802 nic_stats_display(i);
3803 else if (!strcmp(res->what, "fdir"))
3804 for (i = 0; i < nb_ports; i++)
3806 else if (!strcmp(res->what, "stat_qmap"))
3807 for (i = 0; i < nb_ports; i++)
3808 nic_stats_mapping_display(i);
3811 cmdline_parse_token_string_t cmd_showportall_show =
3812 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3814 cmdline_parse_token_string_t cmd_showportall_port =
3815 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3816 cmdline_parse_token_string_t cmd_showportall_what =
3817 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3818 "info#stats#fdir#stat_qmap");
3819 cmdline_parse_token_string_t cmd_showportall_all =
3820 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3821 cmdline_parse_inst_t cmd_showportall = {
3822 .f = cmd_showportall_parsed,
3824 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3826 (void *)&cmd_showportall_show,
3827 (void *)&cmd_showportall_port,
3828 (void *)&cmd_showportall_what,
3829 (void *)&cmd_showportall_all,
3834 /* *** SHOW PORT INFO *** */
3835 struct cmd_showport_result {
3836 cmdline_fixed_string_t show;
3837 cmdline_fixed_string_t port;
3838 cmdline_fixed_string_t what;
3842 static void cmd_showport_parsed(void *parsed_result,
3843 __attribute__((unused)) struct cmdline *cl,
3844 __attribute__((unused)) void *data)
3846 struct cmd_showport_result *res = parsed_result;
3847 if (!strcmp(res->show, "clear")) {
3848 if (!strcmp(res->what, "stats"))
3849 nic_stats_clear(res->portnum);
3850 } else if (!strcmp(res->what, "info"))
3851 port_infos_display(res->portnum);
3852 else if (!strcmp(res->what, "stats"))
3853 nic_stats_display(res->portnum);
3854 else if (!strcmp(res->what, "fdir"))
3855 fdir_get_infos(res->portnum);
3856 else if (!strcmp(res->what, "stat_qmap"))
3857 nic_stats_mapping_display(res->portnum);
3860 cmdline_parse_token_string_t cmd_showport_show =
3861 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3863 cmdline_parse_token_string_t cmd_showport_port =
3864 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3865 cmdline_parse_token_string_t cmd_showport_what =
3866 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3867 "info#stats#fdir#stat_qmap");
3868 cmdline_parse_token_num_t cmd_showport_portnum =
3869 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3871 cmdline_parse_inst_t cmd_showport = {
3872 .f = cmd_showport_parsed,
3874 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3876 (void *)&cmd_showport_show,
3877 (void *)&cmd_showport_port,
3878 (void *)&cmd_showport_what,
3879 (void *)&cmd_showport_portnum,
3884 /* *** READ PORT REGISTER *** */
3885 struct cmd_read_reg_result {
3886 cmdline_fixed_string_t read;
3887 cmdline_fixed_string_t reg;
3893 cmd_read_reg_parsed(void *parsed_result,
3894 __attribute__((unused)) struct cmdline *cl,
3895 __attribute__((unused)) void *data)
3897 struct cmd_read_reg_result *res = parsed_result;
3898 port_reg_display(res->port_id, res->reg_off);
3901 cmdline_parse_token_string_t cmd_read_reg_read =
3902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3903 cmdline_parse_token_string_t cmd_read_reg_reg =
3904 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3905 cmdline_parse_token_num_t cmd_read_reg_port_id =
3906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3907 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3908 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3910 cmdline_parse_inst_t cmd_read_reg = {
3911 .f = cmd_read_reg_parsed,
3913 .help_str = "read reg port_id reg_off",
3915 (void *)&cmd_read_reg_read,
3916 (void *)&cmd_read_reg_reg,
3917 (void *)&cmd_read_reg_port_id,
3918 (void *)&cmd_read_reg_reg_off,
3923 /* *** READ PORT REGISTER BIT FIELD *** */
3924 struct cmd_read_reg_bit_field_result {
3925 cmdline_fixed_string_t read;
3926 cmdline_fixed_string_t regfield;
3934 cmd_read_reg_bit_field_parsed(void *parsed_result,
3935 __attribute__((unused)) struct cmdline *cl,
3936 __attribute__((unused)) void *data)
3938 struct cmd_read_reg_bit_field_result *res = parsed_result;
3939 port_reg_bit_field_display(res->port_id, res->reg_off,
3940 res->bit1_pos, res->bit2_pos);
3943 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3944 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3946 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3947 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3948 regfield, "regfield");
3949 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3950 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3952 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3953 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3955 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3956 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3958 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3959 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3962 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3963 .f = cmd_read_reg_bit_field_parsed,
3965 .help_str = "read regfield port_id reg_off bit_x bit_y "
3966 "(read register bit field between bit_x and bit_y included)",
3968 (void *)&cmd_read_reg_bit_field_read,
3969 (void *)&cmd_read_reg_bit_field_regfield,
3970 (void *)&cmd_read_reg_bit_field_port_id,
3971 (void *)&cmd_read_reg_bit_field_reg_off,
3972 (void *)&cmd_read_reg_bit_field_bit1_pos,
3973 (void *)&cmd_read_reg_bit_field_bit2_pos,
3978 /* *** READ PORT REGISTER BIT *** */
3979 struct cmd_read_reg_bit_result {
3980 cmdline_fixed_string_t read;
3981 cmdline_fixed_string_t regbit;
3988 cmd_read_reg_bit_parsed(void *parsed_result,
3989 __attribute__((unused)) struct cmdline *cl,
3990 __attribute__((unused)) void *data)
3992 struct cmd_read_reg_bit_result *res = parsed_result;
3993 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3996 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3997 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3998 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3999 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4001 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4003 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4005 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4006 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4008 cmdline_parse_inst_t cmd_read_reg_bit = {
4009 .f = cmd_read_reg_bit_parsed,
4011 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4013 (void *)&cmd_read_reg_bit_read,
4014 (void *)&cmd_read_reg_bit_regbit,
4015 (void *)&cmd_read_reg_bit_port_id,
4016 (void *)&cmd_read_reg_bit_reg_off,
4017 (void *)&cmd_read_reg_bit_bit_pos,
4022 /* *** WRITE PORT REGISTER *** */
4023 struct cmd_write_reg_result {
4024 cmdline_fixed_string_t write;
4025 cmdline_fixed_string_t reg;
4032 cmd_write_reg_parsed(void *parsed_result,
4033 __attribute__((unused)) struct cmdline *cl,
4034 __attribute__((unused)) void *data)
4036 struct cmd_write_reg_result *res = parsed_result;
4037 port_reg_set(res->port_id, res->reg_off, res->value);
4040 cmdline_parse_token_string_t cmd_write_reg_write =
4041 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4042 cmdline_parse_token_string_t cmd_write_reg_reg =
4043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4044 cmdline_parse_token_num_t cmd_write_reg_port_id =
4045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4046 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4047 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4048 cmdline_parse_token_num_t cmd_write_reg_value =
4049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4051 cmdline_parse_inst_t cmd_write_reg = {
4052 .f = cmd_write_reg_parsed,
4054 .help_str = "write reg port_id reg_off reg_value",
4056 (void *)&cmd_write_reg_write,
4057 (void *)&cmd_write_reg_reg,
4058 (void *)&cmd_write_reg_port_id,
4059 (void *)&cmd_write_reg_reg_off,
4060 (void *)&cmd_write_reg_value,
4065 /* *** WRITE PORT REGISTER BIT FIELD *** */
4066 struct cmd_write_reg_bit_field_result {
4067 cmdline_fixed_string_t write;
4068 cmdline_fixed_string_t regfield;
4077 cmd_write_reg_bit_field_parsed(void *parsed_result,
4078 __attribute__((unused)) struct cmdline *cl,
4079 __attribute__((unused)) void *data)
4081 struct cmd_write_reg_bit_field_result *res = parsed_result;
4082 port_reg_bit_field_set(res->port_id, res->reg_off,
4083 res->bit1_pos, res->bit2_pos, res->value);
4086 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4087 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4089 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4090 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4091 regfield, "regfield");
4092 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4093 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4095 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4096 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4098 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4099 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4101 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4102 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4104 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4108 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4109 .f = cmd_write_reg_bit_field_parsed,
4111 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4112 "(set register bit field between bit_x and bit_y included)",
4114 (void *)&cmd_write_reg_bit_field_write,
4115 (void *)&cmd_write_reg_bit_field_regfield,
4116 (void *)&cmd_write_reg_bit_field_port_id,
4117 (void *)&cmd_write_reg_bit_field_reg_off,
4118 (void *)&cmd_write_reg_bit_field_bit1_pos,
4119 (void *)&cmd_write_reg_bit_field_bit2_pos,
4120 (void *)&cmd_write_reg_bit_field_value,
4125 /* *** WRITE PORT REGISTER BIT *** */
4126 struct cmd_write_reg_bit_result {
4127 cmdline_fixed_string_t write;
4128 cmdline_fixed_string_t regbit;
4136 cmd_write_reg_bit_parsed(void *parsed_result,
4137 __attribute__((unused)) struct cmdline *cl,
4138 __attribute__((unused)) void *data)
4140 struct cmd_write_reg_bit_result *res = parsed_result;
4141 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4144 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4145 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4147 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4148 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4150 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4152 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4154 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4156 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4157 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4159 cmdline_parse_inst_t cmd_write_reg_bit = {
4160 .f = cmd_write_reg_bit_parsed,
4162 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4164 (void *)&cmd_write_reg_bit_write,
4165 (void *)&cmd_write_reg_bit_regbit,
4166 (void *)&cmd_write_reg_bit_port_id,
4167 (void *)&cmd_write_reg_bit_reg_off,
4168 (void *)&cmd_write_reg_bit_bit_pos,
4169 (void *)&cmd_write_reg_bit_value,
4174 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4175 struct cmd_read_rxd_txd_result {
4176 cmdline_fixed_string_t read;
4177 cmdline_fixed_string_t rxd_txd;
4184 cmd_read_rxd_txd_parsed(void *parsed_result,
4185 __attribute__((unused)) struct cmdline *cl,
4186 __attribute__((unused)) void *data)
4188 struct cmd_read_rxd_txd_result *res = parsed_result;
4190 if (!strcmp(res->rxd_txd, "rxd"))
4191 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4192 else if (!strcmp(res->rxd_txd, "txd"))
4193 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4196 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4197 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4198 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4199 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4201 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4202 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4203 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4204 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4205 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4206 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4208 cmdline_parse_inst_t cmd_read_rxd_txd = {
4209 .f = cmd_read_rxd_txd_parsed,
4211 .help_str = "read rxd|txd port_id queue_id rxd_id",
4213 (void *)&cmd_read_rxd_txd_read,
4214 (void *)&cmd_read_rxd_txd_rxd_txd,
4215 (void *)&cmd_read_rxd_txd_port_id,
4216 (void *)&cmd_read_rxd_txd_queue_id,
4217 (void *)&cmd_read_rxd_txd_desc_id,
4223 struct cmd_quit_result {
4224 cmdline_fixed_string_t quit;
4227 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4229 __attribute__((unused)) void *data)
4235 cmdline_parse_token_string_t cmd_quit_quit =
4236 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4238 cmdline_parse_inst_t cmd_quit = {
4239 .f = cmd_quit_parsed,
4241 .help_str = "exit application",
4243 (void *)&cmd_quit_quit,
4248 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4249 struct cmd_mac_addr_result {
4250 cmdline_fixed_string_t mac_addr_cmd;
4251 cmdline_fixed_string_t what;
4253 struct ether_addr address;
4256 static void cmd_mac_addr_parsed(void *parsed_result,
4257 __attribute__((unused)) struct cmdline *cl,
4258 __attribute__((unused)) void *data)
4260 struct cmd_mac_addr_result *res = parsed_result;
4263 if (strcmp(res->what, "add") == 0)
4264 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4266 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4268 /* check the return value and print it if is < 0 */
4270 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4274 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4275 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4277 cmdline_parse_token_string_t cmd_mac_addr_what =
4278 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4280 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4281 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4282 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4283 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4285 cmdline_parse_inst_t cmd_mac_addr = {
4286 .f = cmd_mac_addr_parsed,
4288 .help_str = "mac_addr add|remove X <address>: "
4289 "add/remove MAC address on port X",
4291 (void *)&cmd_mac_addr_cmd,
4292 (void *)&cmd_mac_addr_what,
4293 (void *)&cmd_mac_addr_portnum,
4294 (void *)&cmd_mac_addr_addr,
4300 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4301 struct cmd_set_qmap_result {
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t qmap;
4304 cmdline_fixed_string_t what;
4311 cmd_set_qmap_parsed(void *parsed_result,
4312 __attribute__((unused)) struct cmdline *cl,
4313 __attribute__((unused)) void *data)
4315 struct cmd_set_qmap_result *res = parsed_result;
4316 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4318 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4321 cmdline_parse_token_string_t cmd_setqmap_set =
4322 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4324 cmdline_parse_token_string_t cmd_setqmap_qmap =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4327 cmdline_parse_token_string_t cmd_setqmap_what =
4328 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4330 cmdline_parse_token_num_t cmd_setqmap_portid =
4331 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4333 cmdline_parse_token_num_t cmd_setqmap_queueid =
4334 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4336 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4337 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4340 cmdline_parse_inst_t cmd_set_qmap = {
4341 .f = cmd_set_qmap_parsed,
4343 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4345 (void *)&cmd_setqmap_set,
4346 (void *)&cmd_setqmap_qmap,
4347 (void *)&cmd_setqmap_what,
4348 (void *)&cmd_setqmap_portid,
4349 (void *)&cmd_setqmap_queueid,
4350 (void *)&cmd_setqmap_mapvalue,
4355 /* *** CONFIGURE UNICAST HASH TABLE *** */
4356 struct cmd_set_uc_hash_table {
4357 cmdline_fixed_string_t set;
4358 cmdline_fixed_string_t port;
4360 cmdline_fixed_string_t what;
4361 struct ether_addr address;
4362 cmdline_fixed_string_t mode;
4366 cmd_set_uc_hash_parsed(void *parsed_result,
4367 __attribute__((unused)) struct cmdline *cl,
4368 __attribute__((unused)) void *data)
4371 struct cmd_set_uc_hash_table *res = parsed_result;
4373 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4375 if (strcmp(res->what, "uta") == 0)
4376 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4377 &res->address,(uint8_t)is_on);
4379 printf("bad unicast hash table parameter, return code = %d \n", ret);
4383 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4386 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4389 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4390 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4392 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4395 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4396 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4398 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4399 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4402 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4403 .f = cmd_set_uc_hash_parsed,
4405 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4407 (void *)&cmd_set_uc_hash_set,
4408 (void *)&cmd_set_uc_hash_port,
4409 (void *)&cmd_set_uc_hash_portid,
4410 (void *)&cmd_set_uc_hash_what,
4411 (void *)&cmd_set_uc_hash_mac,
4412 (void *)&cmd_set_uc_hash_mode,
4417 struct cmd_set_uc_all_hash_table {
4418 cmdline_fixed_string_t set;
4419 cmdline_fixed_string_t port;
4421 cmdline_fixed_string_t what;
4422 cmdline_fixed_string_t value;
4423 cmdline_fixed_string_t mode;
4427 cmd_set_uc_all_hash_parsed(void *parsed_result,
4428 __attribute__((unused)) struct cmdline *cl,
4429 __attribute__((unused)) void *data)
4432 struct cmd_set_uc_all_hash_table *res = parsed_result;
4434 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4436 if ((strcmp(res->what, "uta") == 0) &&
4437 (strcmp(res->value, "all") == 0))
4438 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4440 printf("bad unicast hash table parameter,"
4441 "return code = %d \n", ret);
4444 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4447 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4450 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4451 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4453 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4454 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4456 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4457 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4459 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4460 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4463 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4464 .f = cmd_set_uc_all_hash_parsed,
4466 .help_str = "set port X uta all on|off (X = port number)",
4468 (void *)&cmd_set_uc_all_hash_set,
4469 (void *)&cmd_set_uc_all_hash_port,
4470 (void *)&cmd_set_uc_all_hash_portid,
4471 (void *)&cmd_set_uc_all_hash_what,
4472 (void *)&cmd_set_uc_all_hash_value,
4473 (void *)&cmd_set_uc_all_hash_mode,
4478 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4479 struct cmd_set_vf_traffic {
4480 cmdline_fixed_string_t set;
4481 cmdline_fixed_string_t port;
4483 cmdline_fixed_string_t vf;
4485 cmdline_fixed_string_t what;
4486 cmdline_fixed_string_t mode;
4490 cmd_set_vf_traffic_parsed(void *parsed_result,
4491 __attribute__((unused)) struct cmdline *cl,
4492 __attribute__((unused)) void *data)
4494 struct cmd_set_vf_traffic *res = parsed_result;
4495 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4496 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4498 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4501 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4504 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4507 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4508 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4510 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4513 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4514 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4516 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4517 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4519 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4523 cmdline_parse_inst_t cmd_set_vf_traffic = {
4524 .f = cmd_set_vf_traffic_parsed,
4526 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4528 (void *)&cmd_setvf_traffic_set,
4529 (void *)&cmd_setvf_traffic_port,
4530 (void *)&cmd_setvf_traffic_portid,
4531 (void *)&cmd_setvf_traffic_vf,
4532 (void *)&cmd_setvf_traffic_vfid,
4533 (void *)&cmd_setvf_traffic_what,
4534 (void *)&cmd_setvf_traffic_mode,
4539 /* *** CONFIGURE VF RECEIVE MODE *** */
4540 struct cmd_set_vf_rxmode {
4541 cmdline_fixed_string_t set;
4542 cmdline_fixed_string_t port;
4544 cmdline_fixed_string_t vf;
4546 cmdline_fixed_string_t what;
4547 cmdline_fixed_string_t mode;
4548 cmdline_fixed_string_t on;
4552 cmd_set_vf_rxmode_parsed(void *parsed_result,
4553 __attribute__((unused)) struct cmdline *cl,
4554 __attribute__((unused)) void *data)
4557 uint16_t rx_mode = 0;
4558 struct cmd_set_vf_rxmode *res = parsed_result;
4560 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4561 if (!strcmp(res->what,"rxmode")) {
4562 if (!strcmp(res->mode, "AUPE"))
4563 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4564 else if (!strcmp(res->mode, "ROPE"))
4565 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4566 else if (!strcmp(res->mode, "BAM"))
4567 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4568 else if (!strncmp(res->mode, "MPE",3))
4569 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4572 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4574 printf("bad VF receive mode parameter, return code = %d \n",
4578 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4579 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4581 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4582 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4584 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4585 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4587 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4588 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4590 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4591 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4593 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4594 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4596 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4597 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4598 mode, "AUPE#ROPE#BAM#MPE");
4599 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4600 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4603 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4604 .f = cmd_set_vf_rxmode_parsed,
4606 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4608 (void *)&cmd_set_vf_rxmode_set,
4609 (void *)&cmd_set_vf_rxmode_port,
4610 (void *)&cmd_set_vf_rxmode_portid,
4611 (void *)&cmd_set_vf_rxmode_vf,
4612 (void *)&cmd_set_vf_rxmode_vfid,
4613 (void *)&cmd_set_vf_rxmode_what,
4614 (void *)&cmd_set_vf_rxmode_mode,
4615 (void *)&cmd_set_vf_rxmode_on,
4620 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4621 struct cmd_vf_mac_addr_result {
4622 cmdline_fixed_string_t mac_addr_cmd;
4623 cmdline_fixed_string_t what;
4624 cmdline_fixed_string_t port;
4626 cmdline_fixed_string_t vf;
4628 struct ether_addr address;
4631 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4632 __attribute__((unused)) struct cmdline *cl,
4633 __attribute__((unused)) void *data)
4635 struct cmd_vf_mac_addr_result *res = parsed_result;
4638 if (strcmp(res->what, "add") == 0)
4639 ret = rte_eth_dev_mac_addr_add(res->port_num,
4640 &res->address, res->vf_num);
4642 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4646 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4647 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4648 mac_addr_cmd,"mac_addr");
4649 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4650 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4652 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4653 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4655 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4656 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4658 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4659 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4661 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4662 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4664 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4668 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4669 .f = cmd_vf_mac_addr_parsed,
4671 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4672 "Y = VF number)add MAC address filtering for a VF on port X",
4674 (void *)&cmd_vf_mac_addr_cmd,
4675 (void *)&cmd_vf_mac_addr_what,
4676 (void *)&cmd_vf_mac_addr_port,
4677 (void *)&cmd_vf_mac_addr_portnum,
4678 (void *)&cmd_vf_mac_addr_vf,
4679 (void *)&cmd_vf_mac_addr_vfnum,
4680 (void *)&cmd_vf_mac_addr_addr,
4685 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4686 struct cmd_vf_rx_vlan_filter {
4687 cmdline_fixed_string_t rx_vlan;
4688 cmdline_fixed_string_t what;
4690 cmdline_fixed_string_t port;
4692 cmdline_fixed_string_t vf;
4697 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4698 __attribute__((unused)) struct cmdline *cl,
4699 __attribute__((unused)) void *data)
4701 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4703 if (!strcmp(res->what, "add"))
4704 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4706 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4709 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4710 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4711 rx_vlan, "rx_vlan");
4712 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4713 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4715 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4716 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4718 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4719 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4721 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4722 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4724 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4725 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4727 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4728 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4731 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4732 .f = cmd_vf_rx_vlan_filter_parsed,
4734 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4735 "Y = port number,Z = hexadecimal VF mask)",
4737 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4738 (void *)&cmd_vf_rx_vlan_filter_what,
4739 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4740 (void *)&cmd_vf_rx_vlan_filter_port,
4741 (void *)&cmd_vf_rx_vlan_filter_portid,
4742 (void *)&cmd_vf_rx_vlan_filter_vf,
4743 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4748 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4749 struct cmd_set_mirror_mask_result {
4750 cmdline_fixed_string_t set;
4751 cmdline_fixed_string_t port;
4753 cmdline_fixed_string_t mirror;
4755 cmdline_fixed_string_t what;
4756 cmdline_fixed_string_t value;
4757 cmdline_fixed_string_t dstpool;
4759 cmdline_fixed_string_t on;
4762 cmdline_parse_token_string_t cmd_mirror_mask_set =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4765 cmdline_parse_token_string_t cmd_mirror_mask_port =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4768 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4769 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4771 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4772 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4773 mirror, "mirror-rule");
4774 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4775 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4777 cmdline_parse_token_string_t cmd_mirror_mask_what =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4779 what, "pool-mirror#vlan-mirror");
4780 cmdline_parse_token_string_t cmd_mirror_mask_value =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4783 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4785 dstpool, "dst-pool");
4786 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4787 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4789 cmdline_parse_token_string_t cmd_mirror_mask_on =
4790 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4794 cmd_set_mirror_mask_parsed(void *parsed_result,
4795 __attribute__((unused)) struct cmdline *cl,
4796 __attribute__((unused)) void *data)
4799 struct cmd_set_mirror_mask_result *res = parsed_result;
4800 struct rte_eth_vmdq_mirror_conf mr_conf;
4802 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4804 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4806 mr_conf.dst_pool = res->dstpool_id;
4808 if (!strcmp(res->what, "pool-mirror")) {
4809 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4810 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4811 } else if(!strcmp(res->what, "vlan-mirror")) {
4812 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4813 nb_item = parse_item_list(res->value, "core",
4814 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4818 for(i=0; i < nb_item; i++) {
4819 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4820 printf("Invalid vlan_id: must be < 4096\n");
4824 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4825 mr_conf.vlan.vlan_mask |= 1ULL << i;
4829 if(!strcmp(res->on, "on"))
4830 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4833 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4836 printf("mirror rule add error: (%s)\n", strerror(-ret));
4839 cmdline_parse_inst_t cmd_set_mirror_mask = {
4840 .f = cmd_set_mirror_mask_parsed,
4842 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4843 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4845 (void *)&cmd_mirror_mask_set,
4846 (void *)&cmd_mirror_mask_port,
4847 (void *)&cmd_mirror_mask_portid,
4848 (void *)&cmd_mirror_mask_mirror,
4849 (void *)&cmd_mirror_mask_ruleid,
4850 (void *)&cmd_mirror_mask_what,
4851 (void *)&cmd_mirror_mask_value,
4852 (void *)&cmd_mirror_mask_dstpool,
4853 (void *)&cmd_mirror_mask_poolid,
4854 (void *)&cmd_mirror_mask_on,
4859 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4860 struct cmd_set_mirror_link_result {
4861 cmdline_fixed_string_t set;
4862 cmdline_fixed_string_t port;
4864 cmdline_fixed_string_t mirror;
4866 cmdline_fixed_string_t what;
4867 cmdline_fixed_string_t dstpool;
4869 cmdline_fixed_string_t on;
4872 cmdline_parse_token_string_t cmd_mirror_link_set =
4873 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4875 cmdline_parse_token_string_t cmd_mirror_link_port =
4876 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4878 cmdline_parse_token_string_t cmd_mirror_link_portid =
4879 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4881 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4882 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4883 mirror, "mirror-rule");
4884 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4885 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4887 cmdline_parse_token_string_t cmd_mirror_link_what =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4889 what, "uplink-mirror#downlink-mirror");
4890 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4891 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4892 dstpool, "dst-pool");
4893 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4894 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4896 cmdline_parse_token_string_t cmd_mirror_link_on =
4897 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4901 cmd_set_mirror_link_parsed(void *parsed_result,
4902 __attribute__((unused)) struct cmdline *cl,
4903 __attribute__((unused)) void *data)
4906 struct cmd_set_mirror_link_result *res = parsed_result;
4907 struct rte_eth_vmdq_mirror_conf mr_conf;
4909 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4910 if(!strcmp(res->what, "uplink-mirror")) {
4911 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4912 }else if(!strcmp(res->what, "downlink-mirror"))
4913 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4915 mr_conf.dst_pool = res->dstpool_id;
4917 if(!strcmp(res->on, "on"))
4918 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4921 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4924 /* check the return value and print it if is < 0 */
4926 printf("mirror rule add error: (%s)\n", strerror(-ret));
4930 cmdline_parse_inst_t cmd_set_mirror_link = {
4931 .f = cmd_set_mirror_link_parsed,
4933 .help_str = "set port X mirror-rule Y uplink-mirror|"
4934 "downlink-mirror dst-pool Z on|off",
4936 (void *)&cmd_mirror_link_set,
4937 (void *)&cmd_mirror_link_port,
4938 (void *)&cmd_mirror_link_portid,
4939 (void *)&cmd_mirror_link_mirror,
4940 (void *)&cmd_mirror_link_ruleid,
4941 (void *)&cmd_mirror_link_what,
4942 (void *)&cmd_mirror_link_dstpool,
4943 (void *)&cmd_mirror_link_poolid,
4944 (void *)&cmd_mirror_link_on,
4949 /* *** RESET VM MIRROR RULE *** */
4950 struct cmd_rm_mirror_rule_result {
4951 cmdline_fixed_string_t reset;
4952 cmdline_fixed_string_t port;
4954 cmdline_fixed_string_t mirror;
4958 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4959 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4961 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4962 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4964 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4965 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4967 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4968 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4969 mirror, "mirror-rule");
4970 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4971 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4975 cmd_reset_mirror_rule_parsed(void *parsed_result,
4976 __attribute__((unused)) struct cmdline *cl,
4977 __attribute__((unused)) void *data)
4980 struct cmd_set_mirror_link_result *res = parsed_result;
4982 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4984 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4987 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4988 .f = cmd_reset_mirror_rule_parsed,
4990 .help_str = "reset port X mirror-rule Y",
4992 (void *)&cmd_rm_mirror_rule_reset,
4993 (void *)&cmd_rm_mirror_rule_port,
4994 (void *)&cmd_rm_mirror_rule_portid,
4995 (void *)&cmd_rm_mirror_rule_mirror,
4996 (void *)&cmd_rm_mirror_rule_ruleid,
5001 /* ******************************************************************************** */
5003 struct cmd_dump_result {
5004 cmdline_fixed_string_t dump;
5008 dump_struct_sizes(void)
5010 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5011 DUMP_SIZE(struct rte_mbuf);
5012 DUMP_SIZE(struct rte_pktmbuf);
5013 DUMP_SIZE(struct rte_ctrlmbuf);
5014 DUMP_SIZE(struct rte_mempool);
5015 DUMP_SIZE(struct rte_ring);
5019 static void cmd_dump_parsed(void *parsed_result,
5020 __attribute__((unused)) struct cmdline *cl,
5021 __attribute__((unused)) void *data)
5023 struct cmd_dump_result *res = parsed_result;
5025 if (!strcmp(res->dump, "dump_physmem"))
5026 rte_dump_physmem_layout();
5027 else if (!strcmp(res->dump, "dump_memzone"))
5029 else if (!strcmp(res->dump, "dump_log_history"))
5030 rte_log_dump_history();
5031 else if (!strcmp(res->dump, "dump_struct_sizes"))
5032 dump_struct_sizes();
5033 else if (!strcmp(res->dump, "dump_ring"))
5034 rte_ring_list_dump();
5035 else if (!strcmp(res->dump, "dump_mempool"))
5036 rte_mempool_list_dump();
5037 else if (!strcmp(res->dump, "dump_devargs"))
5038 rte_eal_devargs_dump();
5041 cmdline_parse_token_string_t cmd_dump_dump =
5042 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5046 "dump_struct_sizes#"
5051 cmdline_parse_inst_t cmd_dump = {
5052 .f = cmd_dump_parsed, /* function to call */
5053 .data = NULL, /* 2nd arg of func */
5054 .help_str = "dump status",
5055 .tokens = { /* token list, NULL terminated */
5056 (void *)&cmd_dump_dump,
5061 /* ******************************************************************************** */
5063 struct cmd_dump_one_result {
5064 cmdline_fixed_string_t dump;
5065 cmdline_fixed_string_t name;
5068 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5069 __attribute__((unused)) void *data)
5071 struct cmd_dump_one_result *res = parsed_result;
5073 if (!strcmp(res->dump, "dump_ring")) {
5075 r = rte_ring_lookup(res->name);
5077 cmdline_printf(cl, "Cannot find ring\n");
5081 } else if (!strcmp(res->dump, "dump_mempool")) {
5082 struct rte_mempool *mp;
5083 mp = rte_mempool_lookup(res->name);
5085 cmdline_printf(cl, "Cannot find mempool\n");
5088 rte_mempool_dump(mp);
5092 cmdline_parse_token_string_t cmd_dump_one_dump =
5093 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5094 "dump_ring#dump_mempool");
5096 cmdline_parse_token_string_t cmd_dump_one_name =
5097 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5099 cmdline_parse_inst_t cmd_dump_one = {
5100 .f = cmd_dump_one_parsed, /* function to call */
5101 .data = NULL, /* 2nd arg of func */
5102 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5103 .tokens = { /* token list, NULL terminated */
5104 (void *)&cmd_dump_one_dump,
5105 (void *)&cmd_dump_one_name,
5110 /* ******************************************************************************** */
5112 /* list of instructions */
5113 cmdline_parse_ctx_t main_ctx[] = {
5114 (cmdline_parse_inst_t *)&cmd_help_brief,
5115 (cmdline_parse_inst_t *)&cmd_help_long,
5116 (cmdline_parse_inst_t *)&cmd_quit,
5117 (cmdline_parse_inst_t *)&cmd_showport,
5118 (cmdline_parse_inst_t *)&cmd_showportall,
5119 (cmdline_parse_inst_t *)&cmd_showcfg,
5120 (cmdline_parse_inst_t *)&cmd_start,
5121 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5122 (cmdline_parse_inst_t *)&cmd_reset,
5123 (cmdline_parse_inst_t *)&cmd_set_numbers,
5124 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5125 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5126 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5127 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5128 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5129 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5130 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5131 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5132 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5133 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5134 #ifdef RTE_NIC_BYPASS
5135 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5136 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5137 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5138 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5140 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5141 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5142 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5143 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5144 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5145 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5146 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5147 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5148 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5149 (cmdline_parse_inst_t *)&cmd_config_dcb,
5150 (cmdline_parse_inst_t *)&cmd_read_reg,
5151 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5152 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5153 (cmdline_parse_inst_t *)&cmd_write_reg,
5154 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5155 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5156 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5157 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5158 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5159 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5160 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5161 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5162 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5163 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5164 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5165 (cmdline_parse_inst_t *)&cmd_stop,
5166 (cmdline_parse_inst_t *)&cmd_mac_addr,
5167 (cmdline_parse_inst_t *)&cmd_set_qmap,
5168 (cmdline_parse_inst_t *)&cmd_operate_port,
5169 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5170 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5171 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5172 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5173 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5174 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5175 (cmdline_parse_inst_t *)&cmd_config_rss,
5176 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5177 (cmdline_parse_inst_t *)&cmd_showport_reta,
5178 (cmdline_parse_inst_t *)&cmd_config_burst,
5179 (cmdline_parse_inst_t *)&cmd_config_thresh,
5180 (cmdline_parse_inst_t *)&cmd_config_threshold,
5181 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5182 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5183 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5184 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5185 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5186 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5187 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5188 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5189 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5190 (cmdline_parse_inst_t *)&cmd_dump,
5191 (cmdline_parse_inst_t *)&cmd_dump_one,
5195 /* prompt function, called from main on MASTER lcore */
5201 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5205 cmdline_interact(cl);
5206 cmdline_stdin_exit(cl);
5210 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5212 if (id < nb_ports) {
5213 /* check if need_reconfig has been set to 1 */
5214 if (ports[id].need_reconfig == 0)
5215 ports[id].need_reconfig = dev;
5216 /* check if need_reconfig_queues has been set to 1 */
5217 if (ports[id].need_reconfig_queues == 0)
5218 ports[id].need_reconfig_queues = queue;
5222 for (pid = 0; pid < nb_ports; pid++) {
5223 /* check if need_reconfig has been set to 1 */
5224 if (ports[pid].need_reconfig == 0)
5225 ports[pid].need_reconfig = dev;
5226 /* check if need_reconfig_queues has been set to 1 */
5227 if (ports[pid].need_reconfig_queues == 0)
5228 ports[pid].need_reconfig_queues = queue;
5233 #ifdef RTE_NIC_BYPASS
5235 bypass_is_supported(portid_t port_id)
5237 struct rte_port *port;
5238 struct rte_pci_id *pci_id;
5240 if (port_id >= nb_ports) {
5241 printf("\tPort id must be less than %d.\n", nb_ports);
5245 /* Get the device id. */
5246 port = &ports[port_id];
5247 pci_id = &port->dev_info.pci_dev->id;
5249 /* Check if NIC supports bypass. */
5250 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5254 printf("\tBypass not supported for port_id = %d.\n", port_id);