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;
1128 if (!all_ports_stopped()) {
1129 printf("Please stop all ports first\n");
1133 if (!strcmp(res->value, "ip"))
1134 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1135 else if (!strcmp(res->value, "udp"))
1136 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1137 else if (!strcmp(res->value, "none"))
1140 printf("Unknown parameter\n");
1146 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1149 cmdline_parse_token_string_t cmd_config_rss_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1151 cmdline_parse_token_string_t cmd_config_rss_keyword =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1153 cmdline_parse_token_string_t cmd_config_rss_all =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1155 cmdline_parse_token_string_t cmd_config_rss_name =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1157 cmdline_parse_token_string_t cmd_config_rss_value =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1160 cmdline_parse_inst_t cmd_config_rss = {
1161 .f = cmd_config_rss_parsed,
1163 .help_str = "port config all rss ip|udp|none",
1165 (void *)&cmd_config_rss_port,
1166 (void *)&cmd_config_rss_keyword,
1167 (void *)&cmd_config_rss_all,
1168 (void *)&cmd_config_rss_name,
1169 (void *)&cmd_config_rss_value,
1174 /* *** Configure RSS RETA *** */
1175 struct cmd_config_rss_reta {
1176 cmdline_fixed_string_t port;
1177 cmdline_fixed_string_t keyword;
1179 cmdline_fixed_string_t name;
1180 cmdline_fixed_string_t list_name;
1181 cmdline_fixed_string_t list_of_items;
1185 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1192 const char *p, *p0 = str;
1199 unsigned long int_fld[_NUM_FLD];
1200 char *str_fld[_NUM_FLD];
1202 while ((p = strchr(p0,'(')) != NULL) {
1204 if((p0 = strchr(p,')')) == NULL)
1208 if(size >= sizeof(s))
1211 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1212 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1214 for (i = 0; i < _NUM_FLD; i++) {
1216 int_fld[i] = strtoul(str_fld[i], &end, 0);
1217 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1221 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1222 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1224 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1225 printf("Invalid RETA hash index=%d",hash_index);
1229 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1230 reta_conf->mask_lo |= (1ULL << hash_index);
1232 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1234 reta_conf->reta[hash_index] = nb_queue;
1241 cmd_set_rss_reta_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1246 struct rte_eth_rss_reta reta_conf;
1247 struct cmd_config_rss_reta *res = parsed_result;
1249 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1250 if (!strcmp(res->list_name, "reta")) {
1251 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1252 printf("Invalid RSS Redirection Table config entered\n");
1255 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1257 printf("Bad redirection table parameter, return code = %d \n",ret);
1261 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1262 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1263 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1265 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1266 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1267 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1269 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1271 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1274 cmdline_parse_inst_t cmd_config_rss_reta = {
1275 .f = cmd_set_rss_reta_parsed,
1277 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1279 (void *)&cmd_config_rss_reta_port,
1280 (void *)&cmd_config_rss_reta_keyword,
1281 (void *)&cmd_config_rss_reta_port_id,
1282 (void *)&cmd_config_rss_reta_name,
1283 (void *)&cmd_config_rss_reta_list_name,
1284 (void *)&cmd_config_rss_reta_list_of_items,
1289 /* *** SHOW PORT RETA INFO *** */
1290 struct cmd_showport_reta {
1291 cmdline_fixed_string_t show;
1292 cmdline_fixed_string_t port;
1294 cmdline_fixed_string_t rss;
1295 cmdline_fixed_string_t reta;
1300 static void cmd_showport_reta_parsed(void *parsed_result,
1301 __attribute__((unused)) struct cmdline *cl,
1302 __attribute__((unused)) void *data)
1304 struct cmd_showport_reta *res = parsed_result;
1305 struct rte_eth_rss_reta reta_conf;
1307 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1308 printf("Invalid RSS Redirection Table config entered\n");
1312 reta_conf.mask_lo = res->mask_lo;
1313 reta_conf.mask_hi = res->mask_hi;
1315 port_rss_reta_info(res->port_id,&reta_conf);
1318 cmdline_parse_token_string_t cmd_showport_reta_show =
1319 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1320 cmdline_parse_token_string_t cmd_showport_reta_port =
1321 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1322 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1323 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1324 cmdline_parse_token_string_t cmd_showport_reta_rss =
1325 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1326 cmdline_parse_token_string_t cmd_showport_reta_reta =
1327 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1328 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1329 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1330 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1331 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1333 cmdline_parse_inst_t cmd_showport_reta = {
1334 .f = cmd_showport_reta_parsed,
1336 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1337 (mask_lo and mask_hi is UINT64)",
1339 (void *)&cmd_showport_reta_show,
1340 (void *)&cmd_showport_reta_port,
1341 (void *)&cmd_showport_reta_port_id,
1342 (void *)&cmd_showport_reta_rss,
1343 (void *)&cmd_showport_reta_reta,
1344 (void *)&cmd_showport_reta_mask_lo,
1345 (void *)&cmd_showport_reta_mask_hi,
1350 /* *** Configure DCB *** */
1351 struct cmd_config_dcb {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t config;
1355 cmdline_fixed_string_t dcb;
1356 cmdline_fixed_string_t vt;
1357 cmdline_fixed_string_t vt_en;
1359 cmdline_fixed_string_t pfc;
1360 cmdline_fixed_string_t pfc_en;
1364 cmd_config_dcb_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_config_dcb *res = parsed_result;
1369 struct dcb_config dcb_conf;
1370 portid_t port_id = res->port_id;
1371 struct rte_port *port;
1373 port = &ports[port_id];
1374 /** Check if the port is not started **/
1375 if (port->port_status != RTE_PORT_STOPPED) {
1376 printf("Please stop port %d first\n",port_id);
1380 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1381 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1382 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1386 /* DCB in VT mode */
1387 if (!strncmp(res->vt_en, "on",2))
1388 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1390 dcb_conf.dcb_mode = DCB_ENABLED;
1392 if (!strncmp(res->pfc_en, "on",2)) {
1393 dcb_conf.pfc_en = 1;
1396 dcb_conf.pfc_en = 0;
1398 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1399 printf("Cannot initialize network ports\n");
1403 cmd_reconfig_device_queue(port_id, 1, 1);
1406 cmdline_parse_token_string_t cmd_config_dcb_port =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1408 cmdline_parse_token_string_t cmd_config_dcb_config =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1410 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1411 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1412 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1413 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1414 cmdline_parse_token_string_t cmd_config_dcb_vt =
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1416 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1418 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1419 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1420 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1422 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1425 cmdline_parse_inst_t cmd_config_dcb = {
1426 .f = cmd_config_dcb_parsed,
1428 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1430 (void *)&cmd_config_dcb_port,
1431 (void *)&cmd_config_dcb_config,
1432 (void *)&cmd_config_dcb_port_id,
1433 (void *)&cmd_config_dcb_dcb,
1434 (void *)&cmd_config_dcb_vt,
1435 (void *)&cmd_config_dcb_vt_en,
1436 (void *)&cmd_config_dcb_num_tcs,
1437 (void *)&cmd_config_dcb_pfc,
1438 (void *)&cmd_config_dcb_pfc_en,
1443 /* *** configure number of packets per burst *** */
1444 struct cmd_config_burst {
1445 cmdline_fixed_string_t port;
1446 cmdline_fixed_string_t keyword;
1447 cmdline_fixed_string_t all;
1448 cmdline_fixed_string_t name;
1453 cmd_config_burst_parsed(void *parsed_result,
1454 __attribute__((unused)) struct cmdline *cl,
1455 __attribute__((unused)) void *data)
1457 struct cmd_config_burst *res = parsed_result;
1459 if (!all_ports_stopped()) {
1460 printf("Please stop all ports first\n");
1464 if (!strcmp(res->name, "burst")) {
1465 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1466 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1469 nb_pkt_per_burst = res->value;
1471 printf("Unknown parameter\n");
1477 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1480 cmdline_parse_token_string_t cmd_config_burst_port =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1482 cmdline_parse_token_string_t cmd_config_burst_keyword =
1483 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1484 cmdline_parse_token_string_t cmd_config_burst_all =
1485 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1486 cmdline_parse_token_string_t cmd_config_burst_name =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1488 cmdline_parse_token_num_t cmd_config_burst_value =
1489 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1491 cmdline_parse_inst_t cmd_config_burst = {
1492 .f = cmd_config_burst_parsed,
1494 .help_str = "port config all burst value",
1496 (void *)&cmd_config_burst_port,
1497 (void *)&cmd_config_burst_keyword,
1498 (void *)&cmd_config_burst_all,
1499 (void *)&cmd_config_burst_name,
1500 (void *)&cmd_config_burst_value,
1505 /* *** configure rx/tx queues *** */
1506 struct cmd_config_thresh {
1507 cmdline_fixed_string_t port;
1508 cmdline_fixed_string_t keyword;
1509 cmdline_fixed_string_t all;
1510 cmdline_fixed_string_t name;
1515 cmd_config_thresh_parsed(void *parsed_result,
1516 __attribute__((unused)) struct cmdline *cl,
1517 __attribute__((unused)) void *data)
1519 struct cmd_config_thresh *res = parsed_result;
1521 if (!all_ports_stopped()) {
1522 printf("Please stop all ports first\n");
1526 if (!strcmp(res->name, "txpt"))
1527 tx_thresh.pthresh = res->value;
1528 else if(!strcmp(res->name, "txht"))
1529 tx_thresh.hthresh = res->value;
1530 else if(!strcmp(res->name, "txwt"))
1531 tx_thresh.wthresh = res->value;
1532 else if(!strcmp(res->name, "rxpt"))
1533 rx_thresh.pthresh = res->value;
1534 else if(!strcmp(res->name, "rxht"))
1535 rx_thresh.hthresh = res->value;
1536 else if(!strcmp(res->name, "rxwt"))
1537 rx_thresh.wthresh = res->value;
1539 printf("Unknown parameter\n");
1545 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1548 cmdline_parse_token_string_t cmd_config_thresh_port =
1549 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1550 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1551 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1552 cmdline_parse_token_string_t cmd_config_thresh_all =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1554 cmdline_parse_token_string_t cmd_config_thresh_name =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1556 "txpt#txht#txwt#rxpt#rxht#rxwt");
1557 cmdline_parse_token_num_t cmd_config_thresh_value =
1558 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1560 cmdline_parse_inst_t cmd_config_thresh = {
1561 .f = cmd_config_thresh_parsed,
1563 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1565 (void *)&cmd_config_thresh_port,
1566 (void *)&cmd_config_thresh_keyword,
1567 (void *)&cmd_config_thresh_all,
1568 (void *)&cmd_config_thresh_name,
1569 (void *)&cmd_config_thresh_value,
1574 /* *** configure free/rs threshold *** */
1575 struct cmd_config_threshold {
1576 cmdline_fixed_string_t port;
1577 cmdline_fixed_string_t keyword;
1578 cmdline_fixed_string_t all;
1579 cmdline_fixed_string_t name;
1584 cmd_config_threshold_parsed(void *parsed_result,
1585 __attribute__((unused)) struct cmdline *cl,
1586 __attribute__((unused)) void *data)
1588 struct cmd_config_threshold *res = parsed_result;
1590 if (!all_ports_stopped()) {
1591 printf("Please stop all ports first\n");
1595 if (!strcmp(res->name, "txfreet"))
1596 tx_free_thresh = res->value;
1597 else if (!strcmp(res->name, "txrst"))
1598 tx_rs_thresh = res->value;
1599 else if (!strcmp(res->name, "rxfreet"))
1600 rx_free_thresh = res->value;
1602 printf("Unknown parameter\n");
1608 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1611 cmdline_parse_token_string_t cmd_config_threshold_port =
1612 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1613 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1614 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1616 cmdline_parse_token_string_t cmd_config_threshold_all =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1618 cmdline_parse_token_string_t cmd_config_threshold_name =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1620 "txfreet#txrst#rxfreet");
1621 cmdline_parse_token_num_t cmd_config_threshold_value =
1622 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1624 cmdline_parse_inst_t cmd_config_threshold = {
1625 .f = cmd_config_threshold_parsed,
1627 .help_str = "port config all txfreet|txrst|rxfreet value",
1629 (void *)&cmd_config_threshold_port,
1630 (void *)&cmd_config_threshold_keyword,
1631 (void *)&cmd_config_threshold_all,
1632 (void *)&cmd_config_threshold_name,
1633 (void *)&cmd_config_threshold_value,
1639 struct cmd_stop_result {
1640 cmdline_fixed_string_t stop;
1643 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1644 __attribute__((unused)) struct cmdline *cl,
1645 __attribute__((unused)) void *data)
1647 stop_packet_forwarding();
1650 cmdline_parse_token_string_t cmd_stop_stop =
1651 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1653 cmdline_parse_inst_t cmd_stop = {
1654 .f = cmd_stop_parsed,
1656 .help_str = "stop - stop packet forwarding",
1658 (void *)&cmd_stop_stop,
1663 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1666 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1667 unsigned int *parsed_items, int check_unique_values)
1669 unsigned int nb_item;
1677 * First parse all items in the list and store their value.
1682 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1684 if ((c >= '0') && (c <= '9')) {
1685 value = (unsigned int) (value * 10 + (c - '0'));
1690 printf("character %c is not a decimal digit\n", c);
1694 printf("No valid value before comma\n");
1697 if (nb_item < max_items) {
1698 parsed_items[nb_item] = value;
1704 if (nb_item >= max_items) {
1705 printf("Number of %s = %u > %u (maximum items)\n",
1706 item_name, nb_item + 1, max_items);
1709 parsed_items[nb_item++] = value;
1710 if (! check_unique_values)
1714 * Then, check that all values in the list are differents.
1715 * No optimization here...
1717 for (i = 0; i < nb_item; i++) {
1718 for (j = i + 1; j < nb_item; j++) {
1719 if (parsed_items[j] == parsed_items[i]) {
1720 printf("duplicated %s %u at index %u and %u\n",
1721 item_name, parsed_items[i], i, j);
1729 struct cmd_set_list_result {
1730 cmdline_fixed_string_t cmd_keyword;
1731 cmdline_fixed_string_t list_name;
1732 cmdline_fixed_string_t list_of_items;
1735 static void cmd_set_list_parsed(void *parsed_result,
1736 __attribute__((unused)) struct cmdline *cl,
1737 __attribute__((unused)) void *data)
1739 struct cmd_set_list_result *res;
1741 unsigned int lcorelist[RTE_MAX_LCORE];
1742 unsigned int portlist[RTE_MAX_ETHPORTS];
1744 unsigned int nb_item;
1746 res = parsed_result;
1747 if (!strcmp(res->list_name, "corelist")) {
1748 nb_item = parse_item_list(res->list_of_items, "core",
1750 parsed_items.lcorelist, 1);
1752 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1755 if (!strcmp(res->list_name, "portlist")) {
1756 nb_item = parse_item_list(res->list_of_items, "port",
1758 parsed_items.portlist, 1);
1760 set_fwd_ports_list(parsed_items.portlist, nb_item);
1764 cmdline_parse_token_string_t cmd_set_list_keyword =
1765 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1767 cmdline_parse_token_string_t cmd_set_list_name =
1768 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1769 "corelist#portlist");
1770 cmdline_parse_token_string_t cmd_set_list_of_items =
1771 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1774 cmdline_parse_inst_t cmd_set_fwd_list = {
1775 .f = cmd_set_list_parsed,
1777 .help_str = "set corelist|portlist x[,y]*",
1779 (void *)&cmd_set_list_keyword,
1780 (void *)&cmd_set_list_name,
1781 (void *)&cmd_set_list_of_items,
1786 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1788 struct cmd_setmask_result {
1789 cmdline_fixed_string_t set;
1790 cmdline_fixed_string_t mask;
1794 static void cmd_set_mask_parsed(void *parsed_result,
1795 __attribute__((unused)) struct cmdline *cl,
1796 __attribute__((unused)) void *data)
1798 struct cmd_setmask_result *res = parsed_result;
1800 if (!strcmp(res->mask, "coremask"))
1801 set_fwd_lcores_mask(res->hexavalue);
1802 else if (!strcmp(res->mask, "portmask"))
1803 set_fwd_ports_mask(res->hexavalue);
1806 cmdline_parse_token_string_t cmd_setmask_set =
1807 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1808 cmdline_parse_token_string_t cmd_setmask_mask =
1809 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1810 "coremask#portmask");
1811 cmdline_parse_token_num_t cmd_setmask_value =
1812 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1814 cmdline_parse_inst_t cmd_set_fwd_mask = {
1815 .f = cmd_set_mask_parsed,
1817 .help_str = "set coremask|portmask hexadecimal value",
1819 (void *)&cmd_setmask_set,
1820 (void *)&cmd_setmask_mask,
1821 (void *)&cmd_setmask_value,
1827 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1829 struct cmd_set_result {
1830 cmdline_fixed_string_t set;
1831 cmdline_fixed_string_t what;
1835 static void cmd_set_parsed(void *parsed_result,
1836 __attribute__((unused)) struct cmdline *cl,
1837 __attribute__((unused)) void *data)
1839 struct cmd_set_result *res = parsed_result;
1840 if (!strcmp(res->what, "nbport"))
1841 set_fwd_ports_number(res->value);
1842 else if (!strcmp(res->what, "nbcore"))
1843 set_fwd_lcores_number(res->value);
1844 else if (!strcmp(res->what, "burst"))
1845 set_nb_pkt_per_burst(res->value);
1846 else if (!strcmp(res->what, "verbose"))
1847 set_verbose_level(res->value);
1850 cmdline_parse_token_string_t cmd_set_set =
1851 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1852 cmdline_parse_token_string_t cmd_set_what =
1853 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1854 "nbport#nbcore#burst#verbose");
1855 cmdline_parse_token_num_t cmd_set_value =
1856 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1858 cmdline_parse_inst_t cmd_set_numbers = {
1859 .f = cmd_set_parsed,
1861 .help_str = "set nbport|nbcore|burst|verbose value",
1863 (void *)&cmd_set_set,
1864 (void *)&cmd_set_what,
1865 (void *)&cmd_set_value,
1870 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1872 struct cmd_set_txpkts_result {
1873 cmdline_fixed_string_t cmd_keyword;
1874 cmdline_fixed_string_t txpkts;
1875 cmdline_fixed_string_t seg_lengths;
1879 cmd_set_txpkts_parsed(void *parsed_result,
1880 __attribute__((unused)) struct cmdline *cl,
1881 __attribute__((unused)) void *data)
1883 struct cmd_set_txpkts_result *res;
1884 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1885 unsigned int nb_segs;
1887 res = parsed_result;
1888 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1889 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1891 set_tx_pkt_segments(seg_lengths, nb_segs);
1894 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1896 cmd_keyword, "set");
1897 cmdline_parse_token_string_t cmd_set_txpkts_name =
1898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1900 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1901 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1904 cmdline_parse_inst_t cmd_set_txpkts = {
1905 .f = cmd_set_txpkts_parsed,
1907 .help_str = "set txpkts x[,y]*",
1909 (void *)&cmd_set_txpkts_keyword,
1910 (void *)&cmd_set_txpkts_name,
1911 (void *)&cmd_set_txpkts_lengths,
1916 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1917 struct cmd_rx_vlan_filter_all_result {
1918 cmdline_fixed_string_t rx_vlan;
1919 cmdline_fixed_string_t what;
1920 cmdline_fixed_string_t all;
1925 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1926 __attribute__((unused)) struct cmdline *cl,
1927 __attribute__((unused)) void *data)
1929 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1931 if (!strcmp(res->what, "add"))
1932 rx_vlan_all_filter_set(res->port_id, 1);
1934 rx_vlan_all_filter_set(res->port_id, 0);
1937 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1938 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1939 rx_vlan, "rx_vlan");
1940 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1941 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1943 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1944 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1946 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1947 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1950 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1951 .f = cmd_rx_vlan_filter_all_parsed,
1953 .help_str = "add/remove all identifiers to/from the set of VLAN "
1954 "Identifiers filtered by a port",
1956 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1957 (void *)&cmd_rx_vlan_filter_all_what,
1958 (void *)&cmd_rx_vlan_filter_all_all,
1959 (void *)&cmd_rx_vlan_filter_all_portid,
1964 /* *** VLAN OFFLOAD SET ON A PORT *** */
1965 struct cmd_vlan_offload_result {
1966 cmdline_fixed_string_t vlan;
1967 cmdline_fixed_string_t set;
1968 cmdline_fixed_string_t what;
1969 cmdline_fixed_string_t on;
1970 cmdline_fixed_string_t port_id;
1974 cmd_vlan_offload_parsed(void *parsed_result,
1975 __attribute__((unused)) struct cmdline *cl,
1976 __attribute__((unused)) void *data)
1979 struct cmd_vlan_offload_result *res = parsed_result;
1982 portid_t port_id = 0;
1986 len = strnlen(str, STR_TOKEN_SIZE);
1988 /* Get port_id first */
1996 tmp = strtoul(str, NULL, 0);
1997 /* If port_id greater that what portid_t can represent, return */
1998 if(tmp >= RTE_MAX_ETHPORTS)
2000 port_id = (portid_t)tmp;
2002 if (!strcmp(res->on, "on"))
2007 if (!strcmp(res->what, "strip"))
2008 rx_vlan_strip_set(port_id, on);
2009 else if(!strcmp(res->what, "stripq")){
2010 uint16_t queue_id = 0;
2012 /* No queue_id, return */
2014 printf("must specify (port,queue_id)\n");
2017 tmp = strtoul(str + i + 1, NULL, 0);
2018 /* If queue_id greater that what 16-bits can represent, return */
2022 queue_id = (uint16_t)tmp;
2023 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2025 else if (!strcmp(res->what, "filter"))
2026 rx_vlan_filter_set(port_id, on);
2028 vlan_extend_set(port_id, on);
2033 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2034 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2036 cmdline_parse_token_string_t cmd_vlan_offload_set =
2037 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2039 cmdline_parse_token_string_t cmd_vlan_offload_what =
2040 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2041 what, "strip#filter#qinq#stripq");
2042 cmdline_parse_token_string_t cmd_vlan_offload_on =
2043 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2045 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2046 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2049 cmdline_parse_inst_t cmd_vlan_offload = {
2050 .f = cmd_vlan_offload_parsed,
2052 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2053 " qinq(extended) for both rx/tx sides ",
2055 (void *)&cmd_vlan_offload_vlan,
2056 (void *)&cmd_vlan_offload_set,
2057 (void *)&cmd_vlan_offload_what,
2058 (void *)&cmd_vlan_offload_on,
2059 (void *)&cmd_vlan_offload_portid,
2064 /* *** VLAN TPID SET ON A PORT *** */
2065 struct cmd_vlan_tpid_result {
2066 cmdline_fixed_string_t vlan;
2067 cmdline_fixed_string_t set;
2068 cmdline_fixed_string_t what;
2074 cmd_vlan_tpid_parsed(void *parsed_result,
2075 __attribute__((unused)) struct cmdline *cl,
2076 __attribute__((unused)) void *data)
2078 struct cmd_vlan_tpid_result *res = parsed_result;
2079 vlan_tpid_set(res->port_id, res->tp_id);
2083 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2086 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2089 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2090 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2092 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2095 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2096 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2099 cmdline_parse_inst_t cmd_vlan_tpid = {
2100 .f = cmd_vlan_tpid_parsed,
2102 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2104 (void *)&cmd_vlan_tpid_vlan,
2105 (void *)&cmd_vlan_tpid_set,
2106 (void *)&cmd_vlan_tpid_what,
2107 (void *)&cmd_vlan_tpid_tpid,
2108 (void *)&cmd_vlan_tpid_portid,
2113 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2114 struct cmd_rx_vlan_filter_result {
2115 cmdline_fixed_string_t rx_vlan;
2116 cmdline_fixed_string_t what;
2122 cmd_rx_vlan_filter_parsed(void *parsed_result,
2123 __attribute__((unused)) struct cmdline *cl,
2124 __attribute__((unused)) void *data)
2126 struct cmd_rx_vlan_filter_result *res = parsed_result;
2128 if (!strcmp(res->what, "add"))
2129 rx_vft_set(res->port_id, res->vlan_id, 1);
2131 rx_vft_set(res->port_id, res->vlan_id, 0);
2134 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2135 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2136 rx_vlan, "rx_vlan");
2137 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2138 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2140 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2141 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2143 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2144 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2147 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2148 .f = cmd_rx_vlan_filter_parsed,
2150 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2151 "Identifiers filtered by a port",
2153 (void *)&cmd_rx_vlan_filter_rx_vlan,
2154 (void *)&cmd_rx_vlan_filter_what,
2155 (void *)&cmd_rx_vlan_filter_vlanid,
2156 (void *)&cmd_rx_vlan_filter_portid,
2161 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2162 struct cmd_tx_vlan_set_result {
2163 cmdline_fixed_string_t tx_vlan;
2164 cmdline_fixed_string_t set;
2170 cmd_tx_vlan_set_parsed(void *parsed_result,
2171 __attribute__((unused)) struct cmdline *cl,
2172 __attribute__((unused)) void *data)
2174 struct cmd_tx_vlan_set_result *res = parsed_result;
2175 tx_vlan_set(res->port_id, res->vlan_id);
2178 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2179 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2180 tx_vlan, "tx_vlan");
2181 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2182 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2184 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2185 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2187 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2188 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2191 cmdline_parse_inst_t cmd_tx_vlan_set = {
2192 .f = cmd_tx_vlan_set_parsed,
2194 .help_str = "enable hardware insertion of a VLAN header with a given "
2195 "TAG Identifier in packets sent on a port",
2197 (void *)&cmd_tx_vlan_set_tx_vlan,
2198 (void *)&cmd_tx_vlan_set_set,
2199 (void *)&cmd_tx_vlan_set_vlanid,
2200 (void *)&cmd_tx_vlan_set_portid,
2205 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2206 struct cmd_tx_vlan_reset_result {
2207 cmdline_fixed_string_t tx_vlan;
2208 cmdline_fixed_string_t reset;
2213 cmd_tx_vlan_reset_parsed(void *parsed_result,
2214 __attribute__((unused)) struct cmdline *cl,
2215 __attribute__((unused)) void *data)
2217 struct cmd_tx_vlan_reset_result *res = parsed_result;
2219 tx_vlan_reset(res->port_id);
2222 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2224 tx_vlan, "tx_vlan");
2225 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2226 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2228 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2229 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2232 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2233 .f = cmd_tx_vlan_reset_parsed,
2235 .help_str = "disable hardware insertion of a VLAN header in packets "
2238 (void *)&cmd_tx_vlan_reset_tx_vlan,
2239 (void *)&cmd_tx_vlan_reset_reset,
2240 (void *)&cmd_tx_vlan_reset_portid,
2246 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2247 struct cmd_tx_cksum_set_result {
2248 cmdline_fixed_string_t tx_cksum;
2249 cmdline_fixed_string_t set;
2255 cmd_tx_cksum_set_parsed(void *parsed_result,
2256 __attribute__((unused)) struct cmdline *cl,
2257 __attribute__((unused)) void *data)
2259 struct cmd_tx_cksum_set_result *res = parsed_result;
2261 tx_cksum_set(res->port_id, res->cksum_mask);
2264 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2265 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2266 tx_cksum, "tx_checksum");
2267 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2268 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2270 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2271 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2273 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2274 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2277 cmdline_parse_inst_t cmd_tx_cksum_set = {
2278 .f = cmd_tx_cksum_set_parsed,
2280 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2281 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2282 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2284 (void *)&cmd_tx_cksum_set_tx_cksum,
2285 (void *)&cmd_tx_cksum_set_set,
2286 (void *)&cmd_tx_cksum_set_cksum_mask,
2287 (void *)&cmd_tx_cksum_set_portid,
2292 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2293 struct cmd_set_flush_rx {
2294 cmdline_fixed_string_t set;
2295 cmdline_fixed_string_t flush_rx;
2296 cmdline_fixed_string_t mode;
2300 cmd_set_flush_rx_parsed(void *parsed_result,
2301 __attribute__((unused)) struct cmdline *cl,
2302 __attribute__((unused)) void *data)
2304 struct cmd_set_flush_rx *res = parsed_result;
2305 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2308 cmdline_parse_token_string_t cmd_setflushrx_set =
2309 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2311 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2312 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2313 flush_rx, "flush_rx");
2314 cmdline_parse_token_string_t cmd_setflushrx_mode =
2315 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2319 cmdline_parse_inst_t cmd_set_flush_rx = {
2320 .f = cmd_set_flush_rx_parsed,
2321 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2324 (void *)&cmd_setflushrx_set,
2325 (void *)&cmd_setflushrx_flush_rx,
2326 (void *)&cmd_setflushrx_mode,
2331 #ifdef RTE_NIC_BYPASS
2332 /* *** SET NIC BYPASS MODE *** */
2333 struct cmd_set_bypass_mode_result {
2334 cmdline_fixed_string_t set;
2335 cmdline_fixed_string_t bypass;
2336 cmdline_fixed_string_t mode;
2337 cmdline_fixed_string_t value;
2342 cmd_set_bypass_mode_parsed(void *parsed_result,
2343 __attribute__((unused)) struct cmdline *cl,
2344 __attribute__((unused)) void *data)
2346 struct cmd_set_bypass_mode_result *res = parsed_result;
2347 portid_t port_id = res->port_id;
2348 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2350 if (!bypass_is_supported(port_id))
2353 if (!strcmp(res->value, "bypass"))
2354 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2355 else if (!strcmp(res->value, "isolate"))
2356 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2358 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2360 /* Set the bypass mode for the relevant port. */
2361 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2362 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2366 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2369 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2372 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2375 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2377 value, "normal#bypass#isolate");
2378 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2379 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2382 cmdline_parse_inst_t cmd_set_bypass_mode = {
2383 .f = cmd_set_bypass_mode_parsed,
2384 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2385 "Set the NIC bypass mode for port_id",
2388 (void *)&cmd_setbypass_mode_set,
2389 (void *)&cmd_setbypass_mode_bypass,
2390 (void *)&cmd_setbypass_mode_mode,
2391 (void *)&cmd_setbypass_mode_value,
2392 (void *)&cmd_setbypass_mode_port,
2397 /* *** SET NIC BYPASS EVENT *** */
2398 struct cmd_set_bypass_event_result {
2399 cmdline_fixed_string_t set;
2400 cmdline_fixed_string_t bypass;
2401 cmdline_fixed_string_t event;
2402 cmdline_fixed_string_t event_value;
2403 cmdline_fixed_string_t mode;
2404 cmdline_fixed_string_t mode_value;
2409 cmd_set_bypass_event_parsed(void *parsed_result,
2410 __attribute__((unused)) struct cmdline *cl,
2411 __attribute__((unused)) void *data)
2414 struct cmd_set_bypass_event_result *res = parsed_result;
2415 portid_t port_id = res->port_id;
2416 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2417 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2419 if (!bypass_is_supported(port_id))
2422 if (!strcmp(res->event_value, "timeout"))
2423 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2424 else if (!strcmp(res->event_value, "os_on"))
2425 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2426 else if (!strcmp(res->event_value, "os_off"))
2427 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2428 else if (!strcmp(res->event_value, "power_on"))
2429 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2430 else if (!strcmp(res->event_value, "power_off"))
2431 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2433 bypass_event = RTE_BYPASS_EVENT_NONE;
2435 if (!strcmp(res->mode_value, "bypass"))
2436 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2437 else if (!strcmp(res->mode_value, "isolate"))
2438 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2440 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2442 /* Set the watchdog timeout. */
2443 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2446 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2447 (rc = rte_eth_dev_wd_timeout_store(port_id,
2448 bypass_timeout)) != 0) {
2449 printf("Failed to set timeout value %u "
2450 "for port %d, errto code: %d.\n",
2451 bypass_timeout, port_id, rc);
2455 /* Set the bypass event to transition to bypass mode. */
2456 if (0 != rte_eth_dev_bypass_event_store(port_id,
2457 bypass_event, bypass_mode)) {
2458 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2463 cmdline_parse_token_string_t cmd_setbypass_event_set =
2464 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2466 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2469 cmdline_parse_token_string_t cmd_setbypass_event_event =
2470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2472 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2474 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2475 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2478 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2479 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2480 mode_value, "normal#bypass#isolate");
2481 cmdline_parse_token_num_t cmd_setbypass_event_port =
2482 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2485 cmdline_parse_inst_t cmd_set_bypass_event = {
2486 .f = cmd_set_bypass_event_parsed,
2487 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2488 "mode (normal|bypass|isolate) (port_id): "
2489 "Set the NIC bypass event mode for port_id",
2492 (void *)&cmd_setbypass_event_set,
2493 (void *)&cmd_setbypass_event_bypass,
2494 (void *)&cmd_setbypass_event_event,
2495 (void *)&cmd_setbypass_event_event_value,
2496 (void *)&cmd_setbypass_event_mode,
2497 (void *)&cmd_setbypass_event_mode_value,
2498 (void *)&cmd_setbypass_event_port,
2504 /* *** SET NIC BYPASS TIMEOUT *** */
2505 struct cmd_set_bypass_timeout_result {
2506 cmdline_fixed_string_t set;
2507 cmdline_fixed_string_t bypass;
2508 cmdline_fixed_string_t timeout;
2509 cmdline_fixed_string_t value;
2513 cmd_set_bypass_timeout_parsed(void *parsed_result,
2514 __attribute__((unused)) struct cmdline *cl,
2515 __attribute__((unused)) void *data)
2517 struct cmd_set_bypass_timeout_result *res = parsed_result;
2519 if (!strcmp(res->value, "1.5"))
2520 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2521 else if (!strcmp(res->value, "2"))
2522 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2523 else if (!strcmp(res->value, "3"))
2524 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2525 else if (!strcmp(res->value, "4"))
2526 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2527 else if (!strcmp(res->value, "8"))
2528 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2529 else if (!strcmp(res->value, "16"))
2530 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2531 else if (!strcmp(res->value, "32"))
2532 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2534 bypass_timeout = RTE_BYPASS_TMT_OFF;
2537 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2540 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2543 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2545 timeout, "timeout");
2546 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2548 value, "0#1.5#2#3#4#8#16#32");
2550 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2551 .f = cmd_set_bypass_timeout_parsed,
2552 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2553 "Set the NIC bypass watchdog timeout",
2556 (void *)&cmd_setbypass_timeout_set,
2557 (void *)&cmd_setbypass_timeout_bypass,
2558 (void *)&cmd_setbypass_timeout_timeout,
2559 (void *)&cmd_setbypass_timeout_value,
2564 /* *** SHOW NIC BYPASS MODE *** */
2565 struct cmd_show_bypass_config_result {
2566 cmdline_fixed_string_t show;
2567 cmdline_fixed_string_t bypass;
2568 cmdline_fixed_string_t config;
2573 cmd_show_bypass_config_parsed(void *parsed_result,
2574 __attribute__((unused)) struct cmdline *cl,
2575 __attribute__((unused)) void *data)
2577 struct cmd_show_bypass_config_result *res = parsed_result;
2578 uint32_t event_mode;
2579 uint32_t bypass_mode;
2580 portid_t port_id = res->port_id;
2581 uint32_t timeout = bypass_timeout;
2584 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2585 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2586 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2587 {"UNKNOWN", "normal", "bypass", "isolate"};
2588 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2595 int num_events = (sizeof events) / (sizeof events[0]);
2597 if (!bypass_is_supported(port_id))
2600 /* Display the bypass mode.*/
2601 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2602 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2606 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2607 bypass_mode = RTE_BYPASS_MODE_NONE;
2609 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2612 /* Display the bypass timeout.*/
2613 if (!RTE_BYPASS_TMT_VALID(timeout))
2614 timeout = RTE_BYPASS_TMT_OFF;
2616 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2618 /* Display the bypass events and associated modes. */
2619 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2621 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2622 printf("\tFailed to get bypass mode for event = %s\n",
2625 if (!RTE_BYPASS_MODE_VALID(event_mode))
2626 event_mode = RTE_BYPASS_MODE_NONE;
2628 printf("\tbypass event: %-16s = %s\n", events[i],
2634 cmdline_parse_token_string_t cmd_showbypass_config_show =
2635 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2637 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2638 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2640 cmdline_parse_token_string_t cmd_showbypass_config_config =
2641 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2643 cmdline_parse_token_num_t cmd_showbypass_config_port =
2644 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2647 cmdline_parse_inst_t cmd_show_bypass_config = {
2648 .f = cmd_show_bypass_config_parsed,
2649 .help_str = "show bypass config (port_id): "
2650 "Show the NIC bypass config for port_id",
2653 (void *)&cmd_showbypass_config_show,
2654 (void *)&cmd_showbypass_config_bypass,
2655 (void *)&cmd_showbypass_config_config,
2656 (void *)&cmd_showbypass_config_port,
2662 /* *** SET FORWARDING MODE *** */
2663 struct cmd_set_fwd_mode_result {
2664 cmdline_fixed_string_t set;
2665 cmdline_fixed_string_t fwd;
2666 cmdline_fixed_string_t mode;
2669 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2670 __attribute__((unused)) struct cmdline *cl,
2671 __attribute__((unused)) void *data)
2673 struct cmd_set_fwd_mode_result *res = parsed_result;
2675 set_pkt_forwarding_mode(res->mode);
2678 cmdline_parse_token_string_t cmd_setfwd_set =
2679 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2680 cmdline_parse_token_string_t cmd_setfwd_fwd =
2681 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2682 cmdline_parse_token_string_t cmd_setfwd_mode =
2683 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2684 "" /* defined at init */);
2686 cmdline_parse_inst_t cmd_set_fwd_mode = {
2687 .f = cmd_set_fwd_mode_parsed,
2689 .help_str = NULL, /* defined at init */
2691 (void *)&cmd_setfwd_set,
2692 (void *)&cmd_setfwd_fwd,
2693 (void *)&cmd_setfwd_mode,
2698 static void cmd_set_fwd_mode_init(void)
2701 static char token[128];
2702 static char help[256];
2703 cmdline_parse_token_string_t *token_struct;
2705 modes = list_pkt_forwarding_modes();
2706 rte_snprintf(help, sizeof help, "set fwd %s - "
2707 "set packet forwarding mode", modes);
2708 cmd_set_fwd_mode.help_str = help;
2710 /* string token separator is # */
2711 for (c = token; *modes != '\0'; modes++)
2716 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2717 token_struct->string_data.str = token;
2720 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2721 struct cmd_set_burst_tx_retry_result {
2722 cmdline_fixed_string_t set;
2723 cmdline_fixed_string_t burst;
2724 cmdline_fixed_string_t tx;
2725 cmdline_fixed_string_t delay;
2727 cmdline_fixed_string_t retry;
2731 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2732 __attribute__((unused)) struct cmdline *cl,
2733 __attribute__((unused)) void *data)
2735 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2737 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2738 && !strcmp(res->tx, "tx")) {
2739 if (!strcmp(res->delay, "delay"))
2740 burst_tx_delay_time = res->time;
2741 if (!strcmp(res->retry, "retry"))
2742 burst_tx_retry_num = res->retry_num;
2747 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2749 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2752 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2753 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2754 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2755 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2756 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2757 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2758 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2759 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2760 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2761 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2763 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2764 .f = cmd_set_burst_tx_retry_parsed,
2765 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2767 (void *)&cmd_set_burst_tx_retry_set,
2768 (void *)&cmd_set_burst_tx_retry_burst,
2769 (void *)&cmd_set_burst_tx_retry_tx,
2770 (void *)&cmd_set_burst_tx_retry_delay,
2771 (void *)&cmd_set_burst_tx_retry_time,
2772 (void *)&cmd_set_burst_tx_retry_retry,
2773 (void *)&cmd_set_burst_tx_retry_retry_num,
2778 /* *** SET PROMISC MODE *** */
2779 struct cmd_set_promisc_mode_result {
2780 cmdline_fixed_string_t set;
2781 cmdline_fixed_string_t promisc;
2782 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2783 uint8_t port_num; /* valid if "allports" argument == 0 */
2784 cmdline_fixed_string_t mode;
2787 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2788 __attribute__((unused)) struct cmdline *cl,
2791 struct cmd_set_promisc_mode_result *res = parsed_result;
2795 if (!strcmp(res->mode, "on"))
2802 for (i = 0; i < nb_ports; i++) {
2804 rte_eth_promiscuous_enable(i);
2806 rte_eth_promiscuous_disable(i);
2811 rte_eth_promiscuous_enable(res->port_num);
2813 rte_eth_promiscuous_disable(res->port_num);
2817 cmdline_parse_token_string_t cmd_setpromisc_set =
2818 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2819 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2820 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2822 cmdline_parse_token_string_t cmd_setpromisc_portall =
2823 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2825 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2826 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2828 cmdline_parse_token_string_t cmd_setpromisc_mode =
2829 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2832 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2833 .f = cmd_set_promisc_mode_parsed,
2835 .help_str = "set promisc all on|off: set promisc mode for all ports",
2837 (void *)&cmd_setpromisc_set,
2838 (void *)&cmd_setpromisc_promisc,
2839 (void *)&cmd_setpromisc_portall,
2840 (void *)&cmd_setpromisc_mode,
2845 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2846 .f = cmd_set_promisc_mode_parsed,
2848 .help_str = "set promisc X on|off: set promisc mode on port X",
2850 (void *)&cmd_setpromisc_set,
2851 (void *)&cmd_setpromisc_promisc,
2852 (void *)&cmd_setpromisc_portnum,
2853 (void *)&cmd_setpromisc_mode,
2858 /* *** SET ALLMULTI MODE *** */
2859 struct cmd_set_allmulti_mode_result {
2860 cmdline_fixed_string_t set;
2861 cmdline_fixed_string_t allmulti;
2862 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2863 uint8_t port_num; /* valid if "allports" argument == 0 */
2864 cmdline_fixed_string_t mode;
2867 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2871 struct cmd_set_allmulti_mode_result *res = parsed_result;
2875 if (!strcmp(res->mode, "on"))
2882 for (i = 0; i < nb_ports; i++) {
2884 rte_eth_allmulticast_enable(i);
2886 rte_eth_allmulticast_disable(i);
2891 rte_eth_allmulticast_enable(res->port_num);
2893 rte_eth_allmulticast_disable(res->port_num);
2897 cmdline_parse_token_string_t cmd_setallmulti_set =
2898 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2899 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2900 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2902 cmdline_parse_token_string_t cmd_setallmulti_portall =
2903 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2905 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2906 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2908 cmdline_parse_token_string_t cmd_setallmulti_mode =
2909 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2912 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2913 .f = cmd_set_allmulti_mode_parsed,
2915 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2917 (void *)&cmd_setallmulti_set,
2918 (void *)&cmd_setallmulti_allmulti,
2919 (void *)&cmd_setallmulti_portall,
2920 (void *)&cmd_setallmulti_mode,
2925 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2926 .f = cmd_set_allmulti_mode_parsed,
2928 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2930 (void *)&cmd_setallmulti_set,
2931 (void *)&cmd_setallmulti_allmulti,
2932 (void *)&cmd_setallmulti_portnum,
2933 (void *)&cmd_setallmulti_mode,
2938 /* *** ADD/REMOVE A PKT FILTER *** */
2939 struct cmd_pkt_filter_result {
2940 cmdline_fixed_string_t pkt_filter;
2942 cmdline_fixed_string_t protocol;
2943 cmdline_fixed_string_t src;
2944 cmdline_ipaddr_t ip_src;
2946 cmdline_fixed_string_t dst;
2947 cmdline_ipaddr_t ip_dst;
2949 cmdline_fixed_string_t flexbytes;
2950 uint16_t flexbytes_value;
2951 cmdline_fixed_string_t vlan;
2953 cmdline_fixed_string_t queue;
2955 cmdline_fixed_string_t soft;
2960 cmd_pkt_filter_parsed(void *parsed_result,
2961 __attribute__((unused)) struct cmdline *cl,
2962 __attribute__((unused)) void *data)
2964 struct rte_fdir_filter fdir_filter;
2965 struct cmd_pkt_filter_result *res = parsed_result;
2967 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2969 if (res->ip_src.family == AF_INET)
2970 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2972 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2973 &(res->ip_src.addr.ipv6),
2974 sizeof(struct in6_addr));
2976 if (res->ip_dst.family == AF_INET)
2977 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2979 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2980 &(res->ip_dst.addr.ipv6),
2981 sizeof(struct in6_addr));
2983 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2984 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2986 if (!strcmp(res->protocol, "udp"))
2987 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2988 else if (!strcmp(res->protocol, "tcp"))
2989 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2990 else if (!strcmp(res->protocol, "sctp"))
2991 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2992 else /* default only IP */
2993 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2995 if (res->ip_dst.family == AF_INET6)
2996 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2998 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3000 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3001 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3003 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3004 fdir_add_signature_filter(res->port_id, res->queue_id,
3006 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3007 fdir_update_signature_filter(res->port_id, res->queue_id,
3009 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3010 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3011 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3012 fdir_add_perfect_filter(res->port_id, res->soft_id,
3014 (uint8_t) (res->queue_id < 0),
3016 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3017 fdir_update_perfect_filter(res->port_id, res->soft_id,
3019 (uint8_t) (res->queue_id < 0),
3021 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3022 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3028 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3029 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3031 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3032 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3033 protocol, "ip#tcp#udp#sctp");
3034 cmdline_parse_token_string_t cmd_pkt_filter_src =
3035 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3037 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3038 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3040 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3041 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3043 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3044 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3046 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3047 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3049 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3050 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3052 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3053 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3054 flexbytes, "flexbytes");
3055 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3056 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3057 flexbytes_value, UINT16);
3058 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3059 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3061 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3062 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3064 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3065 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3067 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3068 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3070 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3071 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3073 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3074 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3078 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3079 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3080 pkt_filter, "add_signature_filter");
3081 cmdline_parse_inst_t cmd_add_signature_filter = {
3082 .f = cmd_pkt_filter_parsed,
3084 .help_str = "add a signature filter",
3086 (void *)&cmd_pkt_filter_add_signature_filter,
3087 (void *)&cmd_pkt_filter_port_id,
3088 (void *)&cmd_pkt_filter_protocol,
3089 (void *)&cmd_pkt_filter_src,
3090 (void *)&cmd_pkt_filter_ip_src,
3091 (void *)&cmd_pkt_filter_port_src,
3092 (void *)&cmd_pkt_filter_dst,
3093 (void *)&cmd_pkt_filter_ip_dst,
3094 (void *)&cmd_pkt_filter_port_dst,
3095 (void *)&cmd_pkt_filter_flexbytes,
3096 (void *)&cmd_pkt_filter_flexbytes_value,
3097 (void *)&cmd_pkt_filter_vlan,
3098 (void *)&cmd_pkt_filter_vlan_id,
3099 (void *)&cmd_pkt_filter_queue,
3100 (void *)&cmd_pkt_filter_queue_id,
3106 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3107 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3108 pkt_filter, "upd_signature_filter");
3109 cmdline_parse_inst_t cmd_upd_signature_filter = {
3110 .f = cmd_pkt_filter_parsed,
3112 .help_str = "update a signature filter",
3114 (void *)&cmd_pkt_filter_upd_signature_filter,
3115 (void *)&cmd_pkt_filter_port_id,
3116 (void *)&cmd_pkt_filter_protocol,
3117 (void *)&cmd_pkt_filter_src,
3118 (void *)&cmd_pkt_filter_ip_src,
3119 (void *)&cmd_pkt_filter_port_src,
3120 (void *)&cmd_pkt_filter_dst,
3121 (void *)&cmd_pkt_filter_ip_dst,
3122 (void *)&cmd_pkt_filter_port_dst,
3123 (void *)&cmd_pkt_filter_flexbytes,
3124 (void *)&cmd_pkt_filter_flexbytes_value,
3125 (void *)&cmd_pkt_filter_vlan,
3126 (void *)&cmd_pkt_filter_vlan_id,
3127 (void *)&cmd_pkt_filter_queue,
3128 (void *)&cmd_pkt_filter_queue_id,
3134 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3135 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3136 pkt_filter, "rm_signature_filter");
3137 cmdline_parse_inst_t cmd_rm_signature_filter = {
3138 .f = cmd_pkt_filter_parsed,
3140 .help_str = "remove a signature filter",
3142 (void *)&cmd_pkt_filter_rm_signature_filter,
3143 (void *)&cmd_pkt_filter_port_id,
3144 (void *)&cmd_pkt_filter_protocol,
3145 (void *)&cmd_pkt_filter_src,
3146 (void *)&cmd_pkt_filter_ip_src,
3147 (void *)&cmd_pkt_filter_port_src,
3148 (void *)&cmd_pkt_filter_dst,
3149 (void *)&cmd_pkt_filter_ip_dst,
3150 (void *)&cmd_pkt_filter_port_dst,
3151 (void *)&cmd_pkt_filter_flexbytes,
3152 (void *)&cmd_pkt_filter_flexbytes_value,
3153 (void *)&cmd_pkt_filter_vlan,
3154 (void *)&cmd_pkt_filter_vlan_id,
3160 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3161 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3162 pkt_filter, "add_perfect_filter");
3163 cmdline_parse_inst_t cmd_add_perfect_filter = {
3164 .f = cmd_pkt_filter_parsed,
3166 .help_str = "add a perfect filter",
3168 (void *)&cmd_pkt_filter_add_perfect_filter,
3169 (void *)&cmd_pkt_filter_port_id,
3170 (void *)&cmd_pkt_filter_protocol,
3171 (void *)&cmd_pkt_filter_src,
3172 (void *)&cmd_pkt_filter_ip_src,
3173 (void *)&cmd_pkt_filter_port_src,
3174 (void *)&cmd_pkt_filter_dst,
3175 (void *)&cmd_pkt_filter_ip_dst,
3176 (void *)&cmd_pkt_filter_port_dst,
3177 (void *)&cmd_pkt_filter_flexbytes,
3178 (void *)&cmd_pkt_filter_flexbytes_value,
3179 (void *)&cmd_pkt_filter_vlan,
3180 (void *)&cmd_pkt_filter_vlan_id,
3181 (void *)&cmd_pkt_filter_queue,
3182 (void *)&cmd_pkt_filter_queue_id,
3183 (void *)&cmd_pkt_filter_soft,
3184 (void *)&cmd_pkt_filter_soft_id,
3190 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3191 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3192 pkt_filter, "upd_perfect_filter");
3193 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3194 .f = cmd_pkt_filter_parsed,
3196 .help_str = "update a perfect filter",
3198 (void *)&cmd_pkt_filter_upd_perfect_filter,
3199 (void *)&cmd_pkt_filter_port_id,
3200 (void *)&cmd_pkt_filter_protocol,
3201 (void *)&cmd_pkt_filter_src,
3202 (void *)&cmd_pkt_filter_ip_src,
3203 (void *)&cmd_pkt_filter_port_src,
3204 (void *)&cmd_pkt_filter_dst,
3205 (void *)&cmd_pkt_filter_ip_dst,
3206 (void *)&cmd_pkt_filter_port_dst,
3207 (void *)&cmd_pkt_filter_flexbytes,
3208 (void *)&cmd_pkt_filter_flexbytes_value,
3209 (void *)&cmd_pkt_filter_vlan,
3210 (void *)&cmd_pkt_filter_vlan_id,
3211 (void *)&cmd_pkt_filter_queue,
3212 (void *)&cmd_pkt_filter_queue_id,
3213 (void *)&cmd_pkt_filter_soft,
3214 (void *)&cmd_pkt_filter_soft_id,
3220 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3221 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3222 pkt_filter, "rm_perfect_filter");
3223 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3224 .f = cmd_pkt_filter_parsed,
3226 .help_str = "remove a perfect filter",
3228 (void *)&cmd_pkt_filter_rm_perfect_filter,
3229 (void *)&cmd_pkt_filter_port_id,
3230 (void *)&cmd_pkt_filter_protocol,
3231 (void *)&cmd_pkt_filter_src,
3232 (void *)&cmd_pkt_filter_ip_src,
3233 (void *)&cmd_pkt_filter_port_src,
3234 (void *)&cmd_pkt_filter_dst,
3235 (void *)&cmd_pkt_filter_ip_dst,
3236 (void *)&cmd_pkt_filter_port_dst,
3237 (void *)&cmd_pkt_filter_flexbytes,
3238 (void *)&cmd_pkt_filter_flexbytes_value,
3239 (void *)&cmd_pkt_filter_vlan,
3240 (void *)&cmd_pkt_filter_vlan_id,
3241 (void *)&cmd_pkt_filter_soft,
3242 (void *)&cmd_pkt_filter_soft_id,
3247 /* *** SETUP MASKS FILTER *** */
3248 struct cmd_pkt_filter_masks_result {
3249 cmdline_fixed_string_t filter_mask;
3251 cmdline_fixed_string_t src_mask;
3252 uint32_t ip_src_mask;
3253 uint16_t ipv6_src_mask;
3254 uint16_t port_src_mask;
3255 cmdline_fixed_string_t dst_mask;
3256 uint32_t ip_dst_mask;
3257 uint16_t ipv6_dst_mask;
3258 uint16_t port_dst_mask;
3259 cmdline_fixed_string_t flexbytes;
3260 uint8_t flexbytes_value;
3261 cmdline_fixed_string_t vlan_id;
3262 uint8_t vlan_id_value;
3263 cmdline_fixed_string_t vlan_prio;
3264 uint8_t vlan_prio_value;
3265 cmdline_fixed_string_t only_ip_flow;
3266 uint8_t only_ip_flow_value;
3267 cmdline_fixed_string_t comp_ipv6_dst;
3268 uint8_t comp_ipv6_dst_value;
3272 cmd_pkt_filter_masks_parsed(void *parsed_result,
3273 __attribute__((unused)) struct cmdline *cl,
3274 __attribute__((unused)) void *data)
3276 struct rte_fdir_masks fdir_masks;
3277 struct cmd_pkt_filter_masks_result *res = parsed_result;
3279 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3281 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3282 fdir_masks.vlan_id = res->vlan_id_value;
3283 fdir_masks.vlan_prio = res->vlan_prio_value;
3284 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3285 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3286 fdir_masks.src_port_mask = res->port_src_mask;
3287 fdir_masks.dst_port_mask = res->port_dst_mask;
3288 fdir_masks.flexbytes = res->flexbytes_value;
3290 fdir_set_masks(res->port_id, &fdir_masks);
3293 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3294 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3295 filter_mask, "set_masks_filter");
3296 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3297 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3299 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3300 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3301 only_ip_flow, "only_ip_flow");
3302 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3303 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3304 only_ip_flow_value, UINT8);
3305 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3306 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3307 src_mask, "src_mask");
3308 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3309 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3310 ip_src_mask, UINT32);
3311 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3312 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3313 port_src_mask, UINT16);
3314 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3315 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3316 dst_mask, "dst_mask");
3317 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3318 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3319 ip_dst_mask, UINT32);
3320 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3321 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3322 port_dst_mask, UINT16);
3323 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3324 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3325 flexbytes, "flexbytes");
3326 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3327 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3328 flexbytes_value, UINT8);
3329 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3330 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3331 vlan_id, "vlan_id");
3332 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3333 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3334 vlan_id_value, UINT8);
3335 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3336 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3337 vlan_prio, "vlan_prio");
3338 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3339 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3340 vlan_prio_value, UINT8);
3342 cmdline_parse_inst_t cmd_set_masks_filter = {
3343 .f = cmd_pkt_filter_masks_parsed,
3345 .help_str = "setup masks filter",
3347 (void *)&cmd_pkt_filter_masks_filter_mask,
3348 (void *)&cmd_pkt_filter_masks_port_id,
3349 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3350 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3351 (void *)&cmd_pkt_filter_masks_src_mask,
3352 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3353 (void *)&cmd_pkt_filter_masks_port_src_mask,
3354 (void *)&cmd_pkt_filter_masks_dst_mask,
3355 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3356 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3357 (void *)&cmd_pkt_filter_masks_flexbytes,
3358 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3359 (void *)&cmd_pkt_filter_masks_vlan_id,
3360 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3361 (void *)&cmd_pkt_filter_masks_vlan_prio,
3362 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3368 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3369 __attribute__((unused)) struct cmdline *cl,
3370 __attribute__((unused)) void *data)
3372 struct rte_fdir_masks fdir_masks;
3373 struct cmd_pkt_filter_masks_result *res = parsed_result;
3375 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3377 fdir_masks.set_ipv6_mask = 1;
3378 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3379 fdir_masks.vlan_id = res->vlan_id_value;
3380 fdir_masks.vlan_prio = res->vlan_prio_value;
3381 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3382 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3383 fdir_masks.src_port_mask = res->port_src_mask;
3384 fdir_masks.dst_port_mask = res->port_dst_mask;
3385 fdir_masks.flexbytes = res->flexbytes_value;
3386 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3388 fdir_set_masks(res->port_id, &fdir_masks);
3391 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3392 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3393 filter_mask, "set_ipv6_masks_filter");
3394 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3395 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3396 ipv6_src_mask, UINT16);
3397 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3398 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3399 ipv6_dst_mask, UINT16);
3401 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3402 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3403 comp_ipv6_dst, "compare_dst");
3404 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3405 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3406 comp_ipv6_dst_value, UINT8);
3408 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3409 .f = cmd_pkt_filter_masks_ipv6_parsed,
3411 .help_str = "setup ipv6 masks filter",
3413 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3414 (void *)&cmd_pkt_filter_masks_port_id,
3415 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3416 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3417 (void *)&cmd_pkt_filter_masks_src_mask,
3418 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3419 (void *)&cmd_pkt_filter_masks_port_src_mask,
3420 (void *)&cmd_pkt_filter_masks_dst_mask,
3421 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3422 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3423 (void *)&cmd_pkt_filter_masks_flexbytes,
3424 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3425 (void *)&cmd_pkt_filter_masks_vlan_id,
3426 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3427 (void *)&cmd_pkt_filter_masks_vlan_prio,
3428 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3429 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3430 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3435 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3436 struct cmd_link_flow_ctrl_set_result {
3437 cmdline_fixed_string_t set;
3438 cmdline_fixed_string_t flow_ctrl;
3439 cmdline_fixed_string_t rx;
3440 cmdline_fixed_string_t rx_lfc_mode;
3441 cmdline_fixed_string_t tx;
3442 cmdline_fixed_string_t tx_lfc_mode;
3443 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3444 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3445 uint32_t high_water;
3447 uint16_t pause_time;
3453 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3458 struct rte_eth_fc_conf fc_conf;
3459 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3463 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3464 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3465 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3466 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3468 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3469 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3472 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3473 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3474 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3476 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3477 fc_conf.high_water = res->high_water;
3478 fc_conf.low_water = res->low_water;
3479 fc_conf.pause_time = res->pause_time;
3480 fc_conf.send_xon = res->send_xon;
3481 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3483 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3485 printf("bad flow contrl parameter, return code = %d \n", ret);
3488 cmdline_parse_token_string_t cmd_lfc_set_set =
3489 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3491 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3492 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3493 flow_ctrl, "flow_ctrl");
3494 cmdline_parse_token_string_t cmd_lfc_set_rx =
3495 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3497 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3498 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3499 rx_lfc_mode, "on#off");
3500 cmdline_parse_token_string_t cmd_lfc_set_tx =
3501 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3503 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3504 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3505 tx_lfc_mode, "on#off");
3506 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3507 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3508 high_water, UINT32);
3509 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3510 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3512 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3513 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3514 pause_time, UINT16);
3515 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3516 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3518 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3519 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3520 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3521 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3522 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3523 mac_ctrl_frame_fwd_mode, "on#off");
3524 cmdline_parse_token_num_t cmd_lfc_set_portid =
3525 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3528 cmdline_parse_inst_t cmd_link_flow_control_set = {
3529 .f = cmd_link_flow_ctrl_set_parsed,
3531 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3532 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3535 (void *)&cmd_lfc_set_set,
3536 (void *)&cmd_lfc_set_flow_ctrl,
3537 (void *)&cmd_lfc_set_rx,
3538 (void *)&cmd_lfc_set_rx_mode,
3539 (void *)&cmd_lfc_set_tx,
3540 (void *)&cmd_lfc_set_tx_mode,
3541 (void *)&cmd_lfc_set_high_water,
3542 (void *)&cmd_lfc_set_low_water,
3543 (void *)&cmd_lfc_set_pause_time,
3544 (void *)&cmd_lfc_set_send_xon,
3545 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3546 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3547 (void *)&cmd_lfc_set_portid,
3552 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3553 struct cmd_priority_flow_ctrl_set_result {
3554 cmdline_fixed_string_t set;
3555 cmdline_fixed_string_t pfc_ctrl;
3556 cmdline_fixed_string_t rx;
3557 cmdline_fixed_string_t rx_pfc_mode;
3558 cmdline_fixed_string_t tx;
3559 cmdline_fixed_string_t tx_pfc_mode;
3560 uint32_t high_water;
3562 uint16_t pause_time;
3568 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3573 struct rte_eth_pfc_conf pfc_conf;
3574 int rx_fc_enable, tx_fc_enable;
3578 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3579 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3580 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3581 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3583 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3584 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3587 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3588 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3589 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3590 pfc_conf.fc.high_water = res->high_water;
3591 pfc_conf.fc.low_water = res->low_water;
3592 pfc_conf.fc.pause_time = res->pause_time;
3593 pfc_conf.priority = res->priority;
3595 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3597 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3600 cmdline_parse_token_string_t cmd_pfc_set_set =
3601 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3603 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3604 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3605 pfc_ctrl, "pfc_ctrl");
3606 cmdline_parse_token_string_t cmd_pfc_set_rx =
3607 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3609 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3610 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3611 rx_pfc_mode, "on#off");
3612 cmdline_parse_token_string_t cmd_pfc_set_tx =
3613 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3615 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3616 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3617 tx_pfc_mode, "on#off");
3618 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3619 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3620 high_water, UINT32);
3621 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3622 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3624 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3625 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3626 pause_time, UINT16);
3627 cmdline_parse_token_num_t cmd_pfc_set_priority =
3628 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3630 cmdline_parse_token_num_t cmd_pfc_set_portid =
3631 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3634 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3635 .f = cmd_priority_flow_ctrl_set_parsed,
3637 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3638 tx on|off high_water low_water pause_time priority port_id",
3640 (void *)&cmd_pfc_set_set,
3641 (void *)&cmd_pfc_set_flow_ctrl,
3642 (void *)&cmd_pfc_set_rx,
3643 (void *)&cmd_pfc_set_rx_mode,
3644 (void *)&cmd_pfc_set_tx,
3645 (void *)&cmd_pfc_set_tx_mode,
3646 (void *)&cmd_pfc_set_high_water,
3647 (void *)&cmd_pfc_set_low_water,
3648 (void *)&cmd_pfc_set_pause_time,
3649 (void *)&cmd_pfc_set_priority,
3650 (void *)&cmd_pfc_set_portid,
3655 /* *** RESET CONFIGURATION *** */
3656 struct cmd_reset_result {
3657 cmdline_fixed_string_t reset;
3658 cmdline_fixed_string_t def;
3661 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3663 __attribute__((unused)) void *data)
3665 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3666 set_def_fwd_config();
3669 cmdline_parse_token_string_t cmd_reset_set =
3670 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3671 cmdline_parse_token_string_t cmd_reset_def =
3672 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3675 cmdline_parse_inst_t cmd_reset = {
3676 .f = cmd_reset_parsed,
3678 .help_str = "set default: reset default forwarding configuration",
3680 (void *)&cmd_reset_set,
3681 (void *)&cmd_reset_def,
3686 /* *** START FORWARDING *** */
3687 struct cmd_start_result {
3688 cmdline_fixed_string_t start;
3691 cmdline_parse_token_string_t cmd_start_start =
3692 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3694 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3695 __attribute__((unused)) struct cmdline *cl,
3696 __attribute__((unused)) void *data)
3698 start_packet_forwarding(0);
3701 cmdline_parse_inst_t cmd_start = {
3702 .f = cmd_start_parsed,
3704 .help_str = "start packet forwarding",
3706 (void *)&cmd_start_start,
3711 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3712 struct cmd_start_tx_first_result {
3713 cmdline_fixed_string_t start;
3714 cmdline_fixed_string_t tx_first;
3718 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3719 __attribute__((unused)) struct cmdline *cl,
3720 __attribute__((unused)) void *data)
3722 start_packet_forwarding(1);
3725 cmdline_parse_token_string_t cmd_start_tx_first_start =
3726 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3728 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3729 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3730 tx_first, "tx_first");
3732 cmdline_parse_inst_t cmd_start_tx_first = {
3733 .f = cmd_start_tx_first_parsed,
3735 .help_str = "start packet forwarding, after sending 1 burst of packets",
3737 (void *)&cmd_start_tx_first_start,
3738 (void *)&cmd_start_tx_first_tx_first,
3743 /* *** SHOW CFG *** */
3744 struct cmd_showcfg_result {
3745 cmdline_fixed_string_t show;
3746 cmdline_fixed_string_t cfg;
3747 cmdline_fixed_string_t what;
3750 static void cmd_showcfg_parsed(void *parsed_result,
3751 __attribute__((unused)) struct cmdline *cl,
3752 __attribute__((unused)) void *data)
3754 struct cmd_showcfg_result *res = parsed_result;
3755 if (!strcmp(res->what, "rxtx"))
3756 rxtx_config_display();
3757 else if (!strcmp(res->what, "cores"))
3758 fwd_lcores_config_display();
3759 else if (!strcmp(res->what, "fwd"))
3760 fwd_config_display();
3763 cmdline_parse_token_string_t cmd_showcfg_show =
3764 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3765 cmdline_parse_token_string_t cmd_showcfg_port =
3766 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3767 cmdline_parse_token_string_t cmd_showcfg_what =
3768 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3771 cmdline_parse_inst_t cmd_showcfg = {
3772 .f = cmd_showcfg_parsed,
3774 .help_str = "show config rxtx|cores|fwd",
3776 (void *)&cmd_showcfg_show,
3777 (void *)&cmd_showcfg_port,
3778 (void *)&cmd_showcfg_what,
3783 /* *** SHOW ALL PORT INFO *** */
3784 struct cmd_showportall_result {
3785 cmdline_fixed_string_t show;
3786 cmdline_fixed_string_t port;
3787 cmdline_fixed_string_t what;
3788 cmdline_fixed_string_t all;
3791 static void cmd_showportall_parsed(void *parsed_result,
3792 __attribute__((unused)) struct cmdline *cl,
3793 __attribute__((unused)) void *data)
3797 struct cmd_showportall_result *res = parsed_result;
3798 if (!strcmp(res->show, "clear")) {
3799 if (!strcmp(res->what, "stats"))
3800 for (i = 0; i < nb_ports; i++)
3802 } else if (!strcmp(res->what, "info"))
3803 for (i = 0; i < nb_ports; i++)
3804 port_infos_display(i);
3805 else if (!strcmp(res->what, "stats"))
3806 for (i = 0; i < nb_ports; i++)
3807 nic_stats_display(i);
3808 else if (!strcmp(res->what, "fdir"))
3809 for (i = 0; i < nb_ports; i++)
3811 else if (!strcmp(res->what, "stat_qmap"))
3812 for (i = 0; i < nb_ports; i++)
3813 nic_stats_mapping_display(i);
3816 cmdline_parse_token_string_t cmd_showportall_show =
3817 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3819 cmdline_parse_token_string_t cmd_showportall_port =
3820 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3821 cmdline_parse_token_string_t cmd_showportall_what =
3822 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3823 "info#stats#fdir#stat_qmap");
3824 cmdline_parse_token_string_t cmd_showportall_all =
3825 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3826 cmdline_parse_inst_t cmd_showportall = {
3827 .f = cmd_showportall_parsed,
3829 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3831 (void *)&cmd_showportall_show,
3832 (void *)&cmd_showportall_port,
3833 (void *)&cmd_showportall_what,
3834 (void *)&cmd_showportall_all,
3839 /* *** SHOW PORT INFO *** */
3840 struct cmd_showport_result {
3841 cmdline_fixed_string_t show;
3842 cmdline_fixed_string_t port;
3843 cmdline_fixed_string_t what;
3847 static void cmd_showport_parsed(void *parsed_result,
3848 __attribute__((unused)) struct cmdline *cl,
3849 __attribute__((unused)) void *data)
3851 struct cmd_showport_result *res = parsed_result;
3852 if (!strcmp(res->show, "clear")) {
3853 if (!strcmp(res->what, "stats"))
3854 nic_stats_clear(res->portnum);
3855 } else if (!strcmp(res->what, "info"))
3856 port_infos_display(res->portnum);
3857 else if (!strcmp(res->what, "stats"))
3858 nic_stats_display(res->portnum);
3859 else if (!strcmp(res->what, "fdir"))
3860 fdir_get_infos(res->portnum);
3861 else if (!strcmp(res->what, "stat_qmap"))
3862 nic_stats_mapping_display(res->portnum);
3865 cmdline_parse_token_string_t cmd_showport_show =
3866 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3868 cmdline_parse_token_string_t cmd_showport_port =
3869 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3870 cmdline_parse_token_string_t cmd_showport_what =
3871 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3872 "info#stats#fdir#stat_qmap");
3873 cmdline_parse_token_num_t cmd_showport_portnum =
3874 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3876 cmdline_parse_inst_t cmd_showport = {
3877 .f = cmd_showport_parsed,
3879 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3881 (void *)&cmd_showport_show,
3882 (void *)&cmd_showport_port,
3883 (void *)&cmd_showport_what,
3884 (void *)&cmd_showport_portnum,
3889 /* *** READ PORT REGISTER *** */
3890 struct cmd_read_reg_result {
3891 cmdline_fixed_string_t read;
3892 cmdline_fixed_string_t reg;
3898 cmd_read_reg_parsed(void *parsed_result,
3899 __attribute__((unused)) struct cmdline *cl,
3900 __attribute__((unused)) void *data)
3902 struct cmd_read_reg_result *res = parsed_result;
3903 port_reg_display(res->port_id, res->reg_off);
3906 cmdline_parse_token_string_t cmd_read_reg_read =
3907 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3908 cmdline_parse_token_string_t cmd_read_reg_reg =
3909 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3910 cmdline_parse_token_num_t cmd_read_reg_port_id =
3911 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3912 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3913 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3915 cmdline_parse_inst_t cmd_read_reg = {
3916 .f = cmd_read_reg_parsed,
3918 .help_str = "read reg port_id reg_off",
3920 (void *)&cmd_read_reg_read,
3921 (void *)&cmd_read_reg_reg,
3922 (void *)&cmd_read_reg_port_id,
3923 (void *)&cmd_read_reg_reg_off,
3928 /* *** READ PORT REGISTER BIT FIELD *** */
3929 struct cmd_read_reg_bit_field_result {
3930 cmdline_fixed_string_t read;
3931 cmdline_fixed_string_t regfield;
3939 cmd_read_reg_bit_field_parsed(void *parsed_result,
3940 __attribute__((unused)) struct cmdline *cl,
3941 __attribute__((unused)) void *data)
3943 struct cmd_read_reg_bit_field_result *res = parsed_result;
3944 port_reg_bit_field_display(res->port_id, res->reg_off,
3945 res->bit1_pos, res->bit2_pos);
3948 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3949 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3951 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3952 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3953 regfield, "regfield");
3954 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3955 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3957 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3958 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3960 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3961 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3963 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3964 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3967 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3968 .f = cmd_read_reg_bit_field_parsed,
3970 .help_str = "read regfield port_id reg_off bit_x bit_y "
3971 "(read register bit field between bit_x and bit_y included)",
3973 (void *)&cmd_read_reg_bit_field_read,
3974 (void *)&cmd_read_reg_bit_field_regfield,
3975 (void *)&cmd_read_reg_bit_field_port_id,
3976 (void *)&cmd_read_reg_bit_field_reg_off,
3977 (void *)&cmd_read_reg_bit_field_bit1_pos,
3978 (void *)&cmd_read_reg_bit_field_bit2_pos,
3983 /* *** READ PORT REGISTER BIT *** */
3984 struct cmd_read_reg_bit_result {
3985 cmdline_fixed_string_t read;
3986 cmdline_fixed_string_t regbit;
3993 cmd_read_reg_bit_parsed(void *parsed_result,
3994 __attribute__((unused)) struct cmdline *cl,
3995 __attribute__((unused)) void *data)
3997 struct cmd_read_reg_bit_result *res = parsed_result;
3998 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4001 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4002 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4003 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4006 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4007 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4008 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4009 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4010 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4011 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4013 cmdline_parse_inst_t cmd_read_reg_bit = {
4014 .f = cmd_read_reg_bit_parsed,
4016 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4018 (void *)&cmd_read_reg_bit_read,
4019 (void *)&cmd_read_reg_bit_regbit,
4020 (void *)&cmd_read_reg_bit_port_id,
4021 (void *)&cmd_read_reg_bit_reg_off,
4022 (void *)&cmd_read_reg_bit_bit_pos,
4027 /* *** WRITE PORT REGISTER *** */
4028 struct cmd_write_reg_result {
4029 cmdline_fixed_string_t write;
4030 cmdline_fixed_string_t reg;
4037 cmd_write_reg_parsed(void *parsed_result,
4038 __attribute__((unused)) struct cmdline *cl,
4039 __attribute__((unused)) void *data)
4041 struct cmd_write_reg_result *res = parsed_result;
4042 port_reg_set(res->port_id, res->reg_off, res->value);
4045 cmdline_parse_token_string_t cmd_write_reg_write =
4046 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4047 cmdline_parse_token_string_t cmd_write_reg_reg =
4048 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4049 cmdline_parse_token_num_t cmd_write_reg_port_id =
4050 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4051 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4053 cmdline_parse_token_num_t cmd_write_reg_value =
4054 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4056 cmdline_parse_inst_t cmd_write_reg = {
4057 .f = cmd_write_reg_parsed,
4059 .help_str = "write reg port_id reg_off reg_value",
4061 (void *)&cmd_write_reg_write,
4062 (void *)&cmd_write_reg_reg,
4063 (void *)&cmd_write_reg_port_id,
4064 (void *)&cmd_write_reg_reg_off,
4065 (void *)&cmd_write_reg_value,
4070 /* *** WRITE PORT REGISTER BIT FIELD *** */
4071 struct cmd_write_reg_bit_field_result {
4072 cmdline_fixed_string_t write;
4073 cmdline_fixed_string_t regfield;
4082 cmd_write_reg_bit_field_parsed(void *parsed_result,
4083 __attribute__((unused)) struct cmdline *cl,
4084 __attribute__((unused)) void *data)
4086 struct cmd_write_reg_bit_field_result *res = parsed_result;
4087 port_reg_bit_field_set(res->port_id, res->reg_off,
4088 res->bit1_pos, res->bit2_pos, res->value);
4091 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4092 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4094 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4095 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4096 regfield, "regfield");
4097 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4098 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4100 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4101 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4103 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4104 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4106 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4109 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4110 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4113 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4114 .f = cmd_write_reg_bit_field_parsed,
4116 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4117 "(set register bit field between bit_x and bit_y included)",
4119 (void *)&cmd_write_reg_bit_field_write,
4120 (void *)&cmd_write_reg_bit_field_regfield,
4121 (void *)&cmd_write_reg_bit_field_port_id,
4122 (void *)&cmd_write_reg_bit_field_reg_off,
4123 (void *)&cmd_write_reg_bit_field_bit1_pos,
4124 (void *)&cmd_write_reg_bit_field_bit2_pos,
4125 (void *)&cmd_write_reg_bit_field_value,
4130 /* *** WRITE PORT REGISTER BIT *** */
4131 struct cmd_write_reg_bit_result {
4132 cmdline_fixed_string_t write;
4133 cmdline_fixed_string_t regbit;
4141 cmd_write_reg_bit_parsed(void *parsed_result,
4142 __attribute__((unused)) struct cmdline *cl,
4143 __attribute__((unused)) void *data)
4145 struct cmd_write_reg_bit_result *res = parsed_result;
4146 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4149 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4150 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4152 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4153 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4155 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4156 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4157 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4158 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4159 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4160 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4161 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4162 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4164 cmdline_parse_inst_t cmd_write_reg_bit = {
4165 .f = cmd_write_reg_bit_parsed,
4167 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4169 (void *)&cmd_write_reg_bit_write,
4170 (void *)&cmd_write_reg_bit_regbit,
4171 (void *)&cmd_write_reg_bit_port_id,
4172 (void *)&cmd_write_reg_bit_reg_off,
4173 (void *)&cmd_write_reg_bit_bit_pos,
4174 (void *)&cmd_write_reg_bit_value,
4179 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4180 struct cmd_read_rxd_txd_result {
4181 cmdline_fixed_string_t read;
4182 cmdline_fixed_string_t rxd_txd;
4189 cmd_read_rxd_txd_parsed(void *parsed_result,
4190 __attribute__((unused)) struct cmdline *cl,
4191 __attribute__((unused)) void *data)
4193 struct cmd_read_rxd_txd_result *res = parsed_result;
4195 if (!strcmp(res->rxd_txd, "rxd"))
4196 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4197 else if (!strcmp(res->rxd_txd, "txd"))
4198 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4201 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4202 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4203 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4204 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4206 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4207 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4208 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4209 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4210 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4211 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4213 cmdline_parse_inst_t cmd_read_rxd_txd = {
4214 .f = cmd_read_rxd_txd_parsed,
4216 .help_str = "read rxd|txd port_id queue_id rxd_id",
4218 (void *)&cmd_read_rxd_txd_read,
4219 (void *)&cmd_read_rxd_txd_rxd_txd,
4220 (void *)&cmd_read_rxd_txd_port_id,
4221 (void *)&cmd_read_rxd_txd_queue_id,
4222 (void *)&cmd_read_rxd_txd_desc_id,
4228 struct cmd_quit_result {
4229 cmdline_fixed_string_t quit;
4232 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4234 __attribute__((unused)) void *data)
4240 cmdline_parse_token_string_t cmd_quit_quit =
4241 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4243 cmdline_parse_inst_t cmd_quit = {
4244 .f = cmd_quit_parsed,
4246 .help_str = "exit application",
4248 (void *)&cmd_quit_quit,
4253 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4254 struct cmd_mac_addr_result {
4255 cmdline_fixed_string_t mac_addr_cmd;
4256 cmdline_fixed_string_t what;
4258 struct ether_addr address;
4261 static void cmd_mac_addr_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_mac_addr_result *res = parsed_result;
4268 if (strcmp(res->what, "add") == 0)
4269 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4271 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4273 /* check the return value and print it if is < 0 */
4275 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4279 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4280 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4282 cmdline_parse_token_string_t cmd_mac_addr_what =
4283 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4285 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4286 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4287 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4288 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4290 cmdline_parse_inst_t cmd_mac_addr = {
4291 .f = cmd_mac_addr_parsed,
4293 .help_str = "mac_addr add|remove X <address>: "
4294 "add/remove MAC address on port X",
4296 (void *)&cmd_mac_addr_cmd,
4297 (void *)&cmd_mac_addr_what,
4298 (void *)&cmd_mac_addr_portnum,
4299 (void *)&cmd_mac_addr_addr,
4305 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4306 struct cmd_set_qmap_result {
4307 cmdline_fixed_string_t set;
4308 cmdline_fixed_string_t qmap;
4309 cmdline_fixed_string_t what;
4316 cmd_set_qmap_parsed(void *parsed_result,
4317 __attribute__((unused)) struct cmdline *cl,
4318 __attribute__((unused)) void *data)
4320 struct cmd_set_qmap_result *res = parsed_result;
4321 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4323 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4326 cmdline_parse_token_string_t cmd_setqmap_set =
4327 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4329 cmdline_parse_token_string_t cmd_setqmap_qmap =
4330 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4332 cmdline_parse_token_string_t cmd_setqmap_what =
4333 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4335 cmdline_parse_token_num_t cmd_setqmap_portid =
4336 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4338 cmdline_parse_token_num_t cmd_setqmap_queueid =
4339 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4341 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4342 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4345 cmdline_parse_inst_t cmd_set_qmap = {
4346 .f = cmd_set_qmap_parsed,
4348 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4350 (void *)&cmd_setqmap_set,
4351 (void *)&cmd_setqmap_qmap,
4352 (void *)&cmd_setqmap_what,
4353 (void *)&cmd_setqmap_portid,
4354 (void *)&cmd_setqmap_queueid,
4355 (void *)&cmd_setqmap_mapvalue,
4360 /* *** CONFIGURE UNICAST HASH TABLE *** */
4361 struct cmd_set_uc_hash_table {
4362 cmdline_fixed_string_t set;
4363 cmdline_fixed_string_t port;
4365 cmdline_fixed_string_t what;
4366 struct ether_addr address;
4367 cmdline_fixed_string_t mode;
4371 cmd_set_uc_hash_parsed(void *parsed_result,
4372 __attribute__((unused)) struct cmdline *cl,
4373 __attribute__((unused)) void *data)
4376 struct cmd_set_uc_hash_table *res = parsed_result;
4378 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4380 if (strcmp(res->what, "uta") == 0)
4381 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4382 &res->address,(uint8_t)is_on);
4384 printf("bad unicast hash table parameter, return code = %d \n", ret);
4388 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4391 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4392 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4394 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4395 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4397 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4398 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4400 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4401 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4403 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4404 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4407 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4408 .f = cmd_set_uc_hash_parsed,
4410 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4412 (void *)&cmd_set_uc_hash_set,
4413 (void *)&cmd_set_uc_hash_port,
4414 (void *)&cmd_set_uc_hash_portid,
4415 (void *)&cmd_set_uc_hash_what,
4416 (void *)&cmd_set_uc_hash_mac,
4417 (void *)&cmd_set_uc_hash_mode,
4422 struct cmd_set_uc_all_hash_table {
4423 cmdline_fixed_string_t set;
4424 cmdline_fixed_string_t port;
4426 cmdline_fixed_string_t what;
4427 cmdline_fixed_string_t value;
4428 cmdline_fixed_string_t mode;
4432 cmd_set_uc_all_hash_parsed(void *parsed_result,
4433 __attribute__((unused)) struct cmdline *cl,
4434 __attribute__((unused)) void *data)
4437 struct cmd_set_uc_all_hash_table *res = parsed_result;
4439 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4441 if ((strcmp(res->what, "uta") == 0) &&
4442 (strcmp(res->value, "all") == 0))
4443 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4445 printf("bad unicast hash table parameter,"
4446 "return code = %d \n", ret);
4449 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4450 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4452 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4453 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4455 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4456 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4458 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4461 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4462 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4464 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4468 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4469 .f = cmd_set_uc_all_hash_parsed,
4471 .help_str = "set port X uta all on|off (X = port number)",
4473 (void *)&cmd_set_uc_all_hash_set,
4474 (void *)&cmd_set_uc_all_hash_port,
4475 (void *)&cmd_set_uc_all_hash_portid,
4476 (void *)&cmd_set_uc_all_hash_what,
4477 (void *)&cmd_set_uc_all_hash_value,
4478 (void *)&cmd_set_uc_all_hash_mode,
4483 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4484 struct cmd_set_vf_traffic {
4485 cmdline_fixed_string_t set;
4486 cmdline_fixed_string_t port;
4488 cmdline_fixed_string_t vf;
4490 cmdline_fixed_string_t what;
4491 cmdline_fixed_string_t mode;
4495 cmd_set_vf_traffic_parsed(void *parsed_result,
4496 __attribute__((unused)) struct cmdline *cl,
4497 __attribute__((unused)) void *data)
4499 struct cmd_set_vf_traffic *res = parsed_result;
4500 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4501 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4503 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4506 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4509 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4512 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4513 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4515 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4516 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4518 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4519 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4521 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4522 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4524 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4525 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4528 cmdline_parse_inst_t cmd_set_vf_traffic = {
4529 .f = cmd_set_vf_traffic_parsed,
4531 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4533 (void *)&cmd_setvf_traffic_set,
4534 (void *)&cmd_setvf_traffic_port,
4535 (void *)&cmd_setvf_traffic_portid,
4536 (void *)&cmd_setvf_traffic_vf,
4537 (void *)&cmd_setvf_traffic_vfid,
4538 (void *)&cmd_setvf_traffic_what,
4539 (void *)&cmd_setvf_traffic_mode,
4544 /* *** CONFIGURE VF RECEIVE MODE *** */
4545 struct cmd_set_vf_rxmode {
4546 cmdline_fixed_string_t set;
4547 cmdline_fixed_string_t port;
4549 cmdline_fixed_string_t vf;
4551 cmdline_fixed_string_t what;
4552 cmdline_fixed_string_t mode;
4553 cmdline_fixed_string_t on;
4557 cmd_set_vf_rxmode_parsed(void *parsed_result,
4558 __attribute__((unused)) struct cmdline *cl,
4559 __attribute__((unused)) void *data)
4562 uint16_t rx_mode = 0;
4563 struct cmd_set_vf_rxmode *res = parsed_result;
4565 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4566 if (!strcmp(res->what,"rxmode")) {
4567 if (!strcmp(res->mode, "AUPE"))
4568 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4569 else if (!strcmp(res->mode, "ROPE"))
4570 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4571 else if (!strcmp(res->mode, "BAM"))
4572 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4573 else if (!strncmp(res->mode, "MPE",3))
4574 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4577 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4579 printf("bad VF receive mode parameter, return code = %d \n",
4583 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4584 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4586 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4589 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4590 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4592 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4593 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4595 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4596 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4598 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4601 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4603 mode, "AUPE#ROPE#BAM#MPE");
4604 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4605 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4608 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4609 .f = cmd_set_vf_rxmode_parsed,
4611 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4613 (void *)&cmd_set_vf_rxmode_set,
4614 (void *)&cmd_set_vf_rxmode_port,
4615 (void *)&cmd_set_vf_rxmode_portid,
4616 (void *)&cmd_set_vf_rxmode_vf,
4617 (void *)&cmd_set_vf_rxmode_vfid,
4618 (void *)&cmd_set_vf_rxmode_what,
4619 (void *)&cmd_set_vf_rxmode_mode,
4620 (void *)&cmd_set_vf_rxmode_on,
4625 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4626 struct cmd_vf_mac_addr_result {
4627 cmdline_fixed_string_t mac_addr_cmd;
4628 cmdline_fixed_string_t what;
4629 cmdline_fixed_string_t port;
4631 cmdline_fixed_string_t vf;
4633 struct ether_addr address;
4636 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4637 __attribute__((unused)) struct cmdline *cl,
4638 __attribute__((unused)) void *data)
4640 struct cmd_vf_mac_addr_result *res = parsed_result;
4643 if (strcmp(res->what, "add") == 0)
4644 ret = rte_eth_dev_mac_addr_add(res->port_num,
4645 &res->address, res->vf_num);
4647 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4651 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4652 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4653 mac_addr_cmd,"mac_addr");
4654 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4655 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4657 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4658 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4660 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4661 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4663 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4664 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4666 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4667 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4669 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4670 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4673 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4674 .f = cmd_vf_mac_addr_parsed,
4676 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4677 "Y = VF number)add MAC address filtering for a VF on port X",
4679 (void *)&cmd_vf_mac_addr_cmd,
4680 (void *)&cmd_vf_mac_addr_what,
4681 (void *)&cmd_vf_mac_addr_port,
4682 (void *)&cmd_vf_mac_addr_portnum,
4683 (void *)&cmd_vf_mac_addr_vf,
4684 (void *)&cmd_vf_mac_addr_vfnum,
4685 (void *)&cmd_vf_mac_addr_addr,
4690 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4691 struct cmd_vf_rx_vlan_filter {
4692 cmdline_fixed_string_t rx_vlan;
4693 cmdline_fixed_string_t what;
4695 cmdline_fixed_string_t port;
4697 cmdline_fixed_string_t vf;
4702 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4703 __attribute__((unused)) struct cmdline *cl,
4704 __attribute__((unused)) void *data)
4706 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4708 if (!strcmp(res->what, "add"))
4709 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4711 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4714 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4715 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4716 rx_vlan, "rx_vlan");
4717 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4718 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4720 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4721 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4723 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4724 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4726 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4727 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4729 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4730 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4732 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4733 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4736 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4737 .f = cmd_vf_rx_vlan_filter_parsed,
4739 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4740 "Y = port number,Z = hexadecimal VF mask)",
4742 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4743 (void *)&cmd_vf_rx_vlan_filter_what,
4744 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4745 (void *)&cmd_vf_rx_vlan_filter_port,
4746 (void *)&cmd_vf_rx_vlan_filter_portid,
4747 (void *)&cmd_vf_rx_vlan_filter_vf,
4748 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4753 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4754 struct cmd_set_mirror_mask_result {
4755 cmdline_fixed_string_t set;
4756 cmdline_fixed_string_t port;
4758 cmdline_fixed_string_t mirror;
4760 cmdline_fixed_string_t what;
4761 cmdline_fixed_string_t value;
4762 cmdline_fixed_string_t dstpool;
4764 cmdline_fixed_string_t on;
4767 cmdline_parse_token_string_t cmd_mirror_mask_set =
4768 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4770 cmdline_parse_token_string_t cmd_mirror_mask_port =
4771 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4773 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4774 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4776 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4777 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4778 mirror, "mirror-rule");
4779 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4780 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4782 cmdline_parse_token_string_t cmd_mirror_mask_what =
4783 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4784 what, "pool-mirror#vlan-mirror");
4785 cmdline_parse_token_string_t cmd_mirror_mask_value =
4786 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4788 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4790 dstpool, "dst-pool");
4791 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4792 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4794 cmdline_parse_token_string_t cmd_mirror_mask_on =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4799 cmd_set_mirror_mask_parsed(void *parsed_result,
4800 __attribute__((unused)) struct cmdline *cl,
4801 __attribute__((unused)) void *data)
4804 struct cmd_set_mirror_mask_result *res = parsed_result;
4805 struct rte_eth_vmdq_mirror_conf mr_conf;
4807 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4809 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4811 mr_conf.dst_pool = res->dstpool_id;
4813 if (!strcmp(res->what, "pool-mirror")) {
4814 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4815 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4816 } else if(!strcmp(res->what, "vlan-mirror")) {
4817 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4818 nb_item = parse_item_list(res->value, "core",
4819 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4823 for(i=0; i < nb_item; i++) {
4824 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4825 printf("Invalid vlan_id: must be < 4096\n");
4829 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4830 mr_conf.vlan.vlan_mask |= 1ULL << i;
4834 if(!strcmp(res->on, "on"))
4835 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4838 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4841 printf("mirror rule add error: (%s)\n", strerror(-ret));
4844 cmdline_parse_inst_t cmd_set_mirror_mask = {
4845 .f = cmd_set_mirror_mask_parsed,
4847 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4848 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4850 (void *)&cmd_mirror_mask_set,
4851 (void *)&cmd_mirror_mask_port,
4852 (void *)&cmd_mirror_mask_portid,
4853 (void *)&cmd_mirror_mask_mirror,
4854 (void *)&cmd_mirror_mask_ruleid,
4855 (void *)&cmd_mirror_mask_what,
4856 (void *)&cmd_mirror_mask_value,
4857 (void *)&cmd_mirror_mask_dstpool,
4858 (void *)&cmd_mirror_mask_poolid,
4859 (void *)&cmd_mirror_mask_on,
4864 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4865 struct cmd_set_mirror_link_result {
4866 cmdline_fixed_string_t set;
4867 cmdline_fixed_string_t port;
4869 cmdline_fixed_string_t mirror;
4871 cmdline_fixed_string_t what;
4872 cmdline_fixed_string_t dstpool;
4874 cmdline_fixed_string_t on;
4877 cmdline_parse_token_string_t cmd_mirror_link_set =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4880 cmdline_parse_token_string_t cmd_mirror_link_port =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4883 cmdline_parse_token_string_t cmd_mirror_link_portid =
4884 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4886 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4887 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4888 mirror, "mirror-rule");
4889 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4890 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4892 cmdline_parse_token_string_t cmd_mirror_link_what =
4893 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4894 what, "uplink-mirror#downlink-mirror");
4895 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4896 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4897 dstpool, "dst-pool");
4898 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4899 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4901 cmdline_parse_token_string_t cmd_mirror_link_on =
4902 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4906 cmd_set_mirror_link_parsed(void *parsed_result,
4907 __attribute__((unused)) struct cmdline *cl,
4908 __attribute__((unused)) void *data)
4911 struct cmd_set_mirror_link_result *res = parsed_result;
4912 struct rte_eth_vmdq_mirror_conf mr_conf;
4914 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4915 if(!strcmp(res->what, "uplink-mirror")) {
4916 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4917 }else if(!strcmp(res->what, "downlink-mirror"))
4918 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4920 mr_conf.dst_pool = res->dstpool_id;
4922 if(!strcmp(res->on, "on"))
4923 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4926 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4929 /* check the return value and print it if is < 0 */
4931 printf("mirror rule add error: (%s)\n", strerror(-ret));
4935 cmdline_parse_inst_t cmd_set_mirror_link = {
4936 .f = cmd_set_mirror_link_parsed,
4938 .help_str = "set port X mirror-rule Y uplink-mirror|"
4939 "downlink-mirror dst-pool Z on|off",
4941 (void *)&cmd_mirror_link_set,
4942 (void *)&cmd_mirror_link_port,
4943 (void *)&cmd_mirror_link_portid,
4944 (void *)&cmd_mirror_link_mirror,
4945 (void *)&cmd_mirror_link_ruleid,
4946 (void *)&cmd_mirror_link_what,
4947 (void *)&cmd_mirror_link_dstpool,
4948 (void *)&cmd_mirror_link_poolid,
4949 (void *)&cmd_mirror_link_on,
4954 /* *** RESET VM MIRROR RULE *** */
4955 struct cmd_rm_mirror_rule_result {
4956 cmdline_fixed_string_t reset;
4957 cmdline_fixed_string_t port;
4959 cmdline_fixed_string_t mirror;
4963 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4964 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4966 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4967 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4969 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4970 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4972 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4973 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4974 mirror, "mirror-rule");
4975 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4976 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4980 cmd_reset_mirror_rule_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4982 __attribute__((unused)) void *data)
4985 struct cmd_set_mirror_link_result *res = parsed_result;
4987 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4989 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4992 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4993 .f = cmd_reset_mirror_rule_parsed,
4995 .help_str = "reset port X mirror-rule Y",
4997 (void *)&cmd_rm_mirror_rule_reset,
4998 (void *)&cmd_rm_mirror_rule_port,
4999 (void *)&cmd_rm_mirror_rule_portid,
5000 (void *)&cmd_rm_mirror_rule_mirror,
5001 (void *)&cmd_rm_mirror_rule_ruleid,
5006 /* ******************************************************************************** */
5008 struct cmd_dump_result {
5009 cmdline_fixed_string_t dump;
5013 dump_struct_sizes(void)
5015 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5016 DUMP_SIZE(struct rte_mbuf);
5017 DUMP_SIZE(struct rte_pktmbuf);
5018 DUMP_SIZE(struct rte_ctrlmbuf);
5019 DUMP_SIZE(struct rte_mempool);
5020 DUMP_SIZE(struct rte_ring);
5024 static void cmd_dump_parsed(void *parsed_result,
5025 __attribute__((unused)) struct cmdline *cl,
5026 __attribute__((unused)) void *data)
5028 struct cmd_dump_result *res = parsed_result;
5030 if (!strcmp(res->dump, "dump_physmem"))
5031 rte_dump_physmem_layout();
5032 else if (!strcmp(res->dump, "dump_memzone"))
5034 else if (!strcmp(res->dump, "dump_log_history"))
5035 rte_log_dump_history();
5036 else if (!strcmp(res->dump, "dump_struct_sizes"))
5037 dump_struct_sizes();
5038 else if (!strcmp(res->dump, "dump_ring"))
5039 rte_ring_list_dump();
5040 else if (!strcmp(res->dump, "dump_mempool"))
5041 rte_mempool_list_dump();
5042 else if (!strcmp(res->dump, "dump_devargs"))
5043 rte_eal_devargs_dump();
5046 cmdline_parse_token_string_t cmd_dump_dump =
5047 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5051 "dump_struct_sizes#"
5056 cmdline_parse_inst_t cmd_dump = {
5057 .f = cmd_dump_parsed, /* function to call */
5058 .data = NULL, /* 2nd arg of func */
5059 .help_str = "dump status",
5060 .tokens = { /* token list, NULL terminated */
5061 (void *)&cmd_dump_dump,
5066 /* ******************************************************************************** */
5068 struct cmd_dump_one_result {
5069 cmdline_fixed_string_t dump;
5070 cmdline_fixed_string_t name;
5073 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5074 __attribute__((unused)) void *data)
5076 struct cmd_dump_one_result *res = parsed_result;
5078 if (!strcmp(res->dump, "dump_ring")) {
5080 r = rte_ring_lookup(res->name);
5082 cmdline_printf(cl, "Cannot find ring\n");
5086 } else if (!strcmp(res->dump, "dump_mempool")) {
5087 struct rte_mempool *mp;
5088 mp = rte_mempool_lookup(res->name);
5090 cmdline_printf(cl, "Cannot find mempool\n");
5093 rte_mempool_dump(mp);
5097 cmdline_parse_token_string_t cmd_dump_one_dump =
5098 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5099 "dump_ring#dump_mempool");
5101 cmdline_parse_token_string_t cmd_dump_one_name =
5102 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5104 cmdline_parse_inst_t cmd_dump_one = {
5105 .f = cmd_dump_one_parsed, /* function to call */
5106 .data = NULL, /* 2nd arg of func */
5107 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5108 .tokens = { /* token list, NULL terminated */
5109 (void *)&cmd_dump_one_dump,
5110 (void *)&cmd_dump_one_name,
5115 /* ******************************************************************************** */
5117 /* list of instructions */
5118 cmdline_parse_ctx_t main_ctx[] = {
5119 (cmdline_parse_inst_t *)&cmd_help_brief,
5120 (cmdline_parse_inst_t *)&cmd_help_long,
5121 (cmdline_parse_inst_t *)&cmd_quit,
5122 (cmdline_parse_inst_t *)&cmd_showport,
5123 (cmdline_parse_inst_t *)&cmd_showportall,
5124 (cmdline_parse_inst_t *)&cmd_showcfg,
5125 (cmdline_parse_inst_t *)&cmd_start,
5126 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5127 (cmdline_parse_inst_t *)&cmd_reset,
5128 (cmdline_parse_inst_t *)&cmd_set_numbers,
5129 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5130 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5131 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5132 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5133 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5134 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5135 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5136 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5137 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5138 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5139 #ifdef RTE_NIC_BYPASS
5140 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5141 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5142 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5143 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5145 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5146 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5147 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5148 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5149 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5150 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5151 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5152 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5153 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5154 (cmdline_parse_inst_t *)&cmd_config_dcb,
5155 (cmdline_parse_inst_t *)&cmd_read_reg,
5156 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5157 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5158 (cmdline_parse_inst_t *)&cmd_write_reg,
5159 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5160 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5161 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5162 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5163 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5164 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5165 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5166 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5167 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5168 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5169 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5170 (cmdline_parse_inst_t *)&cmd_stop,
5171 (cmdline_parse_inst_t *)&cmd_mac_addr,
5172 (cmdline_parse_inst_t *)&cmd_set_qmap,
5173 (cmdline_parse_inst_t *)&cmd_operate_port,
5174 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5175 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5176 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5177 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5178 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5179 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5180 (cmdline_parse_inst_t *)&cmd_config_rss,
5181 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5182 (cmdline_parse_inst_t *)&cmd_showport_reta,
5183 (cmdline_parse_inst_t *)&cmd_config_burst,
5184 (cmdline_parse_inst_t *)&cmd_config_thresh,
5185 (cmdline_parse_inst_t *)&cmd_config_threshold,
5186 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5187 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5188 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5189 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5190 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5191 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5192 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5193 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5194 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5195 (cmdline_parse_inst_t *)&cmd_dump,
5196 (cmdline_parse_inst_t *)&cmd_dump_one,
5200 /* prompt function, called from main on MASTER lcore */
5206 /* initialize non-constant commands */
5207 cmd_set_fwd_mode_init();
5209 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5213 cmdline_interact(cl);
5214 cmdline_stdin_exit(cl);
5218 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5220 if (id < nb_ports) {
5221 /* check if need_reconfig has been set to 1 */
5222 if (ports[id].need_reconfig == 0)
5223 ports[id].need_reconfig = dev;
5224 /* check if need_reconfig_queues has been set to 1 */
5225 if (ports[id].need_reconfig_queues == 0)
5226 ports[id].need_reconfig_queues = queue;
5230 for (pid = 0; pid < nb_ports; pid++) {
5231 /* check if need_reconfig has been set to 1 */
5232 if (ports[pid].need_reconfig == 0)
5233 ports[pid].need_reconfig = dev;
5234 /* check if need_reconfig_queues has been set to 1 */
5235 if (ports[pid].need_reconfig_queues == 0)
5236 ports[pid].need_reconfig_queues = queue;
5241 #ifdef RTE_NIC_BYPASS
5243 bypass_is_supported(portid_t port_id)
5245 struct rte_port *port;
5246 struct rte_pci_id *pci_id;
5248 if (port_id >= nb_ports) {
5249 printf("\tPort id must be less than %d.\n", nb_ports);
5253 /* Get the device id. */
5254 port = &ports[port_id];
5255 pci_id = &port->dev_info.pci_dev->id;
5257 /* Check if NIC supports bypass. */
5258 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5262 printf("\tBypass not supported for port_id = %d.\n", port_id);