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 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2332 struct cmd_set_link_check {
2333 cmdline_fixed_string_t set;
2334 cmdline_fixed_string_t link_check;
2335 cmdline_fixed_string_t mode;
2339 cmd_set_link_check_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_set_link_check *res = parsed_result;
2344 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2347 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2348 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2350 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2351 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2352 link_check, "link_check");
2353 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2354 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2358 cmdline_parse_inst_t cmd_set_link_check = {
2359 .f = cmd_set_link_check_parsed,
2360 .help_str = "set link_check on|off: enable/disable link status check "
2361 "when starting/stopping a port",
2364 (void *)&cmd_setlinkcheck_set,
2365 (void *)&cmd_setlinkcheck_link_check,
2366 (void *)&cmd_setlinkcheck_mode,
2371 #ifdef RTE_NIC_BYPASS
2372 /* *** SET NIC BYPASS MODE *** */
2373 struct cmd_set_bypass_mode_result {
2374 cmdline_fixed_string_t set;
2375 cmdline_fixed_string_t bypass;
2376 cmdline_fixed_string_t mode;
2377 cmdline_fixed_string_t value;
2382 cmd_set_bypass_mode_parsed(void *parsed_result,
2383 __attribute__((unused)) struct cmdline *cl,
2384 __attribute__((unused)) void *data)
2386 struct cmd_set_bypass_mode_result *res = parsed_result;
2387 portid_t port_id = res->port_id;
2388 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2390 if (!bypass_is_supported(port_id))
2393 if (!strcmp(res->value, "bypass"))
2394 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2395 else if (!strcmp(res->value, "isolate"))
2396 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2398 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2400 /* Set the bypass mode for the relevant port. */
2401 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2402 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2406 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2407 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2409 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2410 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2412 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2413 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2415 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2416 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2417 value, "normal#bypass#isolate");
2418 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2419 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2422 cmdline_parse_inst_t cmd_set_bypass_mode = {
2423 .f = cmd_set_bypass_mode_parsed,
2424 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2425 "Set the NIC bypass mode for port_id",
2428 (void *)&cmd_setbypass_mode_set,
2429 (void *)&cmd_setbypass_mode_bypass,
2430 (void *)&cmd_setbypass_mode_mode,
2431 (void *)&cmd_setbypass_mode_value,
2432 (void *)&cmd_setbypass_mode_port,
2437 /* *** SET NIC BYPASS EVENT *** */
2438 struct cmd_set_bypass_event_result {
2439 cmdline_fixed_string_t set;
2440 cmdline_fixed_string_t bypass;
2441 cmdline_fixed_string_t event;
2442 cmdline_fixed_string_t event_value;
2443 cmdline_fixed_string_t mode;
2444 cmdline_fixed_string_t mode_value;
2449 cmd_set_bypass_event_parsed(void *parsed_result,
2450 __attribute__((unused)) struct cmdline *cl,
2451 __attribute__((unused)) void *data)
2454 struct cmd_set_bypass_event_result *res = parsed_result;
2455 portid_t port_id = res->port_id;
2456 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2457 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2459 if (!bypass_is_supported(port_id))
2462 if (!strcmp(res->event_value, "timeout"))
2463 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2464 else if (!strcmp(res->event_value, "os_on"))
2465 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2466 else if (!strcmp(res->event_value, "os_off"))
2467 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2468 else if (!strcmp(res->event_value, "power_on"))
2469 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2470 else if (!strcmp(res->event_value, "power_off"))
2471 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2473 bypass_event = RTE_BYPASS_EVENT_NONE;
2475 if (!strcmp(res->mode_value, "bypass"))
2476 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2477 else if (!strcmp(res->mode_value, "isolate"))
2478 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2480 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2482 /* Set the watchdog timeout. */
2483 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2486 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2487 (rc = rte_eth_dev_wd_timeout_store(port_id,
2488 bypass_timeout)) != 0) {
2489 printf("Failed to set timeout value %u "
2490 "for port %d, errto code: %d.\n",
2491 bypass_timeout, port_id, rc);
2495 /* Set the bypass event to transition to bypass mode. */
2496 if (0 != rte_eth_dev_bypass_event_store(port_id,
2497 bypass_event, bypass_mode)) {
2498 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2503 cmdline_parse_token_string_t cmd_setbypass_event_set =
2504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2506 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2507 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2509 cmdline_parse_token_string_t cmd_setbypass_event_event =
2510 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2512 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2513 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2514 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2515 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2518 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2519 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2520 mode_value, "normal#bypass#isolate");
2521 cmdline_parse_token_num_t cmd_setbypass_event_port =
2522 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2525 cmdline_parse_inst_t cmd_set_bypass_event = {
2526 .f = cmd_set_bypass_event_parsed,
2527 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2528 "mode (normal|bypass|isolate) (port_id): "
2529 "Set the NIC bypass event mode for port_id",
2532 (void *)&cmd_setbypass_event_set,
2533 (void *)&cmd_setbypass_event_bypass,
2534 (void *)&cmd_setbypass_event_event,
2535 (void *)&cmd_setbypass_event_event_value,
2536 (void *)&cmd_setbypass_event_mode,
2537 (void *)&cmd_setbypass_event_mode_value,
2538 (void *)&cmd_setbypass_event_port,
2544 /* *** SET NIC BYPASS TIMEOUT *** */
2545 struct cmd_set_bypass_timeout_result {
2546 cmdline_fixed_string_t set;
2547 cmdline_fixed_string_t bypass;
2548 cmdline_fixed_string_t timeout;
2549 cmdline_fixed_string_t value;
2553 cmd_set_bypass_timeout_parsed(void *parsed_result,
2554 __attribute__((unused)) struct cmdline *cl,
2555 __attribute__((unused)) void *data)
2557 struct cmd_set_bypass_timeout_result *res = parsed_result;
2559 if (!strcmp(res->value, "1.5"))
2560 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2561 else if (!strcmp(res->value, "2"))
2562 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2563 else if (!strcmp(res->value, "3"))
2564 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2565 else if (!strcmp(res->value, "4"))
2566 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2567 else if (!strcmp(res->value, "8"))
2568 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2569 else if (!strcmp(res->value, "16"))
2570 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2571 else if (!strcmp(res->value, "32"))
2572 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2574 bypass_timeout = RTE_BYPASS_TMT_OFF;
2577 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2578 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2580 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2581 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2583 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2584 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2585 timeout, "timeout");
2586 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2587 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2588 value, "0#1.5#2#3#4#8#16#32");
2590 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2591 .f = cmd_set_bypass_timeout_parsed,
2592 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2593 "Set the NIC bypass watchdog timeout",
2596 (void *)&cmd_setbypass_timeout_set,
2597 (void *)&cmd_setbypass_timeout_bypass,
2598 (void *)&cmd_setbypass_timeout_timeout,
2599 (void *)&cmd_setbypass_timeout_value,
2604 /* *** SHOW NIC BYPASS MODE *** */
2605 struct cmd_show_bypass_config_result {
2606 cmdline_fixed_string_t show;
2607 cmdline_fixed_string_t bypass;
2608 cmdline_fixed_string_t config;
2613 cmd_show_bypass_config_parsed(void *parsed_result,
2614 __attribute__((unused)) struct cmdline *cl,
2615 __attribute__((unused)) void *data)
2617 struct cmd_show_bypass_config_result *res = parsed_result;
2618 uint32_t event_mode;
2619 uint32_t bypass_mode;
2620 portid_t port_id = res->port_id;
2621 uint32_t timeout = bypass_timeout;
2624 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2625 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2626 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2627 {"UNKNOWN", "normal", "bypass", "isolate"};
2628 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2635 int num_events = (sizeof events) / (sizeof events[0]);
2637 if (!bypass_is_supported(port_id))
2640 /* Display the bypass mode.*/
2641 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2642 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2646 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2647 bypass_mode = RTE_BYPASS_MODE_NONE;
2649 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2652 /* Display the bypass timeout.*/
2653 if (!RTE_BYPASS_TMT_VALID(timeout))
2654 timeout = RTE_BYPASS_TMT_OFF;
2656 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2658 /* Display the bypass events and associated modes. */
2659 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2661 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2662 printf("\tFailed to get bypass mode for event = %s\n",
2665 if (!RTE_BYPASS_MODE_VALID(event_mode))
2666 event_mode = RTE_BYPASS_MODE_NONE;
2668 printf("\tbypass event: %-16s = %s\n", events[i],
2674 cmdline_parse_token_string_t cmd_showbypass_config_show =
2675 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2677 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2678 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2680 cmdline_parse_token_string_t cmd_showbypass_config_config =
2681 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2683 cmdline_parse_token_num_t cmd_showbypass_config_port =
2684 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2687 cmdline_parse_inst_t cmd_show_bypass_config = {
2688 .f = cmd_show_bypass_config_parsed,
2689 .help_str = "show bypass config (port_id): "
2690 "Show the NIC bypass config for port_id",
2693 (void *)&cmd_showbypass_config_show,
2694 (void *)&cmd_showbypass_config_bypass,
2695 (void *)&cmd_showbypass_config_config,
2696 (void *)&cmd_showbypass_config_port,
2702 /* *** SET FORWARDING MODE *** */
2703 struct cmd_set_fwd_mode_result {
2704 cmdline_fixed_string_t set;
2705 cmdline_fixed_string_t fwd;
2706 cmdline_fixed_string_t mode;
2709 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2710 __attribute__((unused)) struct cmdline *cl,
2711 __attribute__((unused)) void *data)
2713 struct cmd_set_fwd_mode_result *res = parsed_result;
2715 set_pkt_forwarding_mode(res->mode);
2718 cmdline_parse_token_string_t cmd_setfwd_set =
2719 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2720 cmdline_parse_token_string_t cmd_setfwd_fwd =
2721 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2722 cmdline_parse_token_string_t cmd_setfwd_mode =
2723 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2724 "" /* defined at init */);
2726 cmdline_parse_inst_t cmd_set_fwd_mode = {
2727 .f = cmd_set_fwd_mode_parsed,
2729 .help_str = NULL, /* defined at init */
2731 (void *)&cmd_setfwd_set,
2732 (void *)&cmd_setfwd_fwd,
2733 (void *)&cmd_setfwd_mode,
2738 static void cmd_set_fwd_mode_init(void)
2741 static char token[128];
2742 static char help[256];
2743 cmdline_parse_token_string_t *token_struct;
2745 modes = list_pkt_forwarding_modes();
2746 rte_snprintf(help, sizeof help, "set fwd %s - "
2747 "set packet forwarding mode", modes);
2748 cmd_set_fwd_mode.help_str = help;
2750 /* string token separator is # */
2751 for (c = token; *modes != '\0'; modes++)
2756 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2757 token_struct->string_data.str = token;
2760 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2761 struct cmd_set_burst_tx_retry_result {
2762 cmdline_fixed_string_t set;
2763 cmdline_fixed_string_t burst;
2764 cmdline_fixed_string_t tx;
2765 cmdline_fixed_string_t delay;
2767 cmdline_fixed_string_t retry;
2771 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2772 __attribute__((unused)) struct cmdline *cl,
2773 __attribute__((unused)) void *data)
2775 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2777 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2778 && !strcmp(res->tx, "tx")) {
2779 if (!strcmp(res->delay, "delay"))
2780 burst_tx_delay_time = res->time;
2781 if (!strcmp(res->retry, "retry"))
2782 burst_tx_retry_num = res->retry_num;
2787 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2788 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2789 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2790 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2792 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2793 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2794 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2795 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2796 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2797 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2798 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2799 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2800 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2801 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2803 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2804 .f = cmd_set_burst_tx_retry_parsed,
2805 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2807 (void *)&cmd_set_burst_tx_retry_set,
2808 (void *)&cmd_set_burst_tx_retry_burst,
2809 (void *)&cmd_set_burst_tx_retry_tx,
2810 (void *)&cmd_set_burst_tx_retry_delay,
2811 (void *)&cmd_set_burst_tx_retry_time,
2812 (void *)&cmd_set_burst_tx_retry_retry,
2813 (void *)&cmd_set_burst_tx_retry_retry_num,
2818 /* *** SET PROMISC MODE *** */
2819 struct cmd_set_promisc_mode_result {
2820 cmdline_fixed_string_t set;
2821 cmdline_fixed_string_t promisc;
2822 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2823 uint8_t port_num; /* valid if "allports" argument == 0 */
2824 cmdline_fixed_string_t mode;
2827 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2828 __attribute__((unused)) struct cmdline *cl,
2831 struct cmd_set_promisc_mode_result *res = parsed_result;
2835 if (!strcmp(res->mode, "on"))
2842 for (i = 0; i < nb_ports; i++) {
2844 rte_eth_promiscuous_enable(i);
2846 rte_eth_promiscuous_disable(i);
2851 rte_eth_promiscuous_enable(res->port_num);
2853 rte_eth_promiscuous_disable(res->port_num);
2857 cmdline_parse_token_string_t cmd_setpromisc_set =
2858 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2859 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2860 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2862 cmdline_parse_token_string_t cmd_setpromisc_portall =
2863 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2865 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2866 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2868 cmdline_parse_token_string_t cmd_setpromisc_mode =
2869 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2872 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2873 .f = cmd_set_promisc_mode_parsed,
2875 .help_str = "set promisc all on|off: set promisc mode for all ports",
2877 (void *)&cmd_setpromisc_set,
2878 (void *)&cmd_setpromisc_promisc,
2879 (void *)&cmd_setpromisc_portall,
2880 (void *)&cmd_setpromisc_mode,
2885 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2886 .f = cmd_set_promisc_mode_parsed,
2888 .help_str = "set promisc X on|off: set promisc mode on port X",
2890 (void *)&cmd_setpromisc_set,
2891 (void *)&cmd_setpromisc_promisc,
2892 (void *)&cmd_setpromisc_portnum,
2893 (void *)&cmd_setpromisc_mode,
2898 /* *** SET ALLMULTI MODE *** */
2899 struct cmd_set_allmulti_mode_result {
2900 cmdline_fixed_string_t set;
2901 cmdline_fixed_string_t allmulti;
2902 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2903 uint8_t port_num; /* valid if "allports" argument == 0 */
2904 cmdline_fixed_string_t mode;
2907 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2908 __attribute__((unused)) struct cmdline *cl,
2911 struct cmd_set_allmulti_mode_result *res = parsed_result;
2915 if (!strcmp(res->mode, "on"))
2922 for (i = 0; i < nb_ports; i++) {
2924 rte_eth_allmulticast_enable(i);
2926 rte_eth_allmulticast_disable(i);
2931 rte_eth_allmulticast_enable(res->port_num);
2933 rte_eth_allmulticast_disable(res->port_num);
2937 cmdline_parse_token_string_t cmd_setallmulti_set =
2938 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2939 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2940 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2942 cmdline_parse_token_string_t cmd_setallmulti_portall =
2943 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2945 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2946 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2948 cmdline_parse_token_string_t cmd_setallmulti_mode =
2949 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2952 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2953 .f = cmd_set_allmulti_mode_parsed,
2955 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2957 (void *)&cmd_setallmulti_set,
2958 (void *)&cmd_setallmulti_allmulti,
2959 (void *)&cmd_setallmulti_portall,
2960 (void *)&cmd_setallmulti_mode,
2965 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2966 .f = cmd_set_allmulti_mode_parsed,
2968 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2970 (void *)&cmd_setallmulti_set,
2971 (void *)&cmd_setallmulti_allmulti,
2972 (void *)&cmd_setallmulti_portnum,
2973 (void *)&cmd_setallmulti_mode,
2978 /* *** ADD/REMOVE A PKT FILTER *** */
2979 struct cmd_pkt_filter_result {
2980 cmdline_fixed_string_t pkt_filter;
2982 cmdline_fixed_string_t protocol;
2983 cmdline_fixed_string_t src;
2984 cmdline_ipaddr_t ip_src;
2986 cmdline_fixed_string_t dst;
2987 cmdline_ipaddr_t ip_dst;
2989 cmdline_fixed_string_t flexbytes;
2990 uint16_t flexbytes_value;
2991 cmdline_fixed_string_t vlan;
2993 cmdline_fixed_string_t queue;
2995 cmdline_fixed_string_t soft;
3000 cmd_pkt_filter_parsed(void *parsed_result,
3001 __attribute__((unused)) struct cmdline *cl,
3002 __attribute__((unused)) void *data)
3004 struct rte_fdir_filter fdir_filter;
3005 struct cmd_pkt_filter_result *res = parsed_result;
3007 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3009 if (res->ip_src.family == AF_INET)
3010 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3012 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3013 &(res->ip_src.addr.ipv6),
3014 sizeof(struct in6_addr));
3016 if (res->ip_dst.family == AF_INET)
3017 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3019 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3020 &(res->ip_dst.addr.ipv6),
3021 sizeof(struct in6_addr));
3023 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3024 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3026 if (!strcmp(res->protocol, "udp"))
3027 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3028 else if (!strcmp(res->protocol, "tcp"))
3029 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3030 else if (!strcmp(res->protocol, "sctp"))
3031 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3032 else /* default only IP */
3033 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3035 if (res->ip_dst.family == AF_INET6)
3036 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3038 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3040 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3041 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3043 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3044 fdir_add_signature_filter(res->port_id, res->queue_id,
3046 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3047 fdir_update_signature_filter(res->port_id, res->queue_id,
3049 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3050 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3051 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3052 fdir_add_perfect_filter(res->port_id, res->soft_id,
3054 (uint8_t) (res->queue_id < 0),
3056 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3057 fdir_update_perfect_filter(res->port_id, res->soft_id,
3059 (uint8_t) (res->queue_id < 0),
3061 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3062 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3068 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3069 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3071 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3072 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3073 protocol, "ip#tcp#udp#sctp");
3074 cmdline_parse_token_string_t cmd_pkt_filter_src =
3075 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3077 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3078 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3080 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3081 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3083 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3084 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3086 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3087 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3089 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3090 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3092 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3093 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3094 flexbytes, "flexbytes");
3095 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3096 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3097 flexbytes_value, UINT16);
3098 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3099 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3101 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3102 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3104 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3105 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3107 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3108 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3110 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3111 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3113 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3114 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3118 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3119 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3120 pkt_filter, "add_signature_filter");
3121 cmdline_parse_inst_t cmd_add_signature_filter = {
3122 .f = cmd_pkt_filter_parsed,
3124 .help_str = "add a signature filter",
3126 (void *)&cmd_pkt_filter_add_signature_filter,
3127 (void *)&cmd_pkt_filter_port_id,
3128 (void *)&cmd_pkt_filter_protocol,
3129 (void *)&cmd_pkt_filter_src,
3130 (void *)&cmd_pkt_filter_ip_src,
3131 (void *)&cmd_pkt_filter_port_src,
3132 (void *)&cmd_pkt_filter_dst,
3133 (void *)&cmd_pkt_filter_ip_dst,
3134 (void *)&cmd_pkt_filter_port_dst,
3135 (void *)&cmd_pkt_filter_flexbytes,
3136 (void *)&cmd_pkt_filter_flexbytes_value,
3137 (void *)&cmd_pkt_filter_vlan,
3138 (void *)&cmd_pkt_filter_vlan_id,
3139 (void *)&cmd_pkt_filter_queue,
3140 (void *)&cmd_pkt_filter_queue_id,
3146 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3147 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3148 pkt_filter, "upd_signature_filter");
3149 cmdline_parse_inst_t cmd_upd_signature_filter = {
3150 .f = cmd_pkt_filter_parsed,
3152 .help_str = "update a signature filter",
3154 (void *)&cmd_pkt_filter_upd_signature_filter,
3155 (void *)&cmd_pkt_filter_port_id,
3156 (void *)&cmd_pkt_filter_protocol,
3157 (void *)&cmd_pkt_filter_src,
3158 (void *)&cmd_pkt_filter_ip_src,
3159 (void *)&cmd_pkt_filter_port_src,
3160 (void *)&cmd_pkt_filter_dst,
3161 (void *)&cmd_pkt_filter_ip_dst,
3162 (void *)&cmd_pkt_filter_port_dst,
3163 (void *)&cmd_pkt_filter_flexbytes,
3164 (void *)&cmd_pkt_filter_flexbytes_value,
3165 (void *)&cmd_pkt_filter_vlan,
3166 (void *)&cmd_pkt_filter_vlan_id,
3167 (void *)&cmd_pkt_filter_queue,
3168 (void *)&cmd_pkt_filter_queue_id,
3174 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3175 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3176 pkt_filter, "rm_signature_filter");
3177 cmdline_parse_inst_t cmd_rm_signature_filter = {
3178 .f = cmd_pkt_filter_parsed,
3180 .help_str = "remove a signature filter",
3182 (void *)&cmd_pkt_filter_rm_signature_filter,
3183 (void *)&cmd_pkt_filter_port_id,
3184 (void *)&cmd_pkt_filter_protocol,
3185 (void *)&cmd_pkt_filter_src,
3186 (void *)&cmd_pkt_filter_ip_src,
3187 (void *)&cmd_pkt_filter_port_src,
3188 (void *)&cmd_pkt_filter_dst,
3189 (void *)&cmd_pkt_filter_ip_dst,
3190 (void *)&cmd_pkt_filter_port_dst,
3191 (void *)&cmd_pkt_filter_flexbytes,
3192 (void *)&cmd_pkt_filter_flexbytes_value,
3193 (void *)&cmd_pkt_filter_vlan,
3194 (void *)&cmd_pkt_filter_vlan_id,
3200 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3201 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3202 pkt_filter, "add_perfect_filter");
3203 cmdline_parse_inst_t cmd_add_perfect_filter = {
3204 .f = cmd_pkt_filter_parsed,
3206 .help_str = "add a perfect filter",
3208 (void *)&cmd_pkt_filter_add_perfect_filter,
3209 (void *)&cmd_pkt_filter_port_id,
3210 (void *)&cmd_pkt_filter_protocol,
3211 (void *)&cmd_pkt_filter_src,
3212 (void *)&cmd_pkt_filter_ip_src,
3213 (void *)&cmd_pkt_filter_port_src,
3214 (void *)&cmd_pkt_filter_dst,
3215 (void *)&cmd_pkt_filter_ip_dst,
3216 (void *)&cmd_pkt_filter_port_dst,
3217 (void *)&cmd_pkt_filter_flexbytes,
3218 (void *)&cmd_pkt_filter_flexbytes_value,
3219 (void *)&cmd_pkt_filter_vlan,
3220 (void *)&cmd_pkt_filter_vlan_id,
3221 (void *)&cmd_pkt_filter_queue,
3222 (void *)&cmd_pkt_filter_queue_id,
3223 (void *)&cmd_pkt_filter_soft,
3224 (void *)&cmd_pkt_filter_soft_id,
3230 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3231 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3232 pkt_filter, "upd_perfect_filter");
3233 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3234 .f = cmd_pkt_filter_parsed,
3236 .help_str = "update a perfect filter",
3238 (void *)&cmd_pkt_filter_upd_perfect_filter,
3239 (void *)&cmd_pkt_filter_port_id,
3240 (void *)&cmd_pkt_filter_protocol,
3241 (void *)&cmd_pkt_filter_src,
3242 (void *)&cmd_pkt_filter_ip_src,
3243 (void *)&cmd_pkt_filter_port_src,
3244 (void *)&cmd_pkt_filter_dst,
3245 (void *)&cmd_pkt_filter_ip_dst,
3246 (void *)&cmd_pkt_filter_port_dst,
3247 (void *)&cmd_pkt_filter_flexbytes,
3248 (void *)&cmd_pkt_filter_flexbytes_value,
3249 (void *)&cmd_pkt_filter_vlan,
3250 (void *)&cmd_pkt_filter_vlan_id,
3251 (void *)&cmd_pkt_filter_queue,
3252 (void *)&cmd_pkt_filter_queue_id,
3253 (void *)&cmd_pkt_filter_soft,
3254 (void *)&cmd_pkt_filter_soft_id,
3260 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3261 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3262 pkt_filter, "rm_perfect_filter");
3263 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3264 .f = cmd_pkt_filter_parsed,
3266 .help_str = "remove a perfect filter",
3268 (void *)&cmd_pkt_filter_rm_perfect_filter,
3269 (void *)&cmd_pkt_filter_port_id,
3270 (void *)&cmd_pkt_filter_protocol,
3271 (void *)&cmd_pkt_filter_src,
3272 (void *)&cmd_pkt_filter_ip_src,
3273 (void *)&cmd_pkt_filter_port_src,
3274 (void *)&cmd_pkt_filter_dst,
3275 (void *)&cmd_pkt_filter_ip_dst,
3276 (void *)&cmd_pkt_filter_port_dst,
3277 (void *)&cmd_pkt_filter_flexbytes,
3278 (void *)&cmd_pkt_filter_flexbytes_value,
3279 (void *)&cmd_pkt_filter_vlan,
3280 (void *)&cmd_pkt_filter_vlan_id,
3281 (void *)&cmd_pkt_filter_soft,
3282 (void *)&cmd_pkt_filter_soft_id,
3287 /* *** SETUP MASKS FILTER *** */
3288 struct cmd_pkt_filter_masks_result {
3289 cmdline_fixed_string_t filter_mask;
3291 cmdline_fixed_string_t src_mask;
3292 uint32_t ip_src_mask;
3293 uint16_t ipv6_src_mask;
3294 uint16_t port_src_mask;
3295 cmdline_fixed_string_t dst_mask;
3296 uint32_t ip_dst_mask;
3297 uint16_t ipv6_dst_mask;
3298 uint16_t port_dst_mask;
3299 cmdline_fixed_string_t flexbytes;
3300 uint8_t flexbytes_value;
3301 cmdline_fixed_string_t vlan_id;
3302 uint8_t vlan_id_value;
3303 cmdline_fixed_string_t vlan_prio;
3304 uint8_t vlan_prio_value;
3305 cmdline_fixed_string_t only_ip_flow;
3306 uint8_t only_ip_flow_value;
3307 cmdline_fixed_string_t comp_ipv6_dst;
3308 uint8_t comp_ipv6_dst_value;
3312 cmd_pkt_filter_masks_parsed(void *parsed_result,
3313 __attribute__((unused)) struct cmdline *cl,
3314 __attribute__((unused)) void *data)
3316 struct rte_fdir_masks fdir_masks;
3317 struct cmd_pkt_filter_masks_result *res = parsed_result;
3319 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3321 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3322 fdir_masks.vlan_id = res->vlan_id_value;
3323 fdir_masks.vlan_prio = res->vlan_prio_value;
3324 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3325 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3326 fdir_masks.src_port_mask = res->port_src_mask;
3327 fdir_masks.dst_port_mask = res->port_dst_mask;
3328 fdir_masks.flexbytes = res->flexbytes_value;
3330 fdir_set_masks(res->port_id, &fdir_masks);
3333 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3334 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3335 filter_mask, "set_masks_filter");
3336 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3337 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3339 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3340 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3341 only_ip_flow, "only_ip_flow");
3342 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3343 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3344 only_ip_flow_value, UINT8);
3345 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3346 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3347 src_mask, "src_mask");
3348 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3349 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3350 ip_src_mask, UINT32);
3351 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3352 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3353 port_src_mask, UINT16);
3354 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3355 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3356 dst_mask, "dst_mask");
3357 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3358 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3359 ip_dst_mask, UINT32);
3360 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3361 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3362 port_dst_mask, UINT16);
3363 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3364 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3365 flexbytes, "flexbytes");
3366 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3367 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3368 flexbytes_value, UINT8);
3369 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3370 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3371 vlan_id, "vlan_id");
3372 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3373 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3374 vlan_id_value, UINT8);
3375 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3376 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3377 vlan_prio, "vlan_prio");
3378 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3379 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3380 vlan_prio_value, UINT8);
3382 cmdline_parse_inst_t cmd_set_masks_filter = {
3383 .f = cmd_pkt_filter_masks_parsed,
3385 .help_str = "setup masks filter",
3387 (void *)&cmd_pkt_filter_masks_filter_mask,
3388 (void *)&cmd_pkt_filter_masks_port_id,
3389 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3390 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3391 (void *)&cmd_pkt_filter_masks_src_mask,
3392 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3393 (void *)&cmd_pkt_filter_masks_port_src_mask,
3394 (void *)&cmd_pkt_filter_masks_dst_mask,
3395 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3396 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3397 (void *)&cmd_pkt_filter_masks_flexbytes,
3398 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3399 (void *)&cmd_pkt_filter_masks_vlan_id,
3400 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3401 (void *)&cmd_pkt_filter_masks_vlan_prio,
3402 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3408 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3409 __attribute__((unused)) struct cmdline *cl,
3410 __attribute__((unused)) void *data)
3412 struct rte_fdir_masks fdir_masks;
3413 struct cmd_pkt_filter_masks_result *res = parsed_result;
3415 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3417 fdir_masks.set_ipv6_mask = 1;
3418 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3419 fdir_masks.vlan_id = res->vlan_id_value;
3420 fdir_masks.vlan_prio = res->vlan_prio_value;
3421 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3422 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3423 fdir_masks.src_port_mask = res->port_src_mask;
3424 fdir_masks.dst_port_mask = res->port_dst_mask;
3425 fdir_masks.flexbytes = res->flexbytes_value;
3426 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3428 fdir_set_masks(res->port_id, &fdir_masks);
3431 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3432 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3433 filter_mask, "set_ipv6_masks_filter");
3434 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3435 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3436 ipv6_src_mask, UINT16);
3437 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3438 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3439 ipv6_dst_mask, UINT16);
3441 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3442 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3443 comp_ipv6_dst, "compare_dst");
3444 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3445 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3446 comp_ipv6_dst_value, UINT8);
3448 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3449 .f = cmd_pkt_filter_masks_ipv6_parsed,
3451 .help_str = "setup ipv6 masks filter",
3453 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3454 (void *)&cmd_pkt_filter_masks_port_id,
3455 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3456 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3457 (void *)&cmd_pkt_filter_masks_src_mask,
3458 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3459 (void *)&cmd_pkt_filter_masks_port_src_mask,
3460 (void *)&cmd_pkt_filter_masks_dst_mask,
3461 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3462 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3463 (void *)&cmd_pkt_filter_masks_flexbytes,
3464 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3465 (void *)&cmd_pkt_filter_masks_vlan_id,
3466 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3467 (void *)&cmd_pkt_filter_masks_vlan_prio,
3468 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3469 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3470 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3475 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3476 struct cmd_link_flow_ctrl_set_result {
3477 cmdline_fixed_string_t set;
3478 cmdline_fixed_string_t flow_ctrl;
3479 cmdline_fixed_string_t rx;
3480 cmdline_fixed_string_t rx_lfc_mode;
3481 cmdline_fixed_string_t tx;
3482 cmdline_fixed_string_t tx_lfc_mode;
3483 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3484 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3485 uint32_t high_water;
3487 uint16_t pause_time;
3493 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3494 __attribute__((unused)) struct cmdline *cl,
3495 __attribute__((unused)) void *data)
3497 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3498 struct rte_eth_fc_conf fc_conf;
3499 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3503 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3504 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3505 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3506 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3508 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3509 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3512 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3513 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3514 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3516 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3517 fc_conf.high_water = res->high_water;
3518 fc_conf.low_water = res->low_water;
3519 fc_conf.pause_time = res->pause_time;
3520 fc_conf.send_xon = res->send_xon;
3521 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3523 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3525 printf("bad flow contrl parameter, return code = %d \n", ret);
3528 cmdline_parse_token_string_t cmd_lfc_set_set =
3529 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3531 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3532 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3533 flow_ctrl, "flow_ctrl");
3534 cmdline_parse_token_string_t cmd_lfc_set_rx =
3535 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3537 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3538 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3539 rx_lfc_mode, "on#off");
3540 cmdline_parse_token_string_t cmd_lfc_set_tx =
3541 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3543 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3544 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3545 tx_lfc_mode, "on#off");
3546 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3547 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3548 high_water, UINT32);
3549 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3550 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3552 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3553 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3554 pause_time, UINT16);
3555 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3556 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3558 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3559 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3560 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3561 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3563 mac_ctrl_frame_fwd_mode, "on#off");
3564 cmdline_parse_token_num_t cmd_lfc_set_portid =
3565 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3568 cmdline_parse_inst_t cmd_link_flow_control_set = {
3569 .f = cmd_link_flow_ctrl_set_parsed,
3571 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3572 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3575 (void *)&cmd_lfc_set_set,
3576 (void *)&cmd_lfc_set_flow_ctrl,
3577 (void *)&cmd_lfc_set_rx,
3578 (void *)&cmd_lfc_set_rx_mode,
3579 (void *)&cmd_lfc_set_tx,
3580 (void *)&cmd_lfc_set_tx_mode,
3581 (void *)&cmd_lfc_set_high_water,
3582 (void *)&cmd_lfc_set_low_water,
3583 (void *)&cmd_lfc_set_pause_time,
3584 (void *)&cmd_lfc_set_send_xon,
3585 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3586 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3587 (void *)&cmd_lfc_set_portid,
3592 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3593 struct cmd_priority_flow_ctrl_set_result {
3594 cmdline_fixed_string_t set;
3595 cmdline_fixed_string_t pfc_ctrl;
3596 cmdline_fixed_string_t rx;
3597 cmdline_fixed_string_t rx_pfc_mode;
3598 cmdline_fixed_string_t tx;
3599 cmdline_fixed_string_t tx_pfc_mode;
3600 uint32_t high_water;
3602 uint16_t pause_time;
3608 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3609 __attribute__((unused)) struct cmdline *cl,
3610 __attribute__((unused)) void *data)
3612 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3613 struct rte_eth_pfc_conf pfc_conf;
3614 int rx_fc_enable, tx_fc_enable;
3618 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3619 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3620 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3621 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3623 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3624 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3627 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3628 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3629 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3630 pfc_conf.fc.high_water = res->high_water;
3631 pfc_conf.fc.low_water = res->low_water;
3632 pfc_conf.fc.pause_time = res->pause_time;
3633 pfc_conf.priority = res->priority;
3635 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3637 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3640 cmdline_parse_token_string_t cmd_pfc_set_set =
3641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3643 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3645 pfc_ctrl, "pfc_ctrl");
3646 cmdline_parse_token_string_t cmd_pfc_set_rx =
3647 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3649 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3650 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3651 rx_pfc_mode, "on#off");
3652 cmdline_parse_token_string_t cmd_pfc_set_tx =
3653 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3655 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3656 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3657 tx_pfc_mode, "on#off");
3658 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3660 high_water, UINT32);
3661 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3662 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3664 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3665 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3666 pause_time, UINT16);
3667 cmdline_parse_token_num_t cmd_pfc_set_priority =
3668 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3670 cmdline_parse_token_num_t cmd_pfc_set_portid =
3671 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3674 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3675 .f = cmd_priority_flow_ctrl_set_parsed,
3677 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3678 tx on|off high_water low_water pause_time priority port_id",
3680 (void *)&cmd_pfc_set_set,
3681 (void *)&cmd_pfc_set_flow_ctrl,
3682 (void *)&cmd_pfc_set_rx,
3683 (void *)&cmd_pfc_set_rx_mode,
3684 (void *)&cmd_pfc_set_tx,
3685 (void *)&cmd_pfc_set_tx_mode,
3686 (void *)&cmd_pfc_set_high_water,
3687 (void *)&cmd_pfc_set_low_water,
3688 (void *)&cmd_pfc_set_pause_time,
3689 (void *)&cmd_pfc_set_priority,
3690 (void *)&cmd_pfc_set_portid,
3695 /* *** RESET CONFIGURATION *** */
3696 struct cmd_reset_result {
3697 cmdline_fixed_string_t reset;
3698 cmdline_fixed_string_t def;
3701 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3703 __attribute__((unused)) void *data)
3705 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3706 set_def_fwd_config();
3709 cmdline_parse_token_string_t cmd_reset_set =
3710 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3711 cmdline_parse_token_string_t cmd_reset_def =
3712 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3715 cmdline_parse_inst_t cmd_reset = {
3716 .f = cmd_reset_parsed,
3718 .help_str = "set default: reset default forwarding configuration",
3720 (void *)&cmd_reset_set,
3721 (void *)&cmd_reset_def,
3726 /* *** START FORWARDING *** */
3727 struct cmd_start_result {
3728 cmdline_fixed_string_t start;
3731 cmdline_parse_token_string_t cmd_start_start =
3732 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3734 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3735 __attribute__((unused)) struct cmdline *cl,
3736 __attribute__((unused)) void *data)
3738 start_packet_forwarding(0);
3741 cmdline_parse_inst_t cmd_start = {
3742 .f = cmd_start_parsed,
3744 .help_str = "start packet forwarding",
3746 (void *)&cmd_start_start,
3751 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3752 struct cmd_start_tx_first_result {
3753 cmdline_fixed_string_t start;
3754 cmdline_fixed_string_t tx_first;
3758 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 start_packet_forwarding(1);
3765 cmdline_parse_token_string_t cmd_start_tx_first_start =
3766 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3768 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3769 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3770 tx_first, "tx_first");
3772 cmdline_parse_inst_t cmd_start_tx_first = {
3773 .f = cmd_start_tx_first_parsed,
3775 .help_str = "start packet forwarding, after sending 1 burst of packets",
3777 (void *)&cmd_start_tx_first_start,
3778 (void *)&cmd_start_tx_first_tx_first,
3783 /* *** SHOW CFG *** */
3784 struct cmd_showcfg_result {
3785 cmdline_fixed_string_t show;
3786 cmdline_fixed_string_t cfg;
3787 cmdline_fixed_string_t what;
3790 static void cmd_showcfg_parsed(void *parsed_result,
3791 __attribute__((unused)) struct cmdline *cl,
3792 __attribute__((unused)) void *data)
3794 struct cmd_showcfg_result *res = parsed_result;
3795 if (!strcmp(res->what, "rxtx"))
3796 rxtx_config_display();
3797 else if (!strcmp(res->what, "cores"))
3798 fwd_lcores_config_display();
3799 else if (!strcmp(res->what, "fwd"))
3800 fwd_config_display();
3803 cmdline_parse_token_string_t cmd_showcfg_show =
3804 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3805 cmdline_parse_token_string_t cmd_showcfg_port =
3806 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3807 cmdline_parse_token_string_t cmd_showcfg_what =
3808 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3811 cmdline_parse_inst_t cmd_showcfg = {
3812 .f = cmd_showcfg_parsed,
3814 .help_str = "show config rxtx|cores|fwd",
3816 (void *)&cmd_showcfg_show,
3817 (void *)&cmd_showcfg_port,
3818 (void *)&cmd_showcfg_what,
3823 /* *** SHOW ALL PORT INFO *** */
3824 struct cmd_showportall_result {
3825 cmdline_fixed_string_t show;
3826 cmdline_fixed_string_t port;
3827 cmdline_fixed_string_t what;
3828 cmdline_fixed_string_t all;
3831 static void cmd_showportall_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3837 struct cmd_showportall_result *res = parsed_result;
3838 if (!strcmp(res->show, "clear")) {
3839 if (!strcmp(res->what, "stats"))
3840 for (i = 0; i < nb_ports; i++)
3842 } else if (!strcmp(res->what, "info"))
3843 for (i = 0; i < nb_ports; i++)
3844 port_infos_display(i);
3845 else if (!strcmp(res->what, "stats"))
3846 for (i = 0; i < nb_ports; i++)
3847 nic_stats_display(i);
3848 else if (!strcmp(res->what, "fdir"))
3849 for (i = 0; i < nb_ports; i++)
3851 else if (!strcmp(res->what, "stat_qmap"))
3852 for (i = 0; i < nb_ports; i++)
3853 nic_stats_mapping_display(i);
3856 cmdline_parse_token_string_t cmd_showportall_show =
3857 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3859 cmdline_parse_token_string_t cmd_showportall_port =
3860 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3861 cmdline_parse_token_string_t cmd_showportall_what =
3862 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3863 "info#stats#fdir#stat_qmap");
3864 cmdline_parse_token_string_t cmd_showportall_all =
3865 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3866 cmdline_parse_inst_t cmd_showportall = {
3867 .f = cmd_showportall_parsed,
3869 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3871 (void *)&cmd_showportall_show,
3872 (void *)&cmd_showportall_port,
3873 (void *)&cmd_showportall_what,
3874 (void *)&cmd_showportall_all,
3879 /* *** SHOW PORT INFO *** */
3880 struct cmd_showport_result {
3881 cmdline_fixed_string_t show;
3882 cmdline_fixed_string_t port;
3883 cmdline_fixed_string_t what;
3887 static void cmd_showport_parsed(void *parsed_result,
3888 __attribute__((unused)) struct cmdline *cl,
3889 __attribute__((unused)) void *data)
3891 struct cmd_showport_result *res = parsed_result;
3892 if (!strcmp(res->show, "clear")) {
3893 if (!strcmp(res->what, "stats"))
3894 nic_stats_clear(res->portnum);
3895 } else if (!strcmp(res->what, "info"))
3896 port_infos_display(res->portnum);
3897 else if (!strcmp(res->what, "stats"))
3898 nic_stats_display(res->portnum);
3899 else if (!strcmp(res->what, "fdir"))
3900 fdir_get_infos(res->portnum);
3901 else if (!strcmp(res->what, "stat_qmap"))
3902 nic_stats_mapping_display(res->portnum);
3905 cmdline_parse_token_string_t cmd_showport_show =
3906 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3908 cmdline_parse_token_string_t cmd_showport_port =
3909 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3910 cmdline_parse_token_string_t cmd_showport_what =
3911 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3912 "info#stats#fdir#stat_qmap");
3913 cmdline_parse_token_num_t cmd_showport_portnum =
3914 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3916 cmdline_parse_inst_t cmd_showport = {
3917 .f = cmd_showport_parsed,
3919 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3921 (void *)&cmd_showport_show,
3922 (void *)&cmd_showport_port,
3923 (void *)&cmd_showport_what,
3924 (void *)&cmd_showport_portnum,
3929 /* *** READ PORT REGISTER *** */
3930 struct cmd_read_reg_result {
3931 cmdline_fixed_string_t read;
3932 cmdline_fixed_string_t reg;
3938 cmd_read_reg_parsed(void *parsed_result,
3939 __attribute__((unused)) struct cmdline *cl,
3940 __attribute__((unused)) void *data)
3942 struct cmd_read_reg_result *res = parsed_result;
3943 port_reg_display(res->port_id, res->reg_off);
3946 cmdline_parse_token_string_t cmd_read_reg_read =
3947 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3948 cmdline_parse_token_string_t cmd_read_reg_reg =
3949 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3950 cmdline_parse_token_num_t cmd_read_reg_port_id =
3951 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3952 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3953 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3955 cmdline_parse_inst_t cmd_read_reg = {
3956 .f = cmd_read_reg_parsed,
3958 .help_str = "read reg port_id reg_off",
3960 (void *)&cmd_read_reg_read,
3961 (void *)&cmd_read_reg_reg,
3962 (void *)&cmd_read_reg_port_id,
3963 (void *)&cmd_read_reg_reg_off,
3968 /* *** READ PORT REGISTER BIT FIELD *** */
3969 struct cmd_read_reg_bit_field_result {
3970 cmdline_fixed_string_t read;
3971 cmdline_fixed_string_t regfield;
3979 cmd_read_reg_bit_field_parsed(void *parsed_result,
3980 __attribute__((unused)) struct cmdline *cl,
3981 __attribute__((unused)) void *data)
3983 struct cmd_read_reg_bit_field_result *res = parsed_result;
3984 port_reg_bit_field_display(res->port_id, res->reg_off,
3985 res->bit1_pos, res->bit2_pos);
3988 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3989 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3991 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3992 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3993 regfield, "regfield");
3994 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3995 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3997 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3998 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4000 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4001 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4003 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4007 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4008 .f = cmd_read_reg_bit_field_parsed,
4010 .help_str = "read regfield port_id reg_off bit_x bit_y "
4011 "(read register bit field between bit_x and bit_y included)",
4013 (void *)&cmd_read_reg_bit_field_read,
4014 (void *)&cmd_read_reg_bit_field_regfield,
4015 (void *)&cmd_read_reg_bit_field_port_id,
4016 (void *)&cmd_read_reg_bit_field_reg_off,
4017 (void *)&cmd_read_reg_bit_field_bit1_pos,
4018 (void *)&cmd_read_reg_bit_field_bit2_pos,
4023 /* *** READ PORT REGISTER BIT *** */
4024 struct cmd_read_reg_bit_result {
4025 cmdline_fixed_string_t read;
4026 cmdline_fixed_string_t regbit;
4033 cmd_read_reg_bit_parsed(void *parsed_result,
4034 __attribute__((unused)) struct cmdline *cl,
4035 __attribute__((unused)) void *data)
4037 struct cmd_read_reg_bit_result *res = parsed_result;
4038 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4041 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4042 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4043 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4044 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4046 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4047 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4048 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4049 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4050 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4053 cmdline_parse_inst_t cmd_read_reg_bit = {
4054 .f = cmd_read_reg_bit_parsed,
4056 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4058 (void *)&cmd_read_reg_bit_read,
4059 (void *)&cmd_read_reg_bit_regbit,
4060 (void *)&cmd_read_reg_bit_port_id,
4061 (void *)&cmd_read_reg_bit_reg_off,
4062 (void *)&cmd_read_reg_bit_bit_pos,
4067 /* *** WRITE PORT REGISTER *** */
4068 struct cmd_write_reg_result {
4069 cmdline_fixed_string_t write;
4070 cmdline_fixed_string_t reg;
4077 cmd_write_reg_parsed(void *parsed_result,
4078 __attribute__((unused)) struct cmdline *cl,
4079 __attribute__((unused)) void *data)
4081 struct cmd_write_reg_result *res = parsed_result;
4082 port_reg_set(res->port_id, res->reg_off, res->value);
4085 cmdline_parse_token_string_t cmd_write_reg_write =
4086 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4087 cmdline_parse_token_string_t cmd_write_reg_reg =
4088 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4089 cmdline_parse_token_num_t cmd_write_reg_port_id =
4090 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4091 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4092 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4093 cmdline_parse_token_num_t cmd_write_reg_value =
4094 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4096 cmdline_parse_inst_t cmd_write_reg = {
4097 .f = cmd_write_reg_parsed,
4099 .help_str = "write reg port_id reg_off reg_value",
4101 (void *)&cmd_write_reg_write,
4102 (void *)&cmd_write_reg_reg,
4103 (void *)&cmd_write_reg_port_id,
4104 (void *)&cmd_write_reg_reg_off,
4105 (void *)&cmd_write_reg_value,
4110 /* *** WRITE PORT REGISTER BIT FIELD *** */
4111 struct cmd_write_reg_bit_field_result {
4112 cmdline_fixed_string_t write;
4113 cmdline_fixed_string_t regfield;
4122 cmd_write_reg_bit_field_parsed(void *parsed_result,
4123 __attribute__((unused)) struct cmdline *cl,
4124 __attribute__((unused)) void *data)
4126 struct cmd_write_reg_bit_field_result *res = parsed_result;
4127 port_reg_bit_field_set(res->port_id, res->reg_off,
4128 res->bit1_pos, res->bit2_pos, res->value);
4131 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4132 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4134 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4135 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4136 regfield, "regfield");
4137 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4138 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4140 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4141 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4143 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4144 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4146 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4147 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4149 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4153 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4154 .f = cmd_write_reg_bit_field_parsed,
4156 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4157 "(set register bit field between bit_x and bit_y included)",
4159 (void *)&cmd_write_reg_bit_field_write,
4160 (void *)&cmd_write_reg_bit_field_regfield,
4161 (void *)&cmd_write_reg_bit_field_port_id,
4162 (void *)&cmd_write_reg_bit_field_reg_off,
4163 (void *)&cmd_write_reg_bit_field_bit1_pos,
4164 (void *)&cmd_write_reg_bit_field_bit2_pos,
4165 (void *)&cmd_write_reg_bit_field_value,
4170 /* *** WRITE PORT REGISTER BIT *** */
4171 struct cmd_write_reg_bit_result {
4172 cmdline_fixed_string_t write;
4173 cmdline_fixed_string_t regbit;
4181 cmd_write_reg_bit_parsed(void *parsed_result,
4182 __attribute__((unused)) struct cmdline *cl,
4183 __attribute__((unused)) void *data)
4185 struct cmd_write_reg_bit_result *res = parsed_result;
4186 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4189 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4190 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4192 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4193 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4195 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4196 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4197 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4199 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4201 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4202 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4204 cmdline_parse_inst_t cmd_write_reg_bit = {
4205 .f = cmd_write_reg_bit_parsed,
4207 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4209 (void *)&cmd_write_reg_bit_write,
4210 (void *)&cmd_write_reg_bit_regbit,
4211 (void *)&cmd_write_reg_bit_port_id,
4212 (void *)&cmd_write_reg_bit_reg_off,
4213 (void *)&cmd_write_reg_bit_bit_pos,
4214 (void *)&cmd_write_reg_bit_value,
4219 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4220 struct cmd_read_rxd_txd_result {
4221 cmdline_fixed_string_t read;
4222 cmdline_fixed_string_t rxd_txd;
4229 cmd_read_rxd_txd_parsed(void *parsed_result,
4230 __attribute__((unused)) struct cmdline *cl,
4231 __attribute__((unused)) void *data)
4233 struct cmd_read_rxd_txd_result *res = parsed_result;
4235 if (!strcmp(res->rxd_txd, "rxd"))
4236 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4237 else if (!strcmp(res->rxd_txd, "txd"))
4238 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4241 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4242 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4243 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4244 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4246 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4247 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4248 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4249 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4250 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4251 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4253 cmdline_parse_inst_t cmd_read_rxd_txd = {
4254 .f = cmd_read_rxd_txd_parsed,
4256 .help_str = "read rxd|txd port_id queue_id rxd_id",
4258 (void *)&cmd_read_rxd_txd_read,
4259 (void *)&cmd_read_rxd_txd_rxd_txd,
4260 (void *)&cmd_read_rxd_txd_port_id,
4261 (void *)&cmd_read_rxd_txd_queue_id,
4262 (void *)&cmd_read_rxd_txd_desc_id,
4268 struct cmd_quit_result {
4269 cmdline_fixed_string_t quit;
4272 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4274 __attribute__((unused)) void *data)
4280 cmdline_parse_token_string_t cmd_quit_quit =
4281 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4283 cmdline_parse_inst_t cmd_quit = {
4284 .f = cmd_quit_parsed,
4286 .help_str = "exit application",
4288 (void *)&cmd_quit_quit,
4293 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4294 struct cmd_mac_addr_result {
4295 cmdline_fixed_string_t mac_addr_cmd;
4296 cmdline_fixed_string_t what;
4298 struct ether_addr address;
4301 static void cmd_mac_addr_parsed(void *parsed_result,
4302 __attribute__((unused)) struct cmdline *cl,
4303 __attribute__((unused)) void *data)
4305 struct cmd_mac_addr_result *res = parsed_result;
4308 if (strcmp(res->what, "add") == 0)
4309 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4311 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4313 /* check the return value and print it if is < 0 */
4315 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4319 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4320 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4322 cmdline_parse_token_string_t cmd_mac_addr_what =
4323 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4325 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4326 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4327 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4330 cmdline_parse_inst_t cmd_mac_addr = {
4331 .f = cmd_mac_addr_parsed,
4333 .help_str = "mac_addr add|remove X <address>: "
4334 "add/remove MAC address on port X",
4336 (void *)&cmd_mac_addr_cmd,
4337 (void *)&cmd_mac_addr_what,
4338 (void *)&cmd_mac_addr_portnum,
4339 (void *)&cmd_mac_addr_addr,
4345 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4346 struct cmd_set_qmap_result {
4347 cmdline_fixed_string_t set;
4348 cmdline_fixed_string_t qmap;
4349 cmdline_fixed_string_t what;
4356 cmd_set_qmap_parsed(void *parsed_result,
4357 __attribute__((unused)) struct cmdline *cl,
4358 __attribute__((unused)) void *data)
4360 struct cmd_set_qmap_result *res = parsed_result;
4361 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4363 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4366 cmdline_parse_token_string_t cmd_setqmap_set =
4367 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4369 cmdline_parse_token_string_t cmd_setqmap_qmap =
4370 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4372 cmdline_parse_token_string_t cmd_setqmap_what =
4373 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4375 cmdline_parse_token_num_t cmd_setqmap_portid =
4376 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4378 cmdline_parse_token_num_t cmd_setqmap_queueid =
4379 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4381 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4382 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4385 cmdline_parse_inst_t cmd_set_qmap = {
4386 .f = cmd_set_qmap_parsed,
4388 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4390 (void *)&cmd_setqmap_set,
4391 (void *)&cmd_setqmap_qmap,
4392 (void *)&cmd_setqmap_what,
4393 (void *)&cmd_setqmap_portid,
4394 (void *)&cmd_setqmap_queueid,
4395 (void *)&cmd_setqmap_mapvalue,
4400 /* *** CONFIGURE UNICAST HASH TABLE *** */
4401 struct cmd_set_uc_hash_table {
4402 cmdline_fixed_string_t set;
4403 cmdline_fixed_string_t port;
4405 cmdline_fixed_string_t what;
4406 struct ether_addr address;
4407 cmdline_fixed_string_t mode;
4411 cmd_set_uc_hash_parsed(void *parsed_result,
4412 __attribute__((unused)) struct cmdline *cl,
4413 __attribute__((unused)) void *data)
4416 struct cmd_set_uc_hash_table *res = parsed_result;
4418 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4420 if (strcmp(res->what, "uta") == 0)
4421 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4422 &res->address,(uint8_t)is_on);
4424 printf("bad unicast hash table parameter, return code = %d \n", ret);
4428 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4429 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4431 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4432 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4434 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4435 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4437 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4440 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4441 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4443 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4444 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4447 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4448 .f = cmd_set_uc_hash_parsed,
4450 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4452 (void *)&cmd_set_uc_hash_set,
4453 (void *)&cmd_set_uc_hash_port,
4454 (void *)&cmd_set_uc_hash_portid,
4455 (void *)&cmd_set_uc_hash_what,
4456 (void *)&cmd_set_uc_hash_mac,
4457 (void *)&cmd_set_uc_hash_mode,
4462 struct cmd_set_uc_all_hash_table {
4463 cmdline_fixed_string_t set;
4464 cmdline_fixed_string_t port;
4466 cmdline_fixed_string_t what;
4467 cmdline_fixed_string_t value;
4468 cmdline_fixed_string_t mode;
4472 cmd_set_uc_all_hash_parsed(void *parsed_result,
4473 __attribute__((unused)) struct cmdline *cl,
4474 __attribute__((unused)) void *data)
4477 struct cmd_set_uc_all_hash_table *res = parsed_result;
4479 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4481 if ((strcmp(res->what, "uta") == 0) &&
4482 (strcmp(res->value, "all") == 0))
4483 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4485 printf("bad unicast hash table parameter,"
4486 "return code = %d \n", ret);
4489 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4490 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4492 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4493 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4495 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4496 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4498 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4499 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4501 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4502 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4504 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4505 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4508 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4509 .f = cmd_set_uc_all_hash_parsed,
4511 .help_str = "set port X uta all on|off (X = port number)",
4513 (void *)&cmd_set_uc_all_hash_set,
4514 (void *)&cmd_set_uc_all_hash_port,
4515 (void *)&cmd_set_uc_all_hash_portid,
4516 (void *)&cmd_set_uc_all_hash_what,
4517 (void *)&cmd_set_uc_all_hash_value,
4518 (void *)&cmd_set_uc_all_hash_mode,
4523 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4524 struct cmd_set_vf_traffic {
4525 cmdline_fixed_string_t set;
4526 cmdline_fixed_string_t port;
4528 cmdline_fixed_string_t vf;
4530 cmdline_fixed_string_t what;
4531 cmdline_fixed_string_t mode;
4535 cmd_set_vf_traffic_parsed(void *parsed_result,
4536 __attribute__((unused)) struct cmdline *cl,
4537 __attribute__((unused)) void *data)
4539 struct cmd_set_vf_traffic *res = parsed_result;
4540 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4541 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4543 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4546 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4549 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4550 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4552 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4553 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4555 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4556 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4558 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4559 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4561 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4564 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4565 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4568 cmdline_parse_inst_t cmd_set_vf_traffic = {
4569 .f = cmd_set_vf_traffic_parsed,
4571 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4573 (void *)&cmd_setvf_traffic_set,
4574 (void *)&cmd_setvf_traffic_port,
4575 (void *)&cmd_setvf_traffic_portid,
4576 (void *)&cmd_setvf_traffic_vf,
4577 (void *)&cmd_setvf_traffic_vfid,
4578 (void *)&cmd_setvf_traffic_what,
4579 (void *)&cmd_setvf_traffic_mode,
4584 /* *** CONFIGURE VF RECEIVE MODE *** */
4585 struct cmd_set_vf_rxmode {
4586 cmdline_fixed_string_t set;
4587 cmdline_fixed_string_t port;
4589 cmdline_fixed_string_t vf;
4591 cmdline_fixed_string_t what;
4592 cmdline_fixed_string_t mode;
4593 cmdline_fixed_string_t on;
4597 cmd_set_vf_rxmode_parsed(void *parsed_result,
4598 __attribute__((unused)) struct cmdline *cl,
4599 __attribute__((unused)) void *data)
4602 uint16_t rx_mode = 0;
4603 struct cmd_set_vf_rxmode *res = parsed_result;
4605 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4606 if (!strcmp(res->what,"rxmode")) {
4607 if (!strcmp(res->mode, "AUPE"))
4608 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4609 else if (!strcmp(res->mode, "ROPE"))
4610 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4611 else if (!strcmp(res->mode, "BAM"))
4612 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4613 else if (!strncmp(res->mode, "MPE",3))
4614 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4617 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4619 printf("bad VF receive mode parameter, return code = %d \n",
4623 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4626 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4629 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4630 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4632 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4633 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4635 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4636 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4638 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4641 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4642 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4643 mode, "AUPE#ROPE#BAM#MPE");
4644 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4645 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4648 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4649 .f = cmd_set_vf_rxmode_parsed,
4651 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4653 (void *)&cmd_set_vf_rxmode_set,
4654 (void *)&cmd_set_vf_rxmode_port,
4655 (void *)&cmd_set_vf_rxmode_portid,
4656 (void *)&cmd_set_vf_rxmode_vf,
4657 (void *)&cmd_set_vf_rxmode_vfid,
4658 (void *)&cmd_set_vf_rxmode_what,
4659 (void *)&cmd_set_vf_rxmode_mode,
4660 (void *)&cmd_set_vf_rxmode_on,
4665 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4666 struct cmd_vf_mac_addr_result {
4667 cmdline_fixed_string_t mac_addr_cmd;
4668 cmdline_fixed_string_t what;
4669 cmdline_fixed_string_t port;
4671 cmdline_fixed_string_t vf;
4673 struct ether_addr address;
4676 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4677 __attribute__((unused)) struct cmdline *cl,
4678 __attribute__((unused)) void *data)
4680 struct cmd_vf_mac_addr_result *res = parsed_result;
4683 if (strcmp(res->what, "add") == 0)
4684 ret = rte_eth_dev_mac_addr_add(res->port_num,
4685 &res->address, res->vf_num);
4687 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4691 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4692 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4693 mac_addr_cmd,"mac_addr");
4694 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4695 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4697 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4698 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4700 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4701 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4703 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4704 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4706 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4707 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4709 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4710 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4713 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4714 .f = cmd_vf_mac_addr_parsed,
4716 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4717 "Y = VF number)add MAC address filtering for a VF on port X",
4719 (void *)&cmd_vf_mac_addr_cmd,
4720 (void *)&cmd_vf_mac_addr_what,
4721 (void *)&cmd_vf_mac_addr_port,
4722 (void *)&cmd_vf_mac_addr_portnum,
4723 (void *)&cmd_vf_mac_addr_vf,
4724 (void *)&cmd_vf_mac_addr_vfnum,
4725 (void *)&cmd_vf_mac_addr_addr,
4730 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4731 struct cmd_vf_rx_vlan_filter {
4732 cmdline_fixed_string_t rx_vlan;
4733 cmdline_fixed_string_t what;
4735 cmdline_fixed_string_t port;
4737 cmdline_fixed_string_t vf;
4742 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4743 __attribute__((unused)) struct cmdline *cl,
4744 __attribute__((unused)) void *data)
4746 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4748 if (!strcmp(res->what, "add"))
4749 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4751 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4756 rx_vlan, "rx_vlan");
4757 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4760 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4761 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4763 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4764 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4766 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4767 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4769 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4770 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4772 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4773 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4776 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4777 .f = cmd_vf_rx_vlan_filter_parsed,
4779 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4780 "Y = port number,Z = hexadecimal VF mask)",
4782 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4783 (void *)&cmd_vf_rx_vlan_filter_what,
4784 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4785 (void *)&cmd_vf_rx_vlan_filter_port,
4786 (void *)&cmd_vf_rx_vlan_filter_portid,
4787 (void *)&cmd_vf_rx_vlan_filter_vf,
4788 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4793 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4794 struct cmd_set_mirror_mask_result {
4795 cmdline_fixed_string_t set;
4796 cmdline_fixed_string_t port;
4798 cmdline_fixed_string_t mirror;
4800 cmdline_fixed_string_t what;
4801 cmdline_fixed_string_t value;
4802 cmdline_fixed_string_t dstpool;
4804 cmdline_fixed_string_t on;
4807 cmdline_parse_token_string_t cmd_mirror_mask_set =
4808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4810 cmdline_parse_token_string_t cmd_mirror_mask_port =
4811 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4813 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4814 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4816 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4817 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4818 mirror, "mirror-rule");
4819 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4820 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4822 cmdline_parse_token_string_t cmd_mirror_mask_what =
4823 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4824 what, "pool-mirror#vlan-mirror");
4825 cmdline_parse_token_string_t cmd_mirror_mask_value =
4826 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4828 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4830 dstpool, "dst-pool");
4831 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4832 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4834 cmdline_parse_token_string_t cmd_mirror_mask_on =
4835 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4839 cmd_set_mirror_mask_parsed(void *parsed_result,
4840 __attribute__((unused)) struct cmdline *cl,
4841 __attribute__((unused)) void *data)
4844 struct cmd_set_mirror_mask_result *res = parsed_result;
4845 struct rte_eth_vmdq_mirror_conf mr_conf;
4847 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4849 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4851 mr_conf.dst_pool = res->dstpool_id;
4853 if (!strcmp(res->what, "pool-mirror")) {
4854 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4855 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4856 } else if(!strcmp(res->what, "vlan-mirror")) {
4857 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4858 nb_item = parse_item_list(res->value, "core",
4859 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4863 for(i=0; i < nb_item; i++) {
4864 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4865 printf("Invalid vlan_id: must be < 4096\n");
4869 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4870 mr_conf.vlan.vlan_mask |= 1ULL << i;
4874 if(!strcmp(res->on, "on"))
4875 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4878 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4881 printf("mirror rule add error: (%s)\n", strerror(-ret));
4884 cmdline_parse_inst_t cmd_set_mirror_mask = {
4885 .f = cmd_set_mirror_mask_parsed,
4887 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4888 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4890 (void *)&cmd_mirror_mask_set,
4891 (void *)&cmd_mirror_mask_port,
4892 (void *)&cmd_mirror_mask_portid,
4893 (void *)&cmd_mirror_mask_mirror,
4894 (void *)&cmd_mirror_mask_ruleid,
4895 (void *)&cmd_mirror_mask_what,
4896 (void *)&cmd_mirror_mask_value,
4897 (void *)&cmd_mirror_mask_dstpool,
4898 (void *)&cmd_mirror_mask_poolid,
4899 (void *)&cmd_mirror_mask_on,
4904 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4905 struct cmd_set_mirror_link_result {
4906 cmdline_fixed_string_t set;
4907 cmdline_fixed_string_t port;
4909 cmdline_fixed_string_t mirror;
4911 cmdline_fixed_string_t what;
4912 cmdline_fixed_string_t dstpool;
4914 cmdline_fixed_string_t on;
4917 cmdline_parse_token_string_t cmd_mirror_link_set =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4920 cmdline_parse_token_string_t cmd_mirror_link_port =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4923 cmdline_parse_token_string_t cmd_mirror_link_portid =
4924 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4926 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4927 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4928 mirror, "mirror-rule");
4929 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4930 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4932 cmdline_parse_token_string_t cmd_mirror_link_what =
4933 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4934 what, "uplink-mirror#downlink-mirror");
4935 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4937 dstpool, "dst-pool");
4938 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4939 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4941 cmdline_parse_token_string_t cmd_mirror_link_on =
4942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4946 cmd_set_mirror_link_parsed(void *parsed_result,
4947 __attribute__((unused)) struct cmdline *cl,
4948 __attribute__((unused)) void *data)
4951 struct cmd_set_mirror_link_result *res = parsed_result;
4952 struct rte_eth_vmdq_mirror_conf mr_conf;
4954 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4955 if(!strcmp(res->what, "uplink-mirror")) {
4956 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4957 }else if(!strcmp(res->what, "downlink-mirror"))
4958 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4960 mr_conf.dst_pool = res->dstpool_id;
4962 if(!strcmp(res->on, "on"))
4963 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4966 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4969 /* check the return value and print it if is < 0 */
4971 printf("mirror rule add error: (%s)\n", strerror(-ret));
4975 cmdline_parse_inst_t cmd_set_mirror_link = {
4976 .f = cmd_set_mirror_link_parsed,
4978 .help_str = "set port X mirror-rule Y uplink-mirror|"
4979 "downlink-mirror dst-pool Z on|off",
4981 (void *)&cmd_mirror_link_set,
4982 (void *)&cmd_mirror_link_port,
4983 (void *)&cmd_mirror_link_portid,
4984 (void *)&cmd_mirror_link_mirror,
4985 (void *)&cmd_mirror_link_ruleid,
4986 (void *)&cmd_mirror_link_what,
4987 (void *)&cmd_mirror_link_dstpool,
4988 (void *)&cmd_mirror_link_poolid,
4989 (void *)&cmd_mirror_link_on,
4994 /* *** RESET VM MIRROR RULE *** */
4995 struct cmd_rm_mirror_rule_result {
4996 cmdline_fixed_string_t reset;
4997 cmdline_fixed_string_t port;
4999 cmdline_fixed_string_t mirror;
5003 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5004 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5006 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5007 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5009 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5010 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5012 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5013 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5014 mirror, "mirror-rule");
5015 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5016 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5020 cmd_reset_mirror_rule_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5022 __attribute__((unused)) void *data)
5025 struct cmd_set_mirror_link_result *res = parsed_result;
5027 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5029 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5032 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5033 .f = cmd_reset_mirror_rule_parsed,
5035 .help_str = "reset port X mirror-rule Y",
5037 (void *)&cmd_rm_mirror_rule_reset,
5038 (void *)&cmd_rm_mirror_rule_port,
5039 (void *)&cmd_rm_mirror_rule_portid,
5040 (void *)&cmd_rm_mirror_rule_mirror,
5041 (void *)&cmd_rm_mirror_rule_ruleid,
5046 /* ******************************************************************************** */
5048 struct cmd_dump_result {
5049 cmdline_fixed_string_t dump;
5053 dump_struct_sizes(void)
5055 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5056 DUMP_SIZE(struct rte_mbuf);
5057 DUMP_SIZE(struct rte_pktmbuf);
5058 DUMP_SIZE(struct rte_ctrlmbuf);
5059 DUMP_SIZE(struct rte_mempool);
5060 DUMP_SIZE(struct rte_ring);
5064 static void cmd_dump_parsed(void *parsed_result,
5065 __attribute__((unused)) struct cmdline *cl,
5066 __attribute__((unused)) void *data)
5068 struct cmd_dump_result *res = parsed_result;
5070 if (!strcmp(res->dump, "dump_physmem"))
5071 rte_dump_physmem_layout(stdout);
5072 else if (!strcmp(res->dump, "dump_memzone"))
5073 rte_memzone_dump(stdout);
5074 else if (!strcmp(res->dump, "dump_log_history"))
5075 rte_log_dump_history(stdout);
5076 else if (!strcmp(res->dump, "dump_struct_sizes"))
5077 dump_struct_sizes();
5078 else if (!strcmp(res->dump, "dump_ring"))
5079 rte_ring_list_dump(stdout);
5080 else if (!strcmp(res->dump, "dump_mempool"))
5081 rte_mempool_list_dump(stdout);
5082 else if (!strcmp(res->dump, "dump_devargs"))
5083 rte_eal_devargs_dump(stdout);
5086 cmdline_parse_token_string_t cmd_dump_dump =
5087 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5091 "dump_struct_sizes#"
5096 cmdline_parse_inst_t cmd_dump = {
5097 .f = cmd_dump_parsed, /* function to call */
5098 .data = NULL, /* 2nd arg of func */
5099 .help_str = "dump status",
5100 .tokens = { /* token list, NULL terminated */
5101 (void *)&cmd_dump_dump,
5106 /* ******************************************************************************** */
5108 struct cmd_dump_one_result {
5109 cmdline_fixed_string_t dump;
5110 cmdline_fixed_string_t name;
5113 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5114 __attribute__((unused)) void *data)
5116 struct cmd_dump_one_result *res = parsed_result;
5118 if (!strcmp(res->dump, "dump_ring")) {
5120 r = rte_ring_lookup(res->name);
5122 cmdline_printf(cl, "Cannot find ring\n");
5125 rte_ring_dump(stdout, r);
5126 } else if (!strcmp(res->dump, "dump_mempool")) {
5127 struct rte_mempool *mp;
5128 mp = rte_mempool_lookup(res->name);
5130 cmdline_printf(cl, "Cannot find mempool\n");
5133 rte_mempool_dump(stdout, mp);
5137 cmdline_parse_token_string_t cmd_dump_one_dump =
5138 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5139 "dump_ring#dump_mempool");
5141 cmdline_parse_token_string_t cmd_dump_one_name =
5142 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5144 cmdline_parse_inst_t cmd_dump_one = {
5145 .f = cmd_dump_one_parsed, /* function to call */
5146 .data = NULL, /* 2nd arg of func */
5147 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5148 .tokens = { /* token list, NULL terminated */
5149 (void *)&cmd_dump_one_dump,
5150 (void *)&cmd_dump_one_name,
5155 /* ******************************************************************************** */
5157 /* list of instructions */
5158 cmdline_parse_ctx_t main_ctx[] = {
5159 (cmdline_parse_inst_t *)&cmd_help_brief,
5160 (cmdline_parse_inst_t *)&cmd_help_long,
5161 (cmdline_parse_inst_t *)&cmd_quit,
5162 (cmdline_parse_inst_t *)&cmd_showport,
5163 (cmdline_parse_inst_t *)&cmd_showportall,
5164 (cmdline_parse_inst_t *)&cmd_showcfg,
5165 (cmdline_parse_inst_t *)&cmd_start,
5166 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5167 (cmdline_parse_inst_t *)&cmd_reset,
5168 (cmdline_parse_inst_t *)&cmd_set_numbers,
5169 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5170 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5171 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5172 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5173 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5174 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5175 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5176 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5177 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5178 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5179 (cmdline_parse_inst_t *)&cmd_set_link_check,
5180 #ifdef RTE_NIC_BYPASS
5181 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5182 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5183 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5184 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5186 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5187 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5188 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5189 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5190 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5191 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5192 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5193 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5194 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5195 (cmdline_parse_inst_t *)&cmd_config_dcb,
5196 (cmdline_parse_inst_t *)&cmd_read_reg,
5197 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5198 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5199 (cmdline_parse_inst_t *)&cmd_write_reg,
5200 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5201 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5202 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5203 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5204 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5205 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5206 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5207 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5208 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5209 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5210 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5211 (cmdline_parse_inst_t *)&cmd_stop,
5212 (cmdline_parse_inst_t *)&cmd_mac_addr,
5213 (cmdline_parse_inst_t *)&cmd_set_qmap,
5214 (cmdline_parse_inst_t *)&cmd_operate_port,
5215 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5216 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5217 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5218 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5219 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5220 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5221 (cmdline_parse_inst_t *)&cmd_config_rss,
5222 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5223 (cmdline_parse_inst_t *)&cmd_showport_reta,
5224 (cmdline_parse_inst_t *)&cmd_config_burst,
5225 (cmdline_parse_inst_t *)&cmd_config_thresh,
5226 (cmdline_parse_inst_t *)&cmd_config_threshold,
5227 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5228 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5229 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5230 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5231 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5232 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5233 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5234 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5235 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5236 (cmdline_parse_inst_t *)&cmd_dump,
5237 (cmdline_parse_inst_t *)&cmd_dump_one,
5241 /* prompt function, called from main on MASTER lcore */
5247 /* initialize non-constant commands */
5248 cmd_set_fwd_mode_init();
5250 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5254 cmdline_interact(cl);
5255 cmdline_stdin_exit(cl);
5259 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5261 if (id < nb_ports) {
5262 /* check if need_reconfig has been set to 1 */
5263 if (ports[id].need_reconfig == 0)
5264 ports[id].need_reconfig = dev;
5265 /* check if need_reconfig_queues has been set to 1 */
5266 if (ports[id].need_reconfig_queues == 0)
5267 ports[id].need_reconfig_queues = queue;
5271 for (pid = 0; pid < nb_ports; pid++) {
5272 /* check if need_reconfig has been set to 1 */
5273 if (ports[pid].need_reconfig == 0)
5274 ports[pid].need_reconfig = dev;
5275 /* check if need_reconfig_queues has been set to 1 */
5276 if (ports[pid].need_reconfig_queues == 0)
5277 ports[pid].need_reconfig_queues = queue;
5282 #ifdef RTE_NIC_BYPASS
5284 bypass_is_supported(portid_t port_id)
5286 struct rte_port *port;
5287 struct rte_pci_id *pci_id;
5289 if (port_id >= nb_ports) {
5290 printf("\tPort id must be less than %d.\n", nb_ports);
5294 /* Get the device id. */
5295 port = &ports[port_id];
5296 pci_id = &port->dev_info.pci_dev->id;
5298 /* Check if NIC supports bypass. */
5299 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5303 printf("\tBypass not supported for port_id = %d.\n", port_id);