4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_launch.h>
62 #include <rte_tailq.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
76 #include <cmdline_rdline.h>
77 #include <cmdline_parse.h>
78 #include <cmdline_parse_num.h>
79 #include <cmdline_parse_string.h>
80 #include <cmdline_parse_ipaddr.h>
81 #include <cmdline_parse_etheraddr.h>
82 #include <cmdline_socket.h>
84 #include <rte_pci_dev_ids.h>
88 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
91 uint8_t bypass_is_supported(portid_t port_id);
94 /* *** Help command with introduction. *** */
95 struct cmd_help_brief_result {
96 cmdline_fixed_string_t help;
99 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
101 __attribute__((unused)) void *data)
106 "Help is available for the following sections:\n\n"
107 " help control : Start and stop forwarding.\n"
108 " help display : Displaying port, stats and config "
110 " help config : Configuration information.\n"
111 " help ports : Configuring ports.\n"
112 " help flowdir : Flow Director filter help.\n"
113 " help registers : Reading and setting port registers.\n"
114 " help all : All of the above sections.\n\n"
119 cmdline_parse_token_string_t cmd_help_brief_help =
120 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
122 cmdline_parse_inst_t cmd_help_brief = {
123 .f = cmd_help_brief_parsed,
125 .help_str = "show help",
127 (void *)&cmd_help_brief_help,
132 /* *** Help command with help sections. *** */
133 struct cmd_help_long_result {
134 cmdline_fixed_string_t help;
135 cmdline_fixed_string_t section;
138 static void cmd_help_long_parsed(void *parsed_result,
140 __attribute__((unused)) void *data)
143 struct cmd_help_long_result *res = parsed_result;
145 if (!strcmp(res->section, "all"))
148 if (show_all || !strcmp(res->section, "control")) {
153 "Control forwarding:\n"
154 "-------------------\n\n"
157 " Start packet forwarding with current configuration.\n\n"
160 " Start packet forwarding with current config"
161 " after sending one burst of packets.\n\n"
164 " Stop packet forwarding, and display accumulated"
168 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
172 if (show_all || !strcmp(res->section, "display")) {
180 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
181 " Display information for port_id, or all.\n\n"
183 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show config (rxtx|cores|fwd)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
197 if (show_all || !strcmp(res->section, "config")) {
203 "Configuration changes only become active when"
204 " forwarding is started/restarted.\n\n"
207 " Reset forwarding to the default configuration.\n\n"
209 "set verbose (level)\n"
210 " Set the debug verbosity level X.\n\n"
213 " Set number of ports.\n\n"
216 " Set number of cores.\n\n"
218 "set coremask (mask)\n"
219 " Set the forwarding cores hexadecimal mask.\n\n"
221 "set portmask (mask)\n"
222 " Set the forwarding ports hexadecimal mask.\n\n"
225 " Set number of packets per burst.\n\n"
227 "set txpkts (x[,y]*)\n"
228 " Set the length of each segment of TXONLY"
231 "set corelist (x[,y]*)\n"
232 " Set the list of forwarding cores.\n\n"
234 "set portlist (x[,y]*)\n"
235 " Set the list of forwarding ports.\n\n"
237 "vlan set strip (on|off) (port_id)\n"
238 " Set the VLAN strip on a port.\n\n"
240 "vlan set stripq (on|off) (port_id,queue_id)\n"
241 " Set the VLAN strip for a queue on a port.\n\n"
243 "vlan set filter (on|off) (port_id)\n"
244 " Set the VLAN filter on a port.\n\n"
246 "vlan set qinq (on|off) (port_id)\n"
247 " Set the VLAN QinQ (extended queue in queue)"
250 "vlan set tpid (value) (port_id)\n"
251 " Set the outer VLAN TPID for Packet Filtering on"
254 "rx_vlan add (vlan_id|all) (port_id)\n"
255 " Add a vlan_id, or all identifiers, to the set"
256 " of VLAN identifiers filtered by port_id.\n\n"
258 "rx_vlan rm (vlan_id|all) (port_id)\n"
259 " Remove a vlan_id, or all identifiers, from the set"
260 " of VLAN identifiers filtered by port_id.\n\n"
262 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
263 " Add a vlan_id, to the set of VLAN identifiers"
264 "filtered for VF(s) from port_id.\n\n"
266 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
267 " Remove a vlan_id, to the set of VLAN identifiers"
268 "filtered for VF(s) from port_id.\n\n"
270 "rx_vlan set tpid (value) (port_id)\n"
271 " Set the outer VLAN TPID for Packet Filtering on"
274 "tx_vlan set vlan_id (port_id)\n"
275 " Set hardware insertion of VLAN ID in packets sent"
278 "tx_vlan reset (port_id)\n"
279 " Disable hardware insertion of a VLAN header in"
280 " packets sent on a port.\n\n"
282 "tx_checksum set mask (port_id)\n"
283 " Enable hardware insertion of checksum offload with"
284 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
285 " bit 0 - insert ip checksum offload if set\n"
286 " bit 1 - insert udp checksum offload if set\n"
287 " bit 2 - insert tcp checksum offload if set\n"
288 " bit 3 - insert sctp checksum offload if set\n"
289 " Please check the NIC datasheet for HW limits.\n\n"
291 #ifdef RTE_LIBRTE_IEEE1588
292 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
293 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
294 " packet forwarding mode.\n\n"
297 "set fwd (io|mac|rxonly|txonly|csum)\n"
298 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
299 " forwarding mode.\n\n"
302 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
303 " Add a MAC address on port_id.\n\n"
305 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
306 " Remove a MAC address from port_id.\n\n"
308 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
309 " Add a MAC address for a VF on the port.\n\n"
311 "set port (port_id) uta (mac_address|all) (on|off)\n"
312 " Add/Remove a or all unicast hash filter(s)"
315 "set promisc (port_id|all) (on|off)\n"
316 " Set the promiscuous mode on port_id, or all.\n\n"
318 "set allmulti (port_id|all) (on|off)\n"
319 " Set the allmulti mode on port_id, or all.\n\n"
321 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
322 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
323 " (on|off) (port_id)\n"
324 " Set the link flow control parameter on a port.\n\n"
326 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
327 " (low_water) (pause_time) (priority) (port_id)\n"
328 " Set the priority flow control parameter on a"
331 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
332 " Set statistics mapping (qmapping 0..15) for RX/TX"
334 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
335 " on port 0 to mapping 5.\n\n"
337 "set port (port_id) vf (vf_id) rx|tx on|off \n"
338 " Enable/Disable a VF receive/tranmit from a port\n\n"
340 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
342 " AUPE:accepts untagged VLAN;"
343 "ROPE:accept unicast hash\n\n"
344 " BAM:accepts broadcast packets;"
345 "MPE:accepts all multicast packets\n\n"
346 " Enable/Disable a VF receive mode of a port\n\n"
348 "set port (port_id) mirror-rule (rule_id)"
349 "(pool-mirror|vlan-mirror)\n"
350 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
351 " Set pool or vlan type mirror rule on a port.\n"
352 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
353 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
356 "set port (port_id) mirror-rule (rule_id)"
357 " (uplink-mirror|downlink-mirror) dst-pool"
358 " (pool_id) (on|off)\n"
359 " Set uplink or downlink type mirror rule on a port.\n"
360 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
361 " 0 on' enable mirror income traffic to pool 0.\n\n"
363 "reset port (port_id) mirror-rule (rule_id)\n"
364 " Reset a mirror rule.\n\n"
366 "set flush_rx (on|off)\n"
367 " Flush (default) or don't flush RX streams before"
368 " forwarding. Mainly used with PCAP drivers.\n\n"
370 #ifdef RTE_NIC_BYPASS
371 "set bypass mode (normal|bypass|isolate) (port_id)\n"
372 " Set the bypass mode for the lowest port on bypass enabled"
375 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
376 "mode (normal|bypass|isolate) (port_id)\n"
377 " Set the event required to initiate specified bypass mode for"
378 " the lowest port on a bypass enabled NIC where:\n"
379 " timeout = enable bypass after watchdog timeout.\n"
380 " os_on = enable bypass when OS/board is powered on.\n"
381 " os_off = enable bypass when OS/board is powered off.\n"
382 " power_on = enable bypass when power supply is turned on.\n"
383 " power_off = enable bypass when power supply is turned off."
386 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
387 " Set the bypass watchdog timeout to 'n' seconds"
388 " where 0 = instant.\n\n"
390 "show bypass config (port_id)\n"
391 " Show the bypass configuration for a bypass enabled NIC"
392 " using the lowest port on the NIC.\n\n"
399 if (show_all || !strcmp(res->section, "flowdir")) {
404 "Flow director mode:\n"
405 "-------------------\n\n"
407 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
408 " src (src_ip_address) (src_port)"
409 " dst (dst_ip_address) (dst_port)"
410 " flexbytes (flexbytes_values) vlan (vlan_id)"
411 " queue (queue_id)\n"
412 " Add a signature filter.\n\n"
414 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
415 " src (src_ip_address) (src_port)"
416 " dst (dst_ip_address) (dst_port)"
417 " flexbytes (flexbytes_values) vlan (vlan_id)"
418 " queue (queue_id)\n"
419 " Update a signature filter.\n\n"
421 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
422 " src (src_ip_address) (src_port)"
423 " dst (dst_ip_address) (dst_port)"
424 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
425 " Remove a signature filter.\n\n"
427 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
428 " src (src_ip_address) (src_port)"
429 " dst (dst_ip_address) (dst_port)"
430 " flexbytes (flexbytes_values) vlan (vlan_id)"
431 " queue (queue_id) soft (soft_id)\n"
432 " Add a perfect filter.\n\n"
434 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
435 " src (src_ip_address) (src_port)"
436 " dst (dst_ip_address) (dst_port)"
437 " flexbytes (flexbytes_values) vlan (vlan_id)"
438 " queue (queue_id)\n"
439 " Update a perfect filter.\n\n"
441 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
442 " src (src_ip_address) (src_port)"
443 " dst (dst_ip_address) (dst_port)"
444 " flexbytes (flexbytes_values) vlan (vlan_id)"
446 " Remove a perfect filter.\n\n"
448 "set_masks_filter (port_id) only_ip_flow (0|1)"
449 " src_mask (ip_src_mask) (src_port_mask)"
450 " dst_mask (ip_dst_mask) (dst_port_mask)"
451 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
452 " Set IPv4 filter masks.\n\n"
454 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
455 " src_mask (ip_src_mask) (src_port_mask)"
456 " dst_mask (ip_dst_mask) (dst_port_mask)"
457 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
458 " compare_dst (0|1)\n"
459 " Set IPv6 filter masks.\n\n"
463 if (show_all || !strcmp(res->section, "ports")) {
469 "----------------\n\n"
471 "port start (port_id|all)\n"
472 " Start all ports or port_id.\n\n"
474 "port stop (port_id|all)\n"
475 " Stop all ports or port_id.\n\n"
477 "port close (port_id|all)\n"
478 " Close all ports or port_id.\n\n"
480 "port config (port_id|all) speed (10|100|1000|10000|auto)"
481 " duplex (half|full|auto)\n"
482 " Set speed and duplex for all ports or port_id\n\n"
484 "port config all (rxq|txq|rxd|txd) (value)\n"
485 " Set number for rxq/txq/rxd/txd.\n\n"
487 "port config all max-pkt-len (value)\n"
488 " Set the max packet length.\n\n"
490 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
492 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
495 "port config all rss (ip|udp|none)\n"
496 " Set the RSS mode.\n\n"
498 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
499 " Set the RSS redirection table.\n\n"
501 "port config (port_id) dcb vt (on|off) (traffic_class)"
503 " Set the DCB mode.\n\n"
505 "port config all burst (value)\n"
506 " Set the number of packets per burst.\n\n"
508 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
510 " Set the ring prefetch/host/writeback threshold"
511 " for tx/rx queue.\n\n"
513 "port config all (txfreet|txrst|rxfreet) (value)\n"
514 " Set free threshold for rx/tx, or set"
515 " tx rs bit threshold.\n\n"
519 if (show_all || !strcmp(res->section, "registers")) {
527 "read reg (port_id) (address)\n"
528 " Display value of a port register.\n\n"
530 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
531 " Display a port register bit field.\n\n"
533 "read regbit (port_id) (address) (bit_x)\n"
534 " Display a single port register bit.\n\n"
536 "write reg (port_id) (address) (value)\n"
537 " Set value of a port register.\n\n"
539 "write regfield (port_id) (address) (bit_x) (bit_y)"
541 " Set bit field of a port register.\n\n"
543 "write regbit (port_id) (address) (bit_x) (value)\n"
544 " Set single bit value of a port register.\n\n"
549 cmdline_parse_token_string_t cmd_help_long_help =
550 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
552 cmdline_parse_token_string_t cmd_help_long_section =
553 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
554 "all#control#display#config#flowdir#"
557 cmdline_parse_inst_t cmd_help_long = {
558 .f = cmd_help_long_parsed,
560 .help_str = "show help",
562 (void *)&cmd_help_long_help,
563 (void *)&cmd_help_long_section,
569 /* *** start/stop/close all ports *** */
570 struct cmd_operate_port_result {
571 cmdline_fixed_string_t keyword;
572 cmdline_fixed_string_t name;
573 cmdline_fixed_string_t value;
576 static void cmd_operate_port_parsed(void *parsed_result,
577 __attribute__((unused)) struct cmdline *cl,
578 __attribute__((unused)) void *data)
580 struct cmd_operate_port_result *res = parsed_result;
582 if (!strcmp(res->name, "start"))
583 start_port(RTE_PORT_ALL);
584 else if (!strcmp(res->name, "stop"))
585 stop_port(RTE_PORT_ALL);
586 else if (!strcmp(res->name, "close"))
587 close_port(RTE_PORT_ALL);
589 printf("Unknown parameter\n");
592 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
593 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
595 cmdline_parse_token_string_t cmd_operate_port_all_port =
596 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
598 cmdline_parse_token_string_t cmd_operate_port_all_all =
599 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
601 cmdline_parse_inst_t cmd_operate_port = {
602 .f = cmd_operate_port_parsed,
604 .help_str = "port start|stop|close all: start/stop/close all ports",
606 (void *)&cmd_operate_port_all_cmd,
607 (void *)&cmd_operate_port_all_port,
608 (void *)&cmd_operate_port_all_all,
613 /* *** start/stop/close specific port *** */
614 struct cmd_operate_specific_port_result {
615 cmdline_fixed_string_t keyword;
616 cmdline_fixed_string_t name;
620 static void cmd_operate_specific_port_parsed(void *parsed_result,
621 __attribute__((unused)) struct cmdline *cl,
622 __attribute__((unused)) void *data)
624 struct cmd_operate_specific_port_result *res = parsed_result;
626 if (!strcmp(res->name, "start"))
627 start_port(res->value);
628 else if (!strcmp(res->name, "stop"))
629 stop_port(res->value);
630 else if (!strcmp(res->name, "close"))
631 close_port(res->value);
633 printf("Unknown parameter\n");
636 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
637 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
639 cmdline_parse_token_string_t cmd_operate_specific_port_port =
640 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
641 name, "start#stop#close");
642 cmdline_parse_token_num_t cmd_operate_specific_port_id =
643 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
646 cmdline_parse_inst_t cmd_operate_specific_port = {
647 .f = cmd_operate_specific_port_parsed,
649 .help_str = "port start|stop|close X: start/stop/close port X",
651 (void *)&cmd_operate_specific_port_cmd,
652 (void *)&cmd_operate_specific_port_port,
653 (void *)&cmd_operate_specific_port_id,
658 /* *** configure speed for all ports *** */
659 struct cmd_config_speed_all {
660 cmdline_fixed_string_t port;
661 cmdline_fixed_string_t keyword;
662 cmdline_fixed_string_t all;
663 cmdline_fixed_string_t item1;
664 cmdline_fixed_string_t item2;
665 cmdline_fixed_string_t value1;
666 cmdline_fixed_string_t value2;
670 cmd_config_speed_all_parsed(void *parsed_result,
671 __attribute__((unused)) struct cmdline *cl,
672 __attribute__((unused)) void *data)
674 struct cmd_config_speed_all *res = parsed_result;
675 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
676 uint16_t link_duplex = 0;
679 if (!all_ports_stopped()) {
680 printf("Please stop all ports first\n");
684 if (!strcmp(res->value1, "10"))
685 link_speed = ETH_LINK_SPEED_10;
686 else if (!strcmp(res->value1, "100"))
687 link_speed = ETH_LINK_SPEED_100;
688 else if (!strcmp(res->value1, "1000"))
689 link_speed = ETH_LINK_SPEED_1000;
690 else if (!strcmp(res->value1, "10000"))
691 link_speed = ETH_LINK_SPEED_10000;
692 else if (!strcmp(res->value1, "auto"))
693 link_speed = ETH_LINK_SPEED_AUTONEG;
695 printf("Unknown parameter\n");
699 if (!strcmp(res->value2, "half"))
700 link_duplex = ETH_LINK_HALF_DUPLEX;
701 else if (!strcmp(res->value2, "full"))
702 link_duplex = ETH_LINK_FULL_DUPLEX;
703 else if (!strcmp(res->value2, "auto"))
704 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
706 printf("Unknown parameter\n");
710 for (pid = 0; pid < nb_ports; pid++) {
711 ports[pid].dev_conf.link_speed = link_speed;
712 ports[pid].dev_conf.link_duplex = link_duplex;
715 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
718 cmdline_parse_token_string_t cmd_config_speed_all_port =
719 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
720 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
723 cmdline_parse_token_string_t cmd_config_speed_all_all =
724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
725 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
727 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
729 "10#100#1000#10000#auto");
730 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
732 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
736 cmdline_parse_inst_t cmd_config_speed_all = {
737 .f = cmd_config_speed_all_parsed,
739 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
742 (void *)&cmd_config_speed_all_port,
743 (void *)&cmd_config_speed_all_keyword,
744 (void *)&cmd_config_speed_all_all,
745 (void *)&cmd_config_speed_all_item1,
746 (void *)&cmd_config_speed_all_value1,
747 (void *)&cmd_config_speed_all_item2,
748 (void *)&cmd_config_speed_all_value2,
753 /* *** configure speed for specific port *** */
754 struct cmd_config_speed_specific {
755 cmdline_fixed_string_t port;
756 cmdline_fixed_string_t keyword;
758 cmdline_fixed_string_t item1;
759 cmdline_fixed_string_t item2;
760 cmdline_fixed_string_t value1;
761 cmdline_fixed_string_t value2;
765 cmd_config_speed_specific_parsed(void *parsed_result,
766 __attribute__((unused)) struct cmdline *cl,
767 __attribute__((unused)) void *data)
769 struct cmd_config_speed_specific *res = parsed_result;
770 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
771 uint16_t link_duplex = 0;
773 if (!all_ports_stopped()) {
774 printf("Please stop all ports first\n");
778 if (res->id >= nb_ports) {
779 printf("Port id %d must be less than %d\n", res->id, nb_ports);
783 if (!strcmp(res->value1, "10"))
784 link_speed = ETH_LINK_SPEED_10;
785 else if (!strcmp(res->value1, "100"))
786 link_speed = ETH_LINK_SPEED_100;
787 else if (!strcmp(res->value1, "1000"))
788 link_speed = ETH_LINK_SPEED_1000;
789 else if (!strcmp(res->value1, "10000"))
790 link_speed = ETH_LINK_SPEED_10000;
791 else if (!strcmp(res->value1, "auto"))
792 link_speed = ETH_LINK_SPEED_AUTONEG;
794 printf("Unknown parameter\n");
798 if (!strcmp(res->value2, "half"))
799 link_duplex = ETH_LINK_HALF_DUPLEX;
800 else if (!strcmp(res->value2, "full"))
801 link_duplex = ETH_LINK_FULL_DUPLEX;
802 else if (!strcmp(res->value2, "auto"))
803 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
805 printf("Unknown parameter\n");
809 ports[res->id].dev_conf.link_speed = link_speed;
810 ports[res->id].dev_conf.link_duplex = link_duplex;
812 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
816 cmdline_parse_token_string_t cmd_config_speed_specific_port =
817 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
819 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
820 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
822 cmdline_parse_token_num_t cmd_config_speed_specific_id =
823 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
824 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
825 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
827 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
828 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
829 "10#100#1000#10000#auto");
830 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
831 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
833 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
834 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
837 cmdline_parse_inst_t cmd_config_speed_specific = {
838 .f = cmd_config_speed_specific_parsed,
840 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
843 (void *)&cmd_config_speed_specific_port,
844 (void *)&cmd_config_speed_specific_keyword,
845 (void *)&cmd_config_speed_specific_id,
846 (void *)&cmd_config_speed_specific_item1,
847 (void *)&cmd_config_speed_specific_value1,
848 (void *)&cmd_config_speed_specific_item2,
849 (void *)&cmd_config_speed_specific_value2,
854 /* *** configure txq/rxq, txd/rxd *** */
855 struct cmd_config_rx_tx {
856 cmdline_fixed_string_t port;
857 cmdline_fixed_string_t keyword;
858 cmdline_fixed_string_t all;
859 cmdline_fixed_string_t name;
864 cmd_config_rx_tx_parsed(void *parsed_result,
865 __attribute__((unused)) struct cmdline *cl,
866 __attribute__((unused)) void *data)
868 struct cmd_config_rx_tx *res = parsed_result;
870 if (!all_ports_stopped()) {
871 printf("Please stop all ports first\n");
875 if (!strcmp(res->name, "rxq")) {
876 if (res->value <= 0) {
877 printf("rxq %d invalid - must be > 0\n", res->value);
882 else if (!strcmp(res->name, "txq")) {
883 if (res->value <= 0) {
884 printf("txq %d invalid - must be > 0\n", res->value);
889 else if (!strcmp(res->name, "rxd")) {
890 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
891 printf("rxd %d invalid - must be > 0 && <= %d\n",
892 res->value, RTE_TEST_RX_DESC_MAX);
896 } else if (!strcmp(res->name, "txd")) {
897 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
898 printf("txd %d invalid - must be > 0 && <= %d\n",
899 res->value, RTE_TEST_TX_DESC_MAX);
904 printf("Unknown parameter\n");
910 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
913 cmdline_parse_token_string_t cmd_config_rx_tx_port =
914 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
915 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
917 cmdline_parse_token_string_t cmd_config_rx_tx_all =
918 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
919 cmdline_parse_token_string_t cmd_config_rx_tx_name =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
922 cmdline_parse_token_num_t cmd_config_rx_tx_value =
923 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
925 cmdline_parse_inst_t cmd_config_rx_tx = {
926 .f = cmd_config_rx_tx_parsed,
928 .help_str = "port config all rxq|txq|rxd|txd value",
930 (void *)&cmd_config_rx_tx_port,
931 (void *)&cmd_config_rx_tx_keyword,
932 (void *)&cmd_config_rx_tx_all,
933 (void *)&cmd_config_rx_tx_name,
934 (void *)&cmd_config_rx_tx_value,
939 /* *** config max packet length *** */
940 struct cmd_config_max_pkt_len_result {
941 cmdline_fixed_string_t port;
942 cmdline_fixed_string_t keyword;
943 cmdline_fixed_string_t all;
944 cmdline_fixed_string_t name;
949 cmd_config_max_pkt_len_parsed(void *parsed_result,
950 __attribute__((unused)) struct cmdline *cl,
951 __attribute__((unused)) void *data)
953 struct cmd_config_max_pkt_len_result *res = parsed_result;
955 if (!all_ports_stopped()) {
956 printf("Please stop all ports first\n");
960 if (!strcmp(res->name, "max-pkt-len")) {
961 if (res->value < ETHER_MIN_LEN) {
962 printf("max-pkt-len can not be less than %d\n",
966 if (res->value == rx_mode.max_rx_pkt_len)
969 rx_mode.max_rx_pkt_len = res->value;
970 if (res->value > ETHER_MAX_LEN)
971 rx_mode.jumbo_frame = 1;
973 rx_mode.jumbo_frame = 0;
975 printf("Unknown parameter\n");
981 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
984 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
985 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
987 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
990 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
991 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
993 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
994 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
996 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
997 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1000 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1001 .f = cmd_config_max_pkt_len_parsed,
1003 .help_str = "port config all max-pkt-len value",
1005 (void *)&cmd_config_max_pkt_len_port,
1006 (void *)&cmd_config_max_pkt_len_keyword,
1007 (void *)&cmd_config_max_pkt_len_all,
1008 (void *)&cmd_config_max_pkt_len_name,
1009 (void *)&cmd_config_max_pkt_len_value,
1014 /* *** configure rx mode *** */
1015 struct cmd_config_rx_mode_flag {
1016 cmdline_fixed_string_t port;
1017 cmdline_fixed_string_t keyword;
1018 cmdline_fixed_string_t all;
1019 cmdline_fixed_string_t name;
1020 cmdline_fixed_string_t value;
1024 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1025 __attribute__((unused)) struct cmdline *cl,
1026 __attribute__((unused)) void *data)
1028 struct cmd_config_rx_mode_flag *res = parsed_result;
1030 if (!all_ports_stopped()) {
1031 printf("Please stop all ports first\n");
1035 if (!strcmp(res->name, "crc-strip")) {
1036 if (!strcmp(res->value, "on"))
1037 rx_mode.hw_strip_crc = 1;
1038 else if (!strcmp(res->value, "off"))
1039 rx_mode.hw_strip_crc = 0;
1041 printf("Unknown parameter\n");
1044 } else if (!strcmp(res->name, "rx-cksum")) {
1045 if (!strcmp(res->value, "on"))
1046 rx_mode.hw_ip_checksum = 1;
1047 else if (!strcmp(res->value, "off"))
1048 rx_mode.hw_ip_checksum = 0;
1050 printf("Unknown parameter\n");
1053 } else if (!strcmp(res->name, "hw-vlan")) {
1054 if (!strcmp(res->value, "on")) {
1055 rx_mode.hw_vlan_filter = 1;
1056 rx_mode.hw_vlan_strip = 1;
1058 else if (!strcmp(res->value, "off")) {
1059 rx_mode.hw_vlan_filter = 0;
1060 rx_mode.hw_vlan_strip = 0;
1063 printf("Unknown parameter\n");
1066 } else if (!strcmp(res->name, "drop-en")) {
1067 if (!strcmp(res->value, "on"))
1069 else if (!strcmp(res->value, "off"))
1072 printf("Unknown parameter\n");
1076 printf("Unknown parameter\n");
1082 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1085 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1086 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1087 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1088 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1090 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1091 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1092 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1093 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1094 "crc-strip#rx-cksum#hw-vlan");
1095 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1096 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1099 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1100 .f = cmd_config_rx_mode_flag_parsed,
1102 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1104 (void *)&cmd_config_rx_mode_flag_port,
1105 (void *)&cmd_config_rx_mode_flag_keyword,
1106 (void *)&cmd_config_rx_mode_flag_all,
1107 (void *)&cmd_config_rx_mode_flag_name,
1108 (void *)&cmd_config_rx_mode_flag_value,
1113 /* *** configure rss *** */
1114 struct cmd_config_rss {
1115 cmdline_fixed_string_t port;
1116 cmdline_fixed_string_t keyword;
1117 cmdline_fixed_string_t all;
1118 cmdline_fixed_string_t name;
1119 cmdline_fixed_string_t value;
1123 cmd_config_rss_parsed(void *parsed_result,
1124 __attribute__((unused)) struct cmdline *cl,
1125 __attribute__((unused)) void *data)
1127 struct cmd_config_rss *res = parsed_result;
1129 if (!all_ports_stopped()) {
1130 printf("Please stop all ports first\n");
1134 if (!strcmp(res->value, "ip"))
1135 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1136 else if (!strcmp(res->value, "udp"))
1137 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1138 else if (!strcmp(res->value, "none"))
1141 printf("Unknown parameter\n");
1147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1150 cmdline_parse_token_string_t cmd_config_rss_port =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1152 cmdline_parse_token_string_t cmd_config_rss_keyword =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1154 cmdline_parse_token_string_t cmd_config_rss_all =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1156 cmdline_parse_token_string_t cmd_config_rss_name =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1158 cmdline_parse_token_string_t cmd_config_rss_value =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1161 cmdline_parse_inst_t cmd_config_rss = {
1162 .f = cmd_config_rss_parsed,
1164 .help_str = "port config all rss ip|udp|none",
1166 (void *)&cmd_config_rss_port,
1167 (void *)&cmd_config_rss_keyword,
1168 (void *)&cmd_config_rss_all,
1169 (void *)&cmd_config_rss_name,
1170 (void *)&cmd_config_rss_value,
1175 /* *** Configure RSS RETA *** */
1176 struct cmd_config_rss_reta {
1177 cmdline_fixed_string_t port;
1178 cmdline_fixed_string_t keyword;
1180 cmdline_fixed_string_t name;
1181 cmdline_fixed_string_t list_name;
1182 cmdline_fixed_string_t list_of_items;
1186 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1193 const char *p, *p0 = str;
1200 unsigned long int_fld[_NUM_FLD];
1201 char *str_fld[_NUM_FLD];
1203 while ((p = strchr(p0,'(')) != NULL) {
1205 if((p0 = strchr(p,')')) == NULL)
1209 if(size >= sizeof(s))
1212 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1213 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1215 for (i = 0; i < _NUM_FLD; i++) {
1217 int_fld[i] = strtoul(str_fld[i], &end, 0);
1218 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1222 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1223 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1225 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1226 printf("Invalid RETA hash index=%d",hash_index);
1230 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1231 reta_conf->mask_lo |= (1ULL << hash_index);
1233 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1235 reta_conf->reta[hash_index] = nb_queue;
1242 cmd_set_rss_reta_parsed(void *parsed_result,
1243 __attribute__((unused)) struct cmdline *cl,
1244 __attribute__((unused)) void *data)
1247 struct rte_eth_rss_reta reta_conf;
1248 struct cmd_config_rss_reta *res = parsed_result;
1250 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1251 if (!strcmp(res->list_name, "reta")) {
1252 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1253 printf("Invalid RSS Redirection Table config entered\n");
1256 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1258 printf("Bad redirection table parameter, return code = %d \n",ret);
1262 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1263 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1264 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1266 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1267 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1268 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1270 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1271 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1272 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1275 cmdline_parse_inst_t cmd_config_rss_reta = {
1276 .f = cmd_set_rss_reta_parsed,
1278 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1280 (void *)&cmd_config_rss_reta_port,
1281 (void *)&cmd_config_rss_reta_keyword,
1282 (void *)&cmd_config_rss_reta_port_id,
1283 (void *)&cmd_config_rss_reta_name,
1284 (void *)&cmd_config_rss_reta_list_name,
1285 (void *)&cmd_config_rss_reta_list_of_items,
1290 /* *** SHOW PORT RETA INFO *** */
1291 struct cmd_showport_reta {
1292 cmdline_fixed_string_t show;
1293 cmdline_fixed_string_t port;
1295 cmdline_fixed_string_t rss;
1296 cmdline_fixed_string_t reta;
1301 static void cmd_showport_reta_parsed(void *parsed_result,
1302 __attribute__((unused)) struct cmdline *cl,
1303 __attribute__((unused)) void *data)
1305 struct cmd_showport_reta *res = parsed_result;
1306 struct rte_eth_rss_reta reta_conf;
1308 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1309 printf("Invalid RSS Redirection Table config entered\n");
1313 reta_conf.mask_lo = res->mask_lo;
1314 reta_conf.mask_hi = res->mask_hi;
1316 port_rss_reta_info(res->port_id,&reta_conf);
1319 cmdline_parse_token_string_t cmd_showport_reta_show =
1320 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1321 cmdline_parse_token_string_t cmd_showport_reta_port =
1322 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1323 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1324 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1325 cmdline_parse_token_string_t cmd_showport_reta_rss =
1326 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1327 cmdline_parse_token_string_t cmd_showport_reta_reta =
1328 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1329 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1330 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1331 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1332 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1334 cmdline_parse_inst_t cmd_showport_reta = {
1335 .f = cmd_showport_reta_parsed,
1337 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1338 (mask_lo and mask_hi is UINT64)",
1340 (void *)&cmd_showport_reta_show,
1341 (void *)&cmd_showport_reta_port,
1342 (void *)&cmd_showport_reta_port_id,
1343 (void *)&cmd_showport_reta_rss,
1344 (void *)&cmd_showport_reta_reta,
1345 (void *)&cmd_showport_reta_mask_lo,
1346 (void *)&cmd_showport_reta_mask_hi,
1351 /* *** Configure DCB *** */
1352 struct cmd_config_dcb {
1353 cmdline_fixed_string_t port;
1354 cmdline_fixed_string_t config;
1356 cmdline_fixed_string_t dcb;
1357 cmdline_fixed_string_t vt;
1358 cmdline_fixed_string_t vt_en;
1360 cmdline_fixed_string_t pfc;
1361 cmdline_fixed_string_t pfc_en;
1365 cmd_config_dcb_parsed(void *parsed_result,
1366 __attribute__((unused)) struct cmdline *cl,
1367 __attribute__((unused)) void *data)
1369 struct cmd_config_dcb *res = parsed_result;
1370 struct dcb_config dcb_conf;
1371 portid_t port_id = res->port_id;
1372 struct rte_port *port;
1374 port = &ports[port_id];
1375 /** Check if the port is not started **/
1376 if (port->port_status != RTE_PORT_STOPPED) {
1377 printf("Please stop port %d first\n",port_id);
1381 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1382 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1383 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1387 /* DCB in VT mode */
1388 if (!strncmp(res->vt_en, "on",2))
1389 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1391 dcb_conf.dcb_mode = DCB_ENABLED;
1393 if (!strncmp(res->pfc_en, "on",2)) {
1394 dcb_conf.pfc_en = 1;
1397 dcb_conf.pfc_en = 0;
1399 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1400 printf("Cannot initialize network ports\n");
1404 cmd_reconfig_device_queue(port_id, 1, 1);
1407 cmdline_parse_token_string_t cmd_config_dcb_port =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1409 cmdline_parse_token_string_t cmd_config_dcb_config =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1411 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1412 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1413 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1415 cmdline_parse_token_string_t cmd_config_dcb_vt =
1416 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1417 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1419 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1420 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1421 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1423 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1426 cmdline_parse_inst_t cmd_config_dcb = {
1427 .f = cmd_config_dcb_parsed,
1429 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1431 (void *)&cmd_config_dcb_port,
1432 (void *)&cmd_config_dcb_config,
1433 (void *)&cmd_config_dcb_port_id,
1434 (void *)&cmd_config_dcb_dcb,
1435 (void *)&cmd_config_dcb_vt,
1436 (void *)&cmd_config_dcb_vt_en,
1437 (void *)&cmd_config_dcb_num_tcs,
1438 (void *)&cmd_config_dcb_pfc,
1439 (void *)&cmd_config_dcb_pfc_en,
1444 /* *** configure number of packets per burst *** */
1445 struct cmd_config_burst {
1446 cmdline_fixed_string_t port;
1447 cmdline_fixed_string_t keyword;
1448 cmdline_fixed_string_t all;
1449 cmdline_fixed_string_t name;
1454 cmd_config_burst_parsed(void *parsed_result,
1455 __attribute__((unused)) struct cmdline *cl,
1456 __attribute__((unused)) void *data)
1458 struct cmd_config_burst *res = parsed_result;
1460 if (!all_ports_stopped()) {
1461 printf("Please stop all ports first\n");
1465 if (!strcmp(res->name, "burst")) {
1466 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1467 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1470 nb_pkt_per_burst = res->value;
1472 printf("Unknown parameter\n");
1478 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1481 cmdline_parse_token_string_t cmd_config_burst_port =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1483 cmdline_parse_token_string_t cmd_config_burst_keyword =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1485 cmdline_parse_token_string_t cmd_config_burst_all =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1487 cmdline_parse_token_string_t cmd_config_burst_name =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1489 cmdline_parse_token_num_t cmd_config_burst_value =
1490 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1492 cmdline_parse_inst_t cmd_config_burst = {
1493 .f = cmd_config_burst_parsed,
1495 .help_str = "port config all burst value",
1497 (void *)&cmd_config_burst_port,
1498 (void *)&cmd_config_burst_keyword,
1499 (void *)&cmd_config_burst_all,
1500 (void *)&cmd_config_burst_name,
1501 (void *)&cmd_config_burst_value,
1506 /* *** configure rx/tx queues *** */
1507 struct cmd_config_thresh {
1508 cmdline_fixed_string_t port;
1509 cmdline_fixed_string_t keyword;
1510 cmdline_fixed_string_t all;
1511 cmdline_fixed_string_t name;
1516 cmd_config_thresh_parsed(void *parsed_result,
1517 __attribute__((unused)) struct cmdline *cl,
1518 __attribute__((unused)) void *data)
1520 struct cmd_config_thresh *res = parsed_result;
1522 if (!all_ports_stopped()) {
1523 printf("Please stop all ports first\n");
1527 if (!strcmp(res->name, "txpt"))
1528 tx_thresh.pthresh = res->value;
1529 else if(!strcmp(res->name, "txht"))
1530 tx_thresh.hthresh = res->value;
1531 else if(!strcmp(res->name, "txwt"))
1532 tx_thresh.wthresh = res->value;
1533 else if(!strcmp(res->name, "rxpt"))
1534 rx_thresh.pthresh = res->value;
1535 else if(!strcmp(res->name, "rxht"))
1536 rx_thresh.hthresh = res->value;
1537 else if(!strcmp(res->name, "rxwt"))
1538 rx_thresh.wthresh = res->value;
1540 printf("Unknown parameter\n");
1546 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1549 cmdline_parse_token_string_t cmd_config_thresh_port =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1551 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1552 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1553 cmdline_parse_token_string_t cmd_config_thresh_all =
1554 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1555 cmdline_parse_token_string_t cmd_config_thresh_name =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1557 "txpt#txht#txwt#rxpt#rxht#rxwt");
1558 cmdline_parse_token_num_t cmd_config_thresh_value =
1559 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1561 cmdline_parse_inst_t cmd_config_thresh = {
1562 .f = cmd_config_thresh_parsed,
1564 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1566 (void *)&cmd_config_thresh_port,
1567 (void *)&cmd_config_thresh_keyword,
1568 (void *)&cmd_config_thresh_all,
1569 (void *)&cmd_config_thresh_name,
1570 (void *)&cmd_config_thresh_value,
1575 /* *** configure free/rs threshold *** */
1576 struct cmd_config_threshold {
1577 cmdline_fixed_string_t port;
1578 cmdline_fixed_string_t keyword;
1579 cmdline_fixed_string_t all;
1580 cmdline_fixed_string_t name;
1585 cmd_config_threshold_parsed(void *parsed_result,
1586 __attribute__((unused)) struct cmdline *cl,
1587 __attribute__((unused)) void *data)
1589 struct cmd_config_threshold *res = parsed_result;
1591 if (!all_ports_stopped()) {
1592 printf("Please stop all ports first\n");
1596 if (!strcmp(res->name, "txfreet"))
1597 tx_free_thresh = res->value;
1598 else if (!strcmp(res->name, "txrst"))
1599 tx_rs_thresh = res->value;
1600 else if (!strcmp(res->name, "rxfreet"))
1601 rx_free_thresh = res->value;
1603 printf("Unknown parameter\n");
1609 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1612 cmdline_parse_token_string_t cmd_config_threshold_port =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1614 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1617 cmdline_parse_token_string_t cmd_config_threshold_all =
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1619 cmdline_parse_token_string_t cmd_config_threshold_name =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1621 "txfreet#txrst#rxfreet");
1622 cmdline_parse_token_num_t cmd_config_threshold_value =
1623 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1625 cmdline_parse_inst_t cmd_config_threshold = {
1626 .f = cmd_config_threshold_parsed,
1628 .help_str = "port config all txfreet|txrst|rxfreet value",
1630 (void *)&cmd_config_threshold_port,
1631 (void *)&cmd_config_threshold_keyword,
1632 (void *)&cmd_config_threshold_all,
1633 (void *)&cmd_config_threshold_name,
1634 (void *)&cmd_config_threshold_value,
1640 struct cmd_stop_result {
1641 cmdline_fixed_string_t stop;
1644 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1645 __attribute__((unused)) struct cmdline *cl,
1646 __attribute__((unused)) void *data)
1648 stop_packet_forwarding();
1651 cmdline_parse_token_string_t cmd_stop_stop =
1652 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1654 cmdline_parse_inst_t cmd_stop = {
1655 .f = cmd_stop_parsed,
1657 .help_str = "stop - stop packet forwarding",
1659 (void *)&cmd_stop_stop,
1664 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1667 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1668 unsigned int *parsed_items, int check_unique_values)
1670 unsigned int nb_item;
1678 * First parse all items in the list and store their value.
1683 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1685 if ((c >= '0') && (c <= '9')) {
1686 value = (unsigned int) (value * 10 + (c - '0'));
1691 printf("character %c is not a decimal digit\n", c);
1695 printf("No valid value before comma\n");
1698 if (nb_item < max_items) {
1699 parsed_items[nb_item] = value;
1705 if (nb_item >= max_items) {
1706 printf("Number of %s = %u > %u (maximum items)\n",
1707 item_name, nb_item + 1, max_items);
1710 parsed_items[nb_item++] = value;
1711 if (! check_unique_values)
1715 * Then, check that all values in the list are differents.
1716 * No optimization here...
1718 for (i = 0; i < nb_item; i++) {
1719 for (j = i + 1; j < nb_item; j++) {
1720 if (parsed_items[j] == parsed_items[i]) {
1721 printf("duplicated %s %u at index %u and %u\n",
1722 item_name, parsed_items[i], i, j);
1730 struct cmd_set_list_result {
1731 cmdline_fixed_string_t cmd_keyword;
1732 cmdline_fixed_string_t list_name;
1733 cmdline_fixed_string_t list_of_items;
1736 static void cmd_set_list_parsed(void *parsed_result,
1737 __attribute__((unused)) struct cmdline *cl,
1738 __attribute__((unused)) void *data)
1740 struct cmd_set_list_result *res;
1742 unsigned int lcorelist[RTE_MAX_LCORE];
1743 unsigned int portlist[RTE_MAX_ETHPORTS];
1745 unsigned int nb_item;
1747 res = parsed_result;
1748 if (!strcmp(res->list_name, "corelist")) {
1749 nb_item = parse_item_list(res->list_of_items, "core",
1751 parsed_items.lcorelist, 1);
1753 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1756 if (!strcmp(res->list_name, "portlist")) {
1757 nb_item = parse_item_list(res->list_of_items, "port",
1759 parsed_items.portlist, 1);
1761 set_fwd_ports_list(parsed_items.portlist, nb_item);
1765 cmdline_parse_token_string_t cmd_set_list_keyword =
1766 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1768 cmdline_parse_token_string_t cmd_set_list_name =
1769 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1770 "corelist#portlist");
1771 cmdline_parse_token_string_t cmd_set_list_of_items =
1772 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1775 cmdline_parse_inst_t cmd_set_fwd_list = {
1776 .f = cmd_set_list_parsed,
1778 .help_str = "set corelist|portlist x[,y]*",
1780 (void *)&cmd_set_list_keyword,
1781 (void *)&cmd_set_list_name,
1782 (void *)&cmd_set_list_of_items,
1787 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1789 struct cmd_setmask_result {
1790 cmdline_fixed_string_t set;
1791 cmdline_fixed_string_t mask;
1795 static void cmd_set_mask_parsed(void *parsed_result,
1796 __attribute__((unused)) struct cmdline *cl,
1797 __attribute__((unused)) void *data)
1799 struct cmd_setmask_result *res = parsed_result;
1801 if (!strcmp(res->mask, "coremask"))
1802 set_fwd_lcores_mask(res->hexavalue);
1803 else if (!strcmp(res->mask, "portmask"))
1804 set_fwd_ports_mask(res->hexavalue);
1807 cmdline_parse_token_string_t cmd_setmask_set =
1808 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1809 cmdline_parse_token_string_t cmd_setmask_mask =
1810 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1811 "coremask#portmask");
1812 cmdline_parse_token_num_t cmd_setmask_value =
1813 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1815 cmdline_parse_inst_t cmd_set_fwd_mask = {
1816 .f = cmd_set_mask_parsed,
1818 .help_str = "set coremask|portmask hexadecimal value",
1820 (void *)&cmd_setmask_set,
1821 (void *)&cmd_setmask_mask,
1822 (void *)&cmd_setmask_value,
1828 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1830 struct cmd_set_result {
1831 cmdline_fixed_string_t set;
1832 cmdline_fixed_string_t what;
1836 static void cmd_set_parsed(void *parsed_result,
1837 __attribute__((unused)) struct cmdline *cl,
1838 __attribute__((unused)) void *data)
1840 struct cmd_set_result *res = parsed_result;
1841 if (!strcmp(res->what, "nbport"))
1842 set_fwd_ports_number(res->value);
1843 else if (!strcmp(res->what, "nbcore"))
1844 set_fwd_lcores_number(res->value);
1845 else if (!strcmp(res->what, "burst"))
1846 set_nb_pkt_per_burst(res->value);
1847 else if (!strcmp(res->what, "verbose"))
1848 set_verbose_level(res->value);
1851 cmdline_parse_token_string_t cmd_set_set =
1852 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1853 cmdline_parse_token_string_t cmd_set_what =
1854 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1855 "nbport#nbcore#burst#verbose");
1856 cmdline_parse_token_num_t cmd_set_value =
1857 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1859 cmdline_parse_inst_t cmd_set_numbers = {
1860 .f = cmd_set_parsed,
1862 .help_str = "set nbport|nbcore|burst|verbose value",
1864 (void *)&cmd_set_set,
1865 (void *)&cmd_set_what,
1866 (void *)&cmd_set_value,
1871 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1873 struct cmd_set_txpkts_result {
1874 cmdline_fixed_string_t cmd_keyword;
1875 cmdline_fixed_string_t txpkts;
1876 cmdline_fixed_string_t seg_lengths;
1880 cmd_set_txpkts_parsed(void *parsed_result,
1881 __attribute__((unused)) struct cmdline *cl,
1882 __attribute__((unused)) void *data)
1884 struct cmd_set_txpkts_result *res;
1885 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1886 unsigned int nb_segs;
1888 res = parsed_result;
1889 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1890 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1892 set_tx_pkt_segments(seg_lengths, nb_segs);
1895 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1896 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1897 cmd_keyword, "set");
1898 cmdline_parse_token_string_t cmd_set_txpkts_name =
1899 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1901 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1902 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1905 cmdline_parse_inst_t cmd_set_txpkts = {
1906 .f = cmd_set_txpkts_parsed,
1908 .help_str = "set txpkts x[,y]*",
1910 (void *)&cmd_set_txpkts_keyword,
1911 (void *)&cmd_set_txpkts_name,
1912 (void *)&cmd_set_txpkts_lengths,
1917 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1918 struct cmd_rx_vlan_filter_all_result {
1919 cmdline_fixed_string_t rx_vlan;
1920 cmdline_fixed_string_t what;
1921 cmdline_fixed_string_t all;
1926 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1927 __attribute__((unused)) struct cmdline *cl,
1928 __attribute__((unused)) void *data)
1930 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1932 if (!strcmp(res->what, "add"))
1933 rx_vlan_all_filter_set(res->port_id, 1);
1935 rx_vlan_all_filter_set(res->port_id, 0);
1938 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1939 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1940 rx_vlan, "rx_vlan");
1941 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1942 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1944 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1945 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1947 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1948 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1951 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1952 .f = cmd_rx_vlan_filter_all_parsed,
1954 .help_str = "add/remove all identifiers to/from the set of VLAN "
1955 "Identifiers filtered by a port",
1957 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1958 (void *)&cmd_rx_vlan_filter_all_what,
1959 (void *)&cmd_rx_vlan_filter_all_all,
1960 (void *)&cmd_rx_vlan_filter_all_portid,
1965 /* *** VLAN OFFLOAD SET ON A PORT *** */
1966 struct cmd_vlan_offload_result {
1967 cmdline_fixed_string_t vlan;
1968 cmdline_fixed_string_t set;
1969 cmdline_fixed_string_t what;
1970 cmdline_fixed_string_t on;
1971 cmdline_fixed_string_t port_id;
1975 cmd_vlan_offload_parsed(void *parsed_result,
1976 __attribute__((unused)) struct cmdline *cl,
1977 __attribute__((unused)) void *data)
1980 struct cmd_vlan_offload_result *res = parsed_result;
1983 portid_t port_id = 0;
1987 len = strnlen(str, STR_TOKEN_SIZE);
1989 /* Get port_id first */
1997 tmp = strtoul(str, NULL, 0);
1998 /* If port_id greater that what portid_t can represent, return */
1999 if(tmp >= RTE_MAX_ETHPORTS)
2001 port_id = (portid_t)tmp;
2003 if (!strcmp(res->on, "on"))
2008 if (!strcmp(res->what, "strip"))
2009 rx_vlan_strip_set(port_id, on);
2010 else if(!strcmp(res->what, "stripq")){
2011 uint16_t queue_id = 0;
2013 /* No queue_id, return */
2015 printf("must specify (port,queue_id)\n");
2018 tmp = strtoul(str + i + 1, NULL, 0);
2019 /* If queue_id greater that what 16-bits can represent, return */
2023 queue_id = (uint16_t)tmp;
2024 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2026 else if (!strcmp(res->what, "filter"))
2027 rx_vlan_filter_set(port_id, on);
2029 vlan_extend_set(port_id, on);
2034 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2035 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2037 cmdline_parse_token_string_t cmd_vlan_offload_set =
2038 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2040 cmdline_parse_token_string_t cmd_vlan_offload_what =
2041 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2042 what, "strip#filter#qinq#stripq");
2043 cmdline_parse_token_string_t cmd_vlan_offload_on =
2044 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2046 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2047 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2050 cmdline_parse_inst_t cmd_vlan_offload = {
2051 .f = cmd_vlan_offload_parsed,
2053 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2054 " qinq(extended) for both rx/tx sides ",
2056 (void *)&cmd_vlan_offload_vlan,
2057 (void *)&cmd_vlan_offload_set,
2058 (void *)&cmd_vlan_offload_what,
2059 (void *)&cmd_vlan_offload_on,
2060 (void *)&cmd_vlan_offload_portid,
2065 /* *** VLAN TPID SET ON A PORT *** */
2066 struct cmd_vlan_tpid_result {
2067 cmdline_fixed_string_t vlan;
2068 cmdline_fixed_string_t set;
2069 cmdline_fixed_string_t what;
2075 cmd_vlan_tpid_parsed(void *parsed_result,
2076 __attribute__((unused)) struct cmdline *cl,
2077 __attribute__((unused)) void *data)
2079 struct cmd_vlan_tpid_result *res = parsed_result;
2080 vlan_tpid_set(res->port_id, res->tp_id);
2084 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2085 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2087 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2088 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2090 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2093 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2094 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2096 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2097 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2100 cmdline_parse_inst_t cmd_vlan_tpid = {
2101 .f = cmd_vlan_tpid_parsed,
2103 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2105 (void *)&cmd_vlan_tpid_vlan,
2106 (void *)&cmd_vlan_tpid_set,
2107 (void *)&cmd_vlan_tpid_what,
2108 (void *)&cmd_vlan_tpid_tpid,
2109 (void *)&cmd_vlan_tpid_portid,
2114 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2115 struct cmd_rx_vlan_filter_result {
2116 cmdline_fixed_string_t rx_vlan;
2117 cmdline_fixed_string_t what;
2123 cmd_rx_vlan_filter_parsed(void *parsed_result,
2124 __attribute__((unused)) struct cmdline *cl,
2125 __attribute__((unused)) void *data)
2127 struct cmd_rx_vlan_filter_result *res = parsed_result;
2129 if (!strcmp(res->what, "add"))
2130 rx_vft_set(res->port_id, res->vlan_id, 1);
2132 rx_vft_set(res->port_id, res->vlan_id, 0);
2135 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2137 rx_vlan, "rx_vlan");
2138 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2139 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2141 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2142 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2144 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2145 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2148 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2149 .f = cmd_rx_vlan_filter_parsed,
2151 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2152 "Identifiers filtered by a port",
2154 (void *)&cmd_rx_vlan_filter_rx_vlan,
2155 (void *)&cmd_rx_vlan_filter_what,
2156 (void *)&cmd_rx_vlan_filter_vlanid,
2157 (void *)&cmd_rx_vlan_filter_portid,
2162 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2163 struct cmd_tx_vlan_set_result {
2164 cmdline_fixed_string_t tx_vlan;
2165 cmdline_fixed_string_t set;
2171 cmd_tx_vlan_set_parsed(void *parsed_result,
2172 __attribute__((unused)) struct cmdline *cl,
2173 __attribute__((unused)) void *data)
2175 struct cmd_tx_vlan_set_result *res = parsed_result;
2176 tx_vlan_set(res->port_id, res->vlan_id);
2179 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2180 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2181 tx_vlan, "tx_vlan");
2182 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2183 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2185 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2186 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2188 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2189 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2192 cmdline_parse_inst_t cmd_tx_vlan_set = {
2193 .f = cmd_tx_vlan_set_parsed,
2195 .help_str = "enable hardware insertion of a VLAN header with a given "
2196 "TAG Identifier in packets sent on a port",
2198 (void *)&cmd_tx_vlan_set_tx_vlan,
2199 (void *)&cmd_tx_vlan_set_set,
2200 (void *)&cmd_tx_vlan_set_vlanid,
2201 (void *)&cmd_tx_vlan_set_portid,
2206 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2207 struct cmd_tx_vlan_reset_result {
2208 cmdline_fixed_string_t tx_vlan;
2209 cmdline_fixed_string_t reset;
2214 cmd_tx_vlan_reset_parsed(void *parsed_result,
2215 __attribute__((unused)) struct cmdline *cl,
2216 __attribute__((unused)) void *data)
2218 struct cmd_tx_vlan_reset_result *res = parsed_result;
2220 tx_vlan_reset(res->port_id);
2223 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2225 tx_vlan, "tx_vlan");
2226 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2229 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2233 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2234 .f = cmd_tx_vlan_reset_parsed,
2236 .help_str = "disable hardware insertion of a VLAN header in packets "
2239 (void *)&cmd_tx_vlan_reset_tx_vlan,
2240 (void *)&cmd_tx_vlan_reset_reset,
2241 (void *)&cmd_tx_vlan_reset_portid,
2247 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2248 struct cmd_tx_cksum_set_result {
2249 cmdline_fixed_string_t tx_cksum;
2250 cmdline_fixed_string_t set;
2256 cmd_tx_cksum_set_parsed(void *parsed_result,
2257 __attribute__((unused)) struct cmdline *cl,
2258 __attribute__((unused)) void *data)
2260 struct cmd_tx_cksum_set_result *res = parsed_result;
2262 tx_cksum_set(res->port_id, res->cksum_mask);
2265 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2266 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2267 tx_cksum, "tx_checksum");
2268 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2269 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2271 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2272 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2274 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2275 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2278 cmdline_parse_inst_t cmd_tx_cksum_set = {
2279 .f = cmd_tx_cksum_set_parsed,
2281 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2282 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2283 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2285 (void *)&cmd_tx_cksum_set_tx_cksum,
2286 (void *)&cmd_tx_cksum_set_set,
2287 (void *)&cmd_tx_cksum_set_cksum_mask,
2288 (void *)&cmd_tx_cksum_set_portid,
2293 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2294 struct cmd_set_flush_rx {
2295 cmdline_fixed_string_t set;
2296 cmdline_fixed_string_t flush_rx;
2297 cmdline_fixed_string_t mode;
2301 cmd_set_flush_rx_parsed(void *parsed_result,
2302 __attribute__((unused)) struct cmdline *cl,
2303 __attribute__((unused)) void *data)
2305 struct cmd_set_flush_rx *res = parsed_result;
2306 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2309 cmdline_parse_token_string_t cmd_setflushrx_set =
2310 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2312 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2313 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2314 flush_rx, "flush_rx");
2315 cmdline_parse_token_string_t cmd_setflushrx_mode =
2316 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2320 cmdline_parse_inst_t cmd_set_flush_rx = {
2321 .f = cmd_set_flush_rx_parsed,
2322 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2325 (void *)&cmd_setflushrx_set,
2326 (void *)&cmd_setflushrx_flush_rx,
2327 (void *)&cmd_setflushrx_mode,
2332 #ifdef RTE_NIC_BYPASS
2333 /* *** SET NIC BYPASS MODE *** */
2334 struct cmd_set_bypass_mode_result {
2335 cmdline_fixed_string_t set;
2336 cmdline_fixed_string_t bypass;
2337 cmdline_fixed_string_t mode;
2338 cmdline_fixed_string_t value;
2343 cmd_set_bypass_mode_parsed(void *parsed_result,
2344 __attribute__((unused)) struct cmdline *cl,
2345 __attribute__((unused)) void *data)
2347 struct cmd_set_bypass_mode_result *res = parsed_result;
2348 portid_t port_id = res->port_id;
2349 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2351 if (!bypass_is_supported(port_id))
2354 if (!strcmp(res->value, "bypass"))
2355 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2356 else if (!strcmp(res->value, "isolate"))
2357 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2359 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2361 /* Set the bypass mode for the relevant port. */
2362 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2363 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2367 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2368 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2370 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2371 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2373 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2374 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2376 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2377 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2378 value, "normal#bypass#isolate");
2379 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2380 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2383 cmdline_parse_inst_t cmd_set_bypass_mode = {
2384 .f = cmd_set_bypass_mode_parsed,
2385 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2386 "Set the NIC bypass mode for port_id",
2389 (void *)&cmd_setbypass_mode_set,
2390 (void *)&cmd_setbypass_mode_bypass,
2391 (void *)&cmd_setbypass_mode_mode,
2392 (void *)&cmd_setbypass_mode_value,
2393 (void *)&cmd_setbypass_mode_port,
2398 /* *** SET NIC BYPASS EVENT *** */
2399 struct cmd_set_bypass_event_result {
2400 cmdline_fixed_string_t set;
2401 cmdline_fixed_string_t bypass;
2402 cmdline_fixed_string_t event;
2403 cmdline_fixed_string_t event_value;
2404 cmdline_fixed_string_t mode;
2405 cmdline_fixed_string_t mode_value;
2410 cmd_set_bypass_event_parsed(void *parsed_result,
2411 __attribute__((unused)) struct cmdline *cl,
2412 __attribute__((unused)) void *data)
2415 struct cmd_set_bypass_event_result *res = parsed_result;
2416 portid_t port_id = res->port_id;
2417 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2418 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2420 if (!bypass_is_supported(port_id))
2423 if (!strcmp(res->event_value, "timeout"))
2424 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2425 else if (!strcmp(res->event_value, "os_on"))
2426 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2427 else if (!strcmp(res->event_value, "os_off"))
2428 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2429 else if (!strcmp(res->event_value, "power_on"))
2430 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2431 else if (!strcmp(res->event_value, "power_off"))
2432 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2434 bypass_event = RTE_BYPASS_EVENT_NONE;
2436 if (!strcmp(res->mode_value, "bypass"))
2437 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2438 else if (!strcmp(res->mode_value, "isolate"))
2439 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2441 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2443 /* Set the watchdog timeout. */
2444 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2447 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2448 (rc = rte_eth_dev_wd_timeout_store(port_id,
2449 bypass_timeout)) != 0) {
2450 printf("Failed to set timeout value %u "
2451 "for port %d, errto code: %d.\n",
2452 bypass_timeout, port_id, rc);
2456 /* Set the bypass event to transition to bypass mode. */
2457 if (0 != rte_eth_dev_bypass_event_store(port_id,
2458 bypass_event, bypass_mode)) {
2459 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2464 cmdline_parse_token_string_t cmd_setbypass_event_set =
2465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2467 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2470 cmdline_parse_token_string_t cmd_setbypass_event_event =
2471 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2473 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2474 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2475 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2476 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2477 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2479 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2480 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2481 mode_value, "normal#bypass#isolate");
2482 cmdline_parse_token_num_t cmd_setbypass_event_port =
2483 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2486 cmdline_parse_inst_t cmd_set_bypass_event = {
2487 .f = cmd_set_bypass_event_parsed,
2488 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2489 "mode (normal|bypass|isolate) (port_id): "
2490 "Set the NIC bypass event mode for port_id",
2493 (void *)&cmd_setbypass_event_set,
2494 (void *)&cmd_setbypass_event_bypass,
2495 (void *)&cmd_setbypass_event_event,
2496 (void *)&cmd_setbypass_event_event_value,
2497 (void *)&cmd_setbypass_event_mode,
2498 (void *)&cmd_setbypass_event_mode_value,
2499 (void *)&cmd_setbypass_event_port,
2505 /* *** SET NIC BYPASS TIMEOUT *** */
2506 struct cmd_set_bypass_timeout_result {
2507 cmdline_fixed_string_t set;
2508 cmdline_fixed_string_t bypass;
2509 cmdline_fixed_string_t timeout;
2510 cmdline_fixed_string_t value;
2514 cmd_set_bypass_timeout_parsed(void *parsed_result,
2515 __attribute__((unused)) struct cmdline *cl,
2516 __attribute__((unused)) void *data)
2518 struct cmd_set_bypass_timeout_result *res = parsed_result;
2520 if (!strcmp(res->value, "1.5"))
2521 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2522 else if (!strcmp(res->value, "2"))
2523 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2524 else if (!strcmp(res->value, "3"))
2525 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2526 else if (!strcmp(res->value, "4"))
2527 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2528 else if (!strcmp(res->value, "8"))
2529 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2530 else if (!strcmp(res->value, "16"))
2531 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2532 else if (!strcmp(res->value, "32"))
2533 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2535 bypass_timeout = RTE_BYPASS_TMT_OFF;
2538 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2539 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2541 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2542 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2544 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2545 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2546 timeout, "timeout");
2547 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2549 value, "0#1.5#2#3#4#8#16#32");
2551 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2552 .f = cmd_set_bypass_timeout_parsed,
2553 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2554 "Set the NIC bypass watchdog timeout",
2557 (void *)&cmd_setbypass_timeout_set,
2558 (void *)&cmd_setbypass_timeout_bypass,
2559 (void *)&cmd_setbypass_timeout_timeout,
2560 (void *)&cmd_setbypass_timeout_value,
2565 /* *** SHOW NIC BYPASS MODE *** */
2566 struct cmd_show_bypass_config_result {
2567 cmdline_fixed_string_t show;
2568 cmdline_fixed_string_t bypass;
2569 cmdline_fixed_string_t config;
2574 cmd_show_bypass_config_parsed(void *parsed_result,
2575 __attribute__((unused)) struct cmdline *cl,
2576 __attribute__((unused)) void *data)
2578 struct cmd_show_bypass_config_result *res = parsed_result;
2579 uint32_t event_mode;
2580 uint32_t bypass_mode;
2581 portid_t port_id = res->port_id;
2582 uint32_t timeout = bypass_timeout;
2585 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2586 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2587 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2588 {"UNKNOWN", "normal", "bypass", "isolate"};
2589 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2596 int num_events = (sizeof events) / (sizeof events[0]);
2598 if (!bypass_is_supported(port_id))
2601 /* Display the bypass mode.*/
2602 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2603 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2607 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2608 bypass_mode = RTE_BYPASS_MODE_NONE;
2610 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2613 /* Display the bypass timeout.*/
2614 if (!RTE_BYPASS_TMT_VALID(timeout))
2615 timeout = RTE_BYPASS_TMT_OFF;
2617 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2619 /* Display the bypass events and associated modes. */
2620 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2622 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2623 printf("\tFailed to get bypass mode for event = %s\n",
2626 if (!RTE_BYPASS_MODE_VALID(event_mode))
2627 event_mode = RTE_BYPASS_MODE_NONE;
2629 printf("\tbypass event: %-16s = %s\n", events[i],
2635 cmdline_parse_token_string_t cmd_showbypass_config_show =
2636 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2638 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2639 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2641 cmdline_parse_token_string_t cmd_showbypass_config_config =
2642 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2644 cmdline_parse_token_num_t cmd_showbypass_config_port =
2645 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2648 cmdline_parse_inst_t cmd_show_bypass_config = {
2649 .f = cmd_show_bypass_config_parsed,
2650 .help_str = "show bypass config (port_id): "
2651 "Show the NIC bypass config for port_id",
2654 (void *)&cmd_showbypass_config_show,
2655 (void *)&cmd_showbypass_config_bypass,
2656 (void *)&cmd_showbypass_config_config,
2657 (void *)&cmd_showbypass_config_port,
2663 /* *** SET FORWARDING MODE *** */
2664 struct cmd_set_fwd_mode_result {
2665 cmdline_fixed_string_t set;
2666 cmdline_fixed_string_t fwd;
2667 cmdline_fixed_string_t mode;
2670 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2671 __attribute__((unused)) struct cmdline *cl,
2672 __attribute__((unused)) void *data)
2674 struct cmd_set_fwd_mode_result *res = parsed_result;
2676 set_pkt_forwarding_mode(res->mode);
2679 cmdline_parse_token_string_t cmd_setfwd_set =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2681 cmdline_parse_token_string_t cmd_setfwd_fwd =
2682 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2683 cmdline_parse_token_string_t cmd_setfwd_mode =
2684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2685 #ifdef RTE_LIBRTE_IEEE1588
2686 "io#mac#rxonly#txonly#csum#ieee1588");
2688 "io#mac#rxonly#txonly#csum");
2691 cmdline_parse_inst_t cmd_set_fwd_mode = {
2692 .f = cmd_set_fwd_mode_parsed,
2694 #ifdef RTE_LIBRTE_IEEE1588
2695 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2696 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2698 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2699 " RXONLY, CSUM or TXONLY packet forwarding mode",
2702 (void *)&cmd_setfwd_set,
2703 (void *)&cmd_setfwd_fwd,
2704 (void *)&cmd_setfwd_mode,
2709 /* *** SET PROMISC MODE *** */
2710 struct cmd_set_promisc_mode_result {
2711 cmdline_fixed_string_t set;
2712 cmdline_fixed_string_t promisc;
2713 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2714 uint8_t port_num; /* valid if "allports" argument == 0 */
2715 cmdline_fixed_string_t mode;
2718 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2719 __attribute__((unused)) struct cmdline *cl,
2722 struct cmd_set_promisc_mode_result *res = parsed_result;
2726 if (!strcmp(res->mode, "on"))
2733 for (i = 0; i < nb_ports; i++) {
2735 rte_eth_promiscuous_enable(i);
2737 rte_eth_promiscuous_disable(i);
2742 rte_eth_promiscuous_enable(res->port_num);
2744 rte_eth_promiscuous_disable(res->port_num);
2748 cmdline_parse_token_string_t cmd_setpromisc_set =
2749 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2750 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2751 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2753 cmdline_parse_token_string_t cmd_setpromisc_portall =
2754 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2756 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2757 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2759 cmdline_parse_token_string_t cmd_setpromisc_mode =
2760 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2763 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2764 .f = cmd_set_promisc_mode_parsed,
2766 .help_str = "set promisc all on|off: set promisc mode for all ports",
2768 (void *)&cmd_setpromisc_set,
2769 (void *)&cmd_setpromisc_promisc,
2770 (void *)&cmd_setpromisc_portall,
2771 (void *)&cmd_setpromisc_mode,
2776 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2777 .f = cmd_set_promisc_mode_parsed,
2779 .help_str = "set promisc X on|off: set promisc mode on port X",
2781 (void *)&cmd_setpromisc_set,
2782 (void *)&cmd_setpromisc_promisc,
2783 (void *)&cmd_setpromisc_portnum,
2784 (void *)&cmd_setpromisc_mode,
2789 /* *** SET ALLMULTI MODE *** */
2790 struct cmd_set_allmulti_mode_result {
2791 cmdline_fixed_string_t set;
2792 cmdline_fixed_string_t allmulti;
2793 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2794 uint8_t port_num; /* valid if "allports" argument == 0 */
2795 cmdline_fixed_string_t mode;
2798 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2799 __attribute__((unused)) struct cmdline *cl,
2802 struct cmd_set_allmulti_mode_result *res = parsed_result;
2806 if (!strcmp(res->mode, "on"))
2813 for (i = 0; i < nb_ports; i++) {
2815 rte_eth_allmulticast_enable(i);
2817 rte_eth_allmulticast_disable(i);
2822 rte_eth_allmulticast_enable(res->port_num);
2824 rte_eth_allmulticast_disable(res->port_num);
2828 cmdline_parse_token_string_t cmd_setallmulti_set =
2829 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2830 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2831 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2833 cmdline_parse_token_string_t cmd_setallmulti_portall =
2834 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2836 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2837 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2839 cmdline_parse_token_string_t cmd_setallmulti_mode =
2840 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2843 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2844 .f = cmd_set_allmulti_mode_parsed,
2846 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2848 (void *)&cmd_setallmulti_set,
2849 (void *)&cmd_setallmulti_allmulti,
2850 (void *)&cmd_setallmulti_portall,
2851 (void *)&cmd_setallmulti_mode,
2856 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2857 .f = cmd_set_allmulti_mode_parsed,
2859 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2861 (void *)&cmd_setallmulti_set,
2862 (void *)&cmd_setallmulti_allmulti,
2863 (void *)&cmd_setallmulti_portnum,
2864 (void *)&cmd_setallmulti_mode,
2869 /* *** ADD/REMOVE A PKT FILTER *** */
2870 struct cmd_pkt_filter_result {
2871 cmdline_fixed_string_t pkt_filter;
2873 cmdline_fixed_string_t protocol;
2874 cmdline_fixed_string_t src;
2875 cmdline_ipaddr_t ip_src;
2877 cmdline_fixed_string_t dst;
2878 cmdline_ipaddr_t ip_dst;
2880 cmdline_fixed_string_t flexbytes;
2881 uint16_t flexbytes_value;
2882 cmdline_fixed_string_t vlan;
2884 cmdline_fixed_string_t queue;
2886 cmdline_fixed_string_t soft;
2891 cmd_pkt_filter_parsed(void *parsed_result,
2892 __attribute__((unused)) struct cmdline *cl,
2893 __attribute__((unused)) void *data)
2895 struct rte_fdir_filter fdir_filter;
2896 struct cmd_pkt_filter_result *res = parsed_result;
2898 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2900 if (res->ip_src.family == AF_INET)
2901 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2903 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2904 &(res->ip_src.addr.ipv6),
2905 sizeof(struct in6_addr));
2907 if (res->ip_dst.family == AF_INET)
2908 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2910 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2911 &(res->ip_dst.addr.ipv6),
2912 sizeof(struct in6_addr));
2914 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2915 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2917 if (!strcmp(res->protocol, "udp"))
2918 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2919 else if (!strcmp(res->protocol, "tcp"))
2920 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2921 else if (!strcmp(res->protocol, "sctp"))
2922 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2923 else /* default only IP */
2924 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2926 if (res->ip_dst.family == AF_INET6)
2927 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2929 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2931 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2932 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2934 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2935 fdir_add_signature_filter(res->port_id, res->queue_id,
2937 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2938 fdir_update_signature_filter(res->port_id, res->queue_id,
2940 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2941 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2942 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2943 fdir_add_perfect_filter(res->port_id, res->soft_id,
2945 (uint8_t) (res->queue_id < 0),
2947 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2948 fdir_update_perfect_filter(res->port_id, res->soft_id,
2950 (uint8_t) (res->queue_id < 0),
2952 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2953 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2959 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2960 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2962 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2963 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2964 protocol, "ip#tcp#udp#sctp");
2965 cmdline_parse_token_string_t cmd_pkt_filter_src =
2966 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2968 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2969 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2971 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2972 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2974 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2975 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2977 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2978 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2980 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2981 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2983 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2984 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2985 flexbytes, "flexbytes");
2986 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2987 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2988 flexbytes_value, UINT16);
2989 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2990 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2992 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2993 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2995 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2996 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2998 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2999 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3001 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3002 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3004 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3005 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3009 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3010 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3011 pkt_filter, "add_signature_filter");
3012 cmdline_parse_inst_t cmd_add_signature_filter = {
3013 .f = cmd_pkt_filter_parsed,
3015 .help_str = "add a signature filter",
3017 (void *)&cmd_pkt_filter_add_signature_filter,
3018 (void *)&cmd_pkt_filter_port_id,
3019 (void *)&cmd_pkt_filter_protocol,
3020 (void *)&cmd_pkt_filter_src,
3021 (void *)&cmd_pkt_filter_ip_src,
3022 (void *)&cmd_pkt_filter_port_src,
3023 (void *)&cmd_pkt_filter_dst,
3024 (void *)&cmd_pkt_filter_ip_dst,
3025 (void *)&cmd_pkt_filter_port_dst,
3026 (void *)&cmd_pkt_filter_flexbytes,
3027 (void *)&cmd_pkt_filter_flexbytes_value,
3028 (void *)&cmd_pkt_filter_vlan,
3029 (void *)&cmd_pkt_filter_vlan_id,
3030 (void *)&cmd_pkt_filter_queue,
3031 (void *)&cmd_pkt_filter_queue_id,
3037 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3038 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3039 pkt_filter, "upd_signature_filter");
3040 cmdline_parse_inst_t cmd_upd_signature_filter = {
3041 .f = cmd_pkt_filter_parsed,
3043 .help_str = "update a signature filter",
3045 (void *)&cmd_pkt_filter_upd_signature_filter,
3046 (void *)&cmd_pkt_filter_port_id,
3047 (void *)&cmd_pkt_filter_protocol,
3048 (void *)&cmd_pkt_filter_src,
3049 (void *)&cmd_pkt_filter_ip_src,
3050 (void *)&cmd_pkt_filter_port_src,
3051 (void *)&cmd_pkt_filter_dst,
3052 (void *)&cmd_pkt_filter_ip_dst,
3053 (void *)&cmd_pkt_filter_port_dst,
3054 (void *)&cmd_pkt_filter_flexbytes,
3055 (void *)&cmd_pkt_filter_flexbytes_value,
3056 (void *)&cmd_pkt_filter_vlan,
3057 (void *)&cmd_pkt_filter_vlan_id,
3058 (void *)&cmd_pkt_filter_queue,
3059 (void *)&cmd_pkt_filter_queue_id,
3065 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3066 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3067 pkt_filter, "rm_signature_filter");
3068 cmdline_parse_inst_t cmd_rm_signature_filter = {
3069 .f = cmd_pkt_filter_parsed,
3071 .help_str = "remove a signature filter",
3073 (void *)&cmd_pkt_filter_rm_signature_filter,
3074 (void *)&cmd_pkt_filter_port_id,
3075 (void *)&cmd_pkt_filter_protocol,
3076 (void *)&cmd_pkt_filter_src,
3077 (void *)&cmd_pkt_filter_ip_src,
3078 (void *)&cmd_pkt_filter_port_src,
3079 (void *)&cmd_pkt_filter_dst,
3080 (void *)&cmd_pkt_filter_ip_dst,
3081 (void *)&cmd_pkt_filter_port_dst,
3082 (void *)&cmd_pkt_filter_flexbytes,
3083 (void *)&cmd_pkt_filter_flexbytes_value,
3084 (void *)&cmd_pkt_filter_vlan,
3085 (void *)&cmd_pkt_filter_vlan_id,
3091 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3092 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3093 pkt_filter, "add_perfect_filter");
3094 cmdline_parse_inst_t cmd_add_perfect_filter = {
3095 .f = cmd_pkt_filter_parsed,
3097 .help_str = "add a perfect filter",
3099 (void *)&cmd_pkt_filter_add_perfect_filter,
3100 (void *)&cmd_pkt_filter_port_id,
3101 (void *)&cmd_pkt_filter_protocol,
3102 (void *)&cmd_pkt_filter_src,
3103 (void *)&cmd_pkt_filter_ip_src,
3104 (void *)&cmd_pkt_filter_port_src,
3105 (void *)&cmd_pkt_filter_dst,
3106 (void *)&cmd_pkt_filter_ip_dst,
3107 (void *)&cmd_pkt_filter_port_dst,
3108 (void *)&cmd_pkt_filter_flexbytes,
3109 (void *)&cmd_pkt_filter_flexbytes_value,
3110 (void *)&cmd_pkt_filter_vlan,
3111 (void *)&cmd_pkt_filter_vlan_id,
3112 (void *)&cmd_pkt_filter_queue,
3113 (void *)&cmd_pkt_filter_queue_id,
3114 (void *)&cmd_pkt_filter_soft,
3115 (void *)&cmd_pkt_filter_soft_id,
3121 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3122 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3123 pkt_filter, "upd_perfect_filter");
3124 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3125 .f = cmd_pkt_filter_parsed,
3127 .help_str = "update a perfect filter",
3129 (void *)&cmd_pkt_filter_upd_perfect_filter,
3130 (void *)&cmd_pkt_filter_port_id,
3131 (void *)&cmd_pkt_filter_protocol,
3132 (void *)&cmd_pkt_filter_src,
3133 (void *)&cmd_pkt_filter_ip_src,
3134 (void *)&cmd_pkt_filter_port_src,
3135 (void *)&cmd_pkt_filter_dst,
3136 (void *)&cmd_pkt_filter_ip_dst,
3137 (void *)&cmd_pkt_filter_port_dst,
3138 (void *)&cmd_pkt_filter_flexbytes,
3139 (void *)&cmd_pkt_filter_flexbytes_value,
3140 (void *)&cmd_pkt_filter_vlan,
3141 (void *)&cmd_pkt_filter_vlan_id,
3142 (void *)&cmd_pkt_filter_queue,
3143 (void *)&cmd_pkt_filter_queue_id,
3144 (void *)&cmd_pkt_filter_soft,
3145 (void *)&cmd_pkt_filter_soft_id,
3151 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3152 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3153 pkt_filter, "rm_perfect_filter");
3154 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3155 .f = cmd_pkt_filter_parsed,
3157 .help_str = "remove a perfect filter",
3159 (void *)&cmd_pkt_filter_rm_perfect_filter,
3160 (void *)&cmd_pkt_filter_port_id,
3161 (void *)&cmd_pkt_filter_protocol,
3162 (void *)&cmd_pkt_filter_src,
3163 (void *)&cmd_pkt_filter_ip_src,
3164 (void *)&cmd_pkt_filter_port_src,
3165 (void *)&cmd_pkt_filter_dst,
3166 (void *)&cmd_pkt_filter_ip_dst,
3167 (void *)&cmd_pkt_filter_port_dst,
3168 (void *)&cmd_pkt_filter_flexbytes,
3169 (void *)&cmd_pkt_filter_flexbytes_value,
3170 (void *)&cmd_pkt_filter_vlan,
3171 (void *)&cmd_pkt_filter_vlan_id,
3172 (void *)&cmd_pkt_filter_soft,
3173 (void *)&cmd_pkt_filter_soft_id,
3178 /* *** SETUP MASKS FILTER *** */
3179 struct cmd_pkt_filter_masks_result {
3180 cmdline_fixed_string_t filter_mask;
3182 cmdline_fixed_string_t src_mask;
3183 uint32_t ip_src_mask;
3184 uint16_t ipv6_src_mask;
3185 uint16_t port_src_mask;
3186 cmdline_fixed_string_t dst_mask;
3187 uint32_t ip_dst_mask;
3188 uint16_t ipv6_dst_mask;
3189 uint16_t port_dst_mask;
3190 cmdline_fixed_string_t flexbytes;
3191 uint8_t flexbytes_value;
3192 cmdline_fixed_string_t vlan_id;
3193 uint8_t vlan_id_value;
3194 cmdline_fixed_string_t vlan_prio;
3195 uint8_t vlan_prio_value;
3196 cmdline_fixed_string_t only_ip_flow;
3197 uint8_t only_ip_flow_value;
3198 cmdline_fixed_string_t comp_ipv6_dst;
3199 uint8_t comp_ipv6_dst_value;
3203 cmd_pkt_filter_masks_parsed(void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3207 struct rte_fdir_masks fdir_masks;
3208 struct cmd_pkt_filter_masks_result *res = parsed_result;
3210 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3212 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3213 fdir_masks.vlan_id = res->vlan_id_value;
3214 fdir_masks.vlan_prio = res->vlan_prio_value;
3215 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3216 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3217 fdir_masks.src_port_mask = res->port_src_mask;
3218 fdir_masks.dst_port_mask = res->port_dst_mask;
3219 fdir_masks.flexbytes = res->flexbytes_value;
3221 fdir_set_masks(res->port_id, &fdir_masks);
3224 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3225 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3226 filter_mask, "set_masks_filter");
3227 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3228 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3230 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3231 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3232 only_ip_flow, "only_ip_flow");
3233 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3234 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3235 only_ip_flow_value, UINT8);
3236 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3237 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3238 src_mask, "src_mask");
3239 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3240 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3241 ip_src_mask, UINT32);
3242 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3243 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3244 port_src_mask, UINT16);
3245 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3246 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3247 dst_mask, "dst_mask");
3248 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3249 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3250 ip_dst_mask, UINT32);
3251 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3252 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3253 port_dst_mask, UINT16);
3254 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3255 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3256 flexbytes, "flexbytes");
3257 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3258 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3259 flexbytes_value, UINT8);
3260 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3261 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3262 vlan_id, "vlan_id");
3263 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3264 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3265 vlan_id_value, UINT8);
3266 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3267 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3268 vlan_prio, "vlan_prio");
3269 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3270 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3271 vlan_prio_value, UINT8);
3273 cmdline_parse_inst_t cmd_set_masks_filter = {
3274 .f = cmd_pkt_filter_masks_parsed,
3276 .help_str = "setup masks filter",
3278 (void *)&cmd_pkt_filter_masks_filter_mask,
3279 (void *)&cmd_pkt_filter_masks_port_id,
3280 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3281 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3282 (void *)&cmd_pkt_filter_masks_src_mask,
3283 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3284 (void *)&cmd_pkt_filter_masks_port_src_mask,
3285 (void *)&cmd_pkt_filter_masks_dst_mask,
3286 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3287 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3288 (void *)&cmd_pkt_filter_masks_flexbytes,
3289 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3290 (void *)&cmd_pkt_filter_masks_vlan_id,
3291 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3292 (void *)&cmd_pkt_filter_masks_vlan_prio,
3293 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3299 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3300 __attribute__((unused)) struct cmdline *cl,
3301 __attribute__((unused)) void *data)
3303 struct rte_fdir_masks fdir_masks;
3304 struct cmd_pkt_filter_masks_result *res = parsed_result;
3306 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3308 fdir_masks.set_ipv6_mask = 1;
3309 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3310 fdir_masks.vlan_id = res->vlan_id_value;
3311 fdir_masks.vlan_prio = res->vlan_prio_value;
3312 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3313 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3314 fdir_masks.src_port_mask = res->port_src_mask;
3315 fdir_masks.dst_port_mask = res->port_dst_mask;
3316 fdir_masks.flexbytes = res->flexbytes_value;
3317 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3319 fdir_set_masks(res->port_id, &fdir_masks);
3322 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3323 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3324 filter_mask, "set_ipv6_masks_filter");
3325 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3326 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3327 ipv6_src_mask, UINT16);
3328 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3329 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3330 ipv6_dst_mask, UINT16);
3332 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3333 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3334 comp_ipv6_dst, "compare_dst");
3335 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3336 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3337 comp_ipv6_dst_value, UINT8);
3339 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3340 .f = cmd_pkt_filter_masks_ipv6_parsed,
3342 .help_str = "setup ipv6 masks filter",
3344 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3345 (void *)&cmd_pkt_filter_masks_port_id,
3346 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3347 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3348 (void *)&cmd_pkt_filter_masks_src_mask,
3349 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3350 (void *)&cmd_pkt_filter_masks_port_src_mask,
3351 (void *)&cmd_pkt_filter_masks_dst_mask,
3352 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3353 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3354 (void *)&cmd_pkt_filter_masks_flexbytes,
3355 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3356 (void *)&cmd_pkt_filter_masks_vlan_id,
3357 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3358 (void *)&cmd_pkt_filter_masks_vlan_prio,
3359 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3360 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3361 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3366 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3367 struct cmd_link_flow_ctrl_set_result {
3368 cmdline_fixed_string_t set;
3369 cmdline_fixed_string_t flow_ctrl;
3370 cmdline_fixed_string_t rx;
3371 cmdline_fixed_string_t rx_lfc_mode;
3372 cmdline_fixed_string_t tx;
3373 cmdline_fixed_string_t tx_lfc_mode;
3374 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3375 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3376 uint32_t high_water;
3378 uint16_t pause_time;
3384 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3385 __attribute__((unused)) struct cmdline *cl,
3386 __attribute__((unused)) void *data)
3388 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3389 struct rte_eth_fc_conf fc_conf;
3390 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3394 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3395 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3396 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3397 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3399 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3400 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3403 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3404 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3405 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3407 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3408 fc_conf.high_water = res->high_water;
3409 fc_conf.low_water = res->low_water;
3410 fc_conf.pause_time = res->pause_time;
3411 fc_conf.send_xon = res->send_xon;
3412 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3414 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3416 printf("bad flow contrl parameter, return code = %d \n", ret);
3419 cmdline_parse_token_string_t cmd_lfc_set_set =
3420 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3422 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3423 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3424 flow_ctrl, "flow_ctrl");
3425 cmdline_parse_token_string_t cmd_lfc_set_rx =
3426 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3428 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3429 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3430 rx_lfc_mode, "on#off");
3431 cmdline_parse_token_string_t cmd_lfc_set_tx =
3432 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3434 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3435 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3436 tx_lfc_mode, "on#off");
3437 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3438 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3439 high_water, UINT32);
3440 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3441 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3443 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3444 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3445 pause_time, UINT16);
3446 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3447 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3449 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3450 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3451 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3452 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3453 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3454 mac_ctrl_frame_fwd_mode, "on#off");
3455 cmdline_parse_token_num_t cmd_lfc_set_portid =
3456 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3459 cmdline_parse_inst_t cmd_link_flow_control_set = {
3460 .f = cmd_link_flow_ctrl_set_parsed,
3462 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3463 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3466 (void *)&cmd_lfc_set_set,
3467 (void *)&cmd_lfc_set_flow_ctrl,
3468 (void *)&cmd_lfc_set_rx,
3469 (void *)&cmd_lfc_set_rx_mode,
3470 (void *)&cmd_lfc_set_tx,
3471 (void *)&cmd_lfc_set_tx_mode,
3472 (void *)&cmd_lfc_set_high_water,
3473 (void *)&cmd_lfc_set_low_water,
3474 (void *)&cmd_lfc_set_pause_time,
3475 (void *)&cmd_lfc_set_send_xon,
3476 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3477 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3478 (void *)&cmd_lfc_set_portid,
3483 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3484 struct cmd_priority_flow_ctrl_set_result {
3485 cmdline_fixed_string_t set;
3486 cmdline_fixed_string_t pfc_ctrl;
3487 cmdline_fixed_string_t rx;
3488 cmdline_fixed_string_t rx_pfc_mode;
3489 cmdline_fixed_string_t tx;
3490 cmdline_fixed_string_t tx_pfc_mode;
3491 uint32_t high_water;
3493 uint16_t pause_time;
3499 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3500 __attribute__((unused)) struct cmdline *cl,
3501 __attribute__((unused)) void *data)
3503 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3504 struct rte_eth_pfc_conf pfc_conf;
3505 int rx_fc_enable, tx_fc_enable;
3509 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3510 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3511 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3512 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3514 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3515 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3518 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3519 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3520 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3521 pfc_conf.fc.high_water = res->high_water;
3522 pfc_conf.fc.low_water = res->low_water;
3523 pfc_conf.fc.pause_time = res->pause_time;
3524 pfc_conf.priority = res->priority;
3526 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3528 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3531 cmdline_parse_token_string_t cmd_pfc_set_set =
3532 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3534 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3535 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3536 pfc_ctrl, "pfc_ctrl");
3537 cmdline_parse_token_string_t cmd_pfc_set_rx =
3538 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3540 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3541 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3542 rx_pfc_mode, "on#off");
3543 cmdline_parse_token_string_t cmd_pfc_set_tx =
3544 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3546 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3547 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3548 tx_pfc_mode, "on#off");
3549 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3550 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3551 high_water, UINT32);
3552 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3553 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3555 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3556 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3557 pause_time, UINT16);
3558 cmdline_parse_token_num_t cmd_pfc_set_priority =
3559 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3561 cmdline_parse_token_num_t cmd_pfc_set_portid =
3562 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3565 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3566 .f = cmd_priority_flow_ctrl_set_parsed,
3568 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3569 tx on|off high_water low_water pause_time priority port_id",
3571 (void *)&cmd_pfc_set_set,
3572 (void *)&cmd_pfc_set_flow_ctrl,
3573 (void *)&cmd_pfc_set_rx,
3574 (void *)&cmd_pfc_set_rx_mode,
3575 (void *)&cmd_pfc_set_tx,
3576 (void *)&cmd_pfc_set_tx_mode,
3577 (void *)&cmd_pfc_set_high_water,
3578 (void *)&cmd_pfc_set_low_water,
3579 (void *)&cmd_pfc_set_pause_time,
3580 (void *)&cmd_pfc_set_priority,
3581 (void *)&cmd_pfc_set_portid,
3586 /* *** RESET CONFIGURATION *** */
3587 struct cmd_reset_result {
3588 cmdline_fixed_string_t reset;
3589 cmdline_fixed_string_t def;
3592 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3594 __attribute__((unused)) void *data)
3596 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3597 set_def_fwd_config();
3600 cmdline_parse_token_string_t cmd_reset_set =
3601 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3602 cmdline_parse_token_string_t cmd_reset_def =
3603 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3606 cmdline_parse_inst_t cmd_reset = {
3607 .f = cmd_reset_parsed,
3609 .help_str = "set default: reset default forwarding configuration",
3611 (void *)&cmd_reset_set,
3612 (void *)&cmd_reset_def,
3617 /* *** START FORWARDING *** */
3618 struct cmd_start_result {
3619 cmdline_fixed_string_t start;
3622 cmdline_parse_token_string_t cmd_start_start =
3623 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3625 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3626 __attribute__((unused)) struct cmdline *cl,
3627 __attribute__((unused)) void *data)
3629 start_packet_forwarding(0);
3632 cmdline_parse_inst_t cmd_start = {
3633 .f = cmd_start_parsed,
3635 .help_str = "start packet forwarding",
3637 (void *)&cmd_start_start,
3642 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3643 struct cmd_start_tx_first_result {
3644 cmdline_fixed_string_t start;
3645 cmdline_fixed_string_t tx_first;
3649 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3650 __attribute__((unused)) struct cmdline *cl,
3651 __attribute__((unused)) void *data)
3653 start_packet_forwarding(1);
3656 cmdline_parse_token_string_t cmd_start_tx_first_start =
3657 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3659 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3660 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3661 tx_first, "tx_first");
3663 cmdline_parse_inst_t cmd_start_tx_first = {
3664 .f = cmd_start_tx_first_parsed,
3666 .help_str = "start packet forwarding, after sending 1 burst of packets",
3668 (void *)&cmd_start_tx_first_start,
3669 (void *)&cmd_start_tx_first_tx_first,
3674 /* *** SHOW CFG *** */
3675 struct cmd_showcfg_result {
3676 cmdline_fixed_string_t show;
3677 cmdline_fixed_string_t cfg;
3678 cmdline_fixed_string_t what;
3681 static void cmd_showcfg_parsed(void *parsed_result,
3682 __attribute__((unused)) struct cmdline *cl,
3683 __attribute__((unused)) void *data)
3685 struct cmd_showcfg_result *res = parsed_result;
3686 if (!strcmp(res->what, "rxtx"))
3687 rxtx_config_display();
3688 else if (!strcmp(res->what, "cores"))
3689 fwd_lcores_config_display();
3690 else if (!strcmp(res->what, "fwd"))
3691 fwd_config_display();
3694 cmdline_parse_token_string_t cmd_showcfg_show =
3695 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3696 cmdline_parse_token_string_t cmd_showcfg_port =
3697 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3698 cmdline_parse_token_string_t cmd_showcfg_what =
3699 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3702 cmdline_parse_inst_t cmd_showcfg = {
3703 .f = cmd_showcfg_parsed,
3705 .help_str = "show config rxtx|cores|fwd",
3707 (void *)&cmd_showcfg_show,
3708 (void *)&cmd_showcfg_port,
3709 (void *)&cmd_showcfg_what,
3714 /* *** SHOW ALL PORT INFO *** */
3715 struct cmd_showportall_result {
3716 cmdline_fixed_string_t show;
3717 cmdline_fixed_string_t port;
3718 cmdline_fixed_string_t what;
3719 cmdline_fixed_string_t all;
3722 static void cmd_showportall_parsed(void *parsed_result,
3723 __attribute__((unused)) struct cmdline *cl,
3724 __attribute__((unused)) void *data)
3728 struct cmd_showportall_result *res = parsed_result;
3729 if (!strcmp(res->show, "clear")) {
3730 if (!strcmp(res->what, "stats"))
3731 for (i = 0; i < nb_ports; i++)
3733 } else if (!strcmp(res->what, "info"))
3734 for (i = 0; i < nb_ports; i++)
3735 port_infos_display(i);
3736 else if (!strcmp(res->what, "stats"))
3737 for (i = 0; i < nb_ports; i++)
3738 nic_stats_display(i);
3739 else if (!strcmp(res->what, "fdir"))
3740 for (i = 0; i < nb_ports; i++)
3742 else if (!strcmp(res->what, "stat_qmap"))
3743 for (i = 0; i < nb_ports; i++)
3744 nic_stats_mapping_display(i);
3747 cmdline_parse_token_string_t cmd_showportall_show =
3748 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3750 cmdline_parse_token_string_t cmd_showportall_port =
3751 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3752 cmdline_parse_token_string_t cmd_showportall_what =
3753 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3754 "info#stats#fdir#stat_qmap");
3755 cmdline_parse_token_string_t cmd_showportall_all =
3756 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3757 cmdline_parse_inst_t cmd_showportall = {
3758 .f = cmd_showportall_parsed,
3760 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3762 (void *)&cmd_showportall_show,
3763 (void *)&cmd_showportall_port,
3764 (void *)&cmd_showportall_what,
3765 (void *)&cmd_showportall_all,
3770 /* *** SHOW PORT INFO *** */
3771 struct cmd_showport_result {
3772 cmdline_fixed_string_t show;
3773 cmdline_fixed_string_t port;
3774 cmdline_fixed_string_t what;
3778 static void cmd_showport_parsed(void *parsed_result,
3779 __attribute__((unused)) struct cmdline *cl,
3780 __attribute__((unused)) void *data)
3782 struct cmd_showport_result *res = parsed_result;
3783 if (!strcmp(res->show, "clear")) {
3784 if (!strcmp(res->what, "stats"))
3785 nic_stats_clear(res->portnum);
3786 } else if (!strcmp(res->what, "info"))
3787 port_infos_display(res->portnum);
3788 else if (!strcmp(res->what, "stats"))
3789 nic_stats_display(res->portnum);
3790 else if (!strcmp(res->what, "fdir"))
3791 fdir_get_infos(res->portnum);
3792 else if (!strcmp(res->what, "stat_qmap"))
3793 nic_stats_mapping_display(res->portnum);
3796 cmdline_parse_token_string_t cmd_showport_show =
3797 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3799 cmdline_parse_token_string_t cmd_showport_port =
3800 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3801 cmdline_parse_token_string_t cmd_showport_what =
3802 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3803 "info#stats#fdir#stat_qmap");
3804 cmdline_parse_token_num_t cmd_showport_portnum =
3805 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3807 cmdline_parse_inst_t cmd_showport = {
3808 .f = cmd_showport_parsed,
3810 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3812 (void *)&cmd_showport_show,
3813 (void *)&cmd_showport_port,
3814 (void *)&cmd_showport_what,
3815 (void *)&cmd_showport_portnum,
3820 /* *** READ PORT REGISTER *** */
3821 struct cmd_read_reg_result {
3822 cmdline_fixed_string_t read;
3823 cmdline_fixed_string_t reg;
3829 cmd_read_reg_parsed(void *parsed_result,
3830 __attribute__((unused)) struct cmdline *cl,
3831 __attribute__((unused)) void *data)
3833 struct cmd_read_reg_result *res = parsed_result;
3834 port_reg_display(res->port_id, res->reg_off);
3837 cmdline_parse_token_string_t cmd_read_reg_read =
3838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3839 cmdline_parse_token_string_t cmd_read_reg_reg =
3840 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3841 cmdline_parse_token_num_t cmd_read_reg_port_id =
3842 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3843 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3846 cmdline_parse_inst_t cmd_read_reg = {
3847 .f = cmd_read_reg_parsed,
3849 .help_str = "read reg port_id reg_off",
3851 (void *)&cmd_read_reg_read,
3852 (void *)&cmd_read_reg_reg,
3853 (void *)&cmd_read_reg_port_id,
3854 (void *)&cmd_read_reg_reg_off,
3859 /* *** READ PORT REGISTER BIT FIELD *** */
3860 struct cmd_read_reg_bit_field_result {
3861 cmdline_fixed_string_t read;
3862 cmdline_fixed_string_t regfield;
3870 cmd_read_reg_bit_field_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_read_reg_bit_field_result *res = parsed_result;
3875 port_reg_bit_field_display(res->port_id, res->reg_off,
3876 res->bit1_pos, res->bit2_pos);
3879 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3880 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3882 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3883 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3884 regfield, "regfield");
3885 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3888 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3889 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3891 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3892 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3894 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3895 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3898 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3899 .f = cmd_read_reg_bit_field_parsed,
3901 .help_str = "read regfield port_id reg_off bit_x bit_y "
3902 "(read register bit field between bit_x and bit_y included)",
3904 (void *)&cmd_read_reg_bit_field_read,
3905 (void *)&cmd_read_reg_bit_field_regfield,
3906 (void *)&cmd_read_reg_bit_field_port_id,
3907 (void *)&cmd_read_reg_bit_field_reg_off,
3908 (void *)&cmd_read_reg_bit_field_bit1_pos,
3909 (void *)&cmd_read_reg_bit_field_bit2_pos,
3914 /* *** READ PORT REGISTER BIT *** */
3915 struct cmd_read_reg_bit_result {
3916 cmdline_fixed_string_t read;
3917 cmdline_fixed_string_t regbit;
3924 cmd_read_reg_bit_parsed(void *parsed_result,
3925 __attribute__((unused)) struct cmdline *cl,
3926 __attribute__((unused)) void *data)
3928 struct cmd_read_reg_bit_result *res = parsed_result;
3929 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3932 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3933 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3934 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3935 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3937 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3938 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3939 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3940 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3941 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3942 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3944 cmdline_parse_inst_t cmd_read_reg_bit = {
3945 .f = cmd_read_reg_bit_parsed,
3947 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3949 (void *)&cmd_read_reg_bit_read,
3950 (void *)&cmd_read_reg_bit_regbit,
3951 (void *)&cmd_read_reg_bit_port_id,
3952 (void *)&cmd_read_reg_bit_reg_off,
3953 (void *)&cmd_read_reg_bit_bit_pos,
3958 /* *** WRITE PORT REGISTER *** */
3959 struct cmd_write_reg_result {
3960 cmdline_fixed_string_t write;
3961 cmdline_fixed_string_t reg;
3968 cmd_write_reg_parsed(void *parsed_result,
3969 __attribute__((unused)) struct cmdline *cl,
3970 __attribute__((unused)) void *data)
3972 struct cmd_write_reg_result *res = parsed_result;
3973 port_reg_set(res->port_id, res->reg_off, res->value);
3976 cmdline_parse_token_string_t cmd_write_reg_write =
3977 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3978 cmdline_parse_token_string_t cmd_write_reg_reg =
3979 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3980 cmdline_parse_token_num_t cmd_write_reg_port_id =
3981 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3982 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3983 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3984 cmdline_parse_token_num_t cmd_write_reg_value =
3985 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3987 cmdline_parse_inst_t cmd_write_reg = {
3988 .f = cmd_write_reg_parsed,
3990 .help_str = "write reg port_id reg_off reg_value",
3992 (void *)&cmd_write_reg_write,
3993 (void *)&cmd_write_reg_reg,
3994 (void *)&cmd_write_reg_port_id,
3995 (void *)&cmd_write_reg_reg_off,
3996 (void *)&cmd_write_reg_value,
4001 /* *** WRITE PORT REGISTER BIT FIELD *** */
4002 struct cmd_write_reg_bit_field_result {
4003 cmdline_fixed_string_t write;
4004 cmdline_fixed_string_t regfield;
4013 cmd_write_reg_bit_field_parsed(void *parsed_result,
4014 __attribute__((unused)) struct cmdline *cl,
4015 __attribute__((unused)) void *data)
4017 struct cmd_write_reg_bit_field_result *res = parsed_result;
4018 port_reg_bit_field_set(res->port_id, res->reg_off,
4019 res->bit1_pos, res->bit2_pos, res->value);
4022 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4023 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4025 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4026 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4027 regfield, "regfield");
4028 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4031 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4032 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4034 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4035 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4037 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4038 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4040 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4041 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4044 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4045 .f = cmd_write_reg_bit_field_parsed,
4047 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4048 "(set register bit field between bit_x and bit_y included)",
4050 (void *)&cmd_write_reg_bit_field_write,
4051 (void *)&cmd_write_reg_bit_field_regfield,
4052 (void *)&cmd_write_reg_bit_field_port_id,
4053 (void *)&cmd_write_reg_bit_field_reg_off,
4054 (void *)&cmd_write_reg_bit_field_bit1_pos,
4055 (void *)&cmd_write_reg_bit_field_bit2_pos,
4056 (void *)&cmd_write_reg_bit_field_value,
4061 /* *** WRITE PORT REGISTER BIT *** */
4062 struct cmd_write_reg_bit_result {
4063 cmdline_fixed_string_t write;
4064 cmdline_fixed_string_t regbit;
4072 cmd_write_reg_bit_parsed(void *parsed_result,
4073 __attribute__((unused)) struct cmdline *cl,
4074 __attribute__((unused)) void *data)
4076 struct cmd_write_reg_bit_result *res = parsed_result;
4077 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4080 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4081 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4083 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4084 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4086 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4087 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4088 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4089 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4090 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4091 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4092 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4093 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4095 cmdline_parse_inst_t cmd_write_reg_bit = {
4096 .f = cmd_write_reg_bit_parsed,
4098 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4100 (void *)&cmd_write_reg_bit_write,
4101 (void *)&cmd_write_reg_bit_regbit,
4102 (void *)&cmd_write_reg_bit_port_id,
4103 (void *)&cmd_write_reg_bit_reg_off,
4104 (void *)&cmd_write_reg_bit_bit_pos,
4105 (void *)&cmd_write_reg_bit_value,
4110 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4111 struct cmd_read_rxd_txd_result {
4112 cmdline_fixed_string_t read;
4113 cmdline_fixed_string_t rxd_txd;
4120 cmd_read_rxd_txd_parsed(void *parsed_result,
4121 __attribute__((unused)) struct cmdline *cl,
4122 __attribute__((unused)) void *data)
4124 struct cmd_read_rxd_txd_result *res = parsed_result;
4126 if (!strcmp(res->rxd_txd, "rxd"))
4127 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4128 else if (!strcmp(res->rxd_txd, "txd"))
4129 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4132 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4133 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4134 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4135 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4137 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4138 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4139 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4140 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4141 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4142 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4144 cmdline_parse_inst_t cmd_read_rxd_txd = {
4145 .f = cmd_read_rxd_txd_parsed,
4147 .help_str = "read rxd|txd port_id queue_id rxd_id",
4149 (void *)&cmd_read_rxd_txd_read,
4150 (void *)&cmd_read_rxd_txd_rxd_txd,
4151 (void *)&cmd_read_rxd_txd_port_id,
4152 (void *)&cmd_read_rxd_txd_queue_id,
4153 (void *)&cmd_read_rxd_txd_desc_id,
4159 struct cmd_quit_result {
4160 cmdline_fixed_string_t quit;
4163 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4165 __attribute__((unused)) void *data)
4171 cmdline_parse_token_string_t cmd_quit_quit =
4172 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4174 cmdline_parse_inst_t cmd_quit = {
4175 .f = cmd_quit_parsed,
4177 .help_str = "exit application",
4179 (void *)&cmd_quit_quit,
4184 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4185 struct cmd_mac_addr_result {
4186 cmdline_fixed_string_t mac_addr_cmd;
4187 cmdline_fixed_string_t what;
4189 struct ether_addr address;
4192 static void cmd_mac_addr_parsed(void *parsed_result,
4193 __attribute__((unused)) struct cmdline *cl,
4194 __attribute__((unused)) void *data)
4196 struct cmd_mac_addr_result *res = parsed_result;
4199 if (strcmp(res->what, "add") == 0)
4200 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4202 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4204 /* check the return value and print it if is < 0 */
4206 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4210 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4211 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4213 cmdline_parse_token_string_t cmd_mac_addr_what =
4214 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4216 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4217 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4218 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4219 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4221 cmdline_parse_inst_t cmd_mac_addr = {
4222 .f = cmd_mac_addr_parsed,
4224 .help_str = "mac_addr add|remove X <address>: "
4225 "add/remove MAC address on port X",
4227 (void *)&cmd_mac_addr_cmd,
4228 (void *)&cmd_mac_addr_what,
4229 (void *)&cmd_mac_addr_portnum,
4230 (void *)&cmd_mac_addr_addr,
4236 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4237 struct cmd_set_qmap_result {
4238 cmdline_fixed_string_t set;
4239 cmdline_fixed_string_t qmap;
4240 cmdline_fixed_string_t what;
4247 cmd_set_qmap_parsed(void *parsed_result,
4248 __attribute__((unused)) struct cmdline *cl,
4249 __attribute__((unused)) void *data)
4251 struct cmd_set_qmap_result *res = parsed_result;
4252 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4254 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4257 cmdline_parse_token_string_t cmd_setqmap_set =
4258 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4260 cmdline_parse_token_string_t cmd_setqmap_qmap =
4261 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4263 cmdline_parse_token_string_t cmd_setqmap_what =
4264 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4266 cmdline_parse_token_num_t cmd_setqmap_portid =
4267 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4269 cmdline_parse_token_num_t cmd_setqmap_queueid =
4270 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4272 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4273 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4276 cmdline_parse_inst_t cmd_set_qmap = {
4277 .f = cmd_set_qmap_parsed,
4279 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4281 (void *)&cmd_setqmap_set,
4282 (void *)&cmd_setqmap_qmap,
4283 (void *)&cmd_setqmap_what,
4284 (void *)&cmd_setqmap_portid,
4285 (void *)&cmd_setqmap_queueid,
4286 (void *)&cmd_setqmap_mapvalue,
4291 /* *** CONFIGURE UNICAST HASH TABLE *** */
4292 struct cmd_set_uc_hash_table {
4293 cmdline_fixed_string_t set;
4294 cmdline_fixed_string_t port;
4296 cmdline_fixed_string_t what;
4297 struct ether_addr address;
4298 cmdline_fixed_string_t mode;
4302 cmd_set_uc_hash_parsed(void *parsed_result,
4303 __attribute__((unused)) struct cmdline *cl,
4304 __attribute__((unused)) void *data)
4307 struct cmd_set_uc_hash_table *res = parsed_result;
4309 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4311 if (strcmp(res->what, "uta") == 0)
4312 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4313 &res->address,(uint8_t)is_on);
4315 printf("bad unicast hash table parameter, return code = %d \n", ret);
4319 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4322 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4323 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4325 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4326 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4328 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4329 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4331 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4332 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4334 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4335 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4338 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4339 .f = cmd_set_uc_hash_parsed,
4341 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4343 (void *)&cmd_set_uc_hash_set,
4344 (void *)&cmd_set_uc_hash_port,
4345 (void *)&cmd_set_uc_hash_portid,
4346 (void *)&cmd_set_uc_hash_what,
4347 (void *)&cmd_set_uc_hash_mac,
4348 (void *)&cmd_set_uc_hash_mode,
4353 struct cmd_set_uc_all_hash_table {
4354 cmdline_fixed_string_t set;
4355 cmdline_fixed_string_t port;
4357 cmdline_fixed_string_t what;
4358 cmdline_fixed_string_t value;
4359 cmdline_fixed_string_t mode;
4363 cmd_set_uc_all_hash_parsed(void *parsed_result,
4364 __attribute__((unused)) struct cmdline *cl,
4365 __attribute__((unused)) void *data)
4368 struct cmd_set_uc_all_hash_table *res = parsed_result;
4370 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4372 if ((strcmp(res->what, "uta") == 0) &&
4373 (strcmp(res->value, "all") == 0))
4374 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4376 printf("bad unicast hash table parameter,"
4377 "return code = %d \n", ret);
4380 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4381 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4383 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4386 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4387 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4389 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4390 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4392 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4395 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4396 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4399 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4400 .f = cmd_set_uc_all_hash_parsed,
4402 .help_str = "set port X uta all on|off (X = port number)",
4404 (void *)&cmd_set_uc_all_hash_set,
4405 (void *)&cmd_set_uc_all_hash_port,
4406 (void *)&cmd_set_uc_all_hash_portid,
4407 (void *)&cmd_set_uc_all_hash_what,
4408 (void *)&cmd_set_uc_all_hash_value,
4409 (void *)&cmd_set_uc_all_hash_mode,
4414 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4415 struct cmd_set_vf_traffic {
4416 cmdline_fixed_string_t set;
4417 cmdline_fixed_string_t port;
4419 cmdline_fixed_string_t vf;
4421 cmdline_fixed_string_t what;
4422 cmdline_fixed_string_t mode;
4426 cmd_set_vf_traffic_parsed(void *parsed_result,
4427 __attribute__((unused)) struct cmdline *cl,
4428 __attribute__((unused)) void *data)
4430 struct cmd_set_vf_traffic *res = parsed_result;
4431 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4432 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4434 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4437 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4440 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4441 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4443 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4444 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4446 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4447 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4449 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4450 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4452 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4453 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4455 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4459 cmdline_parse_inst_t cmd_set_vf_traffic = {
4460 .f = cmd_set_vf_traffic_parsed,
4462 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4464 (void *)&cmd_setvf_traffic_set,
4465 (void *)&cmd_setvf_traffic_port,
4466 (void *)&cmd_setvf_traffic_portid,
4467 (void *)&cmd_setvf_traffic_vf,
4468 (void *)&cmd_setvf_traffic_vfid,
4469 (void *)&cmd_setvf_traffic_what,
4470 (void *)&cmd_setvf_traffic_mode,
4475 /* *** CONFIGURE VF RECEIVE MODE *** */
4476 struct cmd_set_vf_rxmode {
4477 cmdline_fixed_string_t set;
4478 cmdline_fixed_string_t port;
4480 cmdline_fixed_string_t vf;
4482 cmdline_fixed_string_t what;
4483 cmdline_fixed_string_t mode;
4484 cmdline_fixed_string_t on;
4488 cmd_set_vf_rxmode_parsed(void *parsed_result,
4489 __attribute__((unused)) struct cmdline *cl,
4490 __attribute__((unused)) void *data)
4493 uint16_t rx_mode = 0;
4494 struct cmd_set_vf_rxmode *res = parsed_result;
4496 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4497 if (!strcmp(res->what,"rxmode")) {
4498 if (!strcmp(res->mode, "AUPE"))
4499 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4500 else if (!strcmp(res->mode, "ROPE"))
4501 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4502 else if (!strcmp(res->mode, "BAM"))
4503 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4504 else if (!strncmp(res->mode, "MPE",3))
4505 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4508 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4510 printf("bad VF receive mode parameter, return code = %d \n",
4514 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4515 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4517 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4520 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4521 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4523 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4526 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4527 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4529 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4532 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4534 mode, "AUPE#ROPE#BAM#MPE");
4535 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4536 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4539 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4540 .f = cmd_set_vf_rxmode_parsed,
4542 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4544 (void *)&cmd_set_vf_rxmode_set,
4545 (void *)&cmd_set_vf_rxmode_port,
4546 (void *)&cmd_set_vf_rxmode_portid,
4547 (void *)&cmd_set_vf_rxmode_vf,
4548 (void *)&cmd_set_vf_rxmode_vfid,
4549 (void *)&cmd_set_vf_rxmode_what,
4550 (void *)&cmd_set_vf_rxmode_mode,
4551 (void *)&cmd_set_vf_rxmode_on,
4556 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4557 struct cmd_vf_mac_addr_result {
4558 cmdline_fixed_string_t mac_addr_cmd;
4559 cmdline_fixed_string_t what;
4560 cmdline_fixed_string_t port;
4562 cmdline_fixed_string_t vf;
4564 struct ether_addr address;
4567 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4568 __attribute__((unused)) struct cmdline *cl,
4569 __attribute__((unused)) void *data)
4571 struct cmd_vf_mac_addr_result *res = parsed_result;
4574 if (strcmp(res->what, "add") == 0)
4575 ret = rte_eth_dev_mac_addr_add(res->port_num,
4576 &res->address, res->vf_num);
4578 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4582 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4583 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4584 mac_addr_cmd,"mac_addr");
4585 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4586 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4588 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4589 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4591 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4592 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4594 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4595 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4597 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4598 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4600 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4601 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4604 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4605 .f = cmd_vf_mac_addr_parsed,
4607 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4608 "Y = VF number)add MAC address filtering for a VF on port X",
4610 (void *)&cmd_vf_mac_addr_cmd,
4611 (void *)&cmd_vf_mac_addr_what,
4612 (void *)&cmd_vf_mac_addr_port,
4613 (void *)&cmd_vf_mac_addr_portnum,
4614 (void *)&cmd_vf_mac_addr_vf,
4615 (void *)&cmd_vf_mac_addr_vfnum,
4616 (void *)&cmd_vf_mac_addr_addr,
4621 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4622 struct cmd_vf_rx_vlan_filter {
4623 cmdline_fixed_string_t rx_vlan;
4624 cmdline_fixed_string_t what;
4626 cmdline_fixed_string_t port;
4628 cmdline_fixed_string_t vf;
4633 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4634 __attribute__((unused)) struct cmdline *cl,
4635 __attribute__((unused)) void *data)
4637 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4639 if (!strcmp(res->what, "add"))
4640 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4642 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4645 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4646 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4647 rx_vlan, "rx_vlan");
4648 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4649 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4651 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4652 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4654 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4655 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4657 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4658 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4660 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4661 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4663 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4664 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4667 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4668 .f = cmd_vf_rx_vlan_filter_parsed,
4670 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4671 "Y = port number,Z = hexadecimal VF mask)",
4673 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4674 (void *)&cmd_vf_rx_vlan_filter_what,
4675 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4676 (void *)&cmd_vf_rx_vlan_filter_port,
4677 (void *)&cmd_vf_rx_vlan_filter_portid,
4678 (void *)&cmd_vf_rx_vlan_filter_vf,
4679 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4684 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4685 struct cmd_set_mirror_mask_result {
4686 cmdline_fixed_string_t set;
4687 cmdline_fixed_string_t port;
4689 cmdline_fixed_string_t mirror;
4691 cmdline_fixed_string_t what;
4692 cmdline_fixed_string_t value;
4693 cmdline_fixed_string_t dstpool;
4695 cmdline_fixed_string_t on;
4698 cmdline_parse_token_string_t cmd_mirror_mask_set =
4699 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4701 cmdline_parse_token_string_t cmd_mirror_mask_port =
4702 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4704 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4705 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4707 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4709 mirror, "mirror-rule");
4710 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4711 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4713 cmdline_parse_token_string_t cmd_mirror_mask_what =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4715 what, "pool-mirror#vlan-mirror");
4716 cmdline_parse_token_string_t cmd_mirror_mask_value =
4717 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4719 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4720 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4721 dstpool, "dst-pool");
4722 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4723 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4725 cmdline_parse_token_string_t cmd_mirror_mask_on =
4726 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4730 cmd_set_mirror_mask_parsed(void *parsed_result,
4731 __attribute__((unused)) struct cmdline *cl,
4732 __attribute__((unused)) void *data)
4735 struct cmd_set_mirror_mask_result *res = parsed_result;
4736 struct rte_eth_vmdq_mirror_conf mr_conf;
4738 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4740 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4742 mr_conf.dst_pool = res->dstpool_id;
4744 if (!strcmp(res->what, "pool-mirror")) {
4745 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4746 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4747 } else if(!strcmp(res->what, "vlan-mirror")) {
4748 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4749 nb_item = parse_item_list(res->value, "core",
4750 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4754 for(i=0; i < nb_item; i++) {
4755 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4756 printf("Invalid vlan_id: must be < 4096\n");
4760 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4761 mr_conf.vlan.vlan_mask |= 1ULL << i;
4765 if(!strcmp(res->on, "on"))
4766 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4769 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4772 printf("mirror rule add error: (%s)\n", strerror(-ret));
4775 cmdline_parse_inst_t cmd_set_mirror_mask = {
4776 .f = cmd_set_mirror_mask_parsed,
4778 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4779 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4781 (void *)&cmd_mirror_mask_set,
4782 (void *)&cmd_mirror_mask_port,
4783 (void *)&cmd_mirror_mask_portid,
4784 (void *)&cmd_mirror_mask_mirror,
4785 (void *)&cmd_mirror_mask_ruleid,
4786 (void *)&cmd_mirror_mask_what,
4787 (void *)&cmd_mirror_mask_value,
4788 (void *)&cmd_mirror_mask_dstpool,
4789 (void *)&cmd_mirror_mask_poolid,
4790 (void *)&cmd_mirror_mask_on,
4795 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4796 struct cmd_set_mirror_link_result {
4797 cmdline_fixed_string_t set;
4798 cmdline_fixed_string_t port;
4800 cmdline_fixed_string_t mirror;
4802 cmdline_fixed_string_t what;
4803 cmdline_fixed_string_t dstpool;
4805 cmdline_fixed_string_t on;
4808 cmdline_parse_token_string_t cmd_mirror_link_set =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4811 cmdline_parse_token_string_t cmd_mirror_link_port =
4812 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4814 cmdline_parse_token_string_t cmd_mirror_link_portid =
4815 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4817 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4818 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4819 mirror, "mirror-rule");
4820 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4821 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4823 cmdline_parse_token_string_t cmd_mirror_link_what =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4825 what, "uplink-mirror#downlink-mirror");
4826 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4828 dstpool, "dst-pool");
4829 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4830 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4832 cmdline_parse_token_string_t cmd_mirror_link_on =
4833 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4837 cmd_set_mirror_link_parsed(void *parsed_result,
4838 __attribute__((unused)) struct cmdline *cl,
4839 __attribute__((unused)) void *data)
4842 struct cmd_set_mirror_link_result *res = parsed_result;
4843 struct rte_eth_vmdq_mirror_conf mr_conf;
4845 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4846 if(!strcmp(res->what, "uplink-mirror")) {
4847 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4848 }else if(!strcmp(res->what, "downlink-mirror"))
4849 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4851 mr_conf.dst_pool = res->dstpool_id;
4853 if(!strcmp(res->on, "on"))
4854 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4857 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4860 /* check the return value and print it if is < 0 */
4862 printf("mirror rule add error: (%s)\n", strerror(-ret));
4866 cmdline_parse_inst_t cmd_set_mirror_link = {
4867 .f = cmd_set_mirror_link_parsed,
4869 .help_str = "set port X mirror-rule Y uplink-mirror|"
4870 "downlink-mirror dst-pool Z on|off",
4872 (void *)&cmd_mirror_link_set,
4873 (void *)&cmd_mirror_link_port,
4874 (void *)&cmd_mirror_link_portid,
4875 (void *)&cmd_mirror_link_mirror,
4876 (void *)&cmd_mirror_link_ruleid,
4877 (void *)&cmd_mirror_link_what,
4878 (void *)&cmd_mirror_link_dstpool,
4879 (void *)&cmd_mirror_link_poolid,
4880 (void *)&cmd_mirror_link_on,
4885 /* *** RESET VM MIRROR RULE *** */
4886 struct cmd_rm_mirror_rule_result {
4887 cmdline_fixed_string_t reset;
4888 cmdline_fixed_string_t port;
4890 cmdline_fixed_string_t mirror;
4894 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4895 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4897 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4898 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4900 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4901 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4903 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4904 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4905 mirror, "mirror-rule");
4906 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4907 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4911 cmd_reset_mirror_rule_parsed(void *parsed_result,
4912 __attribute__((unused)) struct cmdline *cl,
4913 __attribute__((unused)) void *data)
4916 struct cmd_set_mirror_link_result *res = parsed_result;
4918 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4920 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4923 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4924 .f = cmd_reset_mirror_rule_parsed,
4926 .help_str = "reset port X mirror-rule Y",
4928 (void *)&cmd_rm_mirror_rule_reset,
4929 (void *)&cmd_rm_mirror_rule_port,
4930 (void *)&cmd_rm_mirror_rule_portid,
4931 (void *)&cmd_rm_mirror_rule_mirror,
4932 (void *)&cmd_rm_mirror_rule_ruleid,
4937 /* ******************************************************************************** */
4939 /* list of instructions */
4940 cmdline_parse_ctx_t main_ctx[] = {
4941 (cmdline_parse_inst_t *)&cmd_help_brief,
4942 (cmdline_parse_inst_t *)&cmd_help_long,
4943 (cmdline_parse_inst_t *)&cmd_quit,
4944 (cmdline_parse_inst_t *)&cmd_showport,
4945 (cmdline_parse_inst_t *)&cmd_showportall,
4946 (cmdline_parse_inst_t *)&cmd_showcfg,
4947 (cmdline_parse_inst_t *)&cmd_start,
4948 (cmdline_parse_inst_t *)&cmd_start_tx_first,
4949 (cmdline_parse_inst_t *)&cmd_reset,
4950 (cmdline_parse_inst_t *)&cmd_set_numbers,
4951 (cmdline_parse_inst_t *)&cmd_set_txpkts,
4952 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4953 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4954 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4955 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4956 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4957 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4958 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4959 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4960 #ifdef RTE_NIC_BYPASS
4961 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
4962 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
4963 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
4964 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
4966 (cmdline_parse_inst_t *)&cmd_vlan_offload,
4967 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4968 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4969 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4970 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4971 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4972 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4973 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4974 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4975 (cmdline_parse_inst_t *)&cmd_config_dcb,
4976 (cmdline_parse_inst_t *)&cmd_read_reg,
4977 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4978 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4979 (cmdline_parse_inst_t *)&cmd_write_reg,
4980 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4981 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4982 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4983 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4984 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4985 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4986 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4987 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4988 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4989 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4990 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4991 (cmdline_parse_inst_t *)&cmd_stop,
4992 (cmdline_parse_inst_t *)&cmd_mac_addr,
4993 (cmdline_parse_inst_t *)&cmd_set_qmap,
4994 (cmdline_parse_inst_t *)&cmd_operate_port,
4995 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4996 (cmdline_parse_inst_t *)&cmd_config_speed_all,
4997 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4998 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4999 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5000 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5001 (cmdline_parse_inst_t *)&cmd_config_rss,
5002 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5003 (cmdline_parse_inst_t *)&cmd_showport_reta,
5004 (cmdline_parse_inst_t *)&cmd_config_burst,
5005 (cmdline_parse_inst_t *)&cmd_config_thresh,
5006 (cmdline_parse_inst_t *)&cmd_config_threshold,
5007 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5008 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5009 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5010 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5011 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5012 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5013 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5014 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5015 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5019 /* prompt function, called from main on MASTER lcore */
5025 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5029 cmdline_interact(cl);
5030 cmdline_stdin_exit(cl);
5034 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5036 if (id < nb_ports) {
5037 /* check if need_reconfig has been set to 1 */
5038 if (ports[id].need_reconfig == 0)
5039 ports[id].need_reconfig = dev;
5040 /* check if need_reconfig_queues has been set to 1 */
5041 if (ports[id].need_reconfig_queues == 0)
5042 ports[id].need_reconfig_queues = queue;
5046 for (pid = 0; pid < nb_ports; pid++) {
5047 /* check if need_reconfig has been set to 1 */
5048 if (ports[pid].need_reconfig == 0)
5049 ports[pid].need_reconfig = dev;
5050 /* check if need_reconfig_queues has been set to 1 */
5051 if (ports[pid].need_reconfig_queues == 0)
5052 ports[pid].need_reconfig_queues = queue;
5057 #ifdef RTE_NIC_BYPASS
5059 bypass_is_supported(portid_t port_id)
5061 struct rte_port *port;
5062 struct rte_pci_id *pci_id;
5064 if (port_id >= nb_ports) {
5065 printf("\tPort id must be less than %d.\n", nb_ports);
5069 /* Get the device id. */
5070 port = &ports[port_id];
5071 pci_id = &port->dev_info.pci_dev->id;
5073 /* Check if NIC supports bypass. */
5074 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5078 printf("\tBypass not supported for port_id = %d.\n", port_id);