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"
298 " Set packet forwarding mode.\n\n"
300 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
301 " Add a MAC address on port_id.\n\n"
303 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
304 " Remove a MAC address from port_id.\n\n"
306 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
307 " Add a MAC address for a VF on the port.\n\n"
309 "set port (port_id) uta (mac_address|all) (on|off)\n"
310 " Add/Remove a or all unicast hash filter(s)"
313 "set promisc (port_id|all) (on|off)\n"
314 " Set the promiscuous mode on port_id, or all.\n\n"
316 "set allmulti (port_id|all) (on|off)\n"
317 " Set the allmulti mode on port_id, or all.\n\n"
319 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
320 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
321 " (on|off) (port_id)\n"
322 " Set the link flow control parameter on a port.\n\n"
324 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
325 " (low_water) (pause_time) (priority) (port_id)\n"
326 " Set the priority flow control parameter on a"
329 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
330 " Set statistics mapping (qmapping 0..15) for RX/TX"
332 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
333 " on port 0 to mapping 5.\n\n"
335 "set port (port_id) vf (vf_id) rx|tx on|off \n"
336 " Enable/Disable a VF receive/tranmit from a port\n\n"
338 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
340 " AUPE:accepts untagged VLAN;"
341 "ROPE:accept unicast hash\n\n"
342 " BAM:accepts broadcast packets;"
343 "MPE:accepts all multicast packets\n\n"
344 " Enable/Disable a VF receive mode of a port\n\n"
346 "set port (port_id) mirror-rule (rule_id)"
347 "(pool-mirror|vlan-mirror)\n"
348 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
349 " Set pool or vlan type mirror rule on a port.\n"
350 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
351 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
354 "set port (port_id) mirror-rule (rule_id)"
355 " (uplink-mirror|downlink-mirror) dst-pool"
356 " (pool_id) (on|off)\n"
357 " Set uplink or downlink type mirror rule on a port.\n"
358 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
359 " 0 on' enable mirror income traffic to pool 0.\n\n"
361 "reset port (port_id) mirror-rule (rule_id)\n"
362 " Reset a mirror rule.\n\n"
364 "set flush_rx (on|off)\n"
365 " Flush (default) or don't flush RX streams before"
366 " forwarding. Mainly used with PCAP drivers.\n\n"
368 #ifdef RTE_NIC_BYPASS
369 "set bypass mode (normal|bypass|isolate) (port_id)\n"
370 " Set the bypass mode for the lowest port on bypass enabled"
373 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
374 "mode (normal|bypass|isolate) (port_id)\n"
375 " Set the event required to initiate specified bypass mode for"
376 " the lowest port on a bypass enabled NIC where:\n"
377 " timeout = enable bypass after watchdog timeout.\n"
378 " os_on = enable bypass when OS/board is powered on.\n"
379 " os_off = enable bypass when OS/board is powered off.\n"
380 " power_on = enable bypass when power supply is turned on.\n"
381 " power_off = enable bypass when power supply is turned off."
384 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
385 " Set the bypass watchdog timeout to 'n' seconds"
386 " where 0 = instant.\n\n"
388 "show bypass config (port_id)\n"
389 " Show the bypass configuration for a bypass enabled NIC"
390 " using the lowest port on the NIC.\n\n"
393 , list_pkt_forwarding_modes()
398 if (show_all || !strcmp(res->section, "flowdir")) {
403 "Flow director mode:\n"
404 "-------------------\n\n"
406 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
407 " src (src_ip_address) (src_port)"
408 " dst (dst_ip_address) (dst_port)"
409 " flexbytes (flexbytes_values) vlan (vlan_id)"
410 " queue (queue_id)\n"
411 " Add a signature filter.\n\n"
413 "upd_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 " Update a signature filter.\n\n"
420 "rm_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)\n"
424 " Remove a signature filter.\n\n"
426 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
427 " src (src_ip_address) (src_port)"
428 " dst (dst_ip_address) (dst_port)"
429 " flexbytes (flexbytes_values) vlan (vlan_id)"
430 " queue (queue_id) soft (soft_id)\n"
431 " Add a perfect filter.\n\n"
433 "upd_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)\n"
438 " Update a perfect filter.\n\n"
440 "rm_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)"
445 " Remove a perfect filter.\n\n"
447 "set_masks_filter (port_id) only_ip_flow (0|1)"
448 " src_mask (ip_src_mask) (src_port_mask)"
449 " dst_mask (ip_dst_mask) (dst_port_mask)"
450 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
451 " Set IPv4 filter masks.\n\n"
453 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
454 " src_mask (ip_src_mask) (src_port_mask)"
455 " dst_mask (ip_dst_mask) (dst_port_mask)"
456 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
457 " compare_dst (0|1)\n"
458 " Set IPv6 filter masks.\n\n"
462 if (show_all || !strcmp(res->section, "ports")) {
468 "----------------\n\n"
470 "port start (port_id|all)\n"
471 " Start all ports or port_id.\n\n"
473 "port stop (port_id|all)\n"
474 " Stop all ports or port_id.\n\n"
476 "port close (port_id|all)\n"
477 " Close all ports or port_id.\n\n"
479 "port config (port_id|all) speed (10|100|1000|10000|auto)"
480 " duplex (half|full|auto)\n"
481 " Set speed and duplex for all ports or port_id\n\n"
483 "port config all (rxq|txq|rxd|txd) (value)\n"
484 " Set number for rxq/txq/rxd/txd.\n\n"
486 "port config all max-pkt-len (value)\n"
487 " Set the max packet length.\n\n"
489 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
491 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
494 "port config all rss (ip|udp|none)\n"
495 " Set the RSS mode.\n\n"
497 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
498 " Set the RSS redirection table.\n\n"
500 "port config (port_id) dcb vt (on|off) (traffic_class)"
502 " Set the DCB mode.\n\n"
504 "port config all burst (value)\n"
505 " Set the number of packets per burst.\n\n"
507 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
509 " Set the ring prefetch/host/writeback threshold"
510 " for tx/rx queue.\n\n"
512 "port config all (txfreet|txrst|rxfreet) (value)\n"
513 " Set free threshold for rx/tx, or set"
514 " tx rs bit threshold.\n\n"
518 if (show_all || !strcmp(res->section, "registers")) {
526 "read reg (port_id) (address)\n"
527 " Display value of a port register.\n\n"
529 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
530 " Display a port register bit field.\n\n"
532 "read regbit (port_id) (address) (bit_x)\n"
533 " Display a single port register bit.\n\n"
535 "write reg (port_id) (address) (value)\n"
536 " Set value of a port register.\n\n"
538 "write regfield (port_id) (address) (bit_x) (bit_y)"
540 " Set bit field of a port register.\n\n"
542 "write regbit (port_id) (address) (bit_x) (value)\n"
543 " Set single bit value of a port register.\n\n"
548 cmdline_parse_token_string_t cmd_help_long_help =
549 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
551 cmdline_parse_token_string_t cmd_help_long_section =
552 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
553 "all#control#display#config#flowdir#"
556 cmdline_parse_inst_t cmd_help_long = {
557 .f = cmd_help_long_parsed,
559 .help_str = "show help",
561 (void *)&cmd_help_long_help,
562 (void *)&cmd_help_long_section,
568 /* *** start/stop/close all ports *** */
569 struct cmd_operate_port_result {
570 cmdline_fixed_string_t keyword;
571 cmdline_fixed_string_t name;
572 cmdline_fixed_string_t value;
575 static void cmd_operate_port_parsed(void *parsed_result,
576 __attribute__((unused)) struct cmdline *cl,
577 __attribute__((unused)) void *data)
579 struct cmd_operate_port_result *res = parsed_result;
581 if (!strcmp(res->name, "start"))
582 start_port(RTE_PORT_ALL);
583 else if (!strcmp(res->name, "stop"))
584 stop_port(RTE_PORT_ALL);
585 else if (!strcmp(res->name, "close"))
586 close_port(RTE_PORT_ALL);
588 printf("Unknown parameter\n");
591 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
592 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
594 cmdline_parse_token_string_t cmd_operate_port_all_port =
595 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
597 cmdline_parse_token_string_t cmd_operate_port_all_all =
598 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
600 cmdline_parse_inst_t cmd_operate_port = {
601 .f = cmd_operate_port_parsed,
603 .help_str = "port start|stop|close all: start/stop/close all ports",
605 (void *)&cmd_operate_port_all_cmd,
606 (void *)&cmd_operate_port_all_port,
607 (void *)&cmd_operate_port_all_all,
612 /* *** start/stop/close specific port *** */
613 struct cmd_operate_specific_port_result {
614 cmdline_fixed_string_t keyword;
615 cmdline_fixed_string_t name;
619 static void cmd_operate_specific_port_parsed(void *parsed_result,
620 __attribute__((unused)) struct cmdline *cl,
621 __attribute__((unused)) void *data)
623 struct cmd_operate_specific_port_result *res = parsed_result;
625 if (!strcmp(res->name, "start"))
626 start_port(res->value);
627 else if (!strcmp(res->name, "stop"))
628 stop_port(res->value);
629 else if (!strcmp(res->name, "close"))
630 close_port(res->value);
632 printf("Unknown parameter\n");
635 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
636 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
638 cmdline_parse_token_string_t cmd_operate_specific_port_port =
639 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
640 name, "start#stop#close");
641 cmdline_parse_token_num_t cmd_operate_specific_port_id =
642 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
645 cmdline_parse_inst_t cmd_operate_specific_port = {
646 .f = cmd_operate_specific_port_parsed,
648 .help_str = "port start|stop|close X: start/stop/close port X",
650 (void *)&cmd_operate_specific_port_cmd,
651 (void *)&cmd_operate_specific_port_port,
652 (void *)&cmd_operate_specific_port_id,
657 /* *** configure speed for all ports *** */
658 struct cmd_config_speed_all {
659 cmdline_fixed_string_t port;
660 cmdline_fixed_string_t keyword;
661 cmdline_fixed_string_t all;
662 cmdline_fixed_string_t item1;
663 cmdline_fixed_string_t item2;
664 cmdline_fixed_string_t value1;
665 cmdline_fixed_string_t value2;
669 cmd_config_speed_all_parsed(void *parsed_result,
670 __attribute__((unused)) struct cmdline *cl,
671 __attribute__((unused)) void *data)
673 struct cmd_config_speed_all *res = parsed_result;
674 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
675 uint16_t link_duplex = 0;
678 if (!all_ports_stopped()) {
679 printf("Please stop all ports first\n");
683 if (!strcmp(res->value1, "10"))
684 link_speed = ETH_LINK_SPEED_10;
685 else if (!strcmp(res->value1, "100"))
686 link_speed = ETH_LINK_SPEED_100;
687 else if (!strcmp(res->value1, "1000"))
688 link_speed = ETH_LINK_SPEED_1000;
689 else if (!strcmp(res->value1, "10000"))
690 link_speed = ETH_LINK_SPEED_10000;
691 else if (!strcmp(res->value1, "auto"))
692 link_speed = ETH_LINK_SPEED_AUTONEG;
694 printf("Unknown parameter\n");
698 if (!strcmp(res->value2, "half"))
699 link_duplex = ETH_LINK_HALF_DUPLEX;
700 else if (!strcmp(res->value2, "full"))
701 link_duplex = ETH_LINK_FULL_DUPLEX;
702 else if (!strcmp(res->value2, "auto"))
703 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
705 printf("Unknown parameter\n");
709 for (pid = 0; pid < nb_ports; pid++) {
710 ports[pid].dev_conf.link_speed = link_speed;
711 ports[pid].dev_conf.link_duplex = link_duplex;
714 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
717 cmdline_parse_token_string_t cmd_config_speed_all_port =
718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
719 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
722 cmdline_parse_token_string_t cmd_config_speed_all_all =
723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
724 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
726 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
728 "10#100#1000#10000#auto");
729 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
731 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
735 cmdline_parse_inst_t cmd_config_speed_all = {
736 .f = cmd_config_speed_all_parsed,
738 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
741 (void *)&cmd_config_speed_all_port,
742 (void *)&cmd_config_speed_all_keyword,
743 (void *)&cmd_config_speed_all_all,
744 (void *)&cmd_config_speed_all_item1,
745 (void *)&cmd_config_speed_all_value1,
746 (void *)&cmd_config_speed_all_item2,
747 (void *)&cmd_config_speed_all_value2,
752 /* *** configure speed for specific port *** */
753 struct cmd_config_speed_specific {
754 cmdline_fixed_string_t port;
755 cmdline_fixed_string_t keyword;
757 cmdline_fixed_string_t item1;
758 cmdline_fixed_string_t item2;
759 cmdline_fixed_string_t value1;
760 cmdline_fixed_string_t value2;
764 cmd_config_speed_specific_parsed(void *parsed_result,
765 __attribute__((unused)) struct cmdline *cl,
766 __attribute__((unused)) void *data)
768 struct cmd_config_speed_specific *res = parsed_result;
769 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
770 uint16_t link_duplex = 0;
772 if (!all_ports_stopped()) {
773 printf("Please stop all ports first\n");
777 if (res->id >= nb_ports) {
778 printf("Port id %d must be less than %d\n", res->id, nb_ports);
782 if (!strcmp(res->value1, "10"))
783 link_speed = ETH_LINK_SPEED_10;
784 else if (!strcmp(res->value1, "100"))
785 link_speed = ETH_LINK_SPEED_100;
786 else if (!strcmp(res->value1, "1000"))
787 link_speed = ETH_LINK_SPEED_1000;
788 else if (!strcmp(res->value1, "10000"))
789 link_speed = ETH_LINK_SPEED_10000;
790 else if (!strcmp(res->value1, "auto"))
791 link_speed = ETH_LINK_SPEED_AUTONEG;
793 printf("Unknown parameter\n");
797 if (!strcmp(res->value2, "half"))
798 link_duplex = ETH_LINK_HALF_DUPLEX;
799 else if (!strcmp(res->value2, "full"))
800 link_duplex = ETH_LINK_FULL_DUPLEX;
801 else if (!strcmp(res->value2, "auto"))
802 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
804 printf("Unknown parameter\n");
808 ports[res->id].dev_conf.link_speed = link_speed;
809 ports[res->id].dev_conf.link_duplex = link_duplex;
811 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
815 cmdline_parse_token_string_t cmd_config_speed_specific_port =
816 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
818 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
819 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
821 cmdline_parse_token_num_t cmd_config_speed_specific_id =
822 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
823 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
824 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
826 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
828 "10#100#1000#10000#auto");
829 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
830 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
832 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
833 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
836 cmdline_parse_inst_t cmd_config_speed_specific = {
837 .f = cmd_config_speed_specific_parsed,
839 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
842 (void *)&cmd_config_speed_specific_port,
843 (void *)&cmd_config_speed_specific_keyword,
844 (void *)&cmd_config_speed_specific_id,
845 (void *)&cmd_config_speed_specific_item1,
846 (void *)&cmd_config_speed_specific_value1,
847 (void *)&cmd_config_speed_specific_item2,
848 (void *)&cmd_config_speed_specific_value2,
853 /* *** configure txq/rxq, txd/rxd *** */
854 struct cmd_config_rx_tx {
855 cmdline_fixed_string_t port;
856 cmdline_fixed_string_t keyword;
857 cmdline_fixed_string_t all;
858 cmdline_fixed_string_t name;
863 cmd_config_rx_tx_parsed(void *parsed_result,
864 __attribute__((unused)) struct cmdline *cl,
865 __attribute__((unused)) void *data)
867 struct cmd_config_rx_tx *res = parsed_result;
869 if (!all_ports_stopped()) {
870 printf("Please stop all ports first\n");
874 if (!strcmp(res->name, "rxq")) {
875 if (res->value <= 0) {
876 printf("rxq %d invalid - must be > 0\n", res->value);
881 else if (!strcmp(res->name, "txq")) {
882 if (res->value <= 0) {
883 printf("txq %d invalid - must be > 0\n", res->value);
888 else if (!strcmp(res->name, "rxd")) {
889 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
890 printf("rxd %d invalid - must be > 0 && <= %d\n",
891 res->value, RTE_TEST_RX_DESC_MAX);
895 } else if (!strcmp(res->name, "txd")) {
896 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
897 printf("txd %d invalid - must be > 0 && <= %d\n",
898 res->value, RTE_TEST_TX_DESC_MAX);
903 printf("Unknown parameter\n");
909 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
912 cmdline_parse_token_string_t cmd_config_rx_tx_port =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
914 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
915 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
916 cmdline_parse_token_string_t cmd_config_rx_tx_all =
917 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
918 cmdline_parse_token_string_t cmd_config_rx_tx_name =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
921 cmdline_parse_token_num_t cmd_config_rx_tx_value =
922 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
924 cmdline_parse_inst_t cmd_config_rx_tx = {
925 .f = cmd_config_rx_tx_parsed,
927 .help_str = "port config all rxq|txq|rxd|txd value",
929 (void *)&cmd_config_rx_tx_port,
930 (void *)&cmd_config_rx_tx_keyword,
931 (void *)&cmd_config_rx_tx_all,
932 (void *)&cmd_config_rx_tx_name,
933 (void *)&cmd_config_rx_tx_value,
938 /* *** config max packet length *** */
939 struct cmd_config_max_pkt_len_result {
940 cmdline_fixed_string_t port;
941 cmdline_fixed_string_t keyword;
942 cmdline_fixed_string_t all;
943 cmdline_fixed_string_t name;
948 cmd_config_max_pkt_len_parsed(void *parsed_result,
949 __attribute__((unused)) struct cmdline *cl,
950 __attribute__((unused)) void *data)
952 struct cmd_config_max_pkt_len_result *res = parsed_result;
954 if (!all_ports_stopped()) {
955 printf("Please stop all ports first\n");
959 if (!strcmp(res->name, "max-pkt-len")) {
960 if (res->value < ETHER_MIN_LEN) {
961 printf("max-pkt-len can not be less than %d\n",
965 if (res->value == rx_mode.max_rx_pkt_len)
968 rx_mode.max_rx_pkt_len = res->value;
969 if (res->value > ETHER_MAX_LEN)
970 rx_mode.jumbo_frame = 1;
972 rx_mode.jumbo_frame = 0;
974 printf("Unknown parameter\n");
980 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
983 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
986 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
989 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
992 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
995 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
996 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
999 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1000 .f = cmd_config_max_pkt_len_parsed,
1002 .help_str = "port config all max-pkt-len value",
1004 (void *)&cmd_config_max_pkt_len_port,
1005 (void *)&cmd_config_max_pkt_len_keyword,
1006 (void *)&cmd_config_max_pkt_len_all,
1007 (void *)&cmd_config_max_pkt_len_name,
1008 (void *)&cmd_config_max_pkt_len_value,
1013 /* *** configure rx mode *** */
1014 struct cmd_config_rx_mode_flag {
1015 cmdline_fixed_string_t port;
1016 cmdline_fixed_string_t keyword;
1017 cmdline_fixed_string_t all;
1018 cmdline_fixed_string_t name;
1019 cmdline_fixed_string_t value;
1023 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1024 __attribute__((unused)) struct cmdline *cl,
1025 __attribute__((unused)) void *data)
1027 struct cmd_config_rx_mode_flag *res = parsed_result;
1029 if (!all_ports_stopped()) {
1030 printf("Please stop all ports first\n");
1034 if (!strcmp(res->name, "crc-strip")) {
1035 if (!strcmp(res->value, "on"))
1036 rx_mode.hw_strip_crc = 1;
1037 else if (!strcmp(res->value, "off"))
1038 rx_mode.hw_strip_crc = 0;
1040 printf("Unknown parameter\n");
1043 } else if (!strcmp(res->name, "rx-cksum")) {
1044 if (!strcmp(res->value, "on"))
1045 rx_mode.hw_ip_checksum = 1;
1046 else if (!strcmp(res->value, "off"))
1047 rx_mode.hw_ip_checksum = 0;
1049 printf("Unknown parameter\n");
1052 } else if (!strcmp(res->name, "hw-vlan")) {
1053 if (!strcmp(res->value, "on")) {
1054 rx_mode.hw_vlan_filter = 1;
1055 rx_mode.hw_vlan_strip = 1;
1057 else if (!strcmp(res->value, "off")) {
1058 rx_mode.hw_vlan_filter = 0;
1059 rx_mode.hw_vlan_strip = 0;
1062 printf("Unknown parameter\n");
1065 } else if (!strcmp(res->name, "drop-en")) {
1066 if (!strcmp(res->value, "on"))
1068 else if (!strcmp(res->value, "off"))
1071 printf("Unknown parameter\n");
1075 printf("Unknown parameter\n");
1081 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1084 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1085 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1086 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1087 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1089 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1090 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1091 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1092 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1093 "crc-strip#rx-cksum#hw-vlan");
1094 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1095 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1098 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1099 .f = cmd_config_rx_mode_flag_parsed,
1101 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1103 (void *)&cmd_config_rx_mode_flag_port,
1104 (void *)&cmd_config_rx_mode_flag_keyword,
1105 (void *)&cmd_config_rx_mode_flag_all,
1106 (void *)&cmd_config_rx_mode_flag_name,
1107 (void *)&cmd_config_rx_mode_flag_value,
1112 /* *** configure rss *** */
1113 struct cmd_config_rss {
1114 cmdline_fixed_string_t port;
1115 cmdline_fixed_string_t keyword;
1116 cmdline_fixed_string_t all;
1117 cmdline_fixed_string_t name;
1118 cmdline_fixed_string_t value;
1122 cmd_config_rss_parsed(void *parsed_result,
1123 __attribute__((unused)) struct cmdline *cl,
1124 __attribute__((unused)) void *data)
1126 struct cmd_config_rss *res = parsed_result;
1127 struct rte_eth_rss_conf rss_conf;
1130 if (!strcmp(res->value, "ip"))
1131 rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1132 else if (!strcmp(res->value, "udp"))
1133 rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
1134 else if (!strcmp(res->value, "none"))
1135 rss_conf.rss_hf = 0;
1137 printf("Unknown parameter\n");
1140 rss_conf.rss_key = NULL;
1141 for (i = 0; i < rte_eth_dev_count(); i++)
1142 rte_eth_dev_rss_hash_update(i, &rss_conf);
1145 cmdline_parse_token_string_t cmd_config_rss_port =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1147 cmdline_parse_token_string_t cmd_config_rss_keyword =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1149 cmdline_parse_token_string_t cmd_config_rss_all =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1151 cmdline_parse_token_string_t cmd_config_rss_name =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1153 cmdline_parse_token_string_t cmd_config_rss_value =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1156 cmdline_parse_inst_t cmd_config_rss = {
1157 .f = cmd_config_rss_parsed,
1159 .help_str = "port config all rss ip|udp|none",
1161 (void *)&cmd_config_rss_port,
1162 (void *)&cmd_config_rss_keyword,
1163 (void *)&cmd_config_rss_all,
1164 (void *)&cmd_config_rss_name,
1165 (void *)&cmd_config_rss_value,
1170 /* *** Configure RSS RETA *** */
1171 struct cmd_config_rss_reta {
1172 cmdline_fixed_string_t port;
1173 cmdline_fixed_string_t keyword;
1175 cmdline_fixed_string_t name;
1176 cmdline_fixed_string_t list_name;
1177 cmdline_fixed_string_t list_of_items;
1181 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1188 const char *p, *p0 = str;
1195 unsigned long int_fld[_NUM_FLD];
1196 char *str_fld[_NUM_FLD];
1198 while ((p = strchr(p0,'(')) != NULL) {
1200 if((p0 = strchr(p,')')) == NULL)
1204 if(size >= sizeof(s))
1207 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1208 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1210 for (i = 0; i < _NUM_FLD; i++) {
1212 int_fld[i] = strtoul(str_fld[i], &end, 0);
1213 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1217 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1218 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1220 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1221 printf("Invalid RETA hash index=%d",hash_index);
1225 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1226 reta_conf->mask_lo |= (1ULL << hash_index);
1228 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1230 reta_conf->reta[hash_index] = nb_queue;
1237 cmd_set_rss_reta_parsed(void *parsed_result,
1238 __attribute__((unused)) struct cmdline *cl,
1239 __attribute__((unused)) void *data)
1242 struct rte_eth_rss_reta reta_conf;
1243 struct cmd_config_rss_reta *res = parsed_result;
1245 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1246 if (!strcmp(res->list_name, "reta")) {
1247 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1248 printf("Invalid RSS Redirection Table config entered\n");
1251 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1253 printf("Bad redirection table parameter, return code = %d \n",ret);
1257 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1259 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1260 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1261 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1262 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1263 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1265 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1267 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1270 cmdline_parse_inst_t cmd_config_rss_reta = {
1271 .f = cmd_set_rss_reta_parsed,
1273 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1275 (void *)&cmd_config_rss_reta_port,
1276 (void *)&cmd_config_rss_reta_keyword,
1277 (void *)&cmd_config_rss_reta_port_id,
1278 (void *)&cmd_config_rss_reta_name,
1279 (void *)&cmd_config_rss_reta_list_name,
1280 (void *)&cmd_config_rss_reta_list_of_items,
1285 /* *** SHOW PORT RETA INFO *** */
1286 struct cmd_showport_reta {
1287 cmdline_fixed_string_t show;
1288 cmdline_fixed_string_t port;
1290 cmdline_fixed_string_t rss;
1291 cmdline_fixed_string_t reta;
1296 static void cmd_showport_reta_parsed(void *parsed_result,
1297 __attribute__((unused)) struct cmdline *cl,
1298 __attribute__((unused)) void *data)
1300 struct cmd_showport_reta *res = parsed_result;
1301 struct rte_eth_rss_reta reta_conf;
1303 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1304 printf("Invalid RSS Redirection Table config entered\n");
1308 reta_conf.mask_lo = res->mask_lo;
1309 reta_conf.mask_hi = res->mask_hi;
1311 port_rss_reta_info(res->port_id,&reta_conf);
1314 cmdline_parse_token_string_t cmd_showport_reta_show =
1315 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1316 cmdline_parse_token_string_t cmd_showport_reta_port =
1317 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1318 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1319 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1320 cmdline_parse_token_string_t cmd_showport_reta_rss =
1321 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1322 cmdline_parse_token_string_t cmd_showport_reta_reta =
1323 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1324 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1325 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1326 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1327 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1329 cmdline_parse_inst_t cmd_showport_reta = {
1330 .f = cmd_showport_reta_parsed,
1332 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1333 (mask_lo and mask_hi is UINT64)",
1335 (void *)&cmd_showport_reta_show,
1336 (void *)&cmd_showport_reta_port,
1337 (void *)&cmd_showport_reta_port_id,
1338 (void *)&cmd_showport_reta_rss,
1339 (void *)&cmd_showport_reta_reta,
1340 (void *)&cmd_showport_reta_mask_lo,
1341 (void *)&cmd_showport_reta_mask_hi,
1346 /* *** Configure DCB *** */
1347 struct cmd_config_dcb {
1348 cmdline_fixed_string_t port;
1349 cmdline_fixed_string_t config;
1351 cmdline_fixed_string_t dcb;
1352 cmdline_fixed_string_t vt;
1353 cmdline_fixed_string_t vt_en;
1355 cmdline_fixed_string_t pfc;
1356 cmdline_fixed_string_t pfc_en;
1360 cmd_config_dcb_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_dcb *res = parsed_result;
1365 struct dcb_config dcb_conf;
1366 portid_t port_id = res->port_id;
1367 struct rte_port *port;
1369 port = &ports[port_id];
1370 /** Check if the port is not started **/
1371 if (port->port_status != RTE_PORT_STOPPED) {
1372 printf("Please stop port %d first\n",port_id);
1376 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1377 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1378 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1382 /* DCB in VT mode */
1383 if (!strncmp(res->vt_en, "on",2))
1384 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1386 dcb_conf.dcb_mode = DCB_ENABLED;
1388 if (!strncmp(res->pfc_en, "on",2)) {
1389 dcb_conf.pfc_en = 1;
1392 dcb_conf.pfc_en = 0;
1394 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1395 printf("Cannot initialize network ports\n");
1399 cmd_reconfig_device_queue(port_id, 1, 1);
1402 cmdline_parse_token_string_t cmd_config_dcb_port =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1404 cmdline_parse_token_string_t cmd_config_dcb_config =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1406 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1408 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1410 cmdline_parse_token_string_t cmd_config_dcb_vt =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1412 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1414 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1415 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1416 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1418 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1419 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1421 cmdline_parse_inst_t cmd_config_dcb = {
1422 .f = cmd_config_dcb_parsed,
1424 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1426 (void *)&cmd_config_dcb_port,
1427 (void *)&cmd_config_dcb_config,
1428 (void *)&cmd_config_dcb_port_id,
1429 (void *)&cmd_config_dcb_dcb,
1430 (void *)&cmd_config_dcb_vt,
1431 (void *)&cmd_config_dcb_vt_en,
1432 (void *)&cmd_config_dcb_num_tcs,
1433 (void *)&cmd_config_dcb_pfc,
1434 (void *)&cmd_config_dcb_pfc_en,
1439 /* *** configure number of packets per burst *** */
1440 struct cmd_config_burst {
1441 cmdline_fixed_string_t port;
1442 cmdline_fixed_string_t keyword;
1443 cmdline_fixed_string_t all;
1444 cmdline_fixed_string_t name;
1449 cmd_config_burst_parsed(void *parsed_result,
1450 __attribute__((unused)) struct cmdline *cl,
1451 __attribute__((unused)) void *data)
1453 struct cmd_config_burst *res = parsed_result;
1455 if (!all_ports_stopped()) {
1456 printf("Please stop all ports first\n");
1460 if (!strcmp(res->name, "burst")) {
1461 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1462 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1465 nb_pkt_per_burst = res->value;
1467 printf("Unknown parameter\n");
1473 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1476 cmdline_parse_token_string_t cmd_config_burst_port =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1478 cmdline_parse_token_string_t cmd_config_burst_keyword =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1480 cmdline_parse_token_string_t cmd_config_burst_all =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1482 cmdline_parse_token_string_t cmd_config_burst_name =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1484 cmdline_parse_token_num_t cmd_config_burst_value =
1485 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1487 cmdline_parse_inst_t cmd_config_burst = {
1488 .f = cmd_config_burst_parsed,
1490 .help_str = "port config all burst value",
1492 (void *)&cmd_config_burst_port,
1493 (void *)&cmd_config_burst_keyword,
1494 (void *)&cmd_config_burst_all,
1495 (void *)&cmd_config_burst_name,
1496 (void *)&cmd_config_burst_value,
1501 /* *** configure rx/tx queues *** */
1502 struct cmd_config_thresh {
1503 cmdline_fixed_string_t port;
1504 cmdline_fixed_string_t keyword;
1505 cmdline_fixed_string_t all;
1506 cmdline_fixed_string_t name;
1511 cmd_config_thresh_parsed(void *parsed_result,
1512 __attribute__((unused)) struct cmdline *cl,
1513 __attribute__((unused)) void *data)
1515 struct cmd_config_thresh *res = parsed_result;
1517 if (!all_ports_stopped()) {
1518 printf("Please stop all ports first\n");
1522 if (!strcmp(res->name, "txpt"))
1523 tx_thresh.pthresh = res->value;
1524 else if(!strcmp(res->name, "txht"))
1525 tx_thresh.hthresh = res->value;
1526 else if(!strcmp(res->name, "txwt"))
1527 tx_thresh.wthresh = res->value;
1528 else if(!strcmp(res->name, "rxpt"))
1529 rx_thresh.pthresh = res->value;
1530 else if(!strcmp(res->name, "rxht"))
1531 rx_thresh.hthresh = res->value;
1532 else if(!strcmp(res->name, "rxwt"))
1533 rx_thresh.wthresh = res->value;
1535 printf("Unknown parameter\n");
1541 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1544 cmdline_parse_token_string_t cmd_config_thresh_port =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1546 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1548 cmdline_parse_token_string_t cmd_config_thresh_all =
1549 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1550 cmdline_parse_token_string_t cmd_config_thresh_name =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1552 "txpt#txht#txwt#rxpt#rxht#rxwt");
1553 cmdline_parse_token_num_t cmd_config_thresh_value =
1554 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1556 cmdline_parse_inst_t cmd_config_thresh = {
1557 .f = cmd_config_thresh_parsed,
1559 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1561 (void *)&cmd_config_thresh_port,
1562 (void *)&cmd_config_thresh_keyword,
1563 (void *)&cmd_config_thresh_all,
1564 (void *)&cmd_config_thresh_name,
1565 (void *)&cmd_config_thresh_value,
1570 /* *** configure free/rs threshold *** */
1571 struct cmd_config_threshold {
1572 cmdline_fixed_string_t port;
1573 cmdline_fixed_string_t keyword;
1574 cmdline_fixed_string_t all;
1575 cmdline_fixed_string_t name;
1580 cmd_config_threshold_parsed(void *parsed_result,
1581 __attribute__((unused)) struct cmdline *cl,
1582 __attribute__((unused)) void *data)
1584 struct cmd_config_threshold *res = parsed_result;
1586 if (!all_ports_stopped()) {
1587 printf("Please stop all ports first\n");
1591 if (!strcmp(res->name, "txfreet"))
1592 tx_free_thresh = res->value;
1593 else if (!strcmp(res->name, "txrst"))
1594 tx_rs_thresh = res->value;
1595 else if (!strcmp(res->name, "rxfreet"))
1596 rx_free_thresh = res->value;
1598 printf("Unknown parameter\n");
1604 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1607 cmdline_parse_token_string_t cmd_config_threshold_port =
1608 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1609 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1612 cmdline_parse_token_string_t cmd_config_threshold_all =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1614 cmdline_parse_token_string_t cmd_config_threshold_name =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1616 "txfreet#txrst#rxfreet");
1617 cmdline_parse_token_num_t cmd_config_threshold_value =
1618 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1620 cmdline_parse_inst_t cmd_config_threshold = {
1621 .f = cmd_config_threshold_parsed,
1623 .help_str = "port config all txfreet|txrst|rxfreet value",
1625 (void *)&cmd_config_threshold_port,
1626 (void *)&cmd_config_threshold_keyword,
1627 (void *)&cmd_config_threshold_all,
1628 (void *)&cmd_config_threshold_name,
1629 (void *)&cmd_config_threshold_value,
1635 struct cmd_stop_result {
1636 cmdline_fixed_string_t stop;
1639 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1640 __attribute__((unused)) struct cmdline *cl,
1641 __attribute__((unused)) void *data)
1643 stop_packet_forwarding();
1646 cmdline_parse_token_string_t cmd_stop_stop =
1647 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1649 cmdline_parse_inst_t cmd_stop = {
1650 .f = cmd_stop_parsed,
1652 .help_str = "stop - stop packet forwarding",
1654 (void *)&cmd_stop_stop,
1659 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1662 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1663 unsigned int *parsed_items, int check_unique_values)
1665 unsigned int nb_item;
1673 * First parse all items in the list and store their value.
1678 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1680 if ((c >= '0') && (c <= '9')) {
1681 value = (unsigned int) (value * 10 + (c - '0'));
1686 printf("character %c is not a decimal digit\n", c);
1690 printf("No valid value before comma\n");
1693 if (nb_item < max_items) {
1694 parsed_items[nb_item] = value;
1700 if (nb_item >= max_items) {
1701 printf("Number of %s = %u > %u (maximum items)\n",
1702 item_name, nb_item + 1, max_items);
1705 parsed_items[nb_item++] = value;
1706 if (! check_unique_values)
1710 * Then, check that all values in the list are differents.
1711 * No optimization here...
1713 for (i = 0; i < nb_item; i++) {
1714 for (j = i + 1; j < nb_item; j++) {
1715 if (parsed_items[j] == parsed_items[i]) {
1716 printf("duplicated %s %u at index %u and %u\n",
1717 item_name, parsed_items[i], i, j);
1725 struct cmd_set_list_result {
1726 cmdline_fixed_string_t cmd_keyword;
1727 cmdline_fixed_string_t list_name;
1728 cmdline_fixed_string_t list_of_items;
1731 static void cmd_set_list_parsed(void *parsed_result,
1732 __attribute__((unused)) struct cmdline *cl,
1733 __attribute__((unused)) void *data)
1735 struct cmd_set_list_result *res;
1737 unsigned int lcorelist[RTE_MAX_LCORE];
1738 unsigned int portlist[RTE_MAX_ETHPORTS];
1740 unsigned int nb_item;
1742 res = parsed_result;
1743 if (!strcmp(res->list_name, "corelist")) {
1744 nb_item = parse_item_list(res->list_of_items, "core",
1746 parsed_items.lcorelist, 1);
1748 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1751 if (!strcmp(res->list_name, "portlist")) {
1752 nb_item = parse_item_list(res->list_of_items, "port",
1754 parsed_items.portlist, 1);
1756 set_fwd_ports_list(parsed_items.portlist, nb_item);
1760 cmdline_parse_token_string_t cmd_set_list_keyword =
1761 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1763 cmdline_parse_token_string_t cmd_set_list_name =
1764 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1765 "corelist#portlist");
1766 cmdline_parse_token_string_t cmd_set_list_of_items =
1767 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1770 cmdline_parse_inst_t cmd_set_fwd_list = {
1771 .f = cmd_set_list_parsed,
1773 .help_str = "set corelist|portlist x[,y]*",
1775 (void *)&cmd_set_list_keyword,
1776 (void *)&cmd_set_list_name,
1777 (void *)&cmd_set_list_of_items,
1782 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1784 struct cmd_setmask_result {
1785 cmdline_fixed_string_t set;
1786 cmdline_fixed_string_t mask;
1790 static void cmd_set_mask_parsed(void *parsed_result,
1791 __attribute__((unused)) struct cmdline *cl,
1792 __attribute__((unused)) void *data)
1794 struct cmd_setmask_result *res = parsed_result;
1796 if (!strcmp(res->mask, "coremask"))
1797 set_fwd_lcores_mask(res->hexavalue);
1798 else if (!strcmp(res->mask, "portmask"))
1799 set_fwd_ports_mask(res->hexavalue);
1802 cmdline_parse_token_string_t cmd_setmask_set =
1803 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1804 cmdline_parse_token_string_t cmd_setmask_mask =
1805 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1806 "coremask#portmask");
1807 cmdline_parse_token_num_t cmd_setmask_value =
1808 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1810 cmdline_parse_inst_t cmd_set_fwd_mask = {
1811 .f = cmd_set_mask_parsed,
1813 .help_str = "set coremask|portmask hexadecimal value",
1815 (void *)&cmd_setmask_set,
1816 (void *)&cmd_setmask_mask,
1817 (void *)&cmd_setmask_value,
1823 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1825 struct cmd_set_result {
1826 cmdline_fixed_string_t set;
1827 cmdline_fixed_string_t what;
1831 static void cmd_set_parsed(void *parsed_result,
1832 __attribute__((unused)) struct cmdline *cl,
1833 __attribute__((unused)) void *data)
1835 struct cmd_set_result *res = parsed_result;
1836 if (!strcmp(res->what, "nbport"))
1837 set_fwd_ports_number(res->value);
1838 else if (!strcmp(res->what, "nbcore"))
1839 set_fwd_lcores_number(res->value);
1840 else if (!strcmp(res->what, "burst"))
1841 set_nb_pkt_per_burst(res->value);
1842 else if (!strcmp(res->what, "verbose"))
1843 set_verbose_level(res->value);
1846 cmdline_parse_token_string_t cmd_set_set =
1847 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1848 cmdline_parse_token_string_t cmd_set_what =
1849 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1850 "nbport#nbcore#burst#verbose");
1851 cmdline_parse_token_num_t cmd_set_value =
1852 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1854 cmdline_parse_inst_t cmd_set_numbers = {
1855 .f = cmd_set_parsed,
1857 .help_str = "set nbport|nbcore|burst|verbose value",
1859 (void *)&cmd_set_set,
1860 (void *)&cmd_set_what,
1861 (void *)&cmd_set_value,
1866 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1868 struct cmd_set_txpkts_result {
1869 cmdline_fixed_string_t cmd_keyword;
1870 cmdline_fixed_string_t txpkts;
1871 cmdline_fixed_string_t seg_lengths;
1875 cmd_set_txpkts_parsed(void *parsed_result,
1876 __attribute__((unused)) struct cmdline *cl,
1877 __attribute__((unused)) void *data)
1879 struct cmd_set_txpkts_result *res;
1880 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1881 unsigned int nb_segs;
1883 res = parsed_result;
1884 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1885 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1887 set_tx_pkt_segments(seg_lengths, nb_segs);
1890 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1892 cmd_keyword, "set");
1893 cmdline_parse_token_string_t cmd_set_txpkts_name =
1894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1896 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1897 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1900 cmdline_parse_inst_t cmd_set_txpkts = {
1901 .f = cmd_set_txpkts_parsed,
1903 .help_str = "set txpkts x[,y]*",
1905 (void *)&cmd_set_txpkts_keyword,
1906 (void *)&cmd_set_txpkts_name,
1907 (void *)&cmd_set_txpkts_lengths,
1912 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1913 struct cmd_rx_vlan_filter_all_result {
1914 cmdline_fixed_string_t rx_vlan;
1915 cmdline_fixed_string_t what;
1916 cmdline_fixed_string_t all;
1921 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1922 __attribute__((unused)) struct cmdline *cl,
1923 __attribute__((unused)) void *data)
1925 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1927 if (!strcmp(res->what, "add"))
1928 rx_vlan_all_filter_set(res->port_id, 1);
1930 rx_vlan_all_filter_set(res->port_id, 0);
1933 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1934 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1935 rx_vlan, "rx_vlan");
1936 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1937 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1939 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1940 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1942 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1943 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1946 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1947 .f = cmd_rx_vlan_filter_all_parsed,
1949 .help_str = "add/remove all identifiers to/from the set of VLAN "
1950 "Identifiers filtered by a port",
1952 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1953 (void *)&cmd_rx_vlan_filter_all_what,
1954 (void *)&cmd_rx_vlan_filter_all_all,
1955 (void *)&cmd_rx_vlan_filter_all_portid,
1960 /* *** VLAN OFFLOAD SET ON A PORT *** */
1961 struct cmd_vlan_offload_result {
1962 cmdline_fixed_string_t vlan;
1963 cmdline_fixed_string_t set;
1964 cmdline_fixed_string_t what;
1965 cmdline_fixed_string_t on;
1966 cmdline_fixed_string_t port_id;
1970 cmd_vlan_offload_parsed(void *parsed_result,
1971 __attribute__((unused)) struct cmdline *cl,
1972 __attribute__((unused)) void *data)
1975 struct cmd_vlan_offload_result *res = parsed_result;
1978 portid_t port_id = 0;
1982 len = strnlen(str, STR_TOKEN_SIZE);
1984 /* Get port_id first */
1992 tmp = strtoul(str, NULL, 0);
1993 /* If port_id greater that what portid_t can represent, return */
1994 if(tmp >= RTE_MAX_ETHPORTS)
1996 port_id = (portid_t)tmp;
1998 if (!strcmp(res->on, "on"))
2003 if (!strcmp(res->what, "strip"))
2004 rx_vlan_strip_set(port_id, on);
2005 else if(!strcmp(res->what, "stripq")){
2006 uint16_t queue_id = 0;
2008 /* No queue_id, return */
2010 printf("must specify (port,queue_id)\n");
2013 tmp = strtoul(str + i + 1, NULL, 0);
2014 /* If queue_id greater that what 16-bits can represent, return */
2018 queue_id = (uint16_t)tmp;
2019 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2021 else if (!strcmp(res->what, "filter"))
2022 rx_vlan_filter_set(port_id, on);
2024 vlan_extend_set(port_id, on);
2029 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2030 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2032 cmdline_parse_token_string_t cmd_vlan_offload_set =
2033 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2035 cmdline_parse_token_string_t cmd_vlan_offload_what =
2036 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2037 what, "strip#filter#qinq#stripq");
2038 cmdline_parse_token_string_t cmd_vlan_offload_on =
2039 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2041 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2045 cmdline_parse_inst_t cmd_vlan_offload = {
2046 .f = cmd_vlan_offload_parsed,
2048 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2049 " qinq(extended) for both rx/tx sides ",
2051 (void *)&cmd_vlan_offload_vlan,
2052 (void *)&cmd_vlan_offload_set,
2053 (void *)&cmd_vlan_offload_what,
2054 (void *)&cmd_vlan_offload_on,
2055 (void *)&cmd_vlan_offload_portid,
2060 /* *** VLAN TPID SET ON A PORT *** */
2061 struct cmd_vlan_tpid_result {
2062 cmdline_fixed_string_t vlan;
2063 cmdline_fixed_string_t set;
2064 cmdline_fixed_string_t what;
2070 cmd_vlan_tpid_parsed(void *parsed_result,
2071 __attribute__((unused)) struct cmdline *cl,
2072 __attribute__((unused)) void *data)
2074 struct cmd_vlan_tpid_result *res = parsed_result;
2075 vlan_tpid_set(res->port_id, res->tp_id);
2079 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2080 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2082 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2083 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2085 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2086 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2088 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2089 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2091 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2092 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2095 cmdline_parse_inst_t cmd_vlan_tpid = {
2096 .f = cmd_vlan_tpid_parsed,
2098 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2100 (void *)&cmd_vlan_tpid_vlan,
2101 (void *)&cmd_vlan_tpid_set,
2102 (void *)&cmd_vlan_tpid_what,
2103 (void *)&cmd_vlan_tpid_tpid,
2104 (void *)&cmd_vlan_tpid_portid,
2109 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2110 struct cmd_rx_vlan_filter_result {
2111 cmdline_fixed_string_t rx_vlan;
2112 cmdline_fixed_string_t what;
2118 cmd_rx_vlan_filter_parsed(void *parsed_result,
2119 __attribute__((unused)) struct cmdline *cl,
2120 __attribute__((unused)) void *data)
2122 struct cmd_rx_vlan_filter_result *res = parsed_result;
2124 if (!strcmp(res->what, "add"))
2125 rx_vft_set(res->port_id, res->vlan_id, 1);
2127 rx_vft_set(res->port_id, res->vlan_id, 0);
2130 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2131 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2132 rx_vlan, "rx_vlan");
2133 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2136 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2137 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2139 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2140 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2143 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2144 .f = cmd_rx_vlan_filter_parsed,
2146 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2147 "Identifiers filtered by a port",
2149 (void *)&cmd_rx_vlan_filter_rx_vlan,
2150 (void *)&cmd_rx_vlan_filter_what,
2151 (void *)&cmd_rx_vlan_filter_vlanid,
2152 (void *)&cmd_rx_vlan_filter_portid,
2157 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2158 struct cmd_tx_vlan_set_result {
2159 cmdline_fixed_string_t tx_vlan;
2160 cmdline_fixed_string_t set;
2166 cmd_tx_vlan_set_parsed(void *parsed_result,
2167 __attribute__((unused)) struct cmdline *cl,
2168 __attribute__((unused)) void *data)
2170 struct cmd_tx_vlan_set_result *res = parsed_result;
2171 tx_vlan_set(res->port_id, res->vlan_id);
2174 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2175 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2176 tx_vlan, "tx_vlan");
2177 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2178 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2180 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2181 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2183 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2184 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2187 cmdline_parse_inst_t cmd_tx_vlan_set = {
2188 .f = cmd_tx_vlan_set_parsed,
2190 .help_str = "enable hardware insertion of a VLAN header with a given "
2191 "TAG Identifier in packets sent on a port",
2193 (void *)&cmd_tx_vlan_set_tx_vlan,
2194 (void *)&cmd_tx_vlan_set_set,
2195 (void *)&cmd_tx_vlan_set_vlanid,
2196 (void *)&cmd_tx_vlan_set_portid,
2201 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2202 struct cmd_tx_vlan_reset_result {
2203 cmdline_fixed_string_t tx_vlan;
2204 cmdline_fixed_string_t reset;
2209 cmd_tx_vlan_reset_parsed(void *parsed_result,
2210 __attribute__((unused)) struct cmdline *cl,
2211 __attribute__((unused)) void *data)
2213 struct cmd_tx_vlan_reset_result *res = parsed_result;
2215 tx_vlan_reset(res->port_id);
2218 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2219 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2220 tx_vlan, "tx_vlan");
2221 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2222 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2224 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2225 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2228 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2229 .f = cmd_tx_vlan_reset_parsed,
2231 .help_str = "disable hardware insertion of a VLAN header in packets "
2234 (void *)&cmd_tx_vlan_reset_tx_vlan,
2235 (void *)&cmd_tx_vlan_reset_reset,
2236 (void *)&cmd_tx_vlan_reset_portid,
2242 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2243 struct cmd_tx_cksum_set_result {
2244 cmdline_fixed_string_t tx_cksum;
2245 cmdline_fixed_string_t set;
2251 cmd_tx_cksum_set_parsed(void *parsed_result,
2252 __attribute__((unused)) struct cmdline *cl,
2253 __attribute__((unused)) void *data)
2255 struct cmd_tx_cksum_set_result *res = parsed_result;
2257 tx_cksum_set(res->port_id, res->cksum_mask);
2260 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2261 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2262 tx_cksum, "tx_checksum");
2263 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2264 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2266 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2267 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2269 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2270 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2273 cmdline_parse_inst_t cmd_tx_cksum_set = {
2274 .f = cmd_tx_cksum_set_parsed,
2276 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2277 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2278 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2280 (void *)&cmd_tx_cksum_set_tx_cksum,
2281 (void *)&cmd_tx_cksum_set_set,
2282 (void *)&cmd_tx_cksum_set_cksum_mask,
2283 (void *)&cmd_tx_cksum_set_portid,
2288 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2289 struct cmd_set_flush_rx {
2290 cmdline_fixed_string_t set;
2291 cmdline_fixed_string_t flush_rx;
2292 cmdline_fixed_string_t mode;
2296 cmd_set_flush_rx_parsed(void *parsed_result,
2297 __attribute__((unused)) struct cmdline *cl,
2298 __attribute__((unused)) void *data)
2300 struct cmd_set_flush_rx *res = parsed_result;
2301 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2304 cmdline_parse_token_string_t cmd_setflushrx_set =
2305 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2307 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2308 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2309 flush_rx, "flush_rx");
2310 cmdline_parse_token_string_t cmd_setflushrx_mode =
2311 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2315 cmdline_parse_inst_t cmd_set_flush_rx = {
2316 .f = cmd_set_flush_rx_parsed,
2317 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2320 (void *)&cmd_setflushrx_set,
2321 (void *)&cmd_setflushrx_flush_rx,
2322 (void *)&cmd_setflushrx_mode,
2327 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2328 struct cmd_set_link_check {
2329 cmdline_fixed_string_t set;
2330 cmdline_fixed_string_t link_check;
2331 cmdline_fixed_string_t mode;
2335 cmd_set_link_check_parsed(void *parsed_result,
2336 __attribute__((unused)) struct cmdline *cl,
2337 __attribute__((unused)) void *data)
2339 struct cmd_set_link_check *res = parsed_result;
2340 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2343 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2344 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2346 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2347 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2348 link_check, "link_check");
2349 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2350 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2354 cmdline_parse_inst_t cmd_set_link_check = {
2355 .f = cmd_set_link_check_parsed,
2356 .help_str = "set link_check on|off: enable/disable link status check "
2357 "when starting/stopping a port",
2360 (void *)&cmd_setlinkcheck_set,
2361 (void *)&cmd_setlinkcheck_link_check,
2362 (void *)&cmd_setlinkcheck_mode,
2367 #ifdef RTE_NIC_BYPASS
2368 /* *** SET NIC BYPASS MODE *** */
2369 struct cmd_set_bypass_mode_result {
2370 cmdline_fixed_string_t set;
2371 cmdline_fixed_string_t bypass;
2372 cmdline_fixed_string_t mode;
2373 cmdline_fixed_string_t value;
2378 cmd_set_bypass_mode_parsed(void *parsed_result,
2379 __attribute__((unused)) struct cmdline *cl,
2380 __attribute__((unused)) void *data)
2382 struct cmd_set_bypass_mode_result *res = parsed_result;
2383 portid_t port_id = res->port_id;
2384 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2386 if (!bypass_is_supported(port_id))
2389 if (!strcmp(res->value, "bypass"))
2390 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2391 else if (!strcmp(res->value, "isolate"))
2392 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2394 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2396 /* Set the bypass mode for the relevant port. */
2397 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2398 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2402 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2403 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2405 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2406 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2408 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2409 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2411 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2412 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2413 value, "normal#bypass#isolate");
2414 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2415 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2418 cmdline_parse_inst_t cmd_set_bypass_mode = {
2419 .f = cmd_set_bypass_mode_parsed,
2420 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2421 "Set the NIC bypass mode for port_id",
2424 (void *)&cmd_setbypass_mode_set,
2425 (void *)&cmd_setbypass_mode_bypass,
2426 (void *)&cmd_setbypass_mode_mode,
2427 (void *)&cmd_setbypass_mode_value,
2428 (void *)&cmd_setbypass_mode_port,
2433 /* *** SET NIC BYPASS EVENT *** */
2434 struct cmd_set_bypass_event_result {
2435 cmdline_fixed_string_t set;
2436 cmdline_fixed_string_t bypass;
2437 cmdline_fixed_string_t event;
2438 cmdline_fixed_string_t event_value;
2439 cmdline_fixed_string_t mode;
2440 cmdline_fixed_string_t mode_value;
2445 cmd_set_bypass_event_parsed(void *parsed_result,
2446 __attribute__((unused)) struct cmdline *cl,
2447 __attribute__((unused)) void *data)
2450 struct cmd_set_bypass_event_result *res = parsed_result;
2451 portid_t port_id = res->port_id;
2452 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2453 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2455 if (!bypass_is_supported(port_id))
2458 if (!strcmp(res->event_value, "timeout"))
2459 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2460 else if (!strcmp(res->event_value, "os_on"))
2461 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2462 else if (!strcmp(res->event_value, "os_off"))
2463 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2464 else if (!strcmp(res->event_value, "power_on"))
2465 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2466 else if (!strcmp(res->event_value, "power_off"))
2467 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2469 bypass_event = RTE_BYPASS_EVENT_NONE;
2471 if (!strcmp(res->mode_value, "bypass"))
2472 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2473 else if (!strcmp(res->mode_value, "isolate"))
2474 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2476 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2478 /* Set the watchdog timeout. */
2479 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2482 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2483 (rc = rte_eth_dev_wd_timeout_store(port_id,
2484 bypass_timeout)) != 0) {
2485 printf("Failed to set timeout value %u "
2486 "for port %d, errto code: %d.\n",
2487 bypass_timeout, port_id, rc);
2491 /* Set the bypass event to transition to bypass mode. */
2492 if (0 != rte_eth_dev_bypass_event_store(port_id,
2493 bypass_event, bypass_mode)) {
2494 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2499 cmdline_parse_token_string_t cmd_setbypass_event_set =
2500 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2502 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2503 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2505 cmdline_parse_token_string_t cmd_setbypass_event_event =
2506 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2508 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2509 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2510 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2511 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2512 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2514 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2516 mode_value, "normal#bypass#isolate");
2517 cmdline_parse_token_num_t cmd_setbypass_event_port =
2518 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2521 cmdline_parse_inst_t cmd_set_bypass_event = {
2522 .f = cmd_set_bypass_event_parsed,
2523 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2524 "mode (normal|bypass|isolate) (port_id): "
2525 "Set the NIC bypass event mode for port_id",
2528 (void *)&cmd_setbypass_event_set,
2529 (void *)&cmd_setbypass_event_bypass,
2530 (void *)&cmd_setbypass_event_event,
2531 (void *)&cmd_setbypass_event_event_value,
2532 (void *)&cmd_setbypass_event_mode,
2533 (void *)&cmd_setbypass_event_mode_value,
2534 (void *)&cmd_setbypass_event_port,
2540 /* *** SET NIC BYPASS TIMEOUT *** */
2541 struct cmd_set_bypass_timeout_result {
2542 cmdline_fixed_string_t set;
2543 cmdline_fixed_string_t bypass;
2544 cmdline_fixed_string_t timeout;
2545 cmdline_fixed_string_t value;
2549 cmd_set_bypass_timeout_parsed(void *parsed_result,
2550 __attribute__((unused)) struct cmdline *cl,
2551 __attribute__((unused)) void *data)
2553 struct cmd_set_bypass_timeout_result *res = parsed_result;
2555 if (!strcmp(res->value, "1.5"))
2556 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2557 else if (!strcmp(res->value, "2"))
2558 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2559 else if (!strcmp(res->value, "3"))
2560 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2561 else if (!strcmp(res->value, "4"))
2562 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2563 else if (!strcmp(res->value, "8"))
2564 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2565 else if (!strcmp(res->value, "16"))
2566 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2567 else if (!strcmp(res->value, "32"))
2568 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2570 bypass_timeout = RTE_BYPASS_TMT_OFF;
2573 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2576 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2577 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2579 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2580 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2581 timeout, "timeout");
2582 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2583 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2584 value, "0#1.5#2#3#4#8#16#32");
2586 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2587 .f = cmd_set_bypass_timeout_parsed,
2588 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2589 "Set the NIC bypass watchdog timeout",
2592 (void *)&cmd_setbypass_timeout_set,
2593 (void *)&cmd_setbypass_timeout_bypass,
2594 (void *)&cmd_setbypass_timeout_timeout,
2595 (void *)&cmd_setbypass_timeout_value,
2600 /* *** SHOW NIC BYPASS MODE *** */
2601 struct cmd_show_bypass_config_result {
2602 cmdline_fixed_string_t show;
2603 cmdline_fixed_string_t bypass;
2604 cmdline_fixed_string_t config;
2609 cmd_show_bypass_config_parsed(void *parsed_result,
2610 __attribute__((unused)) struct cmdline *cl,
2611 __attribute__((unused)) void *data)
2613 struct cmd_show_bypass_config_result *res = parsed_result;
2614 uint32_t event_mode;
2615 uint32_t bypass_mode;
2616 portid_t port_id = res->port_id;
2617 uint32_t timeout = bypass_timeout;
2620 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2621 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2622 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2623 {"UNKNOWN", "normal", "bypass", "isolate"};
2624 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2631 int num_events = (sizeof events) / (sizeof events[0]);
2633 if (!bypass_is_supported(port_id))
2636 /* Display the bypass mode.*/
2637 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2638 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2642 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2643 bypass_mode = RTE_BYPASS_MODE_NONE;
2645 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2648 /* Display the bypass timeout.*/
2649 if (!RTE_BYPASS_TMT_VALID(timeout))
2650 timeout = RTE_BYPASS_TMT_OFF;
2652 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2654 /* Display the bypass events and associated modes. */
2655 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2657 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2658 printf("\tFailed to get bypass mode for event = %s\n",
2661 if (!RTE_BYPASS_MODE_VALID(event_mode))
2662 event_mode = RTE_BYPASS_MODE_NONE;
2664 printf("\tbypass event: %-16s = %s\n", events[i],
2670 cmdline_parse_token_string_t cmd_showbypass_config_show =
2671 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2673 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2674 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2676 cmdline_parse_token_string_t cmd_showbypass_config_config =
2677 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2679 cmdline_parse_token_num_t cmd_showbypass_config_port =
2680 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2683 cmdline_parse_inst_t cmd_show_bypass_config = {
2684 .f = cmd_show_bypass_config_parsed,
2685 .help_str = "show bypass config (port_id): "
2686 "Show the NIC bypass config for port_id",
2689 (void *)&cmd_showbypass_config_show,
2690 (void *)&cmd_showbypass_config_bypass,
2691 (void *)&cmd_showbypass_config_config,
2692 (void *)&cmd_showbypass_config_port,
2698 /* *** SET FORWARDING MODE *** */
2699 struct cmd_set_fwd_mode_result {
2700 cmdline_fixed_string_t set;
2701 cmdline_fixed_string_t fwd;
2702 cmdline_fixed_string_t mode;
2705 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2706 __attribute__((unused)) struct cmdline *cl,
2707 __attribute__((unused)) void *data)
2709 struct cmd_set_fwd_mode_result *res = parsed_result;
2711 set_pkt_forwarding_mode(res->mode);
2714 cmdline_parse_token_string_t cmd_setfwd_set =
2715 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2716 cmdline_parse_token_string_t cmd_setfwd_fwd =
2717 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2718 cmdline_parse_token_string_t cmd_setfwd_mode =
2719 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2720 "" /* defined at init */);
2722 cmdline_parse_inst_t cmd_set_fwd_mode = {
2723 .f = cmd_set_fwd_mode_parsed,
2725 .help_str = NULL, /* defined at init */
2727 (void *)&cmd_setfwd_set,
2728 (void *)&cmd_setfwd_fwd,
2729 (void *)&cmd_setfwd_mode,
2734 static void cmd_set_fwd_mode_init(void)
2737 static char token[128];
2738 static char help[256];
2739 cmdline_parse_token_string_t *token_struct;
2741 modes = list_pkt_forwarding_modes();
2742 rte_snprintf(help, sizeof help, "set fwd %s - "
2743 "set packet forwarding mode", modes);
2744 cmd_set_fwd_mode.help_str = help;
2746 /* string token separator is # */
2747 for (c = token; *modes != '\0'; modes++)
2752 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2753 token_struct->string_data.str = token;
2756 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2757 struct cmd_set_burst_tx_retry_result {
2758 cmdline_fixed_string_t set;
2759 cmdline_fixed_string_t burst;
2760 cmdline_fixed_string_t tx;
2761 cmdline_fixed_string_t delay;
2763 cmdline_fixed_string_t retry;
2767 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2768 __attribute__((unused)) struct cmdline *cl,
2769 __attribute__((unused)) void *data)
2771 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2773 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2774 && !strcmp(res->tx, "tx")) {
2775 if (!strcmp(res->delay, "delay"))
2776 burst_tx_delay_time = res->time;
2777 if (!strcmp(res->retry, "retry"))
2778 burst_tx_retry_num = res->retry_num;
2783 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2784 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2785 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2786 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2788 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2789 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2790 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2791 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2792 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2793 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2794 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2796 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2797 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2799 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2800 .f = cmd_set_burst_tx_retry_parsed,
2801 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2803 (void *)&cmd_set_burst_tx_retry_set,
2804 (void *)&cmd_set_burst_tx_retry_burst,
2805 (void *)&cmd_set_burst_tx_retry_tx,
2806 (void *)&cmd_set_burst_tx_retry_delay,
2807 (void *)&cmd_set_burst_tx_retry_time,
2808 (void *)&cmd_set_burst_tx_retry_retry,
2809 (void *)&cmd_set_burst_tx_retry_retry_num,
2814 /* *** SET PROMISC MODE *** */
2815 struct cmd_set_promisc_mode_result {
2816 cmdline_fixed_string_t set;
2817 cmdline_fixed_string_t promisc;
2818 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2819 uint8_t port_num; /* valid if "allports" argument == 0 */
2820 cmdline_fixed_string_t mode;
2823 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2824 __attribute__((unused)) struct cmdline *cl,
2827 struct cmd_set_promisc_mode_result *res = parsed_result;
2831 if (!strcmp(res->mode, "on"))
2838 for (i = 0; i < nb_ports; i++) {
2840 rte_eth_promiscuous_enable(i);
2842 rte_eth_promiscuous_disable(i);
2847 rte_eth_promiscuous_enable(res->port_num);
2849 rte_eth_promiscuous_disable(res->port_num);
2853 cmdline_parse_token_string_t cmd_setpromisc_set =
2854 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2855 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2856 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2858 cmdline_parse_token_string_t cmd_setpromisc_portall =
2859 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2861 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2862 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2864 cmdline_parse_token_string_t cmd_setpromisc_mode =
2865 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2868 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2869 .f = cmd_set_promisc_mode_parsed,
2871 .help_str = "set promisc all on|off: set promisc mode for all ports",
2873 (void *)&cmd_setpromisc_set,
2874 (void *)&cmd_setpromisc_promisc,
2875 (void *)&cmd_setpromisc_portall,
2876 (void *)&cmd_setpromisc_mode,
2881 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2882 .f = cmd_set_promisc_mode_parsed,
2884 .help_str = "set promisc X on|off: set promisc mode on port X",
2886 (void *)&cmd_setpromisc_set,
2887 (void *)&cmd_setpromisc_promisc,
2888 (void *)&cmd_setpromisc_portnum,
2889 (void *)&cmd_setpromisc_mode,
2894 /* *** SET ALLMULTI MODE *** */
2895 struct cmd_set_allmulti_mode_result {
2896 cmdline_fixed_string_t set;
2897 cmdline_fixed_string_t allmulti;
2898 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2899 uint8_t port_num; /* valid if "allports" argument == 0 */
2900 cmdline_fixed_string_t mode;
2903 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2904 __attribute__((unused)) struct cmdline *cl,
2907 struct cmd_set_allmulti_mode_result *res = parsed_result;
2911 if (!strcmp(res->mode, "on"))
2918 for (i = 0; i < nb_ports; i++) {
2920 rte_eth_allmulticast_enable(i);
2922 rte_eth_allmulticast_disable(i);
2927 rte_eth_allmulticast_enable(res->port_num);
2929 rte_eth_allmulticast_disable(res->port_num);
2933 cmdline_parse_token_string_t cmd_setallmulti_set =
2934 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2935 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2936 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2938 cmdline_parse_token_string_t cmd_setallmulti_portall =
2939 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2941 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2942 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2944 cmdline_parse_token_string_t cmd_setallmulti_mode =
2945 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2948 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2949 .f = cmd_set_allmulti_mode_parsed,
2951 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2953 (void *)&cmd_setallmulti_set,
2954 (void *)&cmd_setallmulti_allmulti,
2955 (void *)&cmd_setallmulti_portall,
2956 (void *)&cmd_setallmulti_mode,
2961 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2962 .f = cmd_set_allmulti_mode_parsed,
2964 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2966 (void *)&cmd_setallmulti_set,
2967 (void *)&cmd_setallmulti_allmulti,
2968 (void *)&cmd_setallmulti_portnum,
2969 (void *)&cmd_setallmulti_mode,
2974 /* *** ADD/REMOVE A PKT FILTER *** */
2975 struct cmd_pkt_filter_result {
2976 cmdline_fixed_string_t pkt_filter;
2978 cmdline_fixed_string_t protocol;
2979 cmdline_fixed_string_t src;
2980 cmdline_ipaddr_t ip_src;
2982 cmdline_fixed_string_t dst;
2983 cmdline_ipaddr_t ip_dst;
2985 cmdline_fixed_string_t flexbytes;
2986 uint16_t flexbytes_value;
2987 cmdline_fixed_string_t vlan;
2989 cmdline_fixed_string_t queue;
2991 cmdline_fixed_string_t soft;
2996 cmd_pkt_filter_parsed(void *parsed_result,
2997 __attribute__((unused)) struct cmdline *cl,
2998 __attribute__((unused)) void *data)
3000 struct rte_fdir_filter fdir_filter;
3001 struct cmd_pkt_filter_result *res = parsed_result;
3003 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3005 if (res->ip_src.family == AF_INET)
3006 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3008 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3009 &(res->ip_src.addr.ipv6),
3010 sizeof(struct in6_addr));
3012 if (res->ip_dst.family == AF_INET)
3013 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3015 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3016 &(res->ip_dst.addr.ipv6),
3017 sizeof(struct in6_addr));
3019 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3020 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3022 if (!strcmp(res->protocol, "udp"))
3023 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3024 else if (!strcmp(res->protocol, "tcp"))
3025 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3026 else if (!strcmp(res->protocol, "sctp"))
3027 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3028 else /* default only IP */
3029 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3031 if (res->ip_dst.family == AF_INET6)
3032 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3034 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3036 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3037 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3039 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3040 fdir_add_signature_filter(res->port_id, res->queue_id,
3042 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3043 fdir_update_signature_filter(res->port_id, res->queue_id,
3045 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3046 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3047 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3048 fdir_add_perfect_filter(res->port_id, res->soft_id,
3050 (uint8_t) (res->queue_id < 0),
3052 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3053 fdir_update_perfect_filter(res->port_id, res->soft_id,
3055 (uint8_t) (res->queue_id < 0),
3057 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3058 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3064 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3065 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3067 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3068 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3069 protocol, "ip#tcp#udp#sctp");
3070 cmdline_parse_token_string_t cmd_pkt_filter_src =
3071 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3073 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3074 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3076 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3077 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3079 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3080 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3082 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3083 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3085 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3086 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3088 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3089 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3090 flexbytes, "flexbytes");
3091 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3092 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3093 flexbytes_value, UINT16);
3094 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3095 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3097 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3098 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3100 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3101 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3103 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3104 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3106 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3107 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3109 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3110 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3114 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3115 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3116 pkt_filter, "add_signature_filter");
3117 cmdline_parse_inst_t cmd_add_signature_filter = {
3118 .f = cmd_pkt_filter_parsed,
3120 .help_str = "add a signature filter",
3122 (void *)&cmd_pkt_filter_add_signature_filter,
3123 (void *)&cmd_pkt_filter_port_id,
3124 (void *)&cmd_pkt_filter_protocol,
3125 (void *)&cmd_pkt_filter_src,
3126 (void *)&cmd_pkt_filter_ip_src,
3127 (void *)&cmd_pkt_filter_port_src,
3128 (void *)&cmd_pkt_filter_dst,
3129 (void *)&cmd_pkt_filter_ip_dst,
3130 (void *)&cmd_pkt_filter_port_dst,
3131 (void *)&cmd_pkt_filter_flexbytes,
3132 (void *)&cmd_pkt_filter_flexbytes_value,
3133 (void *)&cmd_pkt_filter_vlan,
3134 (void *)&cmd_pkt_filter_vlan_id,
3135 (void *)&cmd_pkt_filter_queue,
3136 (void *)&cmd_pkt_filter_queue_id,
3142 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3143 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3144 pkt_filter, "upd_signature_filter");
3145 cmdline_parse_inst_t cmd_upd_signature_filter = {
3146 .f = cmd_pkt_filter_parsed,
3148 .help_str = "update a signature filter",
3150 (void *)&cmd_pkt_filter_upd_signature_filter,
3151 (void *)&cmd_pkt_filter_port_id,
3152 (void *)&cmd_pkt_filter_protocol,
3153 (void *)&cmd_pkt_filter_src,
3154 (void *)&cmd_pkt_filter_ip_src,
3155 (void *)&cmd_pkt_filter_port_src,
3156 (void *)&cmd_pkt_filter_dst,
3157 (void *)&cmd_pkt_filter_ip_dst,
3158 (void *)&cmd_pkt_filter_port_dst,
3159 (void *)&cmd_pkt_filter_flexbytes,
3160 (void *)&cmd_pkt_filter_flexbytes_value,
3161 (void *)&cmd_pkt_filter_vlan,
3162 (void *)&cmd_pkt_filter_vlan_id,
3163 (void *)&cmd_pkt_filter_queue,
3164 (void *)&cmd_pkt_filter_queue_id,
3170 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3171 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3172 pkt_filter, "rm_signature_filter");
3173 cmdline_parse_inst_t cmd_rm_signature_filter = {
3174 .f = cmd_pkt_filter_parsed,
3176 .help_str = "remove a signature filter",
3178 (void *)&cmd_pkt_filter_rm_signature_filter,
3179 (void *)&cmd_pkt_filter_port_id,
3180 (void *)&cmd_pkt_filter_protocol,
3181 (void *)&cmd_pkt_filter_src,
3182 (void *)&cmd_pkt_filter_ip_src,
3183 (void *)&cmd_pkt_filter_port_src,
3184 (void *)&cmd_pkt_filter_dst,
3185 (void *)&cmd_pkt_filter_ip_dst,
3186 (void *)&cmd_pkt_filter_port_dst,
3187 (void *)&cmd_pkt_filter_flexbytes,
3188 (void *)&cmd_pkt_filter_flexbytes_value,
3189 (void *)&cmd_pkt_filter_vlan,
3190 (void *)&cmd_pkt_filter_vlan_id,
3196 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3197 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3198 pkt_filter, "add_perfect_filter");
3199 cmdline_parse_inst_t cmd_add_perfect_filter = {
3200 .f = cmd_pkt_filter_parsed,
3202 .help_str = "add a perfect filter",
3204 (void *)&cmd_pkt_filter_add_perfect_filter,
3205 (void *)&cmd_pkt_filter_port_id,
3206 (void *)&cmd_pkt_filter_protocol,
3207 (void *)&cmd_pkt_filter_src,
3208 (void *)&cmd_pkt_filter_ip_src,
3209 (void *)&cmd_pkt_filter_port_src,
3210 (void *)&cmd_pkt_filter_dst,
3211 (void *)&cmd_pkt_filter_ip_dst,
3212 (void *)&cmd_pkt_filter_port_dst,
3213 (void *)&cmd_pkt_filter_flexbytes,
3214 (void *)&cmd_pkt_filter_flexbytes_value,
3215 (void *)&cmd_pkt_filter_vlan,
3216 (void *)&cmd_pkt_filter_vlan_id,
3217 (void *)&cmd_pkt_filter_queue,
3218 (void *)&cmd_pkt_filter_queue_id,
3219 (void *)&cmd_pkt_filter_soft,
3220 (void *)&cmd_pkt_filter_soft_id,
3226 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3227 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3228 pkt_filter, "upd_perfect_filter");
3229 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3230 .f = cmd_pkt_filter_parsed,
3232 .help_str = "update a perfect filter",
3234 (void *)&cmd_pkt_filter_upd_perfect_filter,
3235 (void *)&cmd_pkt_filter_port_id,
3236 (void *)&cmd_pkt_filter_protocol,
3237 (void *)&cmd_pkt_filter_src,
3238 (void *)&cmd_pkt_filter_ip_src,
3239 (void *)&cmd_pkt_filter_port_src,
3240 (void *)&cmd_pkt_filter_dst,
3241 (void *)&cmd_pkt_filter_ip_dst,
3242 (void *)&cmd_pkt_filter_port_dst,
3243 (void *)&cmd_pkt_filter_flexbytes,
3244 (void *)&cmd_pkt_filter_flexbytes_value,
3245 (void *)&cmd_pkt_filter_vlan,
3246 (void *)&cmd_pkt_filter_vlan_id,
3247 (void *)&cmd_pkt_filter_queue,
3248 (void *)&cmd_pkt_filter_queue_id,
3249 (void *)&cmd_pkt_filter_soft,
3250 (void *)&cmd_pkt_filter_soft_id,
3256 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3257 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3258 pkt_filter, "rm_perfect_filter");
3259 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3260 .f = cmd_pkt_filter_parsed,
3262 .help_str = "remove a perfect filter",
3264 (void *)&cmd_pkt_filter_rm_perfect_filter,
3265 (void *)&cmd_pkt_filter_port_id,
3266 (void *)&cmd_pkt_filter_protocol,
3267 (void *)&cmd_pkt_filter_src,
3268 (void *)&cmd_pkt_filter_ip_src,
3269 (void *)&cmd_pkt_filter_port_src,
3270 (void *)&cmd_pkt_filter_dst,
3271 (void *)&cmd_pkt_filter_ip_dst,
3272 (void *)&cmd_pkt_filter_port_dst,
3273 (void *)&cmd_pkt_filter_flexbytes,
3274 (void *)&cmd_pkt_filter_flexbytes_value,
3275 (void *)&cmd_pkt_filter_vlan,
3276 (void *)&cmd_pkt_filter_vlan_id,
3277 (void *)&cmd_pkt_filter_soft,
3278 (void *)&cmd_pkt_filter_soft_id,
3283 /* *** SETUP MASKS FILTER *** */
3284 struct cmd_pkt_filter_masks_result {
3285 cmdline_fixed_string_t filter_mask;
3287 cmdline_fixed_string_t src_mask;
3288 uint32_t ip_src_mask;
3289 uint16_t ipv6_src_mask;
3290 uint16_t port_src_mask;
3291 cmdline_fixed_string_t dst_mask;
3292 uint32_t ip_dst_mask;
3293 uint16_t ipv6_dst_mask;
3294 uint16_t port_dst_mask;
3295 cmdline_fixed_string_t flexbytes;
3296 uint8_t flexbytes_value;
3297 cmdline_fixed_string_t vlan_id;
3298 uint8_t vlan_id_value;
3299 cmdline_fixed_string_t vlan_prio;
3300 uint8_t vlan_prio_value;
3301 cmdline_fixed_string_t only_ip_flow;
3302 uint8_t only_ip_flow_value;
3303 cmdline_fixed_string_t comp_ipv6_dst;
3304 uint8_t comp_ipv6_dst_value;
3308 cmd_pkt_filter_masks_parsed(void *parsed_result,
3309 __attribute__((unused)) struct cmdline *cl,
3310 __attribute__((unused)) void *data)
3312 struct rte_fdir_masks fdir_masks;
3313 struct cmd_pkt_filter_masks_result *res = parsed_result;
3315 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3317 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3318 fdir_masks.vlan_id = res->vlan_id_value;
3319 fdir_masks.vlan_prio = res->vlan_prio_value;
3320 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3321 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3322 fdir_masks.src_port_mask = res->port_src_mask;
3323 fdir_masks.dst_port_mask = res->port_dst_mask;
3324 fdir_masks.flexbytes = res->flexbytes_value;
3326 fdir_set_masks(res->port_id, &fdir_masks);
3329 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3330 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3331 filter_mask, "set_masks_filter");
3332 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3333 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3335 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3336 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3337 only_ip_flow, "only_ip_flow");
3338 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3339 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3340 only_ip_flow_value, UINT8);
3341 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3342 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3343 src_mask, "src_mask");
3344 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3345 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3346 ip_src_mask, UINT32);
3347 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3348 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3349 port_src_mask, UINT16);
3350 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3351 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3352 dst_mask, "dst_mask");
3353 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3354 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3355 ip_dst_mask, UINT32);
3356 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3357 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3358 port_dst_mask, UINT16);
3359 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3360 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3361 flexbytes, "flexbytes");
3362 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3363 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3364 flexbytes_value, UINT8);
3365 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3366 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3367 vlan_id, "vlan_id");
3368 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3369 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3370 vlan_id_value, UINT8);
3371 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3372 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3373 vlan_prio, "vlan_prio");
3374 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3375 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3376 vlan_prio_value, UINT8);
3378 cmdline_parse_inst_t cmd_set_masks_filter = {
3379 .f = cmd_pkt_filter_masks_parsed,
3381 .help_str = "setup masks filter",
3383 (void *)&cmd_pkt_filter_masks_filter_mask,
3384 (void *)&cmd_pkt_filter_masks_port_id,
3385 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3386 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3387 (void *)&cmd_pkt_filter_masks_src_mask,
3388 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3389 (void *)&cmd_pkt_filter_masks_port_src_mask,
3390 (void *)&cmd_pkt_filter_masks_dst_mask,
3391 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3392 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3393 (void *)&cmd_pkt_filter_masks_flexbytes,
3394 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3395 (void *)&cmd_pkt_filter_masks_vlan_id,
3396 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3397 (void *)&cmd_pkt_filter_masks_vlan_prio,
3398 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3404 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct rte_fdir_masks fdir_masks;
3409 struct cmd_pkt_filter_masks_result *res = parsed_result;
3411 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3413 fdir_masks.set_ipv6_mask = 1;
3414 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3415 fdir_masks.vlan_id = res->vlan_id_value;
3416 fdir_masks.vlan_prio = res->vlan_prio_value;
3417 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3418 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3419 fdir_masks.src_port_mask = res->port_src_mask;
3420 fdir_masks.dst_port_mask = res->port_dst_mask;
3421 fdir_masks.flexbytes = res->flexbytes_value;
3422 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3424 fdir_set_masks(res->port_id, &fdir_masks);
3427 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3428 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3429 filter_mask, "set_ipv6_masks_filter");
3430 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3431 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3432 ipv6_src_mask, UINT16);
3433 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3434 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3435 ipv6_dst_mask, UINT16);
3437 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3438 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3439 comp_ipv6_dst, "compare_dst");
3440 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3441 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3442 comp_ipv6_dst_value, UINT8);
3444 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3445 .f = cmd_pkt_filter_masks_ipv6_parsed,
3447 .help_str = "setup ipv6 masks filter",
3449 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3450 (void *)&cmd_pkt_filter_masks_port_id,
3451 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3452 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3453 (void *)&cmd_pkt_filter_masks_src_mask,
3454 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3455 (void *)&cmd_pkt_filter_masks_port_src_mask,
3456 (void *)&cmd_pkt_filter_masks_dst_mask,
3457 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3458 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3459 (void *)&cmd_pkt_filter_masks_flexbytes,
3460 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3461 (void *)&cmd_pkt_filter_masks_vlan_id,
3462 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3463 (void *)&cmd_pkt_filter_masks_vlan_prio,
3464 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3465 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3466 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3471 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3472 struct cmd_link_flow_ctrl_set_result {
3473 cmdline_fixed_string_t set;
3474 cmdline_fixed_string_t flow_ctrl;
3475 cmdline_fixed_string_t rx;
3476 cmdline_fixed_string_t rx_lfc_mode;
3477 cmdline_fixed_string_t tx;
3478 cmdline_fixed_string_t tx_lfc_mode;
3479 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3480 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3481 uint32_t high_water;
3483 uint16_t pause_time;
3489 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3490 __attribute__((unused)) struct cmdline *cl,
3491 __attribute__((unused)) void *data)
3493 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3494 struct rte_eth_fc_conf fc_conf;
3495 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3499 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3500 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3501 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3502 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3504 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3505 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3508 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3509 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3510 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3512 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3513 fc_conf.high_water = res->high_water;
3514 fc_conf.low_water = res->low_water;
3515 fc_conf.pause_time = res->pause_time;
3516 fc_conf.send_xon = res->send_xon;
3517 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3519 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3521 printf("bad flow contrl parameter, return code = %d \n", ret);
3524 cmdline_parse_token_string_t cmd_lfc_set_set =
3525 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3527 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3528 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3529 flow_ctrl, "flow_ctrl");
3530 cmdline_parse_token_string_t cmd_lfc_set_rx =
3531 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3533 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3534 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3535 rx_lfc_mode, "on#off");
3536 cmdline_parse_token_string_t cmd_lfc_set_tx =
3537 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3539 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3540 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3541 tx_lfc_mode, "on#off");
3542 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3543 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3544 high_water, UINT32);
3545 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3546 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3548 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3549 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3550 pause_time, UINT16);
3551 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3552 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3554 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3555 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3556 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3557 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3558 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3559 mac_ctrl_frame_fwd_mode, "on#off");
3560 cmdline_parse_token_num_t cmd_lfc_set_portid =
3561 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3564 cmdline_parse_inst_t cmd_link_flow_control_set = {
3565 .f = cmd_link_flow_ctrl_set_parsed,
3567 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3568 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3571 (void *)&cmd_lfc_set_set,
3572 (void *)&cmd_lfc_set_flow_ctrl,
3573 (void *)&cmd_lfc_set_rx,
3574 (void *)&cmd_lfc_set_rx_mode,
3575 (void *)&cmd_lfc_set_tx,
3576 (void *)&cmd_lfc_set_tx_mode,
3577 (void *)&cmd_lfc_set_high_water,
3578 (void *)&cmd_lfc_set_low_water,
3579 (void *)&cmd_lfc_set_pause_time,
3580 (void *)&cmd_lfc_set_send_xon,
3581 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3582 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3583 (void *)&cmd_lfc_set_portid,
3588 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3589 struct cmd_priority_flow_ctrl_set_result {
3590 cmdline_fixed_string_t set;
3591 cmdline_fixed_string_t pfc_ctrl;
3592 cmdline_fixed_string_t rx;
3593 cmdline_fixed_string_t rx_pfc_mode;
3594 cmdline_fixed_string_t tx;
3595 cmdline_fixed_string_t tx_pfc_mode;
3596 uint32_t high_water;
3598 uint16_t pause_time;
3604 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3605 __attribute__((unused)) struct cmdline *cl,
3606 __attribute__((unused)) void *data)
3608 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3609 struct rte_eth_pfc_conf pfc_conf;
3610 int rx_fc_enable, tx_fc_enable;
3614 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3615 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3616 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3617 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3619 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3620 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3623 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3624 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3625 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3626 pfc_conf.fc.high_water = res->high_water;
3627 pfc_conf.fc.low_water = res->low_water;
3628 pfc_conf.fc.pause_time = res->pause_time;
3629 pfc_conf.priority = res->priority;
3631 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3633 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3636 cmdline_parse_token_string_t cmd_pfc_set_set =
3637 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3639 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3640 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3641 pfc_ctrl, "pfc_ctrl");
3642 cmdline_parse_token_string_t cmd_pfc_set_rx =
3643 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3645 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3646 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3647 rx_pfc_mode, "on#off");
3648 cmdline_parse_token_string_t cmd_pfc_set_tx =
3649 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3651 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3652 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3653 tx_pfc_mode, "on#off");
3654 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3655 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3656 high_water, UINT32);
3657 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3658 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3660 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3661 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3662 pause_time, UINT16);
3663 cmdline_parse_token_num_t cmd_pfc_set_priority =
3664 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3666 cmdline_parse_token_num_t cmd_pfc_set_portid =
3667 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3670 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3671 .f = cmd_priority_flow_ctrl_set_parsed,
3673 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3674 tx on|off high_water low_water pause_time priority port_id",
3676 (void *)&cmd_pfc_set_set,
3677 (void *)&cmd_pfc_set_flow_ctrl,
3678 (void *)&cmd_pfc_set_rx,
3679 (void *)&cmd_pfc_set_rx_mode,
3680 (void *)&cmd_pfc_set_tx,
3681 (void *)&cmd_pfc_set_tx_mode,
3682 (void *)&cmd_pfc_set_high_water,
3683 (void *)&cmd_pfc_set_low_water,
3684 (void *)&cmd_pfc_set_pause_time,
3685 (void *)&cmd_pfc_set_priority,
3686 (void *)&cmd_pfc_set_portid,
3691 /* *** RESET CONFIGURATION *** */
3692 struct cmd_reset_result {
3693 cmdline_fixed_string_t reset;
3694 cmdline_fixed_string_t def;
3697 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3699 __attribute__((unused)) void *data)
3701 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3702 set_def_fwd_config();
3705 cmdline_parse_token_string_t cmd_reset_set =
3706 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3707 cmdline_parse_token_string_t cmd_reset_def =
3708 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3711 cmdline_parse_inst_t cmd_reset = {
3712 .f = cmd_reset_parsed,
3714 .help_str = "set default: reset default forwarding configuration",
3716 (void *)&cmd_reset_set,
3717 (void *)&cmd_reset_def,
3722 /* *** START FORWARDING *** */
3723 struct cmd_start_result {
3724 cmdline_fixed_string_t start;
3727 cmdline_parse_token_string_t cmd_start_start =
3728 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3730 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3731 __attribute__((unused)) struct cmdline *cl,
3732 __attribute__((unused)) void *data)
3734 start_packet_forwarding(0);
3737 cmdline_parse_inst_t cmd_start = {
3738 .f = cmd_start_parsed,
3740 .help_str = "start packet forwarding",
3742 (void *)&cmd_start_start,
3747 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3748 struct cmd_start_tx_first_result {
3749 cmdline_fixed_string_t start;
3750 cmdline_fixed_string_t tx_first;
3754 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3755 __attribute__((unused)) struct cmdline *cl,
3756 __attribute__((unused)) void *data)
3758 start_packet_forwarding(1);
3761 cmdline_parse_token_string_t cmd_start_tx_first_start =
3762 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3764 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3765 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3766 tx_first, "tx_first");
3768 cmdline_parse_inst_t cmd_start_tx_first = {
3769 .f = cmd_start_tx_first_parsed,
3771 .help_str = "start packet forwarding, after sending 1 burst of packets",
3773 (void *)&cmd_start_tx_first_start,
3774 (void *)&cmd_start_tx_first_tx_first,
3779 /* *** SHOW CFG *** */
3780 struct cmd_showcfg_result {
3781 cmdline_fixed_string_t show;
3782 cmdline_fixed_string_t cfg;
3783 cmdline_fixed_string_t what;
3786 static void cmd_showcfg_parsed(void *parsed_result,
3787 __attribute__((unused)) struct cmdline *cl,
3788 __attribute__((unused)) void *data)
3790 struct cmd_showcfg_result *res = parsed_result;
3791 if (!strcmp(res->what, "rxtx"))
3792 rxtx_config_display();
3793 else if (!strcmp(res->what, "cores"))
3794 fwd_lcores_config_display();
3795 else if (!strcmp(res->what, "fwd"))
3796 fwd_config_display();
3799 cmdline_parse_token_string_t cmd_showcfg_show =
3800 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3801 cmdline_parse_token_string_t cmd_showcfg_port =
3802 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3803 cmdline_parse_token_string_t cmd_showcfg_what =
3804 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3807 cmdline_parse_inst_t cmd_showcfg = {
3808 .f = cmd_showcfg_parsed,
3810 .help_str = "show config rxtx|cores|fwd",
3812 (void *)&cmd_showcfg_show,
3813 (void *)&cmd_showcfg_port,
3814 (void *)&cmd_showcfg_what,
3819 /* *** SHOW ALL PORT INFO *** */
3820 struct cmd_showportall_result {
3821 cmdline_fixed_string_t show;
3822 cmdline_fixed_string_t port;
3823 cmdline_fixed_string_t what;
3824 cmdline_fixed_string_t all;
3827 static void cmd_showportall_parsed(void *parsed_result,
3828 __attribute__((unused)) struct cmdline *cl,
3829 __attribute__((unused)) void *data)
3833 struct cmd_showportall_result *res = parsed_result;
3834 if (!strcmp(res->show, "clear")) {
3835 if (!strcmp(res->what, "stats"))
3836 for (i = 0; i < nb_ports; i++)
3838 } else if (!strcmp(res->what, "info"))
3839 for (i = 0; i < nb_ports; i++)
3840 port_infos_display(i);
3841 else if (!strcmp(res->what, "stats"))
3842 for (i = 0; i < nb_ports; i++)
3843 nic_stats_display(i);
3844 else if (!strcmp(res->what, "fdir"))
3845 for (i = 0; i < nb_ports; i++)
3847 else if (!strcmp(res->what, "stat_qmap"))
3848 for (i = 0; i < nb_ports; i++)
3849 nic_stats_mapping_display(i);
3852 cmdline_parse_token_string_t cmd_showportall_show =
3853 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3855 cmdline_parse_token_string_t cmd_showportall_port =
3856 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3857 cmdline_parse_token_string_t cmd_showportall_what =
3858 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3859 "info#stats#fdir#stat_qmap");
3860 cmdline_parse_token_string_t cmd_showportall_all =
3861 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3862 cmdline_parse_inst_t cmd_showportall = {
3863 .f = cmd_showportall_parsed,
3865 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3867 (void *)&cmd_showportall_show,
3868 (void *)&cmd_showportall_port,
3869 (void *)&cmd_showportall_what,
3870 (void *)&cmd_showportall_all,
3875 /* *** SHOW PORT INFO *** */
3876 struct cmd_showport_result {
3877 cmdline_fixed_string_t show;
3878 cmdline_fixed_string_t port;
3879 cmdline_fixed_string_t what;
3883 static void cmd_showport_parsed(void *parsed_result,
3884 __attribute__((unused)) struct cmdline *cl,
3885 __attribute__((unused)) void *data)
3887 struct cmd_showport_result *res = parsed_result;
3888 if (!strcmp(res->show, "clear")) {
3889 if (!strcmp(res->what, "stats"))
3890 nic_stats_clear(res->portnum);
3891 } else if (!strcmp(res->what, "info"))
3892 port_infos_display(res->portnum);
3893 else if (!strcmp(res->what, "stats"))
3894 nic_stats_display(res->portnum);
3895 else if (!strcmp(res->what, "fdir"))
3896 fdir_get_infos(res->portnum);
3897 else if (!strcmp(res->what, "stat_qmap"))
3898 nic_stats_mapping_display(res->portnum);
3901 cmdline_parse_token_string_t cmd_showport_show =
3902 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3904 cmdline_parse_token_string_t cmd_showport_port =
3905 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3906 cmdline_parse_token_string_t cmd_showport_what =
3907 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3908 "info#stats#fdir#stat_qmap");
3909 cmdline_parse_token_num_t cmd_showport_portnum =
3910 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3912 cmdline_parse_inst_t cmd_showport = {
3913 .f = cmd_showport_parsed,
3915 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3917 (void *)&cmd_showport_show,
3918 (void *)&cmd_showport_port,
3919 (void *)&cmd_showport_what,
3920 (void *)&cmd_showport_portnum,
3925 /* *** READ PORT REGISTER *** */
3926 struct cmd_read_reg_result {
3927 cmdline_fixed_string_t read;
3928 cmdline_fixed_string_t reg;
3934 cmd_read_reg_parsed(void *parsed_result,
3935 __attribute__((unused)) struct cmdline *cl,
3936 __attribute__((unused)) void *data)
3938 struct cmd_read_reg_result *res = parsed_result;
3939 port_reg_display(res->port_id, res->reg_off);
3942 cmdline_parse_token_string_t cmd_read_reg_read =
3943 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3944 cmdline_parse_token_string_t cmd_read_reg_reg =
3945 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3946 cmdline_parse_token_num_t cmd_read_reg_port_id =
3947 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3948 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3949 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3951 cmdline_parse_inst_t cmd_read_reg = {
3952 .f = cmd_read_reg_parsed,
3954 .help_str = "read reg port_id reg_off",
3956 (void *)&cmd_read_reg_read,
3957 (void *)&cmd_read_reg_reg,
3958 (void *)&cmd_read_reg_port_id,
3959 (void *)&cmd_read_reg_reg_off,
3964 /* *** READ PORT REGISTER BIT FIELD *** */
3965 struct cmd_read_reg_bit_field_result {
3966 cmdline_fixed_string_t read;
3967 cmdline_fixed_string_t regfield;
3975 cmd_read_reg_bit_field_parsed(void *parsed_result,
3976 __attribute__((unused)) struct cmdline *cl,
3977 __attribute__((unused)) void *data)
3979 struct cmd_read_reg_bit_field_result *res = parsed_result;
3980 port_reg_bit_field_display(res->port_id, res->reg_off,
3981 res->bit1_pos, res->bit2_pos);
3984 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3985 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3987 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3988 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3989 regfield, "regfield");
3990 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3991 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3993 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3994 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3996 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3997 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3999 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4000 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4003 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4004 .f = cmd_read_reg_bit_field_parsed,
4006 .help_str = "read regfield port_id reg_off bit_x bit_y "
4007 "(read register bit field between bit_x and bit_y included)",
4009 (void *)&cmd_read_reg_bit_field_read,
4010 (void *)&cmd_read_reg_bit_field_regfield,
4011 (void *)&cmd_read_reg_bit_field_port_id,
4012 (void *)&cmd_read_reg_bit_field_reg_off,
4013 (void *)&cmd_read_reg_bit_field_bit1_pos,
4014 (void *)&cmd_read_reg_bit_field_bit2_pos,
4019 /* *** READ PORT REGISTER BIT *** */
4020 struct cmd_read_reg_bit_result {
4021 cmdline_fixed_string_t read;
4022 cmdline_fixed_string_t regbit;
4029 cmd_read_reg_bit_parsed(void *parsed_result,
4030 __attribute__((unused)) struct cmdline *cl,
4031 __attribute__((unused)) void *data)
4033 struct cmd_read_reg_bit_result *res = parsed_result;
4034 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4037 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4038 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4039 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4040 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4042 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4043 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4044 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4045 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4046 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4047 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4049 cmdline_parse_inst_t cmd_read_reg_bit = {
4050 .f = cmd_read_reg_bit_parsed,
4052 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4054 (void *)&cmd_read_reg_bit_read,
4055 (void *)&cmd_read_reg_bit_regbit,
4056 (void *)&cmd_read_reg_bit_port_id,
4057 (void *)&cmd_read_reg_bit_reg_off,
4058 (void *)&cmd_read_reg_bit_bit_pos,
4063 /* *** WRITE PORT REGISTER *** */
4064 struct cmd_write_reg_result {
4065 cmdline_fixed_string_t write;
4066 cmdline_fixed_string_t reg;
4073 cmd_write_reg_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_write_reg_result *res = parsed_result;
4078 port_reg_set(res->port_id, res->reg_off, res->value);
4081 cmdline_parse_token_string_t cmd_write_reg_write =
4082 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4083 cmdline_parse_token_string_t cmd_write_reg_reg =
4084 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4085 cmdline_parse_token_num_t cmd_write_reg_port_id =
4086 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4087 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4088 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4089 cmdline_parse_token_num_t cmd_write_reg_value =
4090 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4092 cmdline_parse_inst_t cmd_write_reg = {
4093 .f = cmd_write_reg_parsed,
4095 .help_str = "write reg port_id reg_off reg_value",
4097 (void *)&cmd_write_reg_write,
4098 (void *)&cmd_write_reg_reg,
4099 (void *)&cmd_write_reg_port_id,
4100 (void *)&cmd_write_reg_reg_off,
4101 (void *)&cmd_write_reg_value,
4106 /* *** WRITE PORT REGISTER BIT FIELD *** */
4107 struct cmd_write_reg_bit_field_result {
4108 cmdline_fixed_string_t write;
4109 cmdline_fixed_string_t regfield;
4118 cmd_write_reg_bit_field_parsed(void *parsed_result,
4119 __attribute__((unused)) struct cmdline *cl,
4120 __attribute__((unused)) void *data)
4122 struct cmd_write_reg_bit_field_result *res = parsed_result;
4123 port_reg_bit_field_set(res->port_id, res->reg_off,
4124 res->bit1_pos, res->bit2_pos, res->value);
4127 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4128 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4130 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4131 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4132 regfield, "regfield");
4133 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4136 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4137 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4139 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4140 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4142 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4143 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4145 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4146 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4149 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4150 .f = cmd_write_reg_bit_field_parsed,
4152 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4153 "(set register bit field between bit_x and bit_y included)",
4155 (void *)&cmd_write_reg_bit_field_write,
4156 (void *)&cmd_write_reg_bit_field_regfield,
4157 (void *)&cmd_write_reg_bit_field_port_id,
4158 (void *)&cmd_write_reg_bit_field_reg_off,
4159 (void *)&cmd_write_reg_bit_field_bit1_pos,
4160 (void *)&cmd_write_reg_bit_field_bit2_pos,
4161 (void *)&cmd_write_reg_bit_field_value,
4166 /* *** WRITE PORT REGISTER BIT *** */
4167 struct cmd_write_reg_bit_result {
4168 cmdline_fixed_string_t write;
4169 cmdline_fixed_string_t regbit;
4177 cmd_write_reg_bit_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct cmd_write_reg_bit_result *res = parsed_result;
4182 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4185 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4186 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4188 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4189 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4191 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4192 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4193 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4195 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4196 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4197 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4200 cmdline_parse_inst_t cmd_write_reg_bit = {
4201 .f = cmd_write_reg_bit_parsed,
4203 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4205 (void *)&cmd_write_reg_bit_write,
4206 (void *)&cmd_write_reg_bit_regbit,
4207 (void *)&cmd_write_reg_bit_port_id,
4208 (void *)&cmd_write_reg_bit_reg_off,
4209 (void *)&cmd_write_reg_bit_bit_pos,
4210 (void *)&cmd_write_reg_bit_value,
4215 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4216 struct cmd_read_rxd_txd_result {
4217 cmdline_fixed_string_t read;
4218 cmdline_fixed_string_t rxd_txd;
4225 cmd_read_rxd_txd_parsed(void *parsed_result,
4226 __attribute__((unused)) struct cmdline *cl,
4227 __attribute__((unused)) void *data)
4229 struct cmd_read_rxd_txd_result *res = parsed_result;
4231 if (!strcmp(res->rxd_txd, "rxd"))
4232 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4233 else if (!strcmp(res->rxd_txd, "txd"))
4234 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4237 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4238 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4239 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4240 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4242 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4243 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4244 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4245 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4246 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4247 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4249 cmdline_parse_inst_t cmd_read_rxd_txd = {
4250 .f = cmd_read_rxd_txd_parsed,
4252 .help_str = "read rxd|txd port_id queue_id rxd_id",
4254 (void *)&cmd_read_rxd_txd_read,
4255 (void *)&cmd_read_rxd_txd_rxd_txd,
4256 (void *)&cmd_read_rxd_txd_port_id,
4257 (void *)&cmd_read_rxd_txd_queue_id,
4258 (void *)&cmd_read_rxd_txd_desc_id,
4264 struct cmd_quit_result {
4265 cmdline_fixed_string_t quit;
4268 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4270 __attribute__((unused)) void *data)
4276 cmdline_parse_token_string_t cmd_quit_quit =
4277 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4279 cmdline_parse_inst_t cmd_quit = {
4280 .f = cmd_quit_parsed,
4282 .help_str = "exit application",
4284 (void *)&cmd_quit_quit,
4289 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4290 struct cmd_mac_addr_result {
4291 cmdline_fixed_string_t mac_addr_cmd;
4292 cmdline_fixed_string_t what;
4294 struct ether_addr address;
4297 static void cmd_mac_addr_parsed(void *parsed_result,
4298 __attribute__((unused)) struct cmdline *cl,
4299 __attribute__((unused)) void *data)
4301 struct cmd_mac_addr_result *res = parsed_result;
4304 if (strcmp(res->what, "add") == 0)
4305 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4307 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4309 /* check the return value and print it if is < 0 */
4311 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4315 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4316 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4318 cmdline_parse_token_string_t cmd_mac_addr_what =
4319 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4321 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4322 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4323 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4324 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4326 cmdline_parse_inst_t cmd_mac_addr = {
4327 .f = cmd_mac_addr_parsed,
4329 .help_str = "mac_addr add|remove X <address>: "
4330 "add/remove MAC address on port X",
4332 (void *)&cmd_mac_addr_cmd,
4333 (void *)&cmd_mac_addr_what,
4334 (void *)&cmd_mac_addr_portnum,
4335 (void *)&cmd_mac_addr_addr,
4341 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4342 struct cmd_set_qmap_result {
4343 cmdline_fixed_string_t set;
4344 cmdline_fixed_string_t qmap;
4345 cmdline_fixed_string_t what;
4352 cmd_set_qmap_parsed(void *parsed_result,
4353 __attribute__((unused)) struct cmdline *cl,
4354 __attribute__((unused)) void *data)
4356 struct cmd_set_qmap_result *res = parsed_result;
4357 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4359 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4362 cmdline_parse_token_string_t cmd_setqmap_set =
4363 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4365 cmdline_parse_token_string_t cmd_setqmap_qmap =
4366 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4368 cmdline_parse_token_string_t cmd_setqmap_what =
4369 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4371 cmdline_parse_token_num_t cmd_setqmap_portid =
4372 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4374 cmdline_parse_token_num_t cmd_setqmap_queueid =
4375 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4377 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4378 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4381 cmdline_parse_inst_t cmd_set_qmap = {
4382 .f = cmd_set_qmap_parsed,
4384 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4386 (void *)&cmd_setqmap_set,
4387 (void *)&cmd_setqmap_qmap,
4388 (void *)&cmd_setqmap_what,
4389 (void *)&cmd_setqmap_portid,
4390 (void *)&cmd_setqmap_queueid,
4391 (void *)&cmd_setqmap_mapvalue,
4396 /* *** CONFIGURE UNICAST HASH TABLE *** */
4397 struct cmd_set_uc_hash_table {
4398 cmdline_fixed_string_t set;
4399 cmdline_fixed_string_t port;
4401 cmdline_fixed_string_t what;
4402 struct ether_addr address;
4403 cmdline_fixed_string_t mode;
4407 cmd_set_uc_hash_parsed(void *parsed_result,
4408 __attribute__((unused)) struct cmdline *cl,
4409 __attribute__((unused)) void *data)
4412 struct cmd_set_uc_hash_table *res = parsed_result;
4414 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4416 if (strcmp(res->what, "uta") == 0)
4417 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4418 &res->address,(uint8_t)is_on);
4420 printf("bad unicast hash table parameter, return code = %d \n", ret);
4424 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4425 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4427 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4428 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4430 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4431 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4433 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4434 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4436 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4439 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4440 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4443 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4444 .f = cmd_set_uc_hash_parsed,
4446 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4448 (void *)&cmd_set_uc_hash_set,
4449 (void *)&cmd_set_uc_hash_port,
4450 (void *)&cmd_set_uc_hash_portid,
4451 (void *)&cmd_set_uc_hash_what,
4452 (void *)&cmd_set_uc_hash_mac,
4453 (void *)&cmd_set_uc_hash_mode,
4458 struct cmd_set_uc_all_hash_table {
4459 cmdline_fixed_string_t set;
4460 cmdline_fixed_string_t port;
4462 cmdline_fixed_string_t what;
4463 cmdline_fixed_string_t value;
4464 cmdline_fixed_string_t mode;
4468 cmd_set_uc_all_hash_parsed(void *parsed_result,
4469 __attribute__((unused)) struct cmdline *cl,
4470 __attribute__((unused)) void *data)
4473 struct cmd_set_uc_all_hash_table *res = parsed_result;
4475 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4477 if ((strcmp(res->what, "uta") == 0) &&
4478 (strcmp(res->value, "all") == 0))
4479 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4481 printf("bad unicast hash table parameter,"
4482 "return code = %d \n", ret);
4485 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4486 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4488 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4489 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4491 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4492 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4494 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4497 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4500 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4504 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4505 .f = cmd_set_uc_all_hash_parsed,
4507 .help_str = "set port X uta all on|off (X = port number)",
4509 (void *)&cmd_set_uc_all_hash_set,
4510 (void *)&cmd_set_uc_all_hash_port,
4511 (void *)&cmd_set_uc_all_hash_portid,
4512 (void *)&cmd_set_uc_all_hash_what,
4513 (void *)&cmd_set_uc_all_hash_value,
4514 (void *)&cmd_set_uc_all_hash_mode,
4519 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4520 struct cmd_set_vf_traffic {
4521 cmdline_fixed_string_t set;
4522 cmdline_fixed_string_t port;
4524 cmdline_fixed_string_t vf;
4526 cmdline_fixed_string_t what;
4527 cmdline_fixed_string_t mode;
4531 cmd_set_vf_traffic_parsed(void *parsed_result,
4532 __attribute__((unused)) struct cmdline *cl,
4533 __attribute__((unused)) void *data)
4535 struct cmd_set_vf_traffic *res = parsed_result;
4536 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4537 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4539 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4542 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4543 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4545 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4546 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4548 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4549 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4551 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4554 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4555 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4557 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4558 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4560 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4561 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4564 cmdline_parse_inst_t cmd_set_vf_traffic = {
4565 .f = cmd_set_vf_traffic_parsed,
4567 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4569 (void *)&cmd_setvf_traffic_set,
4570 (void *)&cmd_setvf_traffic_port,
4571 (void *)&cmd_setvf_traffic_portid,
4572 (void *)&cmd_setvf_traffic_vf,
4573 (void *)&cmd_setvf_traffic_vfid,
4574 (void *)&cmd_setvf_traffic_what,
4575 (void *)&cmd_setvf_traffic_mode,
4580 /* *** CONFIGURE VF RECEIVE MODE *** */
4581 struct cmd_set_vf_rxmode {
4582 cmdline_fixed_string_t set;
4583 cmdline_fixed_string_t port;
4585 cmdline_fixed_string_t vf;
4587 cmdline_fixed_string_t what;
4588 cmdline_fixed_string_t mode;
4589 cmdline_fixed_string_t on;
4593 cmd_set_vf_rxmode_parsed(void *parsed_result,
4594 __attribute__((unused)) struct cmdline *cl,
4595 __attribute__((unused)) void *data)
4598 uint16_t rx_mode = 0;
4599 struct cmd_set_vf_rxmode *res = parsed_result;
4601 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4602 if (!strcmp(res->what,"rxmode")) {
4603 if (!strcmp(res->mode, "AUPE"))
4604 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4605 else if (!strcmp(res->mode, "ROPE"))
4606 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4607 else if (!strcmp(res->mode, "BAM"))
4608 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4609 else if (!strncmp(res->mode, "MPE",3))
4610 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4613 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4615 printf("bad VF receive mode parameter, return code = %d \n",
4619 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4620 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4622 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4623 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4625 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4626 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4628 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4629 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4631 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4632 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4634 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4637 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4639 mode, "AUPE#ROPE#BAM#MPE");
4640 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4644 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4645 .f = cmd_set_vf_rxmode_parsed,
4647 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4649 (void *)&cmd_set_vf_rxmode_set,
4650 (void *)&cmd_set_vf_rxmode_port,
4651 (void *)&cmd_set_vf_rxmode_portid,
4652 (void *)&cmd_set_vf_rxmode_vf,
4653 (void *)&cmd_set_vf_rxmode_vfid,
4654 (void *)&cmd_set_vf_rxmode_what,
4655 (void *)&cmd_set_vf_rxmode_mode,
4656 (void *)&cmd_set_vf_rxmode_on,
4661 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4662 struct cmd_vf_mac_addr_result {
4663 cmdline_fixed_string_t mac_addr_cmd;
4664 cmdline_fixed_string_t what;
4665 cmdline_fixed_string_t port;
4667 cmdline_fixed_string_t vf;
4669 struct ether_addr address;
4672 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4673 __attribute__((unused)) struct cmdline *cl,
4674 __attribute__((unused)) void *data)
4676 struct cmd_vf_mac_addr_result *res = parsed_result;
4679 if (strcmp(res->what, "add") == 0)
4680 ret = rte_eth_dev_mac_addr_add(res->port_num,
4681 &res->address, res->vf_num);
4683 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4687 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4688 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4689 mac_addr_cmd,"mac_addr");
4690 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4691 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4693 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4694 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4696 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4697 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4699 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4700 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4702 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4703 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4705 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4706 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4709 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4710 .f = cmd_vf_mac_addr_parsed,
4712 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4713 "Y = VF number)add MAC address filtering for a VF on port X",
4715 (void *)&cmd_vf_mac_addr_cmd,
4716 (void *)&cmd_vf_mac_addr_what,
4717 (void *)&cmd_vf_mac_addr_port,
4718 (void *)&cmd_vf_mac_addr_portnum,
4719 (void *)&cmd_vf_mac_addr_vf,
4720 (void *)&cmd_vf_mac_addr_vfnum,
4721 (void *)&cmd_vf_mac_addr_addr,
4726 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4727 struct cmd_vf_rx_vlan_filter {
4728 cmdline_fixed_string_t rx_vlan;
4729 cmdline_fixed_string_t what;
4731 cmdline_fixed_string_t port;
4733 cmdline_fixed_string_t vf;
4738 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4739 __attribute__((unused)) struct cmdline *cl,
4740 __attribute__((unused)) void *data)
4742 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4744 if (!strcmp(res->what, "add"))
4745 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4747 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4750 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4751 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4752 rx_vlan, "rx_vlan");
4753 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4754 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4756 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4757 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4759 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4760 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4762 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4763 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4765 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4766 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4768 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4769 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4772 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4773 .f = cmd_vf_rx_vlan_filter_parsed,
4775 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4776 "Y = port number,Z = hexadecimal VF mask)",
4778 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4779 (void *)&cmd_vf_rx_vlan_filter_what,
4780 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4781 (void *)&cmd_vf_rx_vlan_filter_port,
4782 (void *)&cmd_vf_rx_vlan_filter_portid,
4783 (void *)&cmd_vf_rx_vlan_filter_vf,
4784 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4789 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4790 struct cmd_set_mirror_mask_result {
4791 cmdline_fixed_string_t set;
4792 cmdline_fixed_string_t port;
4794 cmdline_fixed_string_t mirror;
4796 cmdline_fixed_string_t what;
4797 cmdline_fixed_string_t value;
4798 cmdline_fixed_string_t dstpool;
4800 cmdline_fixed_string_t on;
4803 cmdline_parse_token_string_t cmd_mirror_mask_set =
4804 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4806 cmdline_parse_token_string_t cmd_mirror_mask_port =
4807 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4809 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4810 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4812 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4813 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4814 mirror, "mirror-rule");
4815 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4816 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4818 cmdline_parse_token_string_t cmd_mirror_mask_what =
4819 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4820 what, "pool-mirror#vlan-mirror");
4821 cmdline_parse_token_string_t cmd_mirror_mask_value =
4822 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4824 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4825 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4826 dstpool, "dst-pool");
4827 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4828 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4830 cmdline_parse_token_string_t cmd_mirror_mask_on =
4831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4835 cmd_set_mirror_mask_parsed(void *parsed_result,
4836 __attribute__((unused)) struct cmdline *cl,
4837 __attribute__((unused)) void *data)
4840 struct cmd_set_mirror_mask_result *res = parsed_result;
4841 struct rte_eth_vmdq_mirror_conf mr_conf;
4843 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4845 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4847 mr_conf.dst_pool = res->dstpool_id;
4849 if (!strcmp(res->what, "pool-mirror")) {
4850 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4851 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4852 } else if(!strcmp(res->what, "vlan-mirror")) {
4853 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4854 nb_item = parse_item_list(res->value, "core",
4855 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4859 for(i=0; i < nb_item; i++) {
4860 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4861 printf("Invalid vlan_id: must be < 4096\n");
4865 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4866 mr_conf.vlan.vlan_mask |= 1ULL << i;
4870 if(!strcmp(res->on, "on"))
4871 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4874 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4877 printf("mirror rule add error: (%s)\n", strerror(-ret));
4880 cmdline_parse_inst_t cmd_set_mirror_mask = {
4881 .f = cmd_set_mirror_mask_parsed,
4883 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4884 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4886 (void *)&cmd_mirror_mask_set,
4887 (void *)&cmd_mirror_mask_port,
4888 (void *)&cmd_mirror_mask_portid,
4889 (void *)&cmd_mirror_mask_mirror,
4890 (void *)&cmd_mirror_mask_ruleid,
4891 (void *)&cmd_mirror_mask_what,
4892 (void *)&cmd_mirror_mask_value,
4893 (void *)&cmd_mirror_mask_dstpool,
4894 (void *)&cmd_mirror_mask_poolid,
4895 (void *)&cmd_mirror_mask_on,
4900 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4901 struct cmd_set_mirror_link_result {
4902 cmdline_fixed_string_t set;
4903 cmdline_fixed_string_t port;
4905 cmdline_fixed_string_t mirror;
4907 cmdline_fixed_string_t what;
4908 cmdline_fixed_string_t dstpool;
4910 cmdline_fixed_string_t on;
4913 cmdline_parse_token_string_t cmd_mirror_link_set =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4916 cmdline_parse_token_string_t cmd_mirror_link_port =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4919 cmdline_parse_token_string_t cmd_mirror_link_portid =
4920 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4922 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4924 mirror, "mirror-rule");
4925 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4926 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4928 cmdline_parse_token_string_t cmd_mirror_link_what =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4930 what, "uplink-mirror#downlink-mirror");
4931 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4933 dstpool, "dst-pool");
4934 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4935 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4937 cmdline_parse_token_string_t cmd_mirror_link_on =
4938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4942 cmd_set_mirror_link_parsed(void *parsed_result,
4943 __attribute__((unused)) struct cmdline *cl,
4944 __attribute__((unused)) void *data)
4947 struct cmd_set_mirror_link_result *res = parsed_result;
4948 struct rte_eth_vmdq_mirror_conf mr_conf;
4950 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4951 if(!strcmp(res->what, "uplink-mirror")) {
4952 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4953 }else if(!strcmp(res->what, "downlink-mirror"))
4954 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4956 mr_conf.dst_pool = res->dstpool_id;
4958 if(!strcmp(res->on, "on"))
4959 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4962 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4965 /* check the return value and print it if is < 0 */
4967 printf("mirror rule add error: (%s)\n", strerror(-ret));
4971 cmdline_parse_inst_t cmd_set_mirror_link = {
4972 .f = cmd_set_mirror_link_parsed,
4974 .help_str = "set port X mirror-rule Y uplink-mirror|"
4975 "downlink-mirror dst-pool Z on|off",
4977 (void *)&cmd_mirror_link_set,
4978 (void *)&cmd_mirror_link_port,
4979 (void *)&cmd_mirror_link_portid,
4980 (void *)&cmd_mirror_link_mirror,
4981 (void *)&cmd_mirror_link_ruleid,
4982 (void *)&cmd_mirror_link_what,
4983 (void *)&cmd_mirror_link_dstpool,
4984 (void *)&cmd_mirror_link_poolid,
4985 (void *)&cmd_mirror_link_on,
4990 /* *** RESET VM MIRROR RULE *** */
4991 struct cmd_rm_mirror_rule_result {
4992 cmdline_fixed_string_t reset;
4993 cmdline_fixed_string_t port;
4995 cmdline_fixed_string_t mirror;
4999 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5000 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5002 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5003 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5005 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5006 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5008 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5009 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5010 mirror, "mirror-rule");
5011 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5012 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5016 cmd_reset_mirror_rule_parsed(void *parsed_result,
5017 __attribute__((unused)) struct cmdline *cl,
5018 __attribute__((unused)) void *data)
5021 struct cmd_set_mirror_link_result *res = parsed_result;
5023 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5025 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5028 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5029 .f = cmd_reset_mirror_rule_parsed,
5031 .help_str = "reset port X mirror-rule Y",
5033 (void *)&cmd_rm_mirror_rule_reset,
5034 (void *)&cmd_rm_mirror_rule_port,
5035 (void *)&cmd_rm_mirror_rule_portid,
5036 (void *)&cmd_rm_mirror_rule_mirror,
5037 (void *)&cmd_rm_mirror_rule_ruleid,
5042 /* ******************************************************************************** */
5044 struct cmd_dump_result {
5045 cmdline_fixed_string_t dump;
5049 dump_struct_sizes(void)
5051 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5052 DUMP_SIZE(struct rte_mbuf);
5053 DUMP_SIZE(struct rte_pktmbuf);
5054 DUMP_SIZE(struct rte_ctrlmbuf);
5055 DUMP_SIZE(struct rte_mempool);
5056 DUMP_SIZE(struct rte_ring);
5060 static void cmd_dump_parsed(void *parsed_result,
5061 __attribute__((unused)) struct cmdline *cl,
5062 __attribute__((unused)) void *data)
5064 struct cmd_dump_result *res = parsed_result;
5066 if (!strcmp(res->dump, "dump_physmem"))
5067 rte_dump_physmem_layout(stdout);
5068 else if (!strcmp(res->dump, "dump_memzone"))
5069 rte_memzone_dump(stdout);
5070 else if (!strcmp(res->dump, "dump_log_history"))
5071 rte_log_dump_history(stdout);
5072 else if (!strcmp(res->dump, "dump_struct_sizes"))
5073 dump_struct_sizes();
5074 else if (!strcmp(res->dump, "dump_ring"))
5075 rte_ring_list_dump(stdout);
5076 else if (!strcmp(res->dump, "dump_mempool"))
5077 rte_mempool_list_dump(stdout);
5078 else if (!strcmp(res->dump, "dump_devargs"))
5079 rte_eal_devargs_dump(stdout);
5082 cmdline_parse_token_string_t cmd_dump_dump =
5083 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5087 "dump_struct_sizes#"
5092 cmdline_parse_inst_t cmd_dump = {
5093 .f = cmd_dump_parsed, /* function to call */
5094 .data = NULL, /* 2nd arg of func */
5095 .help_str = "dump status",
5096 .tokens = { /* token list, NULL terminated */
5097 (void *)&cmd_dump_dump,
5102 /* ******************************************************************************** */
5104 struct cmd_dump_one_result {
5105 cmdline_fixed_string_t dump;
5106 cmdline_fixed_string_t name;
5109 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5110 __attribute__((unused)) void *data)
5112 struct cmd_dump_one_result *res = parsed_result;
5114 if (!strcmp(res->dump, "dump_ring")) {
5116 r = rte_ring_lookup(res->name);
5118 cmdline_printf(cl, "Cannot find ring\n");
5121 rte_ring_dump(stdout, r);
5122 } else if (!strcmp(res->dump, "dump_mempool")) {
5123 struct rte_mempool *mp;
5124 mp = rte_mempool_lookup(res->name);
5126 cmdline_printf(cl, "Cannot find mempool\n");
5129 rte_mempool_dump(stdout, mp);
5133 cmdline_parse_token_string_t cmd_dump_one_dump =
5134 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5135 "dump_ring#dump_mempool");
5137 cmdline_parse_token_string_t cmd_dump_one_name =
5138 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5140 cmdline_parse_inst_t cmd_dump_one = {
5141 .f = cmd_dump_one_parsed, /* function to call */
5142 .data = NULL, /* 2nd arg of func */
5143 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5144 .tokens = { /* token list, NULL terminated */
5145 (void *)&cmd_dump_one_dump,
5146 (void *)&cmd_dump_one_name,
5151 /* ******************************************************************************** */
5153 /* list of instructions */
5154 cmdline_parse_ctx_t main_ctx[] = {
5155 (cmdline_parse_inst_t *)&cmd_help_brief,
5156 (cmdline_parse_inst_t *)&cmd_help_long,
5157 (cmdline_parse_inst_t *)&cmd_quit,
5158 (cmdline_parse_inst_t *)&cmd_showport,
5159 (cmdline_parse_inst_t *)&cmd_showportall,
5160 (cmdline_parse_inst_t *)&cmd_showcfg,
5161 (cmdline_parse_inst_t *)&cmd_start,
5162 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5163 (cmdline_parse_inst_t *)&cmd_reset,
5164 (cmdline_parse_inst_t *)&cmd_set_numbers,
5165 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5166 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5167 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5168 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5169 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5170 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5171 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5172 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5173 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5174 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5175 (cmdline_parse_inst_t *)&cmd_set_link_check,
5176 #ifdef RTE_NIC_BYPASS
5177 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5178 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5179 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5180 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5182 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5183 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5184 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5185 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5186 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5187 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5188 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5189 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5190 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5191 (cmdline_parse_inst_t *)&cmd_config_dcb,
5192 (cmdline_parse_inst_t *)&cmd_read_reg,
5193 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5194 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5195 (cmdline_parse_inst_t *)&cmd_write_reg,
5196 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5197 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5198 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5199 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5200 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5201 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5202 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5203 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5204 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5205 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5206 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5207 (cmdline_parse_inst_t *)&cmd_stop,
5208 (cmdline_parse_inst_t *)&cmd_mac_addr,
5209 (cmdline_parse_inst_t *)&cmd_set_qmap,
5210 (cmdline_parse_inst_t *)&cmd_operate_port,
5211 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5212 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5213 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5214 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5215 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5216 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5217 (cmdline_parse_inst_t *)&cmd_config_rss,
5218 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5219 (cmdline_parse_inst_t *)&cmd_showport_reta,
5220 (cmdline_parse_inst_t *)&cmd_config_burst,
5221 (cmdline_parse_inst_t *)&cmd_config_thresh,
5222 (cmdline_parse_inst_t *)&cmd_config_threshold,
5223 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5224 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5225 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5226 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5227 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5228 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5229 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5230 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5231 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5232 (cmdline_parse_inst_t *)&cmd_dump,
5233 (cmdline_parse_inst_t *)&cmd_dump_one,
5237 /* prompt function, called from main on MASTER lcore */
5243 /* initialize non-constant commands */
5244 cmd_set_fwd_mode_init();
5246 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5250 cmdline_interact(cl);
5251 cmdline_stdin_exit(cl);
5255 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5257 if (id < nb_ports) {
5258 /* check if need_reconfig has been set to 1 */
5259 if (ports[id].need_reconfig == 0)
5260 ports[id].need_reconfig = dev;
5261 /* check if need_reconfig_queues has been set to 1 */
5262 if (ports[id].need_reconfig_queues == 0)
5263 ports[id].need_reconfig_queues = queue;
5267 for (pid = 0; pid < nb_ports; pid++) {
5268 /* check if need_reconfig has been set to 1 */
5269 if (ports[pid].need_reconfig == 0)
5270 ports[pid].need_reconfig = dev;
5271 /* check if need_reconfig_queues has been set to 1 */
5272 if (ports[pid].need_reconfig_queues == 0)
5273 ports[pid].need_reconfig_queues = queue;
5278 #ifdef RTE_NIC_BYPASS
5280 bypass_is_supported(portid_t port_id)
5282 struct rte_port *port;
5283 struct rte_pci_id *pci_id;
5285 if (port_id >= nb_ports) {
5286 printf("\tPort id must be less than %d.\n", nb_ports);
5290 /* Get the device id. */
5291 port = &ports[port_id];
5292 pci_id = &port->dev_info.pci_dev->id;
5294 /* Check if NIC supports bypass. */
5295 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5299 printf("\tBypass not supported for port_id = %d.\n", port_id);