4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
90 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
93 uint8_t bypass_is_supported(portid_t port_id);
96 /* *** Help command with introduction. *** */
97 struct cmd_help_brief_result {
98 cmdline_fixed_string_t help;
101 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
103 __attribute__((unused)) void *data)
108 "Help is available for the following sections:\n\n"
109 " help control : Start and stop forwarding.\n"
110 " help display : Displaying port, stats and config "
112 " help config : Configuration information.\n"
113 " help ports : Configuring ports.\n"
114 " help flowdir : Flow Director filter help.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help all : All of the above sections.\n\n"
121 cmdline_parse_token_string_t cmd_help_brief_help =
122 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
124 cmdline_parse_inst_t cmd_help_brief = {
125 .f = cmd_help_brief_parsed,
127 .help_str = "show help",
129 (void *)&cmd_help_brief_help,
134 /* *** Help command with help sections. *** */
135 struct cmd_help_long_result {
136 cmdline_fixed_string_t help;
137 cmdline_fixed_string_t section;
140 static void cmd_help_long_parsed(void *parsed_result,
142 __attribute__((unused)) void *data)
145 struct cmd_help_long_result *res = parsed_result;
147 if (!strcmp(res->section, "all"))
150 if (show_all || !strcmp(res->section, "control")) {
155 "Control forwarding:\n"
156 "-------------------\n\n"
159 " Start packet forwarding with current configuration.\n\n"
162 " Start packet forwarding with current config"
163 " after sending one burst of packets.\n\n"
166 " Stop packet forwarding, and display accumulated"
170 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
174 if (show_all || !strcmp(res->section, "display")) {
182 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
183 " Display information for port_id, or all.\n\n"
185 "show port rss-hash [key]\n"
186 " Display the RSS hash functions and RSS hash key"
189 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
190 " Clear information for port_id, or all.\n\n"
192 "show config (rxtx|cores|fwd)\n"
193 " Display the given configuration.\n\n"
195 "read rxd (port_id) (queue_id) (rxd_id)\n"
196 " Display an RX descriptor of a port RX queue.\n\n"
198 "read txd (port_id) (queue_id) (txd_id)\n"
199 " Display a TX descriptor of a port TX queue.\n\n"
203 if (show_all || !strcmp(res->section, "config")) {
209 "Configuration changes only become active when"
210 " forwarding is started/restarted.\n\n"
213 " Reset forwarding to the default configuration.\n\n"
215 "set verbose (level)\n"
216 " Set the debug verbosity level X.\n\n"
219 " Set number of ports.\n\n"
222 " Set number of cores.\n\n"
224 "set coremask (mask)\n"
225 " Set the forwarding cores hexadecimal mask.\n\n"
227 "set portmask (mask)\n"
228 " Set the forwarding ports hexadecimal mask.\n\n"
231 " Set number of packets per burst.\n\n"
233 "set burst tx delay (microseconds) retry (num)\n"
234 " Set the transmit delay time and number of retries"
235 " in mac_retry forwarding mode.\n\n"
237 "set txpkts (x[,y]*)\n"
238 " Set the length of each segment of TXONLY"
241 "set corelist (x[,y]*)\n"
242 " Set the list of forwarding cores.\n\n"
244 "set portlist (x[,y]*)\n"
245 " Set the list of forwarding ports.\n\n"
247 "vlan set strip (on|off) (port_id)\n"
248 " Set the VLAN strip on a port.\n\n"
250 "vlan set stripq (on|off) (port_id,queue_id)\n"
251 " Set the VLAN strip for a queue on a port.\n\n"
253 "vlan set filter (on|off) (port_id)\n"
254 " Set the VLAN filter on a port.\n\n"
256 "vlan set qinq (on|off) (port_id)\n"
257 " Set the VLAN QinQ (extended queue in queue)"
260 "vlan set tpid (value) (port_id)\n"
261 " Set the outer VLAN TPID for Packet Filtering on"
264 "rx_vlan add (vlan_id|all) (port_id)\n"
265 " Add a vlan_id, or all identifiers, to the set"
266 " of VLAN identifiers filtered by port_id.\n\n"
268 "rx_vlan rm (vlan_id|all) (port_id)\n"
269 " Remove a vlan_id, or all identifiers, from the set"
270 " of VLAN identifiers filtered by port_id.\n\n"
272 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
273 " Add a vlan_id, to the set of VLAN identifiers"
274 "filtered for VF(s) from port_id.\n\n"
276 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
277 " Remove a vlan_id, to the set of VLAN identifiers"
278 "filtered for VF(s) from port_id.\n\n"
280 "rx_vlan set tpid (value) (port_id)\n"
281 " Set the outer VLAN TPID for Packet Filtering on"
284 "tx_vlan set vlan_id (port_id)\n"
285 " Set hardware insertion of VLAN ID in packets sent"
288 "tx_vlan reset (port_id)\n"
289 " Disable hardware insertion of a VLAN header in"
290 " packets sent on a port.\n\n"
292 "tx_checksum set mask (port_id)\n"
293 " Enable hardware insertion of checksum offload with"
294 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
295 " bit 0 - insert ip checksum offload if set\n"
296 " bit 1 - insert udp checksum offload if set\n"
297 " bit 2 - insert tcp checksum offload if set\n"
298 " bit 3 - insert sctp checksum offload if set\n"
299 " Please check the NIC datasheet for HW limits.\n\n"
302 " Set packet forwarding mode.\n\n"
304 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
305 " Add a MAC address on port_id.\n\n"
307 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
308 " Remove a MAC address from port_id.\n\n"
310 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
311 " Add a MAC address for a VF on the port.\n\n"
313 "set port (port_id) uta (mac_address|all) (on|off)\n"
314 " Add/Remove a or all unicast hash filter(s)"
317 "set promisc (port_id|all) (on|off)\n"
318 " Set the promiscuous mode on port_id, or all.\n\n"
320 "set allmulti (port_id|all) (on|off)\n"
321 " Set the allmulti mode on port_id, or all.\n\n"
323 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
324 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
325 " (on|off) (port_id)\n"
326 " Set the link flow control parameter on a port.\n\n"
328 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
329 " (low_water) (pause_time) (priority) (port_id)\n"
330 " Set the priority flow control parameter on a"
333 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
334 " Set statistics mapping (qmapping 0..15) for RX/TX"
336 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
337 " on port 0 to mapping 5.\n\n"
339 "set port (port_id) vf (vf_id) rx|tx on|off \n"
340 " Enable/Disable a VF receive/tranmit from a port\n\n"
342 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
344 " AUPE:accepts untagged VLAN;"
345 "ROPE:accept unicast hash\n\n"
346 " BAM:accepts broadcast packets;"
347 "MPE:accepts all multicast packets\n\n"
348 " Enable/Disable a VF receive mode of a port\n\n"
350 "set port (port_id) mirror-rule (rule_id)"
351 "(pool-mirror|vlan-mirror)\n"
352 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
353 " Set pool or vlan type mirror rule on a port.\n"
354 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
355 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
358 "set port (port_id) mirror-rule (rule_id)"
359 " (uplink-mirror|downlink-mirror) dst-pool"
360 " (pool_id) (on|off)\n"
361 " Set uplink or downlink type mirror rule on a port.\n"
362 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
363 " 0 on' enable mirror income traffic to pool 0.\n\n"
365 "reset port (port_id) mirror-rule (rule_id)\n"
366 " Reset a mirror rule.\n\n"
368 "set flush_rx (on|off)\n"
369 " Flush (default) or don't flush RX streams before"
370 " forwarding. Mainly used with PCAP drivers.\n\n"
372 #ifdef RTE_NIC_BYPASS
373 "set bypass mode (normal|bypass|isolate) (port_id)\n"
374 " Set the bypass mode for the lowest port on bypass enabled"
377 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
378 "mode (normal|bypass|isolate) (port_id)\n"
379 " Set the event required to initiate specified bypass mode for"
380 " the lowest port on a bypass enabled NIC where:\n"
381 " timeout = enable bypass after watchdog timeout.\n"
382 " os_on = enable bypass when OS/board is powered on.\n"
383 " os_off = enable bypass when OS/board is powered off.\n"
384 " power_on = enable bypass when power supply is turned on.\n"
385 " power_off = enable bypass when power supply is turned off."
388 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
389 " Set the bypass watchdog timeout to 'n' seconds"
390 " where 0 = instant.\n\n"
392 "show bypass config (port_id)\n"
393 " Show the bypass configuration for a bypass enabled NIC"
394 " using the lowest port on the NIC.\n\n"
397 , list_pkt_forwarding_modes()
402 if (show_all || !strcmp(res->section, "flowdir")) {
407 "Flow director mode:\n"
408 "-------------------\n\n"
410 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
411 " src (src_ip_address) (src_port)"
412 " dst (dst_ip_address) (dst_port)"
413 " flexbytes (flexbytes_values) vlan (vlan_id)"
414 " queue (queue_id)\n"
415 " Add a signature filter.\n\n"
417 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
418 " src (src_ip_address) (src_port)"
419 " dst (dst_ip_address) (dst_port)"
420 " flexbytes (flexbytes_values) vlan (vlan_id)"
421 " queue (queue_id)\n"
422 " Update a signature filter.\n\n"
424 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
425 " src (src_ip_address) (src_port)"
426 " dst (dst_ip_address) (dst_port)"
427 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
428 " Remove a signature filter.\n\n"
430 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
431 " src (src_ip_address) (src_port)"
432 " dst (dst_ip_address) (dst_port)"
433 " flexbytes (flexbytes_values) vlan (vlan_id)"
434 " queue (queue_id) soft (soft_id)\n"
435 " Add a perfect filter.\n\n"
437 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
438 " src (src_ip_address) (src_port)"
439 " dst (dst_ip_address) (dst_port)"
440 " flexbytes (flexbytes_values) vlan (vlan_id)"
441 " queue (queue_id)\n"
442 " Update a perfect filter.\n\n"
444 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
445 " src (src_ip_address) (src_port)"
446 " dst (dst_ip_address) (dst_port)"
447 " flexbytes (flexbytes_values) vlan (vlan_id)"
449 " Remove a perfect filter.\n\n"
451 "set_masks_filter (port_id) only_ip_flow (0|1)"
452 " src_mask (ip_src_mask) (src_port_mask)"
453 " dst_mask (ip_dst_mask) (dst_port_mask)"
454 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
455 " Set IPv4 filter masks.\n\n"
457 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
458 " src_mask (ip_src_mask) (src_port_mask)"
459 " dst_mask (ip_dst_mask) (dst_port_mask)"
460 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
461 " compare_dst (0|1)\n"
462 " Set IPv6 filter masks.\n\n"
466 if (show_all || !strcmp(res->section, "ports")) {
472 "----------------\n\n"
474 "port start (port_id|all)\n"
475 " Start all ports or port_id.\n\n"
477 "port stop (port_id|all)\n"
478 " Stop all ports or port_id.\n\n"
480 "port close (port_id|all)\n"
481 " Close all ports or port_id.\n\n"
483 "port config (port_id|all) speed (10|100|1000|10000|auto)"
484 " duplex (half|full|auto)\n"
485 " Set speed and duplex for all ports or port_id\n\n"
487 "port config all (rxq|txq|rxd|txd) (value)\n"
488 " Set number for rxq/txq/rxd/txd.\n\n"
490 "port config all max-pkt-len (value)\n"
491 " Set the max packet length.\n\n"
493 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
495 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
498 "port config all rss (ip|udp|none)\n"
499 " Set the RSS mode.\n\n"
501 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
502 " Set the RSS redirection table.\n\n"
504 "port config (port_id) dcb vt (on|off) (traffic_class)"
506 " Set the DCB mode.\n\n"
508 "port config all burst (value)\n"
509 " Set the number of packets per burst.\n\n"
511 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
513 " Set the ring prefetch/host/writeback threshold"
514 " for tx/rx queue.\n\n"
516 "port config all (txfreet|txrst|rxfreet) (value)\n"
517 " Set free threshold for rx/tx, or set"
518 " tx rs bit threshold.\n\n"
522 if (show_all || !strcmp(res->section, "registers")) {
530 "read reg (port_id) (address)\n"
531 " Display value of a port register.\n\n"
533 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
534 " Display a port register bit field.\n\n"
536 "read regbit (port_id) (address) (bit_x)\n"
537 " Display a single port register bit.\n\n"
539 "write reg (port_id) (address) (value)\n"
540 " Set value of a port register.\n\n"
542 "write regfield (port_id) (address) (bit_x) (bit_y)"
544 " Set bit field of a port register.\n\n"
546 "write regbit (port_id) (address) (bit_x) (value)\n"
547 " Set single bit value of a port register.\n\n"
552 cmdline_parse_token_string_t cmd_help_long_help =
553 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
555 cmdline_parse_token_string_t cmd_help_long_section =
556 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
557 "all#control#display#config#flowdir#"
560 cmdline_parse_inst_t cmd_help_long = {
561 .f = cmd_help_long_parsed,
563 .help_str = "show help",
565 (void *)&cmd_help_long_help,
566 (void *)&cmd_help_long_section,
572 /* *** start/stop/close all ports *** */
573 struct cmd_operate_port_result {
574 cmdline_fixed_string_t keyword;
575 cmdline_fixed_string_t name;
576 cmdline_fixed_string_t value;
579 static void cmd_operate_port_parsed(void *parsed_result,
580 __attribute__((unused)) struct cmdline *cl,
581 __attribute__((unused)) void *data)
583 struct cmd_operate_port_result *res = parsed_result;
585 if (!strcmp(res->name, "start"))
586 start_port(RTE_PORT_ALL);
587 else if (!strcmp(res->name, "stop"))
588 stop_port(RTE_PORT_ALL);
589 else if (!strcmp(res->name, "close"))
590 close_port(RTE_PORT_ALL);
592 printf("Unknown parameter\n");
595 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
596 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
598 cmdline_parse_token_string_t cmd_operate_port_all_port =
599 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
601 cmdline_parse_token_string_t cmd_operate_port_all_all =
602 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
604 cmdline_parse_inst_t cmd_operate_port = {
605 .f = cmd_operate_port_parsed,
607 .help_str = "port start|stop|close all: start/stop/close all ports",
609 (void *)&cmd_operate_port_all_cmd,
610 (void *)&cmd_operate_port_all_port,
611 (void *)&cmd_operate_port_all_all,
616 /* *** start/stop/close specific port *** */
617 struct cmd_operate_specific_port_result {
618 cmdline_fixed_string_t keyword;
619 cmdline_fixed_string_t name;
623 static void cmd_operate_specific_port_parsed(void *parsed_result,
624 __attribute__((unused)) struct cmdline *cl,
625 __attribute__((unused)) void *data)
627 struct cmd_operate_specific_port_result *res = parsed_result;
629 if (!strcmp(res->name, "start"))
630 start_port(res->value);
631 else if (!strcmp(res->name, "stop"))
632 stop_port(res->value);
633 else if (!strcmp(res->name, "close"))
634 close_port(res->value);
636 printf("Unknown parameter\n");
639 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
640 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
642 cmdline_parse_token_string_t cmd_operate_specific_port_port =
643 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
644 name, "start#stop#close");
645 cmdline_parse_token_num_t cmd_operate_specific_port_id =
646 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
649 cmdline_parse_inst_t cmd_operate_specific_port = {
650 .f = cmd_operate_specific_port_parsed,
652 .help_str = "port start|stop|close X: start/stop/close port X",
654 (void *)&cmd_operate_specific_port_cmd,
655 (void *)&cmd_operate_specific_port_port,
656 (void *)&cmd_operate_specific_port_id,
661 /* *** configure speed for all ports *** */
662 struct cmd_config_speed_all {
663 cmdline_fixed_string_t port;
664 cmdline_fixed_string_t keyword;
665 cmdline_fixed_string_t all;
666 cmdline_fixed_string_t item1;
667 cmdline_fixed_string_t item2;
668 cmdline_fixed_string_t value1;
669 cmdline_fixed_string_t value2;
673 cmd_config_speed_all_parsed(void *parsed_result,
674 __attribute__((unused)) struct cmdline *cl,
675 __attribute__((unused)) void *data)
677 struct cmd_config_speed_all *res = parsed_result;
678 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
679 uint16_t link_duplex = 0;
682 if (!all_ports_stopped()) {
683 printf("Please stop all ports first\n");
687 if (!strcmp(res->value1, "10"))
688 link_speed = ETH_LINK_SPEED_10;
689 else if (!strcmp(res->value1, "100"))
690 link_speed = ETH_LINK_SPEED_100;
691 else if (!strcmp(res->value1, "1000"))
692 link_speed = ETH_LINK_SPEED_1000;
693 else if (!strcmp(res->value1, "10000"))
694 link_speed = ETH_LINK_SPEED_10000;
695 else if (!strcmp(res->value1, "auto"))
696 link_speed = ETH_LINK_SPEED_AUTONEG;
698 printf("Unknown parameter\n");
702 if (!strcmp(res->value2, "half"))
703 link_duplex = ETH_LINK_HALF_DUPLEX;
704 else if (!strcmp(res->value2, "full"))
705 link_duplex = ETH_LINK_FULL_DUPLEX;
706 else if (!strcmp(res->value2, "auto"))
707 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
709 printf("Unknown parameter\n");
713 for (pid = 0; pid < nb_ports; pid++) {
714 ports[pid].dev_conf.link_speed = link_speed;
715 ports[pid].dev_conf.link_duplex = link_duplex;
718 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
721 cmdline_parse_token_string_t cmd_config_speed_all_port =
722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
723 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
726 cmdline_parse_token_string_t cmd_config_speed_all_all =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
728 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
730 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
732 "10#100#1000#10000#auto");
733 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
735 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
736 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
739 cmdline_parse_inst_t cmd_config_speed_all = {
740 .f = cmd_config_speed_all_parsed,
742 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
745 (void *)&cmd_config_speed_all_port,
746 (void *)&cmd_config_speed_all_keyword,
747 (void *)&cmd_config_speed_all_all,
748 (void *)&cmd_config_speed_all_item1,
749 (void *)&cmd_config_speed_all_value1,
750 (void *)&cmd_config_speed_all_item2,
751 (void *)&cmd_config_speed_all_value2,
756 /* *** configure speed for specific port *** */
757 struct cmd_config_speed_specific {
758 cmdline_fixed_string_t port;
759 cmdline_fixed_string_t keyword;
761 cmdline_fixed_string_t item1;
762 cmdline_fixed_string_t item2;
763 cmdline_fixed_string_t value1;
764 cmdline_fixed_string_t value2;
768 cmd_config_speed_specific_parsed(void *parsed_result,
769 __attribute__((unused)) struct cmdline *cl,
770 __attribute__((unused)) void *data)
772 struct cmd_config_speed_specific *res = parsed_result;
773 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
774 uint16_t link_duplex = 0;
776 if (!all_ports_stopped()) {
777 printf("Please stop all ports first\n");
781 if (res->id >= nb_ports) {
782 printf("Port id %d must be less than %d\n", res->id, nb_ports);
786 if (!strcmp(res->value1, "10"))
787 link_speed = ETH_LINK_SPEED_10;
788 else if (!strcmp(res->value1, "100"))
789 link_speed = ETH_LINK_SPEED_100;
790 else if (!strcmp(res->value1, "1000"))
791 link_speed = ETH_LINK_SPEED_1000;
792 else if (!strcmp(res->value1, "10000"))
793 link_speed = ETH_LINK_SPEED_10000;
794 else if (!strcmp(res->value1, "auto"))
795 link_speed = ETH_LINK_SPEED_AUTONEG;
797 printf("Unknown parameter\n");
801 if (!strcmp(res->value2, "half"))
802 link_duplex = ETH_LINK_HALF_DUPLEX;
803 else if (!strcmp(res->value2, "full"))
804 link_duplex = ETH_LINK_FULL_DUPLEX;
805 else if (!strcmp(res->value2, "auto"))
806 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
808 printf("Unknown parameter\n");
812 ports[res->id].dev_conf.link_speed = link_speed;
813 ports[res->id].dev_conf.link_duplex = link_duplex;
815 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
819 cmdline_parse_token_string_t cmd_config_speed_specific_port =
820 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
822 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
823 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
825 cmdline_parse_token_num_t cmd_config_speed_specific_id =
826 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
827 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
828 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
830 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
831 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
832 "10#100#1000#10000#auto");
833 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
834 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
836 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
837 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
840 cmdline_parse_inst_t cmd_config_speed_specific = {
841 .f = cmd_config_speed_specific_parsed,
843 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
846 (void *)&cmd_config_speed_specific_port,
847 (void *)&cmd_config_speed_specific_keyword,
848 (void *)&cmd_config_speed_specific_id,
849 (void *)&cmd_config_speed_specific_item1,
850 (void *)&cmd_config_speed_specific_value1,
851 (void *)&cmd_config_speed_specific_item2,
852 (void *)&cmd_config_speed_specific_value2,
857 /* *** configure txq/rxq, txd/rxd *** */
858 struct cmd_config_rx_tx {
859 cmdline_fixed_string_t port;
860 cmdline_fixed_string_t keyword;
861 cmdline_fixed_string_t all;
862 cmdline_fixed_string_t name;
867 cmd_config_rx_tx_parsed(void *parsed_result,
868 __attribute__((unused)) struct cmdline *cl,
869 __attribute__((unused)) void *data)
871 struct cmd_config_rx_tx *res = parsed_result;
873 if (!all_ports_stopped()) {
874 printf("Please stop all ports first\n");
878 if (!strcmp(res->name, "rxq")) {
879 if (res->value <= 0) {
880 printf("rxq %d invalid - must be > 0\n", res->value);
885 else if (!strcmp(res->name, "txq")) {
886 if (res->value <= 0) {
887 printf("txq %d invalid - must be > 0\n", res->value);
892 else if (!strcmp(res->name, "rxd")) {
893 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
894 printf("rxd %d invalid - must be > 0 && <= %d\n",
895 res->value, RTE_TEST_RX_DESC_MAX);
899 } else if (!strcmp(res->name, "txd")) {
900 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
901 printf("txd %d invalid - must be > 0 && <= %d\n",
902 res->value, RTE_TEST_TX_DESC_MAX);
907 printf("Unknown parameter\n");
913 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
916 cmdline_parse_token_string_t cmd_config_rx_tx_port =
917 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
918 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
919 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
920 cmdline_parse_token_string_t cmd_config_rx_tx_all =
921 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
922 cmdline_parse_token_string_t cmd_config_rx_tx_name =
923 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
925 cmdline_parse_token_num_t cmd_config_rx_tx_value =
926 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
928 cmdline_parse_inst_t cmd_config_rx_tx = {
929 .f = cmd_config_rx_tx_parsed,
931 .help_str = "port config all rxq|txq|rxd|txd value",
933 (void *)&cmd_config_rx_tx_port,
934 (void *)&cmd_config_rx_tx_keyword,
935 (void *)&cmd_config_rx_tx_all,
936 (void *)&cmd_config_rx_tx_name,
937 (void *)&cmd_config_rx_tx_value,
942 /* *** config max packet length *** */
943 struct cmd_config_max_pkt_len_result {
944 cmdline_fixed_string_t port;
945 cmdline_fixed_string_t keyword;
946 cmdline_fixed_string_t all;
947 cmdline_fixed_string_t name;
952 cmd_config_max_pkt_len_parsed(void *parsed_result,
953 __attribute__((unused)) struct cmdline *cl,
954 __attribute__((unused)) void *data)
956 struct cmd_config_max_pkt_len_result *res = parsed_result;
958 if (!all_ports_stopped()) {
959 printf("Please stop all ports first\n");
963 if (!strcmp(res->name, "max-pkt-len")) {
964 if (res->value < ETHER_MIN_LEN) {
965 printf("max-pkt-len can not be less than %d\n",
969 if (res->value == rx_mode.max_rx_pkt_len)
972 rx_mode.max_rx_pkt_len = res->value;
973 if (res->value > ETHER_MAX_LEN)
974 rx_mode.jumbo_frame = 1;
976 rx_mode.jumbo_frame = 0;
978 printf("Unknown parameter\n");
984 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
987 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
990 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
991 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
993 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
994 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
996 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
997 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
999 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1000 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1003 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1004 .f = cmd_config_max_pkt_len_parsed,
1006 .help_str = "port config all max-pkt-len value",
1008 (void *)&cmd_config_max_pkt_len_port,
1009 (void *)&cmd_config_max_pkt_len_keyword,
1010 (void *)&cmd_config_max_pkt_len_all,
1011 (void *)&cmd_config_max_pkt_len_name,
1012 (void *)&cmd_config_max_pkt_len_value,
1017 /* *** configure rx mode *** */
1018 struct cmd_config_rx_mode_flag {
1019 cmdline_fixed_string_t port;
1020 cmdline_fixed_string_t keyword;
1021 cmdline_fixed_string_t all;
1022 cmdline_fixed_string_t name;
1023 cmdline_fixed_string_t value;
1027 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1028 __attribute__((unused)) struct cmdline *cl,
1029 __attribute__((unused)) void *data)
1031 struct cmd_config_rx_mode_flag *res = parsed_result;
1033 if (!all_ports_stopped()) {
1034 printf("Please stop all ports first\n");
1038 if (!strcmp(res->name, "crc-strip")) {
1039 if (!strcmp(res->value, "on"))
1040 rx_mode.hw_strip_crc = 1;
1041 else if (!strcmp(res->value, "off"))
1042 rx_mode.hw_strip_crc = 0;
1044 printf("Unknown parameter\n");
1047 } else if (!strcmp(res->name, "rx-cksum")) {
1048 if (!strcmp(res->value, "on"))
1049 rx_mode.hw_ip_checksum = 1;
1050 else if (!strcmp(res->value, "off"))
1051 rx_mode.hw_ip_checksum = 0;
1053 printf("Unknown parameter\n");
1056 } else if (!strcmp(res->name, "hw-vlan")) {
1057 if (!strcmp(res->value, "on")) {
1058 rx_mode.hw_vlan_filter = 1;
1059 rx_mode.hw_vlan_strip = 1;
1061 else if (!strcmp(res->value, "off")) {
1062 rx_mode.hw_vlan_filter = 0;
1063 rx_mode.hw_vlan_strip = 0;
1066 printf("Unknown parameter\n");
1069 } else if (!strcmp(res->name, "drop-en")) {
1070 if (!strcmp(res->value, "on"))
1072 else if (!strcmp(res->value, "off"))
1075 printf("Unknown parameter\n");
1079 printf("Unknown parameter\n");
1085 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1088 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1089 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1090 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1091 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1093 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1094 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1095 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1096 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1097 "crc-strip#rx-cksum#hw-vlan");
1098 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1099 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1102 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1103 .f = cmd_config_rx_mode_flag_parsed,
1105 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1107 (void *)&cmd_config_rx_mode_flag_port,
1108 (void *)&cmd_config_rx_mode_flag_keyword,
1109 (void *)&cmd_config_rx_mode_flag_all,
1110 (void *)&cmd_config_rx_mode_flag_name,
1111 (void *)&cmd_config_rx_mode_flag_value,
1116 /* *** configure rss *** */
1117 struct cmd_config_rss {
1118 cmdline_fixed_string_t port;
1119 cmdline_fixed_string_t keyword;
1120 cmdline_fixed_string_t all;
1121 cmdline_fixed_string_t name;
1122 cmdline_fixed_string_t value;
1126 cmd_config_rss_parsed(void *parsed_result,
1127 __attribute__((unused)) struct cmdline *cl,
1128 __attribute__((unused)) void *data)
1130 struct cmd_config_rss *res = parsed_result;
1131 struct rte_eth_rss_conf rss_conf;
1134 if (!strcmp(res->value, "ip"))
1135 rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1136 else if (!strcmp(res->value, "udp"))
1137 rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
1138 else if (!strcmp(res->value, "none"))
1139 rss_conf.rss_hf = 0;
1141 printf("Unknown parameter\n");
1144 rss_conf.rss_key = NULL;
1145 for (i = 0; i < rte_eth_dev_count(); i++)
1146 rte_eth_dev_rss_hash_update(i, &rss_conf);
1149 cmdline_parse_token_string_t cmd_config_rss_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1151 cmdline_parse_token_string_t cmd_config_rss_keyword =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1153 cmdline_parse_token_string_t cmd_config_rss_all =
1154 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1155 cmdline_parse_token_string_t cmd_config_rss_name =
1156 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1157 cmdline_parse_token_string_t cmd_config_rss_value =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1160 cmdline_parse_inst_t cmd_config_rss = {
1161 .f = cmd_config_rss_parsed,
1163 .help_str = "port config all rss ip|udp|none",
1165 (void *)&cmd_config_rss_port,
1166 (void *)&cmd_config_rss_keyword,
1167 (void *)&cmd_config_rss_all,
1168 (void *)&cmd_config_rss_name,
1169 (void *)&cmd_config_rss_value,
1174 /* *** Configure RSS RETA *** */
1175 struct cmd_config_rss_reta {
1176 cmdline_fixed_string_t port;
1177 cmdline_fixed_string_t keyword;
1179 cmdline_fixed_string_t name;
1180 cmdline_fixed_string_t list_name;
1181 cmdline_fixed_string_t list_of_items;
1185 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1192 const char *p, *p0 = str;
1199 unsigned long int_fld[_NUM_FLD];
1200 char *str_fld[_NUM_FLD];
1202 while ((p = strchr(p0,'(')) != NULL) {
1204 if((p0 = strchr(p,')')) == NULL)
1208 if(size >= sizeof(s))
1211 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1212 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1214 for (i = 0; i < _NUM_FLD; i++) {
1216 int_fld[i] = strtoul(str_fld[i], &end, 0);
1217 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1221 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1222 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1224 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1225 printf("Invalid RETA hash index=%d",hash_index);
1229 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1230 reta_conf->mask_lo |= (1ULL << hash_index);
1232 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1234 reta_conf->reta[hash_index] = nb_queue;
1241 cmd_set_rss_reta_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1246 struct rte_eth_rss_reta reta_conf;
1247 struct cmd_config_rss_reta *res = parsed_result;
1249 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1250 if (!strcmp(res->list_name, "reta")) {
1251 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1252 printf("Invalid RSS Redirection Table config entered\n");
1255 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1257 printf("Bad redirection table parameter, return code = %d \n",ret);
1261 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1262 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1263 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1265 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1266 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1267 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1269 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1270 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1271 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1274 cmdline_parse_inst_t cmd_config_rss_reta = {
1275 .f = cmd_set_rss_reta_parsed,
1277 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1279 (void *)&cmd_config_rss_reta_port,
1280 (void *)&cmd_config_rss_reta_keyword,
1281 (void *)&cmd_config_rss_reta_port_id,
1282 (void *)&cmd_config_rss_reta_name,
1283 (void *)&cmd_config_rss_reta_list_name,
1284 (void *)&cmd_config_rss_reta_list_of_items,
1289 /* *** SHOW PORT RETA INFO *** */
1290 struct cmd_showport_reta {
1291 cmdline_fixed_string_t show;
1292 cmdline_fixed_string_t port;
1294 cmdline_fixed_string_t rss;
1295 cmdline_fixed_string_t reta;
1300 static void cmd_showport_reta_parsed(void *parsed_result,
1301 __attribute__((unused)) struct cmdline *cl,
1302 __attribute__((unused)) void *data)
1304 struct cmd_showport_reta *res = parsed_result;
1305 struct rte_eth_rss_reta reta_conf;
1307 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1308 printf("Invalid RSS Redirection Table config entered\n");
1312 reta_conf.mask_lo = res->mask_lo;
1313 reta_conf.mask_hi = res->mask_hi;
1315 port_rss_reta_info(res->port_id,&reta_conf);
1318 cmdline_parse_token_string_t cmd_showport_reta_show =
1319 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1320 cmdline_parse_token_string_t cmd_showport_reta_port =
1321 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1322 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1323 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1324 cmdline_parse_token_string_t cmd_showport_reta_rss =
1325 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1326 cmdline_parse_token_string_t cmd_showport_reta_reta =
1327 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1328 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1329 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1330 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1331 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1333 cmdline_parse_inst_t cmd_showport_reta = {
1334 .f = cmd_showport_reta_parsed,
1336 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1337 (mask_lo and mask_hi is UINT64)",
1339 (void *)&cmd_showport_reta_show,
1340 (void *)&cmd_showport_reta_port,
1341 (void *)&cmd_showport_reta_port_id,
1342 (void *)&cmd_showport_reta_rss,
1343 (void *)&cmd_showport_reta_reta,
1344 (void *)&cmd_showport_reta_mask_lo,
1345 (void *)&cmd_showport_reta_mask_hi,
1350 /* *** Show RSS hash configuration *** */
1351 struct cmd_showport_rss_hash {
1352 cmdline_fixed_string_t show;
1353 cmdline_fixed_string_t port;
1355 cmdline_fixed_string_t rss_hash;
1356 cmdline_fixed_string_t key; /* optional argument */
1359 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1360 __attribute__((unused)) struct cmdline *cl,
1363 struct cmd_showport_rss_hash *res = parsed_result;
1365 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1368 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1369 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1370 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1371 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1372 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1373 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1374 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1375 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1377 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1378 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1380 cmdline_parse_inst_t cmd_showport_rss_hash = {
1381 .f = cmd_showport_rss_hash_parsed,
1383 .help_str = "show port X rss-hash (X = port number)\n",
1385 (void *)&cmd_showport_rss_hash_show,
1386 (void *)&cmd_showport_rss_hash_port,
1387 (void *)&cmd_showport_rss_hash_port_id,
1388 (void *)&cmd_showport_rss_hash_rss_hash,
1393 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1394 .f = cmd_showport_rss_hash_parsed,
1395 .data = "show_rss_key",
1396 .help_str = "show port X rss-hash key (X = port number)\n",
1398 (void *)&cmd_showport_rss_hash_show,
1399 (void *)&cmd_showport_rss_hash_port,
1400 (void *)&cmd_showport_rss_hash_port_id,
1401 (void *)&cmd_showport_rss_hash_rss_hash,
1402 (void *)&cmd_showport_rss_hash_rss_key,
1407 /* *** Configure DCB *** */
1408 struct cmd_config_dcb {
1409 cmdline_fixed_string_t port;
1410 cmdline_fixed_string_t config;
1412 cmdline_fixed_string_t dcb;
1413 cmdline_fixed_string_t vt;
1414 cmdline_fixed_string_t vt_en;
1416 cmdline_fixed_string_t pfc;
1417 cmdline_fixed_string_t pfc_en;
1421 cmd_config_dcb_parsed(void *parsed_result,
1422 __attribute__((unused)) struct cmdline *cl,
1423 __attribute__((unused)) void *data)
1425 struct cmd_config_dcb *res = parsed_result;
1426 struct dcb_config dcb_conf;
1427 portid_t port_id = res->port_id;
1428 struct rte_port *port;
1430 port = &ports[port_id];
1431 /** Check if the port is not started **/
1432 if (port->port_status != RTE_PORT_STOPPED) {
1433 printf("Please stop port %d first\n",port_id);
1437 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1438 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1439 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1443 /* DCB in VT mode */
1444 if (!strncmp(res->vt_en, "on",2))
1445 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1447 dcb_conf.dcb_mode = DCB_ENABLED;
1449 if (!strncmp(res->pfc_en, "on",2)) {
1450 dcb_conf.pfc_en = 1;
1453 dcb_conf.pfc_en = 0;
1455 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1456 printf("Cannot initialize network ports\n");
1460 cmd_reconfig_device_queue(port_id, 1, 1);
1463 cmdline_parse_token_string_t cmd_config_dcb_port =
1464 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1465 cmdline_parse_token_string_t cmd_config_dcb_config =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1467 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1468 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1469 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1470 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1471 cmdline_parse_token_string_t cmd_config_dcb_vt =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1473 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1475 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1476 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1477 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1479 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1482 cmdline_parse_inst_t cmd_config_dcb = {
1483 .f = cmd_config_dcb_parsed,
1485 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1487 (void *)&cmd_config_dcb_port,
1488 (void *)&cmd_config_dcb_config,
1489 (void *)&cmd_config_dcb_port_id,
1490 (void *)&cmd_config_dcb_dcb,
1491 (void *)&cmd_config_dcb_vt,
1492 (void *)&cmd_config_dcb_vt_en,
1493 (void *)&cmd_config_dcb_num_tcs,
1494 (void *)&cmd_config_dcb_pfc,
1495 (void *)&cmd_config_dcb_pfc_en,
1500 /* *** configure number of packets per burst *** */
1501 struct cmd_config_burst {
1502 cmdline_fixed_string_t port;
1503 cmdline_fixed_string_t keyword;
1504 cmdline_fixed_string_t all;
1505 cmdline_fixed_string_t name;
1510 cmd_config_burst_parsed(void *parsed_result,
1511 __attribute__((unused)) struct cmdline *cl,
1512 __attribute__((unused)) void *data)
1514 struct cmd_config_burst *res = parsed_result;
1516 if (!all_ports_stopped()) {
1517 printf("Please stop all ports first\n");
1521 if (!strcmp(res->name, "burst")) {
1522 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1523 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1526 nb_pkt_per_burst = res->value;
1528 printf("Unknown parameter\n");
1534 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1537 cmdline_parse_token_string_t cmd_config_burst_port =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1539 cmdline_parse_token_string_t cmd_config_burst_keyword =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1541 cmdline_parse_token_string_t cmd_config_burst_all =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1543 cmdline_parse_token_string_t cmd_config_burst_name =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1545 cmdline_parse_token_num_t cmd_config_burst_value =
1546 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1548 cmdline_parse_inst_t cmd_config_burst = {
1549 .f = cmd_config_burst_parsed,
1551 .help_str = "port config all burst value",
1553 (void *)&cmd_config_burst_port,
1554 (void *)&cmd_config_burst_keyword,
1555 (void *)&cmd_config_burst_all,
1556 (void *)&cmd_config_burst_name,
1557 (void *)&cmd_config_burst_value,
1562 /* *** configure rx/tx queues *** */
1563 struct cmd_config_thresh {
1564 cmdline_fixed_string_t port;
1565 cmdline_fixed_string_t keyword;
1566 cmdline_fixed_string_t all;
1567 cmdline_fixed_string_t name;
1572 cmd_config_thresh_parsed(void *parsed_result,
1573 __attribute__((unused)) struct cmdline *cl,
1574 __attribute__((unused)) void *data)
1576 struct cmd_config_thresh *res = parsed_result;
1578 if (!all_ports_stopped()) {
1579 printf("Please stop all ports first\n");
1583 if (!strcmp(res->name, "txpt"))
1584 tx_thresh.pthresh = res->value;
1585 else if(!strcmp(res->name, "txht"))
1586 tx_thresh.hthresh = res->value;
1587 else if(!strcmp(res->name, "txwt"))
1588 tx_thresh.wthresh = res->value;
1589 else if(!strcmp(res->name, "rxpt"))
1590 rx_thresh.pthresh = res->value;
1591 else if(!strcmp(res->name, "rxht"))
1592 rx_thresh.hthresh = res->value;
1593 else if(!strcmp(res->name, "rxwt"))
1594 rx_thresh.wthresh = res->value;
1596 printf("Unknown parameter\n");
1602 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1605 cmdline_parse_token_string_t cmd_config_thresh_port =
1606 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1607 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1608 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1609 cmdline_parse_token_string_t cmd_config_thresh_all =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1611 cmdline_parse_token_string_t cmd_config_thresh_name =
1612 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1613 "txpt#txht#txwt#rxpt#rxht#rxwt");
1614 cmdline_parse_token_num_t cmd_config_thresh_value =
1615 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1617 cmdline_parse_inst_t cmd_config_thresh = {
1618 .f = cmd_config_thresh_parsed,
1620 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1622 (void *)&cmd_config_thresh_port,
1623 (void *)&cmd_config_thresh_keyword,
1624 (void *)&cmd_config_thresh_all,
1625 (void *)&cmd_config_thresh_name,
1626 (void *)&cmd_config_thresh_value,
1631 /* *** configure free/rs threshold *** */
1632 struct cmd_config_threshold {
1633 cmdline_fixed_string_t port;
1634 cmdline_fixed_string_t keyword;
1635 cmdline_fixed_string_t all;
1636 cmdline_fixed_string_t name;
1641 cmd_config_threshold_parsed(void *parsed_result,
1642 __attribute__((unused)) struct cmdline *cl,
1643 __attribute__((unused)) void *data)
1645 struct cmd_config_threshold *res = parsed_result;
1647 if (!all_ports_stopped()) {
1648 printf("Please stop all ports first\n");
1652 if (!strcmp(res->name, "txfreet"))
1653 tx_free_thresh = res->value;
1654 else if (!strcmp(res->name, "txrst"))
1655 tx_rs_thresh = res->value;
1656 else if (!strcmp(res->name, "rxfreet"))
1657 rx_free_thresh = res->value;
1659 printf("Unknown parameter\n");
1665 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1668 cmdline_parse_token_string_t cmd_config_threshold_port =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1670 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1673 cmdline_parse_token_string_t cmd_config_threshold_all =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1675 cmdline_parse_token_string_t cmd_config_threshold_name =
1676 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1677 "txfreet#txrst#rxfreet");
1678 cmdline_parse_token_num_t cmd_config_threshold_value =
1679 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1681 cmdline_parse_inst_t cmd_config_threshold = {
1682 .f = cmd_config_threshold_parsed,
1684 .help_str = "port config all txfreet|txrst|rxfreet value",
1686 (void *)&cmd_config_threshold_port,
1687 (void *)&cmd_config_threshold_keyword,
1688 (void *)&cmd_config_threshold_all,
1689 (void *)&cmd_config_threshold_name,
1690 (void *)&cmd_config_threshold_value,
1696 struct cmd_stop_result {
1697 cmdline_fixed_string_t stop;
1700 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1701 __attribute__((unused)) struct cmdline *cl,
1702 __attribute__((unused)) void *data)
1704 stop_packet_forwarding();
1707 cmdline_parse_token_string_t cmd_stop_stop =
1708 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1710 cmdline_parse_inst_t cmd_stop = {
1711 .f = cmd_stop_parsed,
1713 .help_str = "stop - stop packet forwarding",
1715 (void *)&cmd_stop_stop,
1720 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1723 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1724 unsigned int *parsed_items, int check_unique_values)
1726 unsigned int nb_item;
1734 * First parse all items in the list and store their value.
1739 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1741 if ((c >= '0') && (c <= '9')) {
1742 value = (unsigned int) (value * 10 + (c - '0'));
1747 printf("character %c is not a decimal digit\n", c);
1751 printf("No valid value before comma\n");
1754 if (nb_item < max_items) {
1755 parsed_items[nb_item] = value;
1761 if (nb_item >= max_items) {
1762 printf("Number of %s = %u > %u (maximum items)\n",
1763 item_name, nb_item + 1, max_items);
1766 parsed_items[nb_item++] = value;
1767 if (! check_unique_values)
1771 * Then, check that all values in the list are differents.
1772 * No optimization here...
1774 for (i = 0; i < nb_item; i++) {
1775 for (j = i + 1; j < nb_item; j++) {
1776 if (parsed_items[j] == parsed_items[i]) {
1777 printf("duplicated %s %u at index %u and %u\n",
1778 item_name, parsed_items[i], i, j);
1786 struct cmd_set_list_result {
1787 cmdline_fixed_string_t cmd_keyword;
1788 cmdline_fixed_string_t list_name;
1789 cmdline_fixed_string_t list_of_items;
1792 static void cmd_set_list_parsed(void *parsed_result,
1793 __attribute__((unused)) struct cmdline *cl,
1794 __attribute__((unused)) void *data)
1796 struct cmd_set_list_result *res;
1798 unsigned int lcorelist[RTE_MAX_LCORE];
1799 unsigned int portlist[RTE_MAX_ETHPORTS];
1801 unsigned int nb_item;
1803 res = parsed_result;
1804 if (!strcmp(res->list_name, "corelist")) {
1805 nb_item = parse_item_list(res->list_of_items, "core",
1807 parsed_items.lcorelist, 1);
1809 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1812 if (!strcmp(res->list_name, "portlist")) {
1813 nb_item = parse_item_list(res->list_of_items, "port",
1815 parsed_items.portlist, 1);
1817 set_fwd_ports_list(parsed_items.portlist, nb_item);
1821 cmdline_parse_token_string_t cmd_set_list_keyword =
1822 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1824 cmdline_parse_token_string_t cmd_set_list_name =
1825 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1826 "corelist#portlist");
1827 cmdline_parse_token_string_t cmd_set_list_of_items =
1828 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1831 cmdline_parse_inst_t cmd_set_fwd_list = {
1832 .f = cmd_set_list_parsed,
1834 .help_str = "set corelist|portlist x[,y]*",
1836 (void *)&cmd_set_list_keyword,
1837 (void *)&cmd_set_list_name,
1838 (void *)&cmd_set_list_of_items,
1843 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1845 struct cmd_setmask_result {
1846 cmdline_fixed_string_t set;
1847 cmdline_fixed_string_t mask;
1851 static void cmd_set_mask_parsed(void *parsed_result,
1852 __attribute__((unused)) struct cmdline *cl,
1853 __attribute__((unused)) void *data)
1855 struct cmd_setmask_result *res = parsed_result;
1857 if (!strcmp(res->mask, "coremask"))
1858 set_fwd_lcores_mask(res->hexavalue);
1859 else if (!strcmp(res->mask, "portmask"))
1860 set_fwd_ports_mask(res->hexavalue);
1863 cmdline_parse_token_string_t cmd_setmask_set =
1864 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1865 cmdline_parse_token_string_t cmd_setmask_mask =
1866 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1867 "coremask#portmask");
1868 cmdline_parse_token_num_t cmd_setmask_value =
1869 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1871 cmdline_parse_inst_t cmd_set_fwd_mask = {
1872 .f = cmd_set_mask_parsed,
1874 .help_str = "set coremask|portmask hexadecimal value",
1876 (void *)&cmd_setmask_set,
1877 (void *)&cmd_setmask_mask,
1878 (void *)&cmd_setmask_value,
1884 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1886 struct cmd_set_result {
1887 cmdline_fixed_string_t set;
1888 cmdline_fixed_string_t what;
1892 static void cmd_set_parsed(void *parsed_result,
1893 __attribute__((unused)) struct cmdline *cl,
1894 __attribute__((unused)) void *data)
1896 struct cmd_set_result *res = parsed_result;
1897 if (!strcmp(res->what, "nbport"))
1898 set_fwd_ports_number(res->value);
1899 else if (!strcmp(res->what, "nbcore"))
1900 set_fwd_lcores_number(res->value);
1901 else if (!strcmp(res->what, "burst"))
1902 set_nb_pkt_per_burst(res->value);
1903 else if (!strcmp(res->what, "verbose"))
1904 set_verbose_level(res->value);
1907 cmdline_parse_token_string_t cmd_set_set =
1908 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1909 cmdline_parse_token_string_t cmd_set_what =
1910 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1911 "nbport#nbcore#burst#verbose");
1912 cmdline_parse_token_num_t cmd_set_value =
1913 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1915 cmdline_parse_inst_t cmd_set_numbers = {
1916 .f = cmd_set_parsed,
1918 .help_str = "set nbport|nbcore|burst|verbose value",
1920 (void *)&cmd_set_set,
1921 (void *)&cmd_set_what,
1922 (void *)&cmd_set_value,
1927 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1929 struct cmd_set_txpkts_result {
1930 cmdline_fixed_string_t cmd_keyword;
1931 cmdline_fixed_string_t txpkts;
1932 cmdline_fixed_string_t seg_lengths;
1936 cmd_set_txpkts_parsed(void *parsed_result,
1937 __attribute__((unused)) struct cmdline *cl,
1938 __attribute__((unused)) void *data)
1940 struct cmd_set_txpkts_result *res;
1941 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1942 unsigned int nb_segs;
1944 res = parsed_result;
1945 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1946 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1948 set_tx_pkt_segments(seg_lengths, nb_segs);
1951 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1952 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1953 cmd_keyword, "set");
1954 cmdline_parse_token_string_t cmd_set_txpkts_name =
1955 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1957 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1958 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1961 cmdline_parse_inst_t cmd_set_txpkts = {
1962 .f = cmd_set_txpkts_parsed,
1964 .help_str = "set txpkts x[,y]*",
1966 (void *)&cmd_set_txpkts_keyword,
1967 (void *)&cmd_set_txpkts_name,
1968 (void *)&cmd_set_txpkts_lengths,
1973 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1974 struct cmd_rx_vlan_filter_all_result {
1975 cmdline_fixed_string_t rx_vlan;
1976 cmdline_fixed_string_t what;
1977 cmdline_fixed_string_t all;
1982 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1983 __attribute__((unused)) struct cmdline *cl,
1984 __attribute__((unused)) void *data)
1986 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1988 if (!strcmp(res->what, "add"))
1989 rx_vlan_all_filter_set(res->port_id, 1);
1991 rx_vlan_all_filter_set(res->port_id, 0);
1994 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1995 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1996 rx_vlan, "rx_vlan");
1997 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1998 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2000 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2001 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2003 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2004 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2007 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2008 .f = cmd_rx_vlan_filter_all_parsed,
2010 .help_str = "add/remove all identifiers to/from the set of VLAN "
2011 "Identifiers filtered by a port",
2013 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2014 (void *)&cmd_rx_vlan_filter_all_what,
2015 (void *)&cmd_rx_vlan_filter_all_all,
2016 (void *)&cmd_rx_vlan_filter_all_portid,
2021 /* *** VLAN OFFLOAD SET ON A PORT *** */
2022 struct cmd_vlan_offload_result {
2023 cmdline_fixed_string_t vlan;
2024 cmdline_fixed_string_t set;
2025 cmdline_fixed_string_t what;
2026 cmdline_fixed_string_t on;
2027 cmdline_fixed_string_t port_id;
2031 cmd_vlan_offload_parsed(void *parsed_result,
2032 __attribute__((unused)) struct cmdline *cl,
2033 __attribute__((unused)) void *data)
2036 struct cmd_vlan_offload_result *res = parsed_result;
2039 portid_t port_id = 0;
2043 len = strnlen(str, STR_TOKEN_SIZE);
2045 /* Get port_id first */
2053 tmp = strtoul(str, NULL, 0);
2054 /* If port_id greater that what portid_t can represent, return */
2055 if(tmp >= RTE_MAX_ETHPORTS)
2057 port_id = (portid_t)tmp;
2059 if (!strcmp(res->on, "on"))
2064 if (!strcmp(res->what, "strip"))
2065 rx_vlan_strip_set(port_id, on);
2066 else if(!strcmp(res->what, "stripq")){
2067 uint16_t queue_id = 0;
2069 /* No queue_id, return */
2071 printf("must specify (port,queue_id)\n");
2074 tmp = strtoul(str + i + 1, NULL, 0);
2075 /* If queue_id greater that what 16-bits can represent, return */
2079 queue_id = (uint16_t)tmp;
2080 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2082 else if (!strcmp(res->what, "filter"))
2083 rx_vlan_filter_set(port_id, on);
2085 vlan_extend_set(port_id, on);
2090 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2093 cmdline_parse_token_string_t cmd_vlan_offload_set =
2094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2096 cmdline_parse_token_string_t cmd_vlan_offload_what =
2097 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2098 what, "strip#filter#qinq#stripq");
2099 cmdline_parse_token_string_t cmd_vlan_offload_on =
2100 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2102 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2106 cmdline_parse_inst_t cmd_vlan_offload = {
2107 .f = cmd_vlan_offload_parsed,
2109 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2110 " qinq(extended) for both rx/tx sides ",
2112 (void *)&cmd_vlan_offload_vlan,
2113 (void *)&cmd_vlan_offload_set,
2114 (void *)&cmd_vlan_offload_what,
2115 (void *)&cmd_vlan_offload_on,
2116 (void *)&cmd_vlan_offload_portid,
2121 /* *** VLAN TPID SET ON A PORT *** */
2122 struct cmd_vlan_tpid_result {
2123 cmdline_fixed_string_t vlan;
2124 cmdline_fixed_string_t set;
2125 cmdline_fixed_string_t what;
2131 cmd_vlan_tpid_parsed(void *parsed_result,
2132 __attribute__((unused)) struct cmdline *cl,
2133 __attribute__((unused)) void *data)
2135 struct cmd_vlan_tpid_result *res = parsed_result;
2136 vlan_tpid_set(res->port_id, res->tp_id);
2140 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2141 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2143 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2144 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2146 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2147 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2149 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2150 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2152 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2153 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2156 cmdline_parse_inst_t cmd_vlan_tpid = {
2157 .f = cmd_vlan_tpid_parsed,
2159 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2161 (void *)&cmd_vlan_tpid_vlan,
2162 (void *)&cmd_vlan_tpid_set,
2163 (void *)&cmd_vlan_tpid_what,
2164 (void *)&cmd_vlan_tpid_tpid,
2165 (void *)&cmd_vlan_tpid_portid,
2170 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2171 struct cmd_rx_vlan_filter_result {
2172 cmdline_fixed_string_t rx_vlan;
2173 cmdline_fixed_string_t what;
2179 cmd_rx_vlan_filter_parsed(void *parsed_result,
2180 __attribute__((unused)) struct cmdline *cl,
2181 __attribute__((unused)) void *data)
2183 struct cmd_rx_vlan_filter_result *res = parsed_result;
2185 if (!strcmp(res->what, "add"))
2186 rx_vft_set(res->port_id, res->vlan_id, 1);
2188 rx_vft_set(res->port_id, res->vlan_id, 0);
2191 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2192 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2193 rx_vlan, "rx_vlan");
2194 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2195 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2197 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2198 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2200 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2201 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2204 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2205 .f = cmd_rx_vlan_filter_parsed,
2207 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2208 "Identifiers filtered by a port",
2210 (void *)&cmd_rx_vlan_filter_rx_vlan,
2211 (void *)&cmd_rx_vlan_filter_what,
2212 (void *)&cmd_rx_vlan_filter_vlanid,
2213 (void *)&cmd_rx_vlan_filter_portid,
2218 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2219 struct cmd_tx_vlan_set_result {
2220 cmdline_fixed_string_t tx_vlan;
2221 cmdline_fixed_string_t set;
2227 cmd_tx_vlan_set_parsed(void *parsed_result,
2228 __attribute__((unused)) struct cmdline *cl,
2229 __attribute__((unused)) void *data)
2231 struct cmd_tx_vlan_set_result *res = parsed_result;
2232 tx_vlan_set(res->port_id, res->vlan_id);
2235 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2236 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2237 tx_vlan, "tx_vlan");
2238 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2239 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2241 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2242 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2244 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2245 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2248 cmdline_parse_inst_t cmd_tx_vlan_set = {
2249 .f = cmd_tx_vlan_set_parsed,
2251 .help_str = "enable hardware insertion of a VLAN header with a given "
2252 "TAG Identifier in packets sent on a port",
2254 (void *)&cmd_tx_vlan_set_tx_vlan,
2255 (void *)&cmd_tx_vlan_set_set,
2256 (void *)&cmd_tx_vlan_set_vlanid,
2257 (void *)&cmd_tx_vlan_set_portid,
2262 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2263 struct cmd_tx_vlan_reset_result {
2264 cmdline_fixed_string_t tx_vlan;
2265 cmdline_fixed_string_t reset;
2270 cmd_tx_vlan_reset_parsed(void *parsed_result,
2271 __attribute__((unused)) struct cmdline *cl,
2272 __attribute__((unused)) void *data)
2274 struct cmd_tx_vlan_reset_result *res = parsed_result;
2276 tx_vlan_reset(res->port_id);
2279 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2281 tx_vlan, "tx_vlan");
2282 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2283 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2285 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2289 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2290 .f = cmd_tx_vlan_reset_parsed,
2292 .help_str = "disable hardware insertion of a VLAN header in packets "
2295 (void *)&cmd_tx_vlan_reset_tx_vlan,
2296 (void *)&cmd_tx_vlan_reset_reset,
2297 (void *)&cmd_tx_vlan_reset_portid,
2303 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2304 struct cmd_tx_cksum_set_result {
2305 cmdline_fixed_string_t tx_cksum;
2306 cmdline_fixed_string_t set;
2312 cmd_tx_cksum_set_parsed(void *parsed_result,
2313 __attribute__((unused)) struct cmdline *cl,
2314 __attribute__((unused)) void *data)
2316 struct cmd_tx_cksum_set_result *res = parsed_result;
2318 tx_cksum_set(res->port_id, res->cksum_mask);
2321 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2322 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2323 tx_cksum, "tx_checksum");
2324 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2325 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2327 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2328 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2330 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2331 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2334 cmdline_parse_inst_t cmd_tx_cksum_set = {
2335 .f = cmd_tx_cksum_set_parsed,
2337 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2338 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2339 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2341 (void *)&cmd_tx_cksum_set_tx_cksum,
2342 (void *)&cmd_tx_cksum_set_set,
2343 (void *)&cmd_tx_cksum_set_cksum_mask,
2344 (void *)&cmd_tx_cksum_set_portid,
2349 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2350 struct cmd_set_flush_rx {
2351 cmdline_fixed_string_t set;
2352 cmdline_fixed_string_t flush_rx;
2353 cmdline_fixed_string_t mode;
2357 cmd_set_flush_rx_parsed(void *parsed_result,
2358 __attribute__((unused)) struct cmdline *cl,
2359 __attribute__((unused)) void *data)
2361 struct cmd_set_flush_rx *res = parsed_result;
2362 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2365 cmdline_parse_token_string_t cmd_setflushrx_set =
2366 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2368 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2369 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2370 flush_rx, "flush_rx");
2371 cmdline_parse_token_string_t cmd_setflushrx_mode =
2372 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2376 cmdline_parse_inst_t cmd_set_flush_rx = {
2377 .f = cmd_set_flush_rx_parsed,
2378 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2381 (void *)&cmd_setflushrx_set,
2382 (void *)&cmd_setflushrx_flush_rx,
2383 (void *)&cmd_setflushrx_mode,
2388 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2389 struct cmd_set_link_check {
2390 cmdline_fixed_string_t set;
2391 cmdline_fixed_string_t link_check;
2392 cmdline_fixed_string_t mode;
2396 cmd_set_link_check_parsed(void *parsed_result,
2397 __attribute__((unused)) struct cmdline *cl,
2398 __attribute__((unused)) void *data)
2400 struct cmd_set_link_check *res = parsed_result;
2401 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2404 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2405 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2407 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2408 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2409 link_check, "link_check");
2410 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2411 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2415 cmdline_parse_inst_t cmd_set_link_check = {
2416 .f = cmd_set_link_check_parsed,
2417 .help_str = "set link_check on|off: enable/disable link status check "
2418 "when starting/stopping a port",
2421 (void *)&cmd_setlinkcheck_set,
2422 (void *)&cmd_setlinkcheck_link_check,
2423 (void *)&cmd_setlinkcheck_mode,
2428 #ifdef RTE_NIC_BYPASS
2429 /* *** SET NIC BYPASS MODE *** */
2430 struct cmd_set_bypass_mode_result {
2431 cmdline_fixed_string_t set;
2432 cmdline_fixed_string_t bypass;
2433 cmdline_fixed_string_t mode;
2434 cmdline_fixed_string_t value;
2439 cmd_set_bypass_mode_parsed(void *parsed_result,
2440 __attribute__((unused)) struct cmdline *cl,
2441 __attribute__((unused)) void *data)
2443 struct cmd_set_bypass_mode_result *res = parsed_result;
2444 portid_t port_id = res->port_id;
2445 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2447 if (!bypass_is_supported(port_id))
2450 if (!strcmp(res->value, "bypass"))
2451 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2452 else if (!strcmp(res->value, "isolate"))
2453 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2455 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2457 /* Set the bypass mode for the relevant port. */
2458 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2459 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2463 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2464 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2466 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2469 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2472 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2474 value, "normal#bypass#isolate");
2475 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2476 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2479 cmdline_parse_inst_t cmd_set_bypass_mode = {
2480 .f = cmd_set_bypass_mode_parsed,
2481 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2482 "Set the NIC bypass mode for port_id",
2485 (void *)&cmd_setbypass_mode_set,
2486 (void *)&cmd_setbypass_mode_bypass,
2487 (void *)&cmd_setbypass_mode_mode,
2488 (void *)&cmd_setbypass_mode_value,
2489 (void *)&cmd_setbypass_mode_port,
2494 /* *** SET NIC BYPASS EVENT *** */
2495 struct cmd_set_bypass_event_result {
2496 cmdline_fixed_string_t set;
2497 cmdline_fixed_string_t bypass;
2498 cmdline_fixed_string_t event;
2499 cmdline_fixed_string_t event_value;
2500 cmdline_fixed_string_t mode;
2501 cmdline_fixed_string_t mode_value;
2506 cmd_set_bypass_event_parsed(void *parsed_result,
2507 __attribute__((unused)) struct cmdline *cl,
2508 __attribute__((unused)) void *data)
2511 struct cmd_set_bypass_event_result *res = parsed_result;
2512 portid_t port_id = res->port_id;
2513 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2514 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2516 if (!bypass_is_supported(port_id))
2519 if (!strcmp(res->event_value, "timeout"))
2520 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2521 else if (!strcmp(res->event_value, "os_on"))
2522 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2523 else if (!strcmp(res->event_value, "os_off"))
2524 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2525 else if (!strcmp(res->event_value, "power_on"))
2526 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2527 else if (!strcmp(res->event_value, "power_off"))
2528 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2530 bypass_event = RTE_BYPASS_EVENT_NONE;
2532 if (!strcmp(res->mode_value, "bypass"))
2533 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2534 else if (!strcmp(res->mode_value, "isolate"))
2535 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2537 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2539 /* Set the watchdog timeout. */
2540 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2543 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2544 (rc = rte_eth_dev_wd_timeout_store(port_id,
2545 bypass_timeout)) != 0) {
2546 printf("Failed to set timeout value %u "
2547 "for port %d, errto code: %d.\n",
2548 bypass_timeout, port_id, rc);
2552 /* Set the bypass event to transition to bypass mode. */
2553 if (0 != rte_eth_dev_bypass_event_store(port_id,
2554 bypass_event, bypass_mode)) {
2555 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2560 cmdline_parse_token_string_t cmd_setbypass_event_set =
2561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2563 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2566 cmdline_parse_token_string_t cmd_setbypass_event_event =
2567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2569 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2570 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2571 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2572 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2575 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2576 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2577 mode_value, "normal#bypass#isolate");
2578 cmdline_parse_token_num_t cmd_setbypass_event_port =
2579 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2582 cmdline_parse_inst_t cmd_set_bypass_event = {
2583 .f = cmd_set_bypass_event_parsed,
2584 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2585 "mode (normal|bypass|isolate) (port_id): "
2586 "Set the NIC bypass event mode for port_id",
2589 (void *)&cmd_setbypass_event_set,
2590 (void *)&cmd_setbypass_event_bypass,
2591 (void *)&cmd_setbypass_event_event,
2592 (void *)&cmd_setbypass_event_event_value,
2593 (void *)&cmd_setbypass_event_mode,
2594 (void *)&cmd_setbypass_event_mode_value,
2595 (void *)&cmd_setbypass_event_port,
2601 /* *** SET NIC BYPASS TIMEOUT *** */
2602 struct cmd_set_bypass_timeout_result {
2603 cmdline_fixed_string_t set;
2604 cmdline_fixed_string_t bypass;
2605 cmdline_fixed_string_t timeout;
2606 cmdline_fixed_string_t value;
2610 cmd_set_bypass_timeout_parsed(void *parsed_result,
2611 __attribute__((unused)) struct cmdline *cl,
2612 __attribute__((unused)) void *data)
2614 struct cmd_set_bypass_timeout_result *res = parsed_result;
2616 if (!strcmp(res->value, "1.5"))
2617 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2618 else if (!strcmp(res->value, "2"))
2619 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2620 else if (!strcmp(res->value, "3"))
2621 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2622 else if (!strcmp(res->value, "4"))
2623 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2624 else if (!strcmp(res->value, "8"))
2625 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2626 else if (!strcmp(res->value, "16"))
2627 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2628 else if (!strcmp(res->value, "32"))
2629 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2631 bypass_timeout = RTE_BYPASS_TMT_OFF;
2634 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2637 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2640 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2642 timeout, "timeout");
2643 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2645 value, "0#1.5#2#3#4#8#16#32");
2647 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2648 .f = cmd_set_bypass_timeout_parsed,
2649 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2650 "Set the NIC bypass watchdog timeout",
2653 (void *)&cmd_setbypass_timeout_set,
2654 (void *)&cmd_setbypass_timeout_bypass,
2655 (void *)&cmd_setbypass_timeout_timeout,
2656 (void *)&cmd_setbypass_timeout_value,
2661 /* *** SHOW NIC BYPASS MODE *** */
2662 struct cmd_show_bypass_config_result {
2663 cmdline_fixed_string_t show;
2664 cmdline_fixed_string_t bypass;
2665 cmdline_fixed_string_t config;
2670 cmd_show_bypass_config_parsed(void *parsed_result,
2671 __attribute__((unused)) struct cmdline *cl,
2672 __attribute__((unused)) void *data)
2674 struct cmd_show_bypass_config_result *res = parsed_result;
2675 uint32_t event_mode;
2676 uint32_t bypass_mode;
2677 portid_t port_id = res->port_id;
2678 uint32_t timeout = bypass_timeout;
2681 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2682 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2683 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2684 {"UNKNOWN", "normal", "bypass", "isolate"};
2685 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2692 int num_events = (sizeof events) / (sizeof events[0]);
2694 if (!bypass_is_supported(port_id))
2697 /* Display the bypass mode.*/
2698 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2699 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2703 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2704 bypass_mode = RTE_BYPASS_MODE_NONE;
2706 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2709 /* Display the bypass timeout.*/
2710 if (!RTE_BYPASS_TMT_VALID(timeout))
2711 timeout = RTE_BYPASS_TMT_OFF;
2713 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2715 /* Display the bypass events and associated modes. */
2716 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2718 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2719 printf("\tFailed to get bypass mode for event = %s\n",
2722 if (!RTE_BYPASS_MODE_VALID(event_mode))
2723 event_mode = RTE_BYPASS_MODE_NONE;
2725 printf("\tbypass event: %-16s = %s\n", events[i],
2731 cmdline_parse_token_string_t cmd_showbypass_config_show =
2732 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2734 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2735 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2737 cmdline_parse_token_string_t cmd_showbypass_config_config =
2738 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2740 cmdline_parse_token_num_t cmd_showbypass_config_port =
2741 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2744 cmdline_parse_inst_t cmd_show_bypass_config = {
2745 .f = cmd_show_bypass_config_parsed,
2746 .help_str = "show bypass config (port_id): "
2747 "Show the NIC bypass config for port_id",
2750 (void *)&cmd_showbypass_config_show,
2751 (void *)&cmd_showbypass_config_bypass,
2752 (void *)&cmd_showbypass_config_config,
2753 (void *)&cmd_showbypass_config_port,
2759 /* *** SET FORWARDING MODE *** */
2760 struct cmd_set_fwd_mode_result {
2761 cmdline_fixed_string_t set;
2762 cmdline_fixed_string_t fwd;
2763 cmdline_fixed_string_t mode;
2766 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2768 __attribute__((unused)) void *data)
2770 struct cmd_set_fwd_mode_result *res = parsed_result;
2772 set_pkt_forwarding_mode(res->mode);
2775 cmdline_parse_token_string_t cmd_setfwd_set =
2776 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2777 cmdline_parse_token_string_t cmd_setfwd_fwd =
2778 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2779 cmdline_parse_token_string_t cmd_setfwd_mode =
2780 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2781 "" /* defined at init */);
2783 cmdline_parse_inst_t cmd_set_fwd_mode = {
2784 .f = cmd_set_fwd_mode_parsed,
2786 .help_str = NULL, /* defined at init */
2788 (void *)&cmd_setfwd_set,
2789 (void *)&cmd_setfwd_fwd,
2790 (void *)&cmd_setfwd_mode,
2795 static void cmd_set_fwd_mode_init(void)
2798 static char token[128];
2799 static char help[256];
2800 cmdline_parse_token_string_t *token_struct;
2802 modes = list_pkt_forwarding_modes();
2803 rte_snprintf(help, sizeof help, "set fwd %s - "
2804 "set packet forwarding mode", modes);
2805 cmd_set_fwd_mode.help_str = help;
2807 /* string token separator is # */
2808 for (c = token; *modes != '\0'; modes++)
2813 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2814 token_struct->string_data.str = token;
2817 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2818 struct cmd_set_burst_tx_retry_result {
2819 cmdline_fixed_string_t set;
2820 cmdline_fixed_string_t burst;
2821 cmdline_fixed_string_t tx;
2822 cmdline_fixed_string_t delay;
2824 cmdline_fixed_string_t retry;
2828 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2829 __attribute__((unused)) struct cmdline *cl,
2830 __attribute__((unused)) void *data)
2832 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2834 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2835 && !strcmp(res->tx, "tx")) {
2836 if (!strcmp(res->delay, "delay"))
2837 burst_tx_delay_time = res->time;
2838 if (!strcmp(res->retry, "retry"))
2839 burst_tx_retry_num = res->retry_num;
2844 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2846 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2847 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2849 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2850 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2851 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2852 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2853 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2854 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2855 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2856 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2857 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2858 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2860 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2861 .f = cmd_set_burst_tx_retry_parsed,
2862 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2864 (void *)&cmd_set_burst_tx_retry_set,
2865 (void *)&cmd_set_burst_tx_retry_burst,
2866 (void *)&cmd_set_burst_tx_retry_tx,
2867 (void *)&cmd_set_burst_tx_retry_delay,
2868 (void *)&cmd_set_burst_tx_retry_time,
2869 (void *)&cmd_set_burst_tx_retry_retry,
2870 (void *)&cmd_set_burst_tx_retry_retry_num,
2875 /* *** SET PROMISC MODE *** */
2876 struct cmd_set_promisc_mode_result {
2877 cmdline_fixed_string_t set;
2878 cmdline_fixed_string_t promisc;
2879 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2880 uint8_t port_num; /* valid if "allports" argument == 0 */
2881 cmdline_fixed_string_t mode;
2884 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2885 __attribute__((unused)) struct cmdline *cl,
2888 struct cmd_set_promisc_mode_result *res = parsed_result;
2892 if (!strcmp(res->mode, "on"))
2899 for (i = 0; i < nb_ports; i++) {
2901 rte_eth_promiscuous_enable(i);
2903 rte_eth_promiscuous_disable(i);
2908 rte_eth_promiscuous_enable(res->port_num);
2910 rte_eth_promiscuous_disable(res->port_num);
2914 cmdline_parse_token_string_t cmd_setpromisc_set =
2915 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2916 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2919 cmdline_parse_token_string_t cmd_setpromisc_portall =
2920 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2922 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2923 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2925 cmdline_parse_token_string_t cmd_setpromisc_mode =
2926 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2929 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2930 .f = cmd_set_promisc_mode_parsed,
2932 .help_str = "set promisc all on|off: set promisc mode for all ports",
2934 (void *)&cmd_setpromisc_set,
2935 (void *)&cmd_setpromisc_promisc,
2936 (void *)&cmd_setpromisc_portall,
2937 (void *)&cmd_setpromisc_mode,
2942 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2943 .f = cmd_set_promisc_mode_parsed,
2945 .help_str = "set promisc X on|off: set promisc mode on port X",
2947 (void *)&cmd_setpromisc_set,
2948 (void *)&cmd_setpromisc_promisc,
2949 (void *)&cmd_setpromisc_portnum,
2950 (void *)&cmd_setpromisc_mode,
2955 /* *** SET ALLMULTI MODE *** */
2956 struct cmd_set_allmulti_mode_result {
2957 cmdline_fixed_string_t set;
2958 cmdline_fixed_string_t allmulti;
2959 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2960 uint8_t port_num; /* valid if "allports" argument == 0 */
2961 cmdline_fixed_string_t mode;
2964 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2965 __attribute__((unused)) struct cmdline *cl,
2968 struct cmd_set_allmulti_mode_result *res = parsed_result;
2972 if (!strcmp(res->mode, "on"))
2979 for (i = 0; i < nb_ports; i++) {
2981 rte_eth_allmulticast_enable(i);
2983 rte_eth_allmulticast_disable(i);
2988 rte_eth_allmulticast_enable(res->port_num);
2990 rte_eth_allmulticast_disable(res->port_num);
2994 cmdline_parse_token_string_t cmd_setallmulti_set =
2995 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2996 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2997 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2999 cmdline_parse_token_string_t cmd_setallmulti_portall =
3000 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3002 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3003 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3005 cmdline_parse_token_string_t cmd_setallmulti_mode =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3009 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3010 .f = cmd_set_allmulti_mode_parsed,
3012 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3014 (void *)&cmd_setallmulti_set,
3015 (void *)&cmd_setallmulti_allmulti,
3016 (void *)&cmd_setallmulti_portall,
3017 (void *)&cmd_setallmulti_mode,
3022 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3023 .f = cmd_set_allmulti_mode_parsed,
3025 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3027 (void *)&cmd_setallmulti_set,
3028 (void *)&cmd_setallmulti_allmulti,
3029 (void *)&cmd_setallmulti_portnum,
3030 (void *)&cmd_setallmulti_mode,
3035 /* *** ADD/REMOVE A PKT FILTER *** */
3036 struct cmd_pkt_filter_result {
3037 cmdline_fixed_string_t pkt_filter;
3039 cmdline_fixed_string_t protocol;
3040 cmdline_fixed_string_t src;
3041 cmdline_ipaddr_t ip_src;
3043 cmdline_fixed_string_t dst;
3044 cmdline_ipaddr_t ip_dst;
3046 cmdline_fixed_string_t flexbytes;
3047 uint16_t flexbytes_value;
3048 cmdline_fixed_string_t vlan;
3050 cmdline_fixed_string_t queue;
3052 cmdline_fixed_string_t soft;
3057 cmd_pkt_filter_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3059 __attribute__((unused)) void *data)
3061 struct rte_fdir_filter fdir_filter;
3062 struct cmd_pkt_filter_result *res = parsed_result;
3064 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3066 if (res->ip_src.family == AF_INET)
3067 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3069 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3070 &(res->ip_src.addr.ipv6),
3071 sizeof(struct in6_addr));
3073 if (res->ip_dst.family == AF_INET)
3074 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3076 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3077 &(res->ip_dst.addr.ipv6),
3078 sizeof(struct in6_addr));
3080 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3081 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3083 if (!strcmp(res->protocol, "udp"))
3084 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3085 else if (!strcmp(res->protocol, "tcp"))
3086 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3087 else if (!strcmp(res->protocol, "sctp"))
3088 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3089 else /* default only IP */
3090 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3092 if (res->ip_dst.family == AF_INET6)
3093 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3095 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3097 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3098 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3100 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3101 fdir_add_signature_filter(res->port_id, res->queue_id,
3103 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3104 fdir_update_signature_filter(res->port_id, res->queue_id,
3106 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3107 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3108 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3109 fdir_add_perfect_filter(res->port_id, res->soft_id,
3111 (uint8_t) (res->queue_id < 0),
3113 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3114 fdir_update_perfect_filter(res->port_id, res->soft_id,
3116 (uint8_t) (res->queue_id < 0),
3118 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3119 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3125 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3126 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3128 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3129 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3130 protocol, "ip#tcp#udp#sctp");
3131 cmdline_parse_token_string_t cmd_pkt_filter_src =
3132 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3134 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3135 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3137 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3138 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3140 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3141 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3143 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3144 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3146 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3147 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3149 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3150 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3151 flexbytes, "flexbytes");
3152 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3153 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3154 flexbytes_value, UINT16);
3155 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3156 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3158 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3159 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3161 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3162 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3164 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3165 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3167 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3168 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3170 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3171 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3175 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3176 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3177 pkt_filter, "add_signature_filter");
3178 cmdline_parse_inst_t cmd_add_signature_filter = {
3179 .f = cmd_pkt_filter_parsed,
3181 .help_str = "add a signature filter",
3183 (void *)&cmd_pkt_filter_add_signature_filter,
3184 (void *)&cmd_pkt_filter_port_id,
3185 (void *)&cmd_pkt_filter_protocol,
3186 (void *)&cmd_pkt_filter_src,
3187 (void *)&cmd_pkt_filter_ip_src,
3188 (void *)&cmd_pkt_filter_port_src,
3189 (void *)&cmd_pkt_filter_dst,
3190 (void *)&cmd_pkt_filter_ip_dst,
3191 (void *)&cmd_pkt_filter_port_dst,
3192 (void *)&cmd_pkt_filter_flexbytes,
3193 (void *)&cmd_pkt_filter_flexbytes_value,
3194 (void *)&cmd_pkt_filter_vlan,
3195 (void *)&cmd_pkt_filter_vlan_id,
3196 (void *)&cmd_pkt_filter_queue,
3197 (void *)&cmd_pkt_filter_queue_id,
3203 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3204 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3205 pkt_filter, "upd_signature_filter");
3206 cmdline_parse_inst_t cmd_upd_signature_filter = {
3207 .f = cmd_pkt_filter_parsed,
3209 .help_str = "update a signature filter",
3211 (void *)&cmd_pkt_filter_upd_signature_filter,
3212 (void *)&cmd_pkt_filter_port_id,
3213 (void *)&cmd_pkt_filter_protocol,
3214 (void *)&cmd_pkt_filter_src,
3215 (void *)&cmd_pkt_filter_ip_src,
3216 (void *)&cmd_pkt_filter_port_src,
3217 (void *)&cmd_pkt_filter_dst,
3218 (void *)&cmd_pkt_filter_ip_dst,
3219 (void *)&cmd_pkt_filter_port_dst,
3220 (void *)&cmd_pkt_filter_flexbytes,
3221 (void *)&cmd_pkt_filter_flexbytes_value,
3222 (void *)&cmd_pkt_filter_vlan,
3223 (void *)&cmd_pkt_filter_vlan_id,
3224 (void *)&cmd_pkt_filter_queue,
3225 (void *)&cmd_pkt_filter_queue_id,
3231 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3232 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3233 pkt_filter, "rm_signature_filter");
3234 cmdline_parse_inst_t cmd_rm_signature_filter = {
3235 .f = cmd_pkt_filter_parsed,
3237 .help_str = "remove a signature filter",
3239 (void *)&cmd_pkt_filter_rm_signature_filter,
3240 (void *)&cmd_pkt_filter_port_id,
3241 (void *)&cmd_pkt_filter_protocol,
3242 (void *)&cmd_pkt_filter_src,
3243 (void *)&cmd_pkt_filter_ip_src,
3244 (void *)&cmd_pkt_filter_port_src,
3245 (void *)&cmd_pkt_filter_dst,
3246 (void *)&cmd_pkt_filter_ip_dst,
3247 (void *)&cmd_pkt_filter_port_dst,
3248 (void *)&cmd_pkt_filter_flexbytes,
3249 (void *)&cmd_pkt_filter_flexbytes_value,
3250 (void *)&cmd_pkt_filter_vlan,
3251 (void *)&cmd_pkt_filter_vlan_id,
3257 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3258 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3259 pkt_filter, "add_perfect_filter");
3260 cmdline_parse_inst_t cmd_add_perfect_filter = {
3261 .f = cmd_pkt_filter_parsed,
3263 .help_str = "add a perfect filter",
3265 (void *)&cmd_pkt_filter_add_perfect_filter,
3266 (void *)&cmd_pkt_filter_port_id,
3267 (void *)&cmd_pkt_filter_protocol,
3268 (void *)&cmd_pkt_filter_src,
3269 (void *)&cmd_pkt_filter_ip_src,
3270 (void *)&cmd_pkt_filter_port_src,
3271 (void *)&cmd_pkt_filter_dst,
3272 (void *)&cmd_pkt_filter_ip_dst,
3273 (void *)&cmd_pkt_filter_port_dst,
3274 (void *)&cmd_pkt_filter_flexbytes,
3275 (void *)&cmd_pkt_filter_flexbytes_value,
3276 (void *)&cmd_pkt_filter_vlan,
3277 (void *)&cmd_pkt_filter_vlan_id,
3278 (void *)&cmd_pkt_filter_queue,
3279 (void *)&cmd_pkt_filter_queue_id,
3280 (void *)&cmd_pkt_filter_soft,
3281 (void *)&cmd_pkt_filter_soft_id,
3287 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3288 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3289 pkt_filter, "upd_perfect_filter");
3290 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3291 .f = cmd_pkt_filter_parsed,
3293 .help_str = "update a perfect filter",
3295 (void *)&cmd_pkt_filter_upd_perfect_filter,
3296 (void *)&cmd_pkt_filter_port_id,
3297 (void *)&cmd_pkt_filter_protocol,
3298 (void *)&cmd_pkt_filter_src,
3299 (void *)&cmd_pkt_filter_ip_src,
3300 (void *)&cmd_pkt_filter_port_src,
3301 (void *)&cmd_pkt_filter_dst,
3302 (void *)&cmd_pkt_filter_ip_dst,
3303 (void *)&cmd_pkt_filter_port_dst,
3304 (void *)&cmd_pkt_filter_flexbytes,
3305 (void *)&cmd_pkt_filter_flexbytes_value,
3306 (void *)&cmd_pkt_filter_vlan,
3307 (void *)&cmd_pkt_filter_vlan_id,
3308 (void *)&cmd_pkt_filter_queue,
3309 (void *)&cmd_pkt_filter_queue_id,
3310 (void *)&cmd_pkt_filter_soft,
3311 (void *)&cmd_pkt_filter_soft_id,
3317 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3318 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3319 pkt_filter, "rm_perfect_filter");
3320 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3321 .f = cmd_pkt_filter_parsed,
3323 .help_str = "remove a perfect filter",
3325 (void *)&cmd_pkt_filter_rm_perfect_filter,
3326 (void *)&cmd_pkt_filter_port_id,
3327 (void *)&cmd_pkt_filter_protocol,
3328 (void *)&cmd_pkt_filter_src,
3329 (void *)&cmd_pkt_filter_ip_src,
3330 (void *)&cmd_pkt_filter_port_src,
3331 (void *)&cmd_pkt_filter_dst,
3332 (void *)&cmd_pkt_filter_ip_dst,
3333 (void *)&cmd_pkt_filter_port_dst,
3334 (void *)&cmd_pkt_filter_flexbytes,
3335 (void *)&cmd_pkt_filter_flexbytes_value,
3336 (void *)&cmd_pkt_filter_vlan,
3337 (void *)&cmd_pkt_filter_vlan_id,
3338 (void *)&cmd_pkt_filter_soft,
3339 (void *)&cmd_pkt_filter_soft_id,
3344 /* *** SETUP MASKS FILTER *** */
3345 struct cmd_pkt_filter_masks_result {
3346 cmdline_fixed_string_t filter_mask;
3348 cmdline_fixed_string_t src_mask;
3349 uint32_t ip_src_mask;
3350 uint16_t ipv6_src_mask;
3351 uint16_t port_src_mask;
3352 cmdline_fixed_string_t dst_mask;
3353 uint32_t ip_dst_mask;
3354 uint16_t ipv6_dst_mask;
3355 uint16_t port_dst_mask;
3356 cmdline_fixed_string_t flexbytes;
3357 uint8_t flexbytes_value;
3358 cmdline_fixed_string_t vlan_id;
3359 uint8_t vlan_id_value;
3360 cmdline_fixed_string_t vlan_prio;
3361 uint8_t vlan_prio_value;
3362 cmdline_fixed_string_t only_ip_flow;
3363 uint8_t only_ip_flow_value;
3364 cmdline_fixed_string_t comp_ipv6_dst;
3365 uint8_t comp_ipv6_dst_value;
3369 cmd_pkt_filter_masks_parsed(void *parsed_result,
3370 __attribute__((unused)) struct cmdline *cl,
3371 __attribute__((unused)) void *data)
3373 struct rte_fdir_masks fdir_masks;
3374 struct cmd_pkt_filter_masks_result *res = parsed_result;
3376 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3378 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3379 fdir_masks.vlan_id = res->vlan_id_value;
3380 fdir_masks.vlan_prio = res->vlan_prio_value;
3381 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3382 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3383 fdir_masks.src_port_mask = res->port_src_mask;
3384 fdir_masks.dst_port_mask = res->port_dst_mask;
3385 fdir_masks.flexbytes = res->flexbytes_value;
3387 fdir_set_masks(res->port_id, &fdir_masks);
3390 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3391 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3392 filter_mask, "set_masks_filter");
3393 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3394 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3396 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3397 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3398 only_ip_flow, "only_ip_flow");
3399 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3400 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3401 only_ip_flow_value, UINT8);
3402 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3403 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3404 src_mask, "src_mask");
3405 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3406 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3407 ip_src_mask, UINT32);
3408 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3409 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3410 port_src_mask, UINT16);
3411 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3412 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3413 dst_mask, "dst_mask");
3414 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3415 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3416 ip_dst_mask, UINT32);
3417 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3418 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3419 port_dst_mask, UINT16);
3420 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3421 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3422 flexbytes, "flexbytes");
3423 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3424 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3425 flexbytes_value, UINT8);
3426 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3427 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3428 vlan_id, "vlan_id");
3429 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3430 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3431 vlan_id_value, UINT8);
3432 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3433 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3434 vlan_prio, "vlan_prio");
3435 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3437 vlan_prio_value, UINT8);
3439 cmdline_parse_inst_t cmd_set_masks_filter = {
3440 .f = cmd_pkt_filter_masks_parsed,
3442 .help_str = "setup masks filter",
3444 (void *)&cmd_pkt_filter_masks_filter_mask,
3445 (void *)&cmd_pkt_filter_masks_port_id,
3446 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3447 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3448 (void *)&cmd_pkt_filter_masks_src_mask,
3449 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3450 (void *)&cmd_pkt_filter_masks_port_src_mask,
3451 (void *)&cmd_pkt_filter_masks_dst_mask,
3452 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3453 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3454 (void *)&cmd_pkt_filter_masks_flexbytes,
3455 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3456 (void *)&cmd_pkt_filter_masks_vlan_id,
3457 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3458 (void *)&cmd_pkt_filter_masks_vlan_prio,
3459 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3465 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3466 __attribute__((unused)) struct cmdline *cl,
3467 __attribute__((unused)) void *data)
3469 struct rte_fdir_masks fdir_masks;
3470 struct cmd_pkt_filter_masks_result *res = parsed_result;
3472 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3474 fdir_masks.set_ipv6_mask = 1;
3475 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3476 fdir_masks.vlan_id = res->vlan_id_value;
3477 fdir_masks.vlan_prio = res->vlan_prio_value;
3478 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3479 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3480 fdir_masks.src_port_mask = res->port_src_mask;
3481 fdir_masks.dst_port_mask = res->port_dst_mask;
3482 fdir_masks.flexbytes = res->flexbytes_value;
3483 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3485 fdir_set_masks(res->port_id, &fdir_masks);
3488 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3489 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3490 filter_mask, "set_ipv6_masks_filter");
3491 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3492 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3493 ipv6_src_mask, UINT16);
3494 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3495 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3496 ipv6_dst_mask, UINT16);
3498 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3499 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3500 comp_ipv6_dst, "compare_dst");
3501 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3502 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3503 comp_ipv6_dst_value, UINT8);
3505 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3506 .f = cmd_pkt_filter_masks_ipv6_parsed,
3508 .help_str = "setup ipv6 masks filter",
3510 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3511 (void *)&cmd_pkt_filter_masks_port_id,
3512 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3513 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3514 (void *)&cmd_pkt_filter_masks_src_mask,
3515 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3516 (void *)&cmd_pkt_filter_masks_port_src_mask,
3517 (void *)&cmd_pkt_filter_masks_dst_mask,
3518 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3519 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3520 (void *)&cmd_pkt_filter_masks_flexbytes,
3521 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3522 (void *)&cmd_pkt_filter_masks_vlan_id,
3523 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3524 (void *)&cmd_pkt_filter_masks_vlan_prio,
3525 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3526 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3527 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3532 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3533 struct cmd_link_flow_ctrl_set_result {
3534 cmdline_fixed_string_t set;
3535 cmdline_fixed_string_t flow_ctrl;
3536 cmdline_fixed_string_t rx;
3537 cmdline_fixed_string_t rx_lfc_mode;
3538 cmdline_fixed_string_t tx;
3539 cmdline_fixed_string_t tx_lfc_mode;
3540 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3541 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3542 uint32_t high_water;
3544 uint16_t pause_time;
3550 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3551 __attribute__((unused)) struct cmdline *cl,
3552 __attribute__((unused)) void *data)
3554 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3555 struct rte_eth_fc_conf fc_conf;
3556 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3560 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3561 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3562 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3563 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3565 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3566 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3569 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3570 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3571 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3573 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3574 fc_conf.high_water = res->high_water;
3575 fc_conf.low_water = res->low_water;
3576 fc_conf.pause_time = res->pause_time;
3577 fc_conf.send_xon = res->send_xon;
3578 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3580 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3582 printf("bad flow contrl parameter, return code = %d \n", ret);
3585 cmdline_parse_token_string_t cmd_lfc_set_set =
3586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3588 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3589 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3590 flow_ctrl, "flow_ctrl");
3591 cmdline_parse_token_string_t cmd_lfc_set_rx =
3592 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3594 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3595 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3596 rx_lfc_mode, "on#off");
3597 cmdline_parse_token_string_t cmd_lfc_set_tx =
3598 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3600 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3601 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3602 tx_lfc_mode, "on#off");
3603 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3604 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3605 high_water, UINT32);
3606 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3607 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3609 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3610 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3611 pause_time, UINT16);
3612 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3613 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3615 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3616 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3617 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3618 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3619 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3620 mac_ctrl_frame_fwd_mode, "on#off");
3621 cmdline_parse_token_num_t cmd_lfc_set_portid =
3622 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3625 cmdline_parse_inst_t cmd_link_flow_control_set = {
3626 .f = cmd_link_flow_ctrl_set_parsed,
3628 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3629 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3632 (void *)&cmd_lfc_set_set,
3633 (void *)&cmd_lfc_set_flow_ctrl,
3634 (void *)&cmd_lfc_set_rx,
3635 (void *)&cmd_lfc_set_rx_mode,
3636 (void *)&cmd_lfc_set_tx,
3637 (void *)&cmd_lfc_set_tx_mode,
3638 (void *)&cmd_lfc_set_high_water,
3639 (void *)&cmd_lfc_set_low_water,
3640 (void *)&cmd_lfc_set_pause_time,
3641 (void *)&cmd_lfc_set_send_xon,
3642 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3643 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3644 (void *)&cmd_lfc_set_portid,
3649 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3650 struct cmd_priority_flow_ctrl_set_result {
3651 cmdline_fixed_string_t set;
3652 cmdline_fixed_string_t pfc_ctrl;
3653 cmdline_fixed_string_t rx;
3654 cmdline_fixed_string_t rx_pfc_mode;
3655 cmdline_fixed_string_t tx;
3656 cmdline_fixed_string_t tx_pfc_mode;
3657 uint32_t high_water;
3659 uint16_t pause_time;
3665 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3666 __attribute__((unused)) struct cmdline *cl,
3667 __attribute__((unused)) void *data)
3669 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3670 struct rte_eth_pfc_conf pfc_conf;
3671 int rx_fc_enable, tx_fc_enable;
3675 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3676 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3677 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3678 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3680 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3681 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3684 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3685 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3686 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3687 pfc_conf.fc.high_water = res->high_water;
3688 pfc_conf.fc.low_water = res->low_water;
3689 pfc_conf.fc.pause_time = res->pause_time;
3690 pfc_conf.priority = res->priority;
3692 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3694 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3697 cmdline_parse_token_string_t cmd_pfc_set_set =
3698 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3700 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3701 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3702 pfc_ctrl, "pfc_ctrl");
3703 cmdline_parse_token_string_t cmd_pfc_set_rx =
3704 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3706 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3707 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3708 rx_pfc_mode, "on#off");
3709 cmdline_parse_token_string_t cmd_pfc_set_tx =
3710 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3712 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3713 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3714 tx_pfc_mode, "on#off");
3715 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3716 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3717 high_water, UINT32);
3718 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3719 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3721 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3722 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3723 pause_time, UINT16);
3724 cmdline_parse_token_num_t cmd_pfc_set_priority =
3725 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3727 cmdline_parse_token_num_t cmd_pfc_set_portid =
3728 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3731 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3732 .f = cmd_priority_flow_ctrl_set_parsed,
3734 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3735 tx on|off high_water low_water pause_time priority port_id",
3737 (void *)&cmd_pfc_set_set,
3738 (void *)&cmd_pfc_set_flow_ctrl,
3739 (void *)&cmd_pfc_set_rx,
3740 (void *)&cmd_pfc_set_rx_mode,
3741 (void *)&cmd_pfc_set_tx,
3742 (void *)&cmd_pfc_set_tx_mode,
3743 (void *)&cmd_pfc_set_high_water,
3744 (void *)&cmd_pfc_set_low_water,
3745 (void *)&cmd_pfc_set_pause_time,
3746 (void *)&cmd_pfc_set_priority,
3747 (void *)&cmd_pfc_set_portid,
3752 /* *** RESET CONFIGURATION *** */
3753 struct cmd_reset_result {
3754 cmdline_fixed_string_t reset;
3755 cmdline_fixed_string_t def;
3758 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3760 __attribute__((unused)) void *data)
3762 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3763 set_def_fwd_config();
3766 cmdline_parse_token_string_t cmd_reset_set =
3767 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3768 cmdline_parse_token_string_t cmd_reset_def =
3769 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3772 cmdline_parse_inst_t cmd_reset = {
3773 .f = cmd_reset_parsed,
3775 .help_str = "set default: reset default forwarding configuration",
3777 (void *)&cmd_reset_set,
3778 (void *)&cmd_reset_def,
3783 /* *** START FORWARDING *** */
3784 struct cmd_start_result {
3785 cmdline_fixed_string_t start;
3788 cmdline_parse_token_string_t cmd_start_start =
3789 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3791 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3792 __attribute__((unused)) struct cmdline *cl,
3793 __attribute__((unused)) void *data)
3795 start_packet_forwarding(0);
3798 cmdline_parse_inst_t cmd_start = {
3799 .f = cmd_start_parsed,
3801 .help_str = "start packet forwarding",
3803 (void *)&cmd_start_start,
3808 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3809 struct cmd_start_tx_first_result {
3810 cmdline_fixed_string_t start;
3811 cmdline_fixed_string_t tx_first;
3815 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3816 __attribute__((unused)) struct cmdline *cl,
3817 __attribute__((unused)) void *data)
3819 start_packet_forwarding(1);
3822 cmdline_parse_token_string_t cmd_start_tx_first_start =
3823 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3825 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3826 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3827 tx_first, "tx_first");
3829 cmdline_parse_inst_t cmd_start_tx_first = {
3830 .f = cmd_start_tx_first_parsed,
3832 .help_str = "start packet forwarding, after sending 1 burst of packets",
3834 (void *)&cmd_start_tx_first_start,
3835 (void *)&cmd_start_tx_first_tx_first,
3840 /* *** SHOW CFG *** */
3841 struct cmd_showcfg_result {
3842 cmdline_fixed_string_t show;
3843 cmdline_fixed_string_t cfg;
3844 cmdline_fixed_string_t what;
3847 static void cmd_showcfg_parsed(void *parsed_result,
3848 __attribute__((unused)) struct cmdline *cl,
3849 __attribute__((unused)) void *data)
3851 struct cmd_showcfg_result *res = parsed_result;
3852 if (!strcmp(res->what, "rxtx"))
3853 rxtx_config_display();
3854 else if (!strcmp(res->what, "cores"))
3855 fwd_lcores_config_display();
3856 else if (!strcmp(res->what, "fwd"))
3857 fwd_config_display();
3860 cmdline_parse_token_string_t cmd_showcfg_show =
3861 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3862 cmdline_parse_token_string_t cmd_showcfg_port =
3863 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3864 cmdline_parse_token_string_t cmd_showcfg_what =
3865 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3868 cmdline_parse_inst_t cmd_showcfg = {
3869 .f = cmd_showcfg_parsed,
3871 .help_str = "show config rxtx|cores|fwd",
3873 (void *)&cmd_showcfg_show,
3874 (void *)&cmd_showcfg_port,
3875 (void *)&cmd_showcfg_what,
3880 /* *** SHOW ALL PORT INFO *** */
3881 struct cmd_showportall_result {
3882 cmdline_fixed_string_t show;
3883 cmdline_fixed_string_t port;
3884 cmdline_fixed_string_t what;
3885 cmdline_fixed_string_t all;
3888 static void cmd_showportall_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3894 struct cmd_showportall_result *res = parsed_result;
3895 if (!strcmp(res->show, "clear")) {
3896 if (!strcmp(res->what, "stats"))
3897 for (i = 0; i < nb_ports; i++)
3899 } else if (!strcmp(res->what, "info"))
3900 for (i = 0; i < nb_ports; i++)
3901 port_infos_display(i);
3902 else if (!strcmp(res->what, "stats"))
3903 for (i = 0; i < nb_ports; i++)
3904 nic_stats_display(i);
3905 else if (!strcmp(res->what, "fdir"))
3906 for (i = 0; i < nb_ports; i++)
3908 else if (!strcmp(res->what, "stat_qmap"))
3909 for (i = 0; i < nb_ports; i++)
3910 nic_stats_mapping_display(i);
3913 cmdline_parse_token_string_t cmd_showportall_show =
3914 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3916 cmdline_parse_token_string_t cmd_showportall_port =
3917 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3918 cmdline_parse_token_string_t cmd_showportall_what =
3919 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3920 "info#stats#fdir#stat_qmap");
3921 cmdline_parse_token_string_t cmd_showportall_all =
3922 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3923 cmdline_parse_inst_t cmd_showportall = {
3924 .f = cmd_showportall_parsed,
3926 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3928 (void *)&cmd_showportall_show,
3929 (void *)&cmd_showportall_port,
3930 (void *)&cmd_showportall_what,
3931 (void *)&cmd_showportall_all,
3936 /* *** SHOW PORT INFO *** */
3937 struct cmd_showport_result {
3938 cmdline_fixed_string_t show;
3939 cmdline_fixed_string_t port;
3940 cmdline_fixed_string_t what;
3944 static void cmd_showport_parsed(void *parsed_result,
3945 __attribute__((unused)) struct cmdline *cl,
3946 __attribute__((unused)) void *data)
3948 struct cmd_showport_result *res = parsed_result;
3949 if (!strcmp(res->show, "clear")) {
3950 if (!strcmp(res->what, "stats"))
3951 nic_stats_clear(res->portnum);
3952 } else if (!strcmp(res->what, "info"))
3953 port_infos_display(res->portnum);
3954 else if (!strcmp(res->what, "stats"))
3955 nic_stats_display(res->portnum);
3956 else if (!strcmp(res->what, "fdir"))
3957 fdir_get_infos(res->portnum);
3958 else if (!strcmp(res->what, "stat_qmap"))
3959 nic_stats_mapping_display(res->portnum);
3962 cmdline_parse_token_string_t cmd_showport_show =
3963 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3965 cmdline_parse_token_string_t cmd_showport_port =
3966 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3967 cmdline_parse_token_string_t cmd_showport_what =
3968 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3969 "info#stats#fdir#stat_qmap");
3970 cmdline_parse_token_num_t cmd_showport_portnum =
3971 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3973 cmdline_parse_inst_t cmd_showport = {
3974 .f = cmd_showport_parsed,
3976 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3978 (void *)&cmd_showport_show,
3979 (void *)&cmd_showport_port,
3980 (void *)&cmd_showport_what,
3981 (void *)&cmd_showport_portnum,
3986 /* *** READ PORT REGISTER *** */
3987 struct cmd_read_reg_result {
3988 cmdline_fixed_string_t read;
3989 cmdline_fixed_string_t reg;
3995 cmd_read_reg_parsed(void *parsed_result,
3996 __attribute__((unused)) struct cmdline *cl,
3997 __attribute__((unused)) void *data)
3999 struct cmd_read_reg_result *res = parsed_result;
4000 port_reg_display(res->port_id, res->reg_off);
4003 cmdline_parse_token_string_t cmd_read_reg_read =
4004 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4005 cmdline_parse_token_string_t cmd_read_reg_reg =
4006 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4007 cmdline_parse_token_num_t cmd_read_reg_port_id =
4008 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4009 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4010 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4012 cmdline_parse_inst_t cmd_read_reg = {
4013 .f = cmd_read_reg_parsed,
4015 .help_str = "read reg port_id reg_off",
4017 (void *)&cmd_read_reg_read,
4018 (void *)&cmd_read_reg_reg,
4019 (void *)&cmd_read_reg_port_id,
4020 (void *)&cmd_read_reg_reg_off,
4025 /* *** READ PORT REGISTER BIT FIELD *** */
4026 struct cmd_read_reg_bit_field_result {
4027 cmdline_fixed_string_t read;
4028 cmdline_fixed_string_t regfield;
4036 cmd_read_reg_bit_field_parsed(void *parsed_result,
4037 __attribute__((unused)) struct cmdline *cl,
4038 __attribute__((unused)) void *data)
4040 struct cmd_read_reg_bit_field_result *res = parsed_result;
4041 port_reg_bit_field_display(res->port_id, res->reg_off,
4042 res->bit1_pos, res->bit2_pos);
4045 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4046 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4048 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4049 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4050 regfield, "regfield");
4051 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4052 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4054 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4055 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4057 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4058 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4060 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4061 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4064 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4065 .f = cmd_read_reg_bit_field_parsed,
4067 .help_str = "read regfield port_id reg_off bit_x bit_y "
4068 "(read register bit field between bit_x and bit_y included)",
4070 (void *)&cmd_read_reg_bit_field_read,
4071 (void *)&cmd_read_reg_bit_field_regfield,
4072 (void *)&cmd_read_reg_bit_field_port_id,
4073 (void *)&cmd_read_reg_bit_field_reg_off,
4074 (void *)&cmd_read_reg_bit_field_bit1_pos,
4075 (void *)&cmd_read_reg_bit_field_bit2_pos,
4080 /* *** READ PORT REGISTER BIT *** */
4081 struct cmd_read_reg_bit_result {
4082 cmdline_fixed_string_t read;
4083 cmdline_fixed_string_t regbit;
4090 cmd_read_reg_bit_parsed(void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 struct cmd_read_reg_bit_result *res = parsed_result;
4095 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4098 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4099 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4100 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4101 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4103 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4104 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4105 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4106 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4107 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4108 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4110 cmdline_parse_inst_t cmd_read_reg_bit = {
4111 .f = cmd_read_reg_bit_parsed,
4113 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4115 (void *)&cmd_read_reg_bit_read,
4116 (void *)&cmd_read_reg_bit_regbit,
4117 (void *)&cmd_read_reg_bit_port_id,
4118 (void *)&cmd_read_reg_bit_reg_off,
4119 (void *)&cmd_read_reg_bit_bit_pos,
4124 /* *** WRITE PORT REGISTER *** */
4125 struct cmd_write_reg_result {
4126 cmdline_fixed_string_t write;
4127 cmdline_fixed_string_t reg;
4134 cmd_write_reg_parsed(void *parsed_result,
4135 __attribute__((unused)) struct cmdline *cl,
4136 __attribute__((unused)) void *data)
4138 struct cmd_write_reg_result *res = parsed_result;
4139 port_reg_set(res->port_id, res->reg_off, res->value);
4142 cmdline_parse_token_string_t cmd_write_reg_write =
4143 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4144 cmdline_parse_token_string_t cmd_write_reg_reg =
4145 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4146 cmdline_parse_token_num_t cmd_write_reg_port_id =
4147 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4148 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4149 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4150 cmdline_parse_token_num_t cmd_write_reg_value =
4151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4153 cmdline_parse_inst_t cmd_write_reg = {
4154 .f = cmd_write_reg_parsed,
4156 .help_str = "write reg port_id reg_off reg_value",
4158 (void *)&cmd_write_reg_write,
4159 (void *)&cmd_write_reg_reg,
4160 (void *)&cmd_write_reg_port_id,
4161 (void *)&cmd_write_reg_reg_off,
4162 (void *)&cmd_write_reg_value,
4167 /* *** WRITE PORT REGISTER BIT FIELD *** */
4168 struct cmd_write_reg_bit_field_result {
4169 cmdline_fixed_string_t write;
4170 cmdline_fixed_string_t regfield;
4179 cmd_write_reg_bit_field_parsed(void *parsed_result,
4180 __attribute__((unused)) struct cmdline *cl,
4181 __attribute__((unused)) void *data)
4183 struct cmd_write_reg_bit_field_result *res = parsed_result;
4184 port_reg_bit_field_set(res->port_id, res->reg_off,
4185 res->bit1_pos, res->bit2_pos, res->value);
4188 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4189 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4191 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4192 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4193 regfield, "regfield");
4194 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4197 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4200 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4201 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4203 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4204 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4206 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4207 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4210 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4211 .f = cmd_write_reg_bit_field_parsed,
4213 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4214 "(set register bit field between bit_x and bit_y included)",
4216 (void *)&cmd_write_reg_bit_field_write,
4217 (void *)&cmd_write_reg_bit_field_regfield,
4218 (void *)&cmd_write_reg_bit_field_port_id,
4219 (void *)&cmd_write_reg_bit_field_reg_off,
4220 (void *)&cmd_write_reg_bit_field_bit1_pos,
4221 (void *)&cmd_write_reg_bit_field_bit2_pos,
4222 (void *)&cmd_write_reg_bit_field_value,
4227 /* *** WRITE PORT REGISTER BIT *** */
4228 struct cmd_write_reg_bit_result {
4229 cmdline_fixed_string_t write;
4230 cmdline_fixed_string_t regbit;
4238 cmd_write_reg_bit_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4240 __attribute__((unused)) void *data)
4242 struct cmd_write_reg_bit_result *res = parsed_result;
4243 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4246 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4247 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4249 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4252 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4254 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4256 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4257 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4258 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4259 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4261 cmdline_parse_inst_t cmd_write_reg_bit = {
4262 .f = cmd_write_reg_bit_parsed,
4264 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4266 (void *)&cmd_write_reg_bit_write,
4267 (void *)&cmd_write_reg_bit_regbit,
4268 (void *)&cmd_write_reg_bit_port_id,
4269 (void *)&cmd_write_reg_bit_reg_off,
4270 (void *)&cmd_write_reg_bit_bit_pos,
4271 (void *)&cmd_write_reg_bit_value,
4276 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4277 struct cmd_read_rxd_txd_result {
4278 cmdline_fixed_string_t read;
4279 cmdline_fixed_string_t rxd_txd;
4286 cmd_read_rxd_txd_parsed(void *parsed_result,
4287 __attribute__((unused)) struct cmdline *cl,
4288 __attribute__((unused)) void *data)
4290 struct cmd_read_rxd_txd_result *res = parsed_result;
4292 if (!strcmp(res->rxd_txd, "rxd"))
4293 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4294 else if (!strcmp(res->rxd_txd, "txd"))
4295 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4298 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4299 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4300 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4301 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4303 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4304 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4305 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4306 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4307 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4308 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4310 cmdline_parse_inst_t cmd_read_rxd_txd = {
4311 .f = cmd_read_rxd_txd_parsed,
4313 .help_str = "read rxd|txd port_id queue_id rxd_id",
4315 (void *)&cmd_read_rxd_txd_read,
4316 (void *)&cmd_read_rxd_txd_rxd_txd,
4317 (void *)&cmd_read_rxd_txd_port_id,
4318 (void *)&cmd_read_rxd_txd_queue_id,
4319 (void *)&cmd_read_rxd_txd_desc_id,
4325 struct cmd_quit_result {
4326 cmdline_fixed_string_t quit;
4329 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4331 __attribute__((unused)) void *data)
4337 cmdline_parse_token_string_t cmd_quit_quit =
4338 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4340 cmdline_parse_inst_t cmd_quit = {
4341 .f = cmd_quit_parsed,
4343 .help_str = "exit application",
4345 (void *)&cmd_quit_quit,
4350 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4351 struct cmd_mac_addr_result {
4352 cmdline_fixed_string_t mac_addr_cmd;
4353 cmdline_fixed_string_t what;
4355 struct ether_addr address;
4358 static void cmd_mac_addr_parsed(void *parsed_result,
4359 __attribute__((unused)) struct cmdline *cl,
4360 __attribute__((unused)) void *data)
4362 struct cmd_mac_addr_result *res = parsed_result;
4365 if (strcmp(res->what, "add") == 0)
4366 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4368 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4370 /* check the return value and print it if is < 0 */
4372 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4376 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4377 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4379 cmdline_parse_token_string_t cmd_mac_addr_what =
4380 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4382 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4383 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4384 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4387 cmdline_parse_inst_t cmd_mac_addr = {
4388 .f = cmd_mac_addr_parsed,
4390 .help_str = "mac_addr add|remove X <address>: "
4391 "add/remove MAC address on port X",
4393 (void *)&cmd_mac_addr_cmd,
4394 (void *)&cmd_mac_addr_what,
4395 (void *)&cmd_mac_addr_portnum,
4396 (void *)&cmd_mac_addr_addr,
4402 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4403 struct cmd_set_qmap_result {
4404 cmdline_fixed_string_t set;
4405 cmdline_fixed_string_t qmap;
4406 cmdline_fixed_string_t what;
4413 cmd_set_qmap_parsed(void *parsed_result,
4414 __attribute__((unused)) struct cmdline *cl,
4415 __attribute__((unused)) void *data)
4417 struct cmd_set_qmap_result *res = parsed_result;
4418 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4420 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4423 cmdline_parse_token_string_t cmd_setqmap_set =
4424 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4426 cmdline_parse_token_string_t cmd_setqmap_qmap =
4427 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4429 cmdline_parse_token_string_t cmd_setqmap_what =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4432 cmdline_parse_token_num_t cmd_setqmap_portid =
4433 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4435 cmdline_parse_token_num_t cmd_setqmap_queueid =
4436 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4438 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4439 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4442 cmdline_parse_inst_t cmd_set_qmap = {
4443 .f = cmd_set_qmap_parsed,
4445 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4447 (void *)&cmd_setqmap_set,
4448 (void *)&cmd_setqmap_qmap,
4449 (void *)&cmd_setqmap_what,
4450 (void *)&cmd_setqmap_portid,
4451 (void *)&cmd_setqmap_queueid,
4452 (void *)&cmd_setqmap_mapvalue,
4457 /* *** CONFIGURE UNICAST HASH TABLE *** */
4458 struct cmd_set_uc_hash_table {
4459 cmdline_fixed_string_t set;
4460 cmdline_fixed_string_t port;
4462 cmdline_fixed_string_t what;
4463 struct ether_addr address;
4464 cmdline_fixed_string_t mode;
4468 cmd_set_uc_hash_parsed(void *parsed_result,
4469 __attribute__((unused)) struct cmdline *cl,
4470 __attribute__((unused)) void *data)
4473 struct cmd_set_uc_hash_table *res = parsed_result;
4475 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4477 if (strcmp(res->what, "uta") == 0)
4478 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4479 &res->address,(uint8_t)is_on);
4481 printf("bad unicast hash table parameter, return code = %d \n", ret);
4485 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4486 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4488 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4489 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4491 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4492 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4494 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4497 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4498 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4500 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4504 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4505 .f = cmd_set_uc_hash_parsed,
4507 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4509 (void *)&cmd_set_uc_hash_set,
4510 (void *)&cmd_set_uc_hash_port,
4511 (void *)&cmd_set_uc_hash_portid,
4512 (void *)&cmd_set_uc_hash_what,
4513 (void *)&cmd_set_uc_hash_mac,
4514 (void *)&cmd_set_uc_hash_mode,
4519 struct cmd_set_uc_all_hash_table {
4520 cmdline_fixed_string_t set;
4521 cmdline_fixed_string_t port;
4523 cmdline_fixed_string_t what;
4524 cmdline_fixed_string_t value;
4525 cmdline_fixed_string_t mode;
4529 cmd_set_uc_all_hash_parsed(void *parsed_result,
4530 __attribute__((unused)) struct cmdline *cl,
4531 __attribute__((unused)) void *data)
4534 struct cmd_set_uc_all_hash_table *res = parsed_result;
4536 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4538 if ((strcmp(res->what, "uta") == 0) &&
4539 (strcmp(res->value, "all") == 0))
4540 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4542 printf("bad unicast hash table parameter,"
4543 "return code = %d \n", ret);
4546 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4549 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4550 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4552 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4553 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4555 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4556 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4558 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4559 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4561 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4565 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4566 .f = cmd_set_uc_all_hash_parsed,
4568 .help_str = "set port X uta all on|off (X = port number)",
4570 (void *)&cmd_set_uc_all_hash_set,
4571 (void *)&cmd_set_uc_all_hash_port,
4572 (void *)&cmd_set_uc_all_hash_portid,
4573 (void *)&cmd_set_uc_all_hash_what,
4574 (void *)&cmd_set_uc_all_hash_value,
4575 (void *)&cmd_set_uc_all_hash_mode,
4580 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4581 struct cmd_set_vf_traffic {
4582 cmdline_fixed_string_t set;
4583 cmdline_fixed_string_t port;
4585 cmdline_fixed_string_t vf;
4587 cmdline_fixed_string_t what;
4588 cmdline_fixed_string_t mode;
4592 cmd_set_vf_traffic_parsed(void *parsed_result,
4593 __attribute__((unused)) struct cmdline *cl,
4594 __attribute__((unused)) void *data)
4596 struct cmd_set_vf_traffic *res = parsed_result;
4597 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4598 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4600 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4603 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4606 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4609 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4610 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4612 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4613 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4615 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4616 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4618 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4619 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4621 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4625 cmdline_parse_inst_t cmd_set_vf_traffic = {
4626 .f = cmd_set_vf_traffic_parsed,
4628 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4630 (void *)&cmd_setvf_traffic_set,
4631 (void *)&cmd_setvf_traffic_port,
4632 (void *)&cmd_setvf_traffic_portid,
4633 (void *)&cmd_setvf_traffic_vf,
4634 (void *)&cmd_setvf_traffic_vfid,
4635 (void *)&cmd_setvf_traffic_what,
4636 (void *)&cmd_setvf_traffic_mode,
4641 /* *** CONFIGURE VF RECEIVE MODE *** */
4642 struct cmd_set_vf_rxmode {
4643 cmdline_fixed_string_t set;
4644 cmdline_fixed_string_t port;
4646 cmdline_fixed_string_t vf;
4648 cmdline_fixed_string_t what;
4649 cmdline_fixed_string_t mode;
4650 cmdline_fixed_string_t on;
4654 cmd_set_vf_rxmode_parsed(void *parsed_result,
4655 __attribute__((unused)) struct cmdline *cl,
4656 __attribute__((unused)) void *data)
4659 uint16_t rx_mode = 0;
4660 struct cmd_set_vf_rxmode *res = parsed_result;
4662 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4663 if (!strcmp(res->what,"rxmode")) {
4664 if (!strcmp(res->mode, "AUPE"))
4665 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4666 else if (!strcmp(res->mode, "ROPE"))
4667 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4668 else if (!strcmp(res->mode, "BAM"))
4669 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4670 else if (!strncmp(res->mode, "MPE",3))
4671 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4674 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4676 printf("bad VF receive mode parameter, return code = %d \n",
4680 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4681 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4683 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4684 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4686 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4687 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4689 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4690 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4692 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4693 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4695 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4696 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4698 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4699 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4700 mode, "AUPE#ROPE#BAM#MPE");
4701 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4702 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4705 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4706 .f = cmd_set_vf_rxmode_parsed,
4708 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4710 (void *)&cmd_set_vf_rxmode_set,
4711 (void *)&cmd_set_vf_rxmode_port,
4712 (void *)&cmd_set_vf_rxmode_portid,
4713 (void *)&cmd_set_vf_rxmode_vf,
4714 (void *)&cmd_set_vf_rxmode_vfid,
4715 (void *)&cmd_set_vf_rxmode_what,
4716 (void *)&cmd_set_vf_rxmode_mode,
4717 (void *)&cmd_set_vf_rxmode_on,
4722 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4723 struct cmd_vf_mac_addr_result {
4724 cmdline_fixed_string_t mac_addr_cmd;
4725 cmdline_fixed_string_t what;
4726 cmdline_fixed_string_t port;
4728 cmdline_fixed_string_t vf;
4730 struct ether_addr address;
4733 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4734 __attribute__((unused)) struct cmdline *cl,
4735 __attribute__((unused)) void *data)
4737 struct cmd_vf_mac_addr_result *res = parsed_result;
4740 if (strcmp(res->what, "add") == 0)
4741 ret = rte_eth_dev_mac_addr_add(res->port_num,
4742 &res->address, res->vf_num);
4744 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4748 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4749 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4750 mac_addr_cmd,"mac_addr");
4751 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4752 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4754 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4755 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4757 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4758 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4760 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4761 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4763 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4764 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4766 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4767 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4770 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4771 .f = cmd_vf_mac_addr_parsed,
4773 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4774 "Y = VF number)add MAC address filtering for a VF on port X",
4776 (void *)&cmd_vf_mac_addr_cmd,
4777 (void *)&cmd_vf_mac_addr_what,
4778 (void *)&cmd_vf_mac_addr_port,
4779 (void *)&cmd_vf_mac_addr_portnum,
4780 (void *)&cmd_vf_mac_addr_vf,
4781 (void *)&cmd_vf_mac_addr_vfnum,
4782 (void *)&cmd_vf_mac_addr_addr,
4787 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4788 struct cmd_vf_rx_vlan_filter {
4789 cmdline_fixed_string_t rx_vlan;
4790 cmdline_fixed_string_t what;
4792 cmdline_fixed_string_t port;
4794 cmdline_fixed_string_t vf;
4799 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4800 __attribute__((unused)) struct cmdline *cl,
4801 __attribute__((unused)) void *data)
4803 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4805 if (!strcmp(res->what, "add"))
4806 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4808 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4811 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4812 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4813 rx_vlan, "rx_vlan");
4814 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4815 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4817 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4818 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4820 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4821 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4823 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4824 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4826 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4827 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4829 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4830 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4833 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4834 .f = cmd_vf_rx_vlan_filter_parsed,
4836 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4837 "Y = port number,Z = hexadecimal VF mask)",
4839 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4840 (void *)&cmd_vf_rx_vlan_filter_what,
4841 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4842 (void *)&cmd_vf_rx_vlan_filter_port,
4843 (void *)&cmd_vf_rx_vlan_filter_portid,
4844 (void *)&cmd_vf_rx_vlan_filter_vf,
4845 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4850 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4851 struct cmd_set_mirror_mask_result {
4852 cmdline_fixed_string_t set;
4853 cmdline_fixed_string_t port;
4855 cmdline_fixed_string_t mirror;
4857 cmdline_fixed_string_t what;
4858 cmdline_fixed_string_t value;
4859 cmdline_fixed_string_t dstpool;
4861 cmdline_fixed_string_t on;
4864 cmdline_parse_token_string_t cmd_mirror_mask_set =
4865 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4867 cmdline_parse_token_string_t cmd_mirror_mask_port =
4868 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4870 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4871 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4873 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4875 mirror, "mirror-rule");
4876 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4879 cmdline_parse_token_string_t cmd_mirror_mask_what =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4881 what, "pool-mirror#vlan-mirror");
4882 cmdline_parse_token_string_t cmd_mirror_mask_value =
4883 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4885 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4886 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4887 dstpool, "dst-pool");
4888 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4889 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4891 cmdline_parse_token_string_t cmd_mirror_mask_on =
4892 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4896 cmd_set_mirror_mask_parsed(void *parsed_result,
4897 __attribute__((unused)) struct cmdline *cl,
4898 __attribute__((unused)) void *data)
4901 struct cmd_set_mirror_mask_result *res = parsed_result;
4902 struct rte_eth_vmdq_mirror_conf mr_conf;
4904 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4906 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4908 mr_conf.dst_pool = res->dstpool_id;
4910 if (!strcmp(res->what, "pool-mirror")) {
4911 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4912 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4913 } else if(!strcmp(res->what, "vlan-mirror")) {
4914 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4915 nb_item = parse_item_list(res->value, "core",
4916 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4920 for(i=0; i < nb_item; i++) {
4921 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4922 printf("Invalid vlan_id: must be < 4096\n");
4926 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4927 mr_conf.vlan.vlan_mask |= 1ULL << i;
4931 if(!strcmp(res->on, "on"))
4932 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4935 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4938 printf("mirror rule add error: (%s)\n", strerror(-ret));
4941 cmdline_parse_inst_t cmd_set_mirror_mask = {
4942 .f = cmd_set_mirror_mask_parsed,
4944 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4945 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4947 (void *)&cmd_mirror_mask_set,
4948 (void *)&cmd_mirror_mask_port,
4949 (void *)&cmd_mirror_mask_portid,
4950 (void *)&cmd_mirror_mask_mirror,
4951 (void *)&cmd_mirror_mask_ruleid,
4952 (void *)&cmd_mirror_mask_what,
4953 (void *)&cmd_mirror_mask_value,
4954 (void *)&cmd_mirror_mask_dstpool,
4955 (void *)&cmd_mirror_mask_poolid,
4956 (void *)&cmd_mirror_mask_on,
4961 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4962 struct cmd_set_mirror_link_result {
4963 cmdline_fixed_string_t set;
4964 cmdline_fixed_string_t port;
4966 cmdline_fixed_string_t mirror;
4968 cmdline_fixed_string_t what;
4969 cmdline_fixed_string_t dstpool;
4971 cmdline_fixed_string_t on;
4974 cmdline_parse_token_string_t cmd_mirror_link_set =
4975 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4977 cmdline_parse_token_string_t cmd_mirror_link_port =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4980 cmdline_parse_token_string_t cmd_mirror_link_portid =
4981 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4983 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4984 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4985 mirror, "mirror-rule");
4986 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4987 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4989 cmdline_parse_token_string_t cmd_mirror_link_what =
4990 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4991 what, "uplink-mirror#downlink-mirror");
4992 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4993 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4994 dstpool, "dst-pool");
4995 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4996 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4998 cmdline_parse_token_string_t cmd_mirror_link_on =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5003 cmd_set_mirror_link_parsed(void *parsed_result,
5004 __attribute__((unused)) struct cmdline *cl,
5005 __attribute__((unused)) void *data)
5008 struct cmd_set_mirror_link_result *res = parsed_result;
5009 struct rte_eth_vmdq_mirror_conf mr_conf;
5011 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5012 if(!strcmp(res->what, "uplink-mirror")) {
5013 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5014 }else if(!strcmp(res->what, "downlink-mirror"))
5015 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5017 mr_conf.dst_pool = res->dstpool_id;
5019 if(!strcmp(res->on, "on"))
5020 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5023 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5026 /* check the return value and print it if is < 0 */
5028 printf("mirror rule add error: (%s)\n", strerror(-ret));
5032 cmdline_parse_inst_t cmd_set_mirror_link = {
5033 .f = cmd_set_mirror_link_parsed,
5035 .help_str = "set port X mirror-rule Y uplink-mirror|"
5036 "downlink-mirror dst-pool Z on|off",
5038 (void *)&cmd_mirror_link_set,
5039 (void *)&cmd_mirror_link_port,
5040 (void *)&cmd_mirror_link_portid,
5041 (void *)&cmd_mirror_link_mirror,
5042 (void *)&cmd_mirror_link_ruleid,
5043 (void *)&cmd_mirror_link_what,
5044 (void *)&cmd_mirror_link_dstpool,
5045 (void *)&cmd_mirror_link_poolid,
5046 (void *)&cmd_mirror_link_on,
5051 /* *** RESET VM MIRROR RULE *** */
5052 struct cmd_rm_mirror_rule_result {
5053 cmdline_fixed_string_t reset;
5054 cmdline_fixed_string_t port;
5056 cmdline_fixed_string_t mirror;
5060 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5061 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5063 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5064 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5066 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5067 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5069 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5070 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5071 mirror, "mirror-rule");
5072 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5073 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5077 cmd_reset_mirror_rule_parsed(void *parsed_result,
5078 __attribute__((unused)) struct cmdline *cl,
5079 __attribute__((unused)) void *data)
5082 struct cmd_set_mirror_link_result *res = parsed_result;
5084 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5086 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5089 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5090 .f = cmd_reset_mirror_rule_parsed,
5092 .help_str = "reset port X mirror-rule Y",
5094 (void *)&cmd_rm_mirror_rule_reset,
5095 (void *)&cmd_rm_mirror_rule_port,
5096 (void *)&cmd_rm_mirror_rule_portid,
5097 (void *)&cmd_rm_mirror_rule_mirror,
5098 (void *)&cmd_rm_mirror_rule_ruleid,
5103 /* ******************************************************************************** */
5105 struct cmd_dump_result {
5106 cmdline_fixed_string_t dump;
5110 dump_struct_sizes(void)
5112 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5113 DUMP_SIZE(struct rte_mbuf);
5114 DUMP_SIZE(struct rte_pktmbuf);
5115 DUMP_SIZE(struct rte_ctrlmbuf);
5116 DUMP_SIZE(struct rte_mempool);
5117 DUMP_SIZE(struct rte_ring);
5121 static void cmd_dump_parsed(void *parsed_result,
5122 __attribute__((unused)) struct cmdline *cl,
5123 __attribute__((unused)) void *data)
5125 struct cmd_dump_result *res = parsed_result;
5127 if (!strcmp(res->dump, "dump_physmem"))
5128 rte_dump_physmem_layout(stdout);
5129 else if (!strcmp(res->dump, "dump_memzone"))
5130 rte_memzone_dump(stdout);
5131 else if (!strcmp(res->dump, "dump_log_history"))
5132 rte_log_dump_history(stdout);
5133 else if (!strcmp(res->dump, "dump_struct_sizes"))
5134 dump_struct_sizes();
5135 else if (!strcmp(res->dump, "dump_ring"))
5136 rte_ring_list_dump(stdout);
5137 else if (!strcmp(res->dump, "dump_mempool"))
5138 rte_mempool_list_dump(stdout);
5139 else if (!strcmp(res->dump, "dump_devargs"))
5140 rte_eal_devargs_dump(stdout);
5143 cmdline_parse_token_string_t cmd_dump_dump =
5144 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5148 "dump_struct_sizes#"
5153 cmdline_parse_inst_t cmd_dump = {
5154 .f = cmd_dump_parsed, /* function to call */
5155 .data = NULL, /* 2nd arg of func */
5156 .help_str = "dump status",
5157 .tokens = { /* token list, NULL terminated */
5158 (void *)&cmd_dump_dump,
5163 /* ******************************************************************************** */
5165 struct cmd_dump_one_result {
5166 cmdline_fixed_string_t dump;
5167 cmdline_fixed_string_t name;
5170 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5171 __attribute__((unused)) void *data)
5173 struct cmd_dump_one_result *res = parsed_result;
5175 if (!strcmp(res->dump, "dump_ring")) {
5177 r = rte_ring_lookup(res->name);
5179 cmdline_printf(cl, "Cannot find ring\n");
5182 rte_ring_dump(stdout, r);
5183 } else if (!strcmp(res->dump, "dump_mempool")) {
5184 struct rte_mempool *mp;
5185 mp = rte_mempool_lookup(res->name);
5187 cmdline_printf(cl, "Cannot find mempool\n");
5190 rte_mempool_dump(stdout, mp);
5194 cmdline_parse_token_string_t cmd_dump_one_dump =
5195 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5196 "dump_ring#dump_mempool");
5198 cmdline_parse_token_string_t cmd_dump_one_name =
5199 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5201 cmdline_parse_inst_t cmd_dump_one = {
5202 .f = cmd_dump_one_parsed, /* function to call */
5203 .data = NULL, /* 2nd arg of func */
5204 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5205 .tokens = { /* token list, NULL terminated */
5206 (void *)&cmd_dump_one_dump,
5207 (void *)&cmd_dump_one_name,
5212 /* ******************************************************************************** */
5214 /* list of instructions */
5215 cmdline_parse_ctx_t main_ctx[] = {
5216 (cmdline_parse_inst_t *)&cmd_help_brief,
5217 (cmdline_parse_inst_t *)&cmd_help_long,
5218 (cmdline_parse_inst_t *)&cmd_quit,
5219 (cmdline_parse_inst_t *)&cmd_showport,
5220 (cmdline_parse_inst_t *)&cmd_showportall,
5221 (cmdline_parse_inst_t *)&cmd_showcfg,
5222 (cmdline_parse_inst_t *)&cmd_start,
5223 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5224 (cmdline_parse_inst_t *)&cmd_reset,
5225 (cmdline_parse_inst_t *)&cmd_set_numbers,
5226 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5227 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5228 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5229 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5230 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5231 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5232 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5233 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5234 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5235 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5236 (cmdline_parse_inst_t *)&cmd_set_link_check,
5237 #ifdef RTE_NIC_BYPASS
5238 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5239 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5240 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5241 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5243 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5244 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5245 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5246 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5247 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5248 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5249 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5250 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5251 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5252 (cmdline_parse_inst_t *)&cmd_config_dcb,
5253 (cmdline_parse_inst_t *)&cmd_read_reg,
5254 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5255 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5256 (cmdline_parse_inst_t *)&cmd_write_reg,
5257 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5258 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5259 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5260 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5261 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5262 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5263 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5264 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5265 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5266 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5267 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5268 (cmdline_parse_inst_t *)&cmd_stop,
5269 (cmdline_parse_inst_t *)&cmd_mac_addr,
5270 (cmdline_parse_inst_t *)&cmd_set_qmap,
5271 (cmdline_parse_inst_t *)&cmd_operate_port,
5272 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5273 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5274 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5275 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5276 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5277 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5278 (cmdline_parse_inst_t *)&cmd_config_rss,
5279 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5280 (cmdline_parse_inst_t *)&cmd_showport_reta,
5281 (cmdline_parse_inst_t *)&cmd_config_burst,
5282 (cmdline_parse_inst_t *)&cmd_config_thresh,
5283 (cmdline_parse_inst_t *)&cmd_config_threshold,
5284 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5285 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5286 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5287 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5288 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5289 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5290 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5291 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5292 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5293 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
5294 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
5295 (cmdline_parse_inst_t *)&cmd_dump,
5296 (cmdline_parse_inst_t *)&cmd_dump_one,
5300 /* prompt function, called from main on MASTER lcore */
5306 /* initialize non-constant commands */
5307 cmd_set_fwd_mode_init();
5309 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5313 cmdline_interact(cl);
5314 cmdline_stdin_exit(cl);
5318 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5320 if (id < nb_ports) {
5321 /* check if need_reconfig has been set to 1 */
5322 if (ports[id].need_reconfig == 0)
5323 ports[id].need_reconfig = dev;
5324 /* check if need_reconfig_queues has been set to 1 */
5325 if (ports[id].need_reconfig_queues == 0)
5326 ports[id].need_reconfig_queues = queue;
5330 for (pid = 0; pid < nb_ports; pid++) {
5331 /* check if need_reconfig has been set to 1 */
5332 if (ports[pid].need_reconfig == 0)
5333 ports[pid].need_reconfig = dev;
5334 /* check if need_reconfig_queues has been set to 1 */
5335 if (ports[pid].need_reconfig_queues == 0)
5336 ports[pid].need_reconfig_queues = queue;
5341 #ifdef RTE_NIC_BYPASS
5343 bypass_is_supported(portid_t port_id)
5345 struct rte_port *port;
5346 struct rte_pci_id *pci_id;
5348 if (port_id >= nb_ports) {
5349 printf("\tPort id must be less than %d.\n", nb_ports);
5353 /* Get the device id. */
5354 port = &ports[port_id];
5355 pci_id = &port->dev_info.pci_dev->id;
5357 /* Check if NIC supports bypass. */
5358 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5362 printf("\tBypass not supported for port_id = %d.\n", port_id);