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 hash key *** */
1175 struct cmd_config_rss_hash_key {
1176 cmdline_fixed_string_t port;
1177 cmdline_fixed_string_t config;
1179 cmdline_fixed_string_t rss_hash_key;
1180 cmdline_fixed_string_t key;
1183 #define RSS_HASH_KEY_LENGTH 40
1185 hexa_digit_to_value(char hexa_digit)
1187 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1188 return (uint8_t) (hexa_digit - '0');
1189 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1190 return (uint8_t) ((hexa_digit - 'a') + 10);
1191 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1192 return (uint8_t) ((hexa_digit - 'A') + 10);
1193 /* Invalid hexa digit */
1198 parse_and_check_key_hexa_digit(char *key, int idx)
1202 hexa_v = hexa_digit_to_value(key[idx]);
1204 printf("invalid key: character %c at position %d is not a "
1205 "valid hexa digit\n", key[idx], idx);
1210 cmd_config_rss_hash_key_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1214 struct cmd_config_rss_hash_key *res = parsed_result;
1215 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1220 /* Check the length of the RSS hash key */
1221 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1222 printf("key length: %d invalid - key must be a string of %d"
1223 "hexa-decimal numbers\n", (int) strlen(res->key),
1224 RSS_HASH_KEY_LENGTH * 2);
1227 /* Translate RSS hash key into binary representation */
1228 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1229 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1232 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1235 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1237 port_rss_hash_key_update(res->port_id, hash_key);
1240 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1241 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1242 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1243 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1245 cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
1246 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1247 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1249 rss_hash_key, "rss-hash-key");
1250 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1251 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1253 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1254 .f = cmd_config_rss_hash_key_parsed,
1256 .help_str = "port config X rss-hash-key 80 hexa digits",
1258 (void *)&cmd_config_rss_hash_key_port,
1259 (void *)&cmd_config_rss_hash_key_config,
1260 (void *)&cmd_config_rss_hash_key_port_id,
1261 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1262 (void *)&cmd_config_rss_hash_key_value,
1267 /* *** Configure RSS RETA *** */
1268 struct cmd_config_rss_reta {
1269 cmdline_fixed_string_t port;
1270 cmdline_fixed_string_t keyword;
1272 cmdline_fixed_string_t name;
1273 cmdline_fixed_string_t list_name;
1274 cmdline_fixed_string_t list_of_items;
1278 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1285 const char *p, *p0 = str;
1292 unsigned long int_fld[_NUM_FLD];
1293 char *str_fld[_NUM_FLD];
1295 while ((p = strchr(p0,'(')) != NULL) {
1297 if((p0 = strchr(p,')')) == NULL)
1301 if(size >= sizeof(s))
1304 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1305 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1307 for (i = 0; i < _NUM_FLD; i++) {
1309 int_fld[i] = strtoul(str_fld[i], &end, 0);
1310 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1314 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1315 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1317 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1318 printf("Invalid RETA hash index=%d",hash_index);
1322 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1323 reta_conf->mask_lo |= (1ULL << hash_index);
1325 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1327 reta_conf->reta[hash_index] = nb_queue;
1334 cmd_set_rss_reta_parsed(void *parsed_result,
1335 __attribute__((unused)) struct cmdline *cl,
1336 __attribute__((unused)) void *data)
1339 struct rte_eth_rss_reta reta_conf;
1340 struct cmd_config_rss_reta *res = parsed_result;
1342 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1343 if (!strcmp(res->list_name, "reta")) {
1344 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1345 printf("Invalid RSS Redirection Table config entered\n");
1348 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1350 printf("Bad redirection table parameter, return code = %d \n",ret);
1354 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1355 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1356 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1357 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1358 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1359 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1360 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1362 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1363 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1364 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1365 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1367 cmdline_parse_inst_t cmd_config_rss_reta = {
1368 .f = cmd_set_rss_reta_parsed,
1370 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1372 (void *)&cmd_config_rss_reta_port,
1373 (void *)&cmd_config_rss_reta_keyword,
1374 (void *)&cmd_config_rss_reta_port_id,
1375 (void *)&cmd_config_rss_reta_name,
1376 (void *)&cmd_config_rss_reta_list_name,
1377 (void *)&cmd_config_rss_reta_list_of_items,
1382 /* *** SHOW PORT RETA INFO *** */
1383 struct cmd_showport_reta {
1384 cmdline_fixed_string_t show;
1385 cmdline_fixed_string_t port;
1387 cmdline_fixed_string_t rss;
1388 cmdline_fixed_string_t reta;
1393 static void cmd_showport_reta_parsed(void *parsed_result,
1394 __attribute__((unused)) struct cmdline *cl,
1395 __attribute__((unused)) void *data)
1397 struct cmd_showport_reta *res = parsed_result;
1398 struct rte_eth_rss_reta reta_conf;
1400 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1401 printf("Invalid RSS Redirection Table config entered\n");
1405 reta_conf.mask_lo = res->mask_lo;
1406 reta_conf.mask_hi = res->mask_hi;
1408 port_rss_reta_info(res->port_id,&reta_conf);
1411 cmdline_parse_token_string_t cmd_showport_reta_show =
1412 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1413 cmdline_parse_token_string_t cmd_showport_reta_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1415 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1416 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1417 cmdline_parse_token_string_t cmd_showport_reta_rss =
1418 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1419 cmdline_parse_token_string_t cmd_showport_reta_reta =
1420 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1421 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1422 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1423 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1424 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1426 cmdline_parse_inst_t cmd_showport_reta = {
1427 .f = cmd_showport_reta_parsed,
1429 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1430 (mask_lo and mask_hi is UINT64)",
1432 (void *)&cmd_showport_reta_show,
1433 (void *)&cmd_showport_reta_port,
1434 (void *)&cmd_showport_reta_port_id,
1435 (void *)&cmd_showport_reta_rss,
1436 (void *)&cmd_showport_reta_reta,
1437 (void *)&cmd_showport_reta_mask_lo,
1438 (void *)&cmd_showport_reta_mask_hi,
1443 /* *** Show RSS hash configuration *** */
1444 struct cmd_showport_rss_hash {
1445 cmdline_fixed_string_t show;
1446 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t rss_hash;
1449 cmdline_fixed_string_t key; /* optional argument */
1452 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1456 struct cmd_showport_rss_hash *res = parsed_result;
1458 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1461 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1462 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1463 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1464 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1465 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1466 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1467 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1468 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1470 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1471 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1473 cmdline_parse_inst_t cmd_showport_rss_hash = {
1474 .f = cmd_showport_rss_hash_parsed,
1476 .help_str = "show port X rss-hash (X = port number)\n",
1478 (void *)&cmd_showport_rss_hash_show,
1479 (void *)&cmd_showport_rss_hash_port,
1480 (void *)&cmd_showport_rss_hash_port_id,
1481 (void *)&cmd_showport_rss_hash_rss_hash,
1486 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1487 .f = cmd_showport_rss_hash_parsed,
1489 .help_str = "show port X rss-hash key (X = port number)\n",
1491 (void *)&cmd_showport_rss_hash_show,
1492 (void *)&cmd_showport_rss_hash_port,
1493 (void *)&cmd_showport_rss_hash_port_id,
1494 (void *)&cmd_showport_rss_hash_rss_hash,
1495 (void *)&cmd_showport_rss_hash_rss_key,
1500 /* *** Configure DCB *** */
1501 struct cmd_config_dcb {
1502 cmdline_fixed_string_t port;
1503 cmdline_fixed_string_t config;
1505 cmdline_fixed_string_t dcb;
1506 cmdline_fixed_string_t vt;
1507 cmdline_fixed_string_t vt_en;
1509 cmdline_fixed_string_t pfc;
1510 cmdline_fixed_string_t pfc_en;
1514 cmd_config_dcb_parsed(void *parsed_result,
1515 __attribute__((unused)) struct cmdline *cl,
1516 __attribute__((unused)) void *data)
1518 struct cmd_config_dcb *res = parsed_result;
1519 struct dcb_config dcb_conf;
1520 portid_t port_id = res->port_id;
1521 struct rte_port *port;
1523 port = &ports[port_id];
1524 /** Check if the port is not started **/
1525 if (port->port_status != RTE_PORT_STOPPED) {
1526 printf("Please stop port %d first\n",port_id);
1530 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1531 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1532 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1536 /* DCB in VT mode */
1537 if (!strncmp(res->vt_en, "on",2))
1538 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1540 dcb_conf.dcb_mode = DCB_ENABLED;
1542 if (!strncmp(res->pfc_en, "on",2)) {
1543 dcb_conf.pfc_en = 1;
1546 dcb_conf.pfc_en = 0;
1548 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1549 printf("Cannot initialize network ports\n");
1553 cmd_reconfig_device_queue(port_id, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_dcb_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1558 cmdline_parse_token_string_t cmd_config_dcb_config =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1560 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1561 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1562 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1564 cmdline_parse_token_string_t cmd_config_dcb_vt =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1566 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1568 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1569 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1570 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1572 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1575 cmdline_parse_inst_t cmd_config_dcb = {
1576 .f = cmd_config_dcb_parsed,
1578 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1580 (void *)&cmd_config_dcb_port,
1581 (void *)&cmd_config_dcb_config,
1582 (void *)&cmd_config_dcb_port_id,
1583 (void *)&cmd_config_dcb_dcb,
1584 (void *)&cmd_config_dcb_vt,
1585 (void *)&cmd_config_dcb_vt_en,
1586 (void *)&cmd_config_dcb_num_tcs,
1587 (void *)&cmd_config_dcb_pfc,
1588 (void *)&cmd_config_dcb_pfc_en,
1593 /* *** configure number of packets per burst *** */
1594 struct cmd_config_burst {
1595 cmdline_fixed_string_t port;
1596 cmdline_fixed_string_t keyword;
1597 cmdline_fixed_string_t all;
1598 cmdline_fixed_string_t name;
1603 cmd_config_burst_parsed(void *parsed_result,
1604 __attribute__((unused)) struct cmdline *cl,
1605 __attribute__((unused)) void *data)
1607 struct cmd_config_burst *res = parsed_result;
1609 if (!all_ports_stopped()) {
1610 printf("Please stop all ports first\n");
1614 if (!strcmp(res->name, "burst")) {
1615 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1616 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1619 nb_pkt_per_burst = res->value;
1621 printf("Unknown parameter\n");
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_burst_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1632 cmdline_parse_token_string_t cmd_config_burst_keyword =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1634 cmdline_parse_token_string_t cmd_config_burst_all =
1635 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1636 cmdline_parse_token_string_t cmd_config_burst_name =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1638 cmdline_parse_token_num_t cmd_config_burst_value =
1639 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1641 cmdline_parse_inst_t cmd_config_burst = {
1642 .f = cmd_config_burst_parsed,
1644 .help_str = "port config all burst value",
1646 (void *)&cmd_config_burst_port,
1647 (void *)&cmd_config_burst_keyword,
1648 (void *)&cmd_config_burst_all,
1649 (void *)&cmd_config_burst_name,
1650 (void *)&cmd_config_burst_value,
1655 /* *** configure rx/tx queues *** */
1656 struct cmd_config_thresh {
1657 cmdline_fixed_string_t port;
1658 cmdline_fixed_string_t keyword;
1659 cmdline_fixed_string_t all;
1660 cmdline_fixed_string_t name;
1665 cmd_config_thresh_parsed(void *parsed_result,
1666 __attribute__((unused)) struct cmdline *cl,
1667 __attribute__((unused)) void *data)
1669 struct cmd_config_thresh *res = parsed_result;
1671 if (!all_ports_stopped()) {
1672 printf("Please stop all ports first\n");
1676 if (!strcmp(res->name, "txpt"))
1677 tx_thresh.pthresh = res->value;
1678 else if(!strcmp(res->name, "txht"))
1679 tx_thresh.hthresh = res->value;
1680 else if(!strcmp(res->name, "txwt"))
1681 tx_thresh.wthresh = res->value;
1682 else if(!strcmp(res->name, "rxpt"))
1683 rx_thresh.pthresh = res->value;
1684 else if(!strcmp(res->name, "rxht"))
1685 rx_thresh.hthresh = res->value;
1686 else if(!strcmp(res->name, "rxwt"))
1687 rx_thresh.wthresh = res->value;
1689 printf("Unknown parameter\n");
1695 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1698 cmdline_parse_token_string_t cmd_config_thresh_port =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1700 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1702 cmdline_parse_token_string_t cmd_config_thresh_all =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1704 cmdline_parse_token_string_t cmd_config_thresh_name =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1706 "txpt#txht#txwt#rxpt#rxht#rxwt");
1707 cmdline_parse_token_num_t cmd_config_thresh_value =
1708 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1710 cmdline_parse_inst_t cmd_config_thresh = {
1711 .f = cmd_config_thresh_parsed,
1713 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1715 (void *)&cmd_config_thresh_port,
1716 (void *)&cmd_config_thresh_keyword,
1717 (void *)&cmd_config_thresh_all,
1718 (void *)&cmd_config_thresh_name,
1719 (void *)&cmd_config_thresh_value,
1724 /* *** configure free/rs threshold *** */
1725 struct cmd_config_threshold {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t keyword;
1728 cmdline_fixed_string_t all;
1729 cmdline_fixed_string_t name;
1734 cmd_config_threshold_parsed(void *parsed_result,
1735 __attribute__((unused)) struct cmdline *cl,
1736 __attribute__((unused)) void *data)
1738 struct cmd_config_threshold *res = parsed_result;
1740 if (!all_ports_stopped()) {
1741 printf("Please stop all ports first\n");
1745 if (!strcmp(res->name, "txfreet"))
1746 tx_free_thresh = res->value;
1747 else if (!strcmp(res->name, "txrst"))
1748 tx_rs_thresh = res->value;
1749 else if (!strcmp(res->name, "rxfreet"))
1750 rx_free_thresh = res->value;
1752 printf("Unknown parameter\n");
1758 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1761 cmdline_parse_token_string_t cmd_config_threshold_port =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1763 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1766 cmdline_parse_token_string_t cmd_config_threshold_all =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1768 cmdline_parse_token_string_t cmd_config_threshold_name =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1770 "txfreet#txrst#rxfreet");
1771 cmdline_parse_token_num_t cmd_config_threshold_value =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1774 cmdline_parse_inst_t cmd_config_threshold = {
1775 .f = cmd_config_threshold_parsed,
1777 .help_str = "port config all txfreet|txrst|rxfreet value",
1779 (void *)&cmd_config_threshold_port,
1780 (void *)&cmd_config_threshold_keyword,
1781 (void *)&cmd_config_threshold_all,
1782 (void *)&cmd_config_threshold_name,
1783 (void *)&cmd_config_threshold_value,
1789 struct cmd_stop_result {
1790 cmdline_fixed_string_t stop;
1793 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1794 __attribute__((unused)) struct cmdline *cl,
1795 __attribute__((unused)) void *data)
1797 stop_packet_forwarding();
1800 cmdline_parse_token_string_t cmd_stop_stop =
1801 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1803 cmdline_parse_inst_t cmd_stop = {
1804 .f = cmd_stop_parsed,
1806 .help_str = "stop - stop packet forwarding",
1808 (void *)&cmd_stop_stop,
1813 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1816 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1817 unsigned int *parsed_items, int check_unique_values)
1819 unsigned int nb_item;
1827 * First parse all items in the list and store their value.
1832 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1834 if ((c >= '0') && (c <= '9')) {
1835 value = (unsigned int) (value * 10 + (c - '0'));
1840 printf("character %c is not a decimal digit\n", c);
1844 printf("No valid value before comma\n");
1847 if (nb_item < max_items) {
1848 parsed_items[nb_item] = value;
1854 if (nb_item >= max_items) {
1855 printf("Number of %s = %u > %u (maximum items)\n",
1856 item_name, nb_item + 1, max_items);
1859 parsed_items[nb_item++] = value;
1860 if (! check_unique_values)
1864 * Then, check that all values in the list are differents.
1865 * No optimization here...
1867 for (i = 0; i < nb_item; i++) {
1868 for (j = i + 1; j < nb_item; j++) {
1869 if (parsed_items[j] == parsed_items[i]) {
1870 printf("duplicated %s %u at index %u and %u\n",
1871 item_name, parsed_items[i], i, j);
1879 struct cmd_set_list_result {
1880 cmdline_fixed_string_t cmd_keyword;
1881 cmdline_fixed_string_t list_name;
1882 cmdline_fixed_string_t list_of_items;
1885 static void cmd_set_list_parsed(void *parsed_result,
1886 __attribute__((unused)) struct cmdline *cl,
1887 __attribute__((unused)) void *data)
1889 struct cmd_set_list_result *res;
1891 unsigned int lcorelist[RTE_MAX_LCORE];
1892 unsigned int portlist[RTE_MAX_ETHPORTS];
1894 unsigned int nb_item;
1896 res = parsed_result;
1897 if (!strcmp(res->list_name, "corelist")) {
1898 nb_item = parse_item_list(res->list_of_items, "core",
1900 parsed_items.lcorelist, 1);
1902 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1905 if (!strcmp(res->list_name, "portlist")) {
1906 nb_item = parse_item_list(res->list_of_items, "port",
1908 parsed_items.portlist, 1);
1910 set_fwd_ports_list(parsed_items.portlist, nb_item);
1914 cmdline_parse_token_string_t cmd_set_list_keyword =
1915 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1917 cmdline_parse_token_string_t cmd_set_list_name =
1918 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1919 "corelist#portlist");
1920 cmdline_parse_token_string_t cmd_set_list_of_items =
1921 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1924 cmdline_parse_inst_t cmd_set_fwd_list = {
1925 .f = cmd_set_list_parsed,
1927 .help_str = "set corelist|portlist x[,y]*",
1929 (void *)&cmd_set_list_keyword,
1930 (void *)&cmd_set_list_name,
1931 (void *)&cmd_set_list_of_items,
1936 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1938 struct cmd_setmask_result {
1939 cmdline_fixed_string_t set;
1940 cmdline_fixed_string_t mask;
1944 static void cmd_set_mask_parsed(void *parsed_result,
1945 __attribute__((unused)) struct cmdline *cl,
1946 __attribute__((unused)) void *data)
1948 struct cmd_setmask_result *res = parsed_result;
1950 if (!strcmp(res->mask, "coremask"))
1951 set_fwd_lcores_mask(res->hexavalue);
1952 else if (!strcmp(res->mask, "portmask"))
1953 set_fwd_ports_mask(res->hexavalue);
1956 cmdline_parse_token_string_t cmd_setmask_set =
1957 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1958 cmdline_parse_token_string_t cmd_setmask_mask =
1959 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1960 "coremask#portmask");
1961 cmdline_parse_token_num_t cmd_setmask_value =
1962 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1964 cmdline_parse_inst_t cmd_set_fwd_mask = {
1965 .f = cmd_set_mask_parsed,
1967 .help_str = "set coremask|portmask hexadecimal value",
1969 (void *)&cmd_setmask_set,
1970 (void *)&cmd_setmask_mask,
1971 (void *)&cmd_setmask_value,
1977 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1979 struct cmd_set_result {
1980 cmdline_fixed_string_t set;
1981 cmdline_fixed_string_t what;
1985 static void cmd_set_parsed(void *parsed_result,
1986 __attribute__((unused)) struct cmdline *cl,
1987 __attribute__((unused)) void *data)
1989 struct cmd_set_result *res = parsed_result;
1990 if (!strcmp(res->what, "nbport"))
1991 set_fwd_ports_number(res->value);
1992 else if (!strcmp(res->what, "nbcore"))
1993 set_fwd_lcores_number(res->value);
1994 else if (!strcmp(res->what, "burst"))
1995 set_nb_pkt_per_burst(res->value);
1996 else if (!strcmp(res->what, "verbose"))
1997 set_verbose_level(res->value);
2000 cmdline_parse_token_string_t cmd_set_set =
2001 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2002 cmdline_parse_token_string_t cmd_set_what =
2003 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2004 "nbport#nbcore#burst#verbose");
2005 cmdline_parse_token_num_t cmd_set_value =
2006 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2008 cmdline_parse_inst_t cmd_set_numbers = {
2009 .f = cmd_set_parsed,
2011 .help_str = "set nbport|nbcore|burst|verbose value",
2013 (void *)&cmd_set_set,
2014 (void *)&cmd_set_what,
2015 (void *)&cmd_set_value,
2020 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2022 struct cmd_set_txpkts_result {
2023 cmdline_fixed_string_t cmd_keyword;
2024 cmdline_fixed_string_t txpkts;
2025 cmdline_fixed_string_t seg_lengths;
2029 cmd_set_txpkts_parsed(void *parsed_result,
2030 __attribute__((unused)) struct cmdline *cl,
2031 __attribute__((unused)) void *data)
2033 struct cmd_set_txpkts_result *res;
2034 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2035 unsigned int nb_segs;
2037 res = parsed_result;
2038 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2039 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2041 set_tx_pkt_segments(seg_lengths, nb_segs);
2044 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2045 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2046 cmd_keyword, "set");
2047 cmdline_parse_token_string_t cmd_set_txpkts_name =
2048 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2050 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2051 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2054 cmdline_parse_inst_t cmd_set_txpkts = {
2055 .f = cmd_set_txpkts_parsed,
2057 .help_str = "set txpkts x[,y]*",
2059 (void *)&cmd_set_txpkts_keyword,
2060 (void *)&cmd_set_txpkts_name,
2061 (void *)&cmd_set_txpkts_lengths,
2066 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2067 struct cmd_rx_vlan_filter_all_result {
2068 cmdline_fixed_string_t rx_vlan;
2069 cmdline_fixed_string_t what;
2070 cmdline_fixed_string_t all;
2075 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2076 __attribute__((unused)) struct cmdline *cl,
2077 __attribute__((unused)) void *data)
2079 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2081 if (!strcmp(res->what, "add"))
2082 rx_vlan_all_filter_set(res->port_id, 1);
2084 rx_vlan_all_filter_set(res->port_id, 0);
2087 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2088 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2089 rx_vlan, "rx_vlan");
2090 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2091 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2093 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2094 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2096 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2097 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2100 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2101 .f = cmd_rx_vlan_filter_all_parsed,
2103 .help_str = "add/remove all identifiers to/from the set of VLAN "
2104 "Identifiers filtered by a port",
2106 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2107 (void *)&cmd_rx_vlan_filter_all_what,
2108 (void *)&cmd_rx_vlan_filter_all_all,
2109 (void *)&cmd_rx_vlan_filter_all_portid,
2114 /* *** VLAN OFFLOAD SET ON A PORT *** */
2115 struct cmd_vlan_offload_result {
2116 cmdline_fixed_string_t vlan;
2117 cmdline_fixed_string_t set;
2118 cmdline_fixed_string_t what;
2119 cmdline_fixed_string_t on;
2120 cmdline_fixed_string_t port_id;
2124 cmd_vlan_offload_parsed(void *parsed_result,
2125 __attribute__((unused)) struct cmdline *cl,
2126 __attribute__((unused)) void *data)
2129 struct cmd_vlan_offload_result *res = parsed_result;
2132 portid_t port_id = 0;
2136 len = strnlen(str, STR_TOKEN_SIZE);
2138 /* Get port_id first */
2146 tmp = strtoul(str, NULL, 0);
2147 /* If port_id greater that what portid_t can represent, return */
2148 if(tmp >= RTE_MAX_ETHPORTS)
2150 port_id = (portid_t)tmp;
2152 if (!strcmp(res->on, "on"))
2157 if (!strcmp(res->what, "strip"))
2158 rx_vlan_strip_set(port_id, on);
2159 else if(!strcmp(res->what, "stripq")){
2160 uint16_t queue_id = 0;
2162 /* No queue_id, return */
2164 printf("must specify (port,queue_id)\n");
2167 tmp = strtoul(str + i + 1, NULL, 0);
2168 /* If queue_id greater that what 16-bits can represent, return */
2172 queue_id = (uint16_t)tmp;
2173 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2175 else if (!strcmp(res->what, "filter"))
2176 rx_vlan_filter_set(port_id, on);
2178 vlan_extend_set(port_id, on);
2183 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2184 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2186 cmdline_parse_token_string_t cmd_vlan_offload_set =
2187 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2189 cmdline_parse_token_string_t cmd_vlan_offload_what =
2190 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2191 what, "strip#filter#qinq#stripq");
2192 cmdline_parse_token_string_t cmd_vlan_offload_on =
2193 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2195 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2196 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2199 cmdline_parse_inst_t cmd_vlan_offload = {
2200 .f = cmd_vlan_offload_parsed,
2202 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2203 " qinq(extended) for both rx/tx sides ",
2205 (void *)&cmd_vlan_offload_vlan,
2206 (void *)&cmd_vlan_offload_set,
2207 (void *)&cmd_vlan_offload_what,
2208 (void *)&cmd_vlan_offload_on,
2209 (void *)&cmd_vlan_offload_portid,
2214 /* *** VLAN TPID SET ON A PORT *** */
2215 struct cmd_vlan_tpid_result {
2216 cmdline_fixed_string_t vlan;
2217 cmdline_fixed_string_t set;
2218 cmdline_fixed_string_t what;
2224 cmd_vlan_tpid_parsed(void *parsed_result,
2225 __attribute__((unused)) struct cmdline *cl,
2226 __attribute__((unused)) void *data)
2228 struct cmd_vlan_tpid_result *res = parsed_result;
2229 vlan_tpid_set(res->port_id, res->tp_id);
2233 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2234 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2236 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2239 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2242 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2243 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2245 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2246 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2249 cmdline_parse_inst_t cmd_vlan_tpid = {
2250 .f = cmd_vlan_tpid_parsed,
2252 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2254 (void *)&cmd_vlan_tpid_vlan,
2255 (void *)&cmd_vlan_tpid_set,
2256 (void *)&cmd_vlan_tpid_what,
2257 (void *)&cmd_vlan_tpid_tpid,
2258 (void *)&cmd_vlan_tpid_portid,
2263 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2264 struct cmd_rx_vlan_filter_result {
2265 cmdline_fixed_string_t rx_vlan;
2266 cmdline_fixed_string_t what;
2272 cmd_rx_vlan_filter_parsed(void *parsed_result,
2273 __attribute__((unused)) struct cmdline *cl,
2274 __attribute__((unused)) void *data)
2276 struct cmd_rx_vlan_filter_result *res = parsed_result;
2278 if (!strcmp(res->what, "add"))
2279 rx_vft_set(res->port_id, res->vlan_id, 1);
2281 rx_vft_set(res->port_id, res->vlan_id, 0);
2284 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2285 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2286 rx_vlan, "rx_vlan");
2287 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2288 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2290 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2291 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2293 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2294 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2297 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2298 .f = cmd_rx_vlan_filter_parsed,
2300 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2301 "Identifiers filtered by a port",
2303 (void *)&cmd_rx_vlan_filter_rx_vlan,
2304 (void *)&cmd_rx_vlan_filter_what,
2305 (void *)&cmd_rx_vlan_filter_vlanid,
2306 (void *)&cmd_rx_vlan_filter_portid,
2311 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2312 struct cmd_tx_vlan_set_result {
2313 cmdline_fixed_string_t tx_vlan;
2314 cmdline_fixed_string_t set;
2320 cmd_tx_vlan_set_parsed(void *parsed_result,
2321 __attribute__((unused)) struct cmdline *cl,
2322 __attribute__((unused)) void *data)
2324 struct cmd_tx_vlan_set_result *res = parsed_result;
2325 tx_vlan_set(res->port_id, res->vlan_id);
2328 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2329 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2330 tx_vlan, "tx_vlan");
2331 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2332 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2334 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2335 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2337 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2338 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2341 cmdline_parse_inst_t cmd_tx_vlan_set = {
2342 .f = cmd_tx_vlan_set_parsed,
2344 .help_str = "enable hardware insertion of a VLAN header with a given "
2345 "TAG Identifier in packets sent on a port",
2347 (void *)&cmd_tx_vlan_set_tx_vlan,
2348 (void *)&cmd_tx_vlan_set_set,
2349 (void *)&cmd_tx_vlan_set_vlanid,
2350 (void *)&cmd_tx_vlan_set_portid,
2355 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2356 struct cmd_tx_vlan_reset_result {
2357 cmdline_fixed_string_t tx_vlan;
2358 cmdline_fixed_string_t reset;
2363 cmd_tx_vlan_reset_parsed(void *parsed_result,
2364 __attribute__((unused)) struct cmdline *cl,
2365 __attribute__((unused)) void *data)
2367 struct cmd_tx_vlan_reset_result *res = parsed_result;
2369 tx_vlan_reset(res->port_id);
2372 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2373 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2374 tx_vlan, "tx_vlan");
2375 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2376 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2378 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2379 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2382 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2383 .f = cmd_tx_vlan_reset_parsed,
2385 .help_str = "disable hardware insertion of a VLAN header in packets "
2388 (void *)&cmd_tx_vlan_reset_tx_vlan,
2389 (void *)&cmd_tx_vlan_reset_reset,
2390 (void *)&cmd_tx_vlan_reset_portid,
2396 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2397 struct cmd_tx_cksum_set_result {
2398 cmdline_fixed_string_t tx_cksum;
2399 cmdline_fixed_string_t set;
2405 cmd_tx_cksum_set_parsed(void *parsed_result,
2406 __attribute__((unused)) struct cmdline *cl,
2407 __attribute__((unused)) void *data)
2409 struct cmd_tx_cksum_set_result *res = parsed_result;
2411 tx_cksum_set(res->port_id, res->cksum_mask);
2414 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2415 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2416 tx_cksum, "tx_checksum");
2417 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2418 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2420 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2421 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2423 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2424 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2427 cmdline_parse_inst_t cmd_tx_cksum_set = {
2428 .f = cmd_tx_cksum_set_parsed,
2430 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2431 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2432 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2434 (void *)&cmd_tx_cksum_set_tx_cksum,
2435 (void *)&cmd_tx_cksum_set_set,
2436 (void *)&cmd_tx_cksum_set_cksum_mask,
2437 (void *)&cmd_tx_cksum_set_portid,
2442 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2443 struct cmd_set_flush_rx {
2444 cmdline_fixed_string_t set;
2445 cmdline_fixed_string_t flush_rx;
2446 cmdline_fixed_string_t mode;
2450 cmd_set_flush_rx_parsed(void *parsed_result,
2451 __attribute__((unused)) struct cmdline *cl,
2452 __attribute__((unused)) void *data)
2454 struct cmd_set_flush_rx *res = parsed_result;
2455 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2458 cmdline_parse_token_string_t cmd_setflushrx_set =
2459 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2461 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2462 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2463 flush_rx, "flush_rx");
2464 cmdline_parse_token_string_t cmd_setflushrx_mode =
2465 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2469 cmdline_parse_inst_t cmd_set_flush_rx = {
2470 .f = cmd_set_flush_rx_parsed,
2471 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2474 (void *)&cmd_setflushrx_set,
2475 (void *)&cmd_setflushrx_flush_rx,
2476 (void *)&cmd_setflushrx_mode,
2481 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2482 struct cmd_set_link_check {
2483 cmdline_fixed_string_t set;
2484 cmdline_fixed_string_t link_check;
2485 cmdline_fixed_string_t mode;
2489 cmd_set_link_check_parsed(void *parsed_result,
2490 __attribute__((unused)) struct cmdline *cl,
2491 __attribute__((unused)) void *data)
2493 struct cmd_set_link_check *res = parsed_result;
2494 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2497 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2498 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2500 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2501 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2502 link_check, "link_check");
2503 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2504 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2508 cmdline_parse_inst_t cmd_set_link_check = {
2509 .f = cmd_set_link_check_parsed,
2510 .help_str = "set link_check on|off: enable/disable link status check "
2511 "when starting/stopping a port",
2514 (void *)&cmd_setlinkcheck_set,
2515 (void *)&cmd_setlinkcheck_link_check,
2516 (void *)&cmd_setlinkcheck_mode,
2521 #ifdef RTE_NIC_BYPASS
2522 /* *** SET NIC BYPASS MODE *** */
2523 struct cmd_set_bypass_mode_result {
2524 cmdline_fixed_string_t set;
2525 cmdline_fixed_string_t bypass;
2526 cmdline_fixed_string_t mode;
2527 cmdline_fixed_string_t value;
2532 cmd_set_bypass_mode_parsed(void *parsed_result,
2533 __attribute__((unused)) struct cmdline *cl,
2534 __attribute__((unused)) void *data)
2536 struct cmd_set_bypass_mode_result *res = parsed_result;
2537 portid_t port_id = res->port_id;
2538 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2540 if (!bypass_is_supported(port_id))
2543 if (!strcmp(res->value, "bypass"))
2544 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2545 else if (!strcmp(res->value, "isolate"))
2546 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2548 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2550 /* Set the bypass mode for the relevant port. */
2551 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2552 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2556 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2559 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2560 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2562 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2563 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2565 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2566 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2567 value, "normal#bypass#isolate");
2568 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2569 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2572 cmdline_parse_inst_t cmd_set_bypass_mode = {
2573 .f = cmd_set_bypass_mode_parsed,
2574 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2575 "Set the NIC bypass mode for port_id",
2578 (void *)&cmd_setbypass_mode_set,
2579 (void *)&cmd_setbypass_mode_bypass,
2580 (void *)&cmd_setbypass_mode_mode,
2581 (void *)&cmd_setbypass_mode_value,
2582 (void *)&cmd_setbypass_mode_port,
2587 /* *** SET NIC BYPASS EVENT *** */
2588 struct cmd_set_bypass_event_result {
2589 cmdline_fixed_string_t set;
2590 cmdline_fixed_string_t bypass;
2591 cmdline_fixed_string_t event;
2592 cmdline_fixed_string_t event_value;
2593 cmdline_fixed_string_t mode;
2594 cmdline_fixed_string_t mode_value;
2599 cmd_set_bypass_event_parsed(void *parsed_result,
2600 __attribute__((unused)) struct cmdline *cl,
2601 __attribute__((unused)) void *data)
2604 struct cmd_set_bypass_event_result *res = parsed_result;
2605 portid_t port_id = res->port_id;
2606 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2607 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2609 if (!bypass_is_supported(port_id))
2612 if (!strcmp(res->event_value, "timeout"))
2613 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2614 else if (!strcmp(res->event_value, "os_on"))
2615 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2616 else if (!strcmp(res->event_value, "os_off"))
2617 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2618 else if (!strcmp(res->event_value, "power_on"))
2619 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2620 else if (!strcmp(res->event_value, "power_off"))
2621 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2623 bypass_event = RTE_BYPASS_EVENT_NONE;
2625 if (!strcmp(res->mode_value, "bypass"))
2626 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2627 else if (!strcmp(res->mode_value, "isolate"))
2628 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2630 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2632 /* Set the watchdog timeout. */
2633 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2636 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2637 (rc = rte_eth_dev_wd_timeout_store(port_id,
2638 bypass_timeout)) != 0) {
2639 printf("Failed to set timeout value %u "
2640 "for port %d, errto code: %d.\n",
2641 bypass_timeout, port_id, rc);
2645 /* Set the bypass event to transition to bypass mode. */
2646 if (0 != rte_eth_dev_bypass_event_store(port_id,
2647 bypass_event, bypass_mode)) {
2648 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2653 cmdline_parse_token_string_t cmd_setbypass_event_set =
2654 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2656 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2657 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2659 cmdline_parse_token_string_t cmd_setbypass_event_event =
2660 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2662 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2663 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2664 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2665 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2666 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2668 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2669 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2670 mode_value, "normal#bypass#isolate");
2671 cmdline_parse_token_num_t cmd_setbypass_event_port =
2672 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2675 cmdline_parse_inst_t cmd_set_bypass_event = {
2676 .f = cmd_set_bypass_event_parsed,
2677 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2678 "mode (normal|bypass|isolate) (port_id): "
2679 "Set the NIC bypass event mode for port_id",
2682 (void *)&cmd_setbypass_event_set,
2683 (void *)&cmd_setbypass_event_bypass,
2684 (void *)&cmd_setbypass_event_event,
2685 (void *)&cmd_setbypass_event_event_value,
2686 (void *)&cmd_setbypass_event_mode,
2687 (void *)&cmd_setbypass_event_mode_value,
2688 (void *)&cmd_setbypass_event_port,
2694 /* *** SET NIC BYPASS TIMEOUT *** */
2695 struct cmd_set_bypass_timeout_result {
2696 cmdline_fixed_string_t set;
2697 cmdline_fixed_string_t bypass;
2698 cmdline_fixed_string_t timeout;
2699 cmdline_fixed_string_t value;
2703 cmd_set_bypass_timeout_parsed(void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_set_bypass_timeout_result *res = parsed_result;
2709 if (!strcmp(res->value, "1.5"))
2710 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2711 else if (!strcmp(res->value, "2"))
2712 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2713 else if (!strcmp(res->value, "3"))
2714 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2715 else if (!strcmp(res->value, "4"))
2716 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2717 else if (!strcmp(res->value, "8"))
2718 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2719 else if (!strcmp(res->value, "16"))
2720 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2721 else if (!strcmp(res->value, "32"))
2722 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2724 bypass_timeout = RTE_BYPASS_TMT_OFF;
2727 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2728 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2730 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2731 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2733 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2734 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2735 timeout, "timeout");
2736 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2737 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2738 value, "0#1.5#2#3#4#8#16#32");
2740 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2741 .f = cmd_set_bypass_timeout_parsed,
2742 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2743 "Set the NIC bypass watchdog timeout",
2746 (void *)&cmd_setbypass_timeout_set,
2747 (void *)&cmd_setbypass_timeout_bypass,
2748 (void *)&cmd_setbypass_timeout_timeout,
2749 (void *)&cmd_setbypass_timeout_value,
2754 /* *** SHOW NIC BYPASS MODE *** */
2755 struct cmd_show_bypass_config_result {
2756 cmdline_fixed_string_t show;
2757 cmdline_fixed_string_t bypass;
2758 cmdline_fixed_string_t config;
2763 cmd_show_bypass_config_parsed(void *parsed_result,
2764 __attribute__((unused)) struct cmdline *cl,
2765 __attribute__((unused)) void *data)
2767 struct cmd_show_bypass_config_result *res = parsed_result;
2768 uint32_t event_mode;
2769 uint32_t bypass_mode;
2770 portid_t port_id = res->port_id;
2771 uint32_t timeout = bypass_timeout;
2774 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2775 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2776 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2777 {"UNKNOWN", "normal", "bypass", "isolate"};
2778 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2785 int num_events = (sizeof events) / (sizeof events[0]);
2787 if (!bypass_is_supported(port_id))
2790 /* Display the bypass mode.*/
2791 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2792 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2796 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2797 bypass_mode = RTE_BYPASS_MODE_NONE;
2799 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2802 /* Display the bypass timeout.*/
2803 if (!RTE_BYPASS_TMT_VALID(timeout))
2804 timeout = RTE_BYPASS_TMT_OFF;
2806 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2808 /* Display the bypass events and associated modes. */
2809 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2811 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2812 printf("\tFailed to get bypass mode for event = %s\n",
2815 if (!RTE_BYPASS_MODE_VALID(event_mode))
2816 event_mode = RTE_BYPASS_MODE_NONE;
2818 printf("\tbypass event: %-16s = %s\n", events[i],
2824 cmdline_parse_token_string_t cmd_showbypass_config_show =
2825 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2827 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2828 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2830 cmdline_parse_token_string_t cmd_showbypass_config_config =
2831 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2833 cmdline_parse_token_num_t cmd_showbypass_config_port =
2834 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2837 cmdline_parse_inst_t cmd_show_bypass_config = {
2838 .f = cmd_show_bypass_config_parsed,
2839 .help_str = "show bypass config (port_id): "
2840 "Show the NIC bypass config for port_id",
2843 (void *)&cmd_showbypass_config_show,
2844 (void *)&cmd_showbypass_config_bypass,
2845 (void *)&cmd_showbypass_config_config,
2846 (void *)&cmd_showbypass_config_port,
2852 /* *** SET FORWARDING MODE *** */
2853 struct cmd_set_fwd_mode_result {
2854 cmdline_fixed_string_t set;
2855 cmdline_fixed_string_t fwd;
2856 cmdline_fixed_string_t mode;
2859 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2860 __attribute__((unused)) struct cmdline *cl,
2861 __attribute__((unused)) void *data)
2863 struct cmd_set_fwd_mode_result *res = parsed_result;
2865 set_pkt_forwarding_mode(res->mode);
2868 cmdline_parse_token_string_t cmd_setfwd_set =
2869 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2870 cmdline_parse_token_string_t cmd_setfwd_fwd =
2871 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2872 cmdline_parse_token_string_t cmd_setfwd_mode =
2873 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2874 "" /* defined at init */);
2876 cmdline_parse_inst_t cmd_set_fwd_mode = {
2877 .f = cmd_set_fwd_mode_parsed,
2879 .help_str = NULL, /* defined at init */
2881 (void *)&cmd_setfwd_set,
2882 (void *)&cmd_setfwd_fwd,
2883 (void *)&cmd_setfwd_mode,
2888 static void cmd_set_fwd_mode_init(void)
2891 static char token[128];
2892 static char help[256];
2893 cmdline_parse_token_string_t *token_struct;
2895 modes = list_pkt_forwarding_modes();
2896 rte_snprintf(help, sizeof help, "set fwd %s - "
2897 "set packet forwarding mode", modes);
2898 cmd_set_fwd_mode.help_str = help;
2900 /* string token separator is # */
2901 for (c = token; *modes != '\0'; modes++)
2906 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2907 token_struct->string_data.str = token;
2910 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2911 struct cmd_set_burst_tx_retry_result {
2912 cmdline_fixed_string_t set;
2913 cmdline_fixed_string_t burst;
2914 cmdline_fixed_string_t tx;
2915 cmdline_fixed_string_t delay;
2917 cmdline_fixed_string_t retry;
2921 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2922 __attribute__((unused)) struct cmdline *cl,
2923 __attribute__((unused)) void *data)
2925 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2927 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2928 && !strcmp(res->tx, "tx")) {
2929 if (!strcmp(res->delay, "delay"))
2930 burst_tx_delay_time = res->time;
2931 if (!strcmp(res->retry, "retry"))
2932 burst_tx_retry_num = res->retry_num;
2937 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2938 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2939 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2940 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2942 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2943 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2944 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2945 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2946 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2947 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2948 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2949 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2950 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2951 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2953 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2954 .f = cmd_set_burst_tx_retry_parsed,
2955 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2957 (void *)&cmd_set_burst_tx_retry_set,
2958 (void *)&cmd_set_burst_tx_retry_burst,
2959 (void *)&cmd_set_burst_tx_retry_tx,
2960 (void *)&cmd_set_burst_tx_retry_delay,
2961 (void *)&cmd_set_burst_tx_retry_time,
2962 (void *)&cmd_set_burst_tx_retry_retry,
2963 (void *)&cmd_set_burst_tx_retry_retry_num,
2968 /* *** SET PROMISC MODE *** */
2969 struct cmd_set_promisc_mode_result {
2970 cmdline_fixed_string_t set;
2971 cmdline_fixed_string_t promisc;
2972 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2973 uint8_t port_num; /* valid if "allports" argument == 0 */
2974 cmdline_fixed_string_t mode;
2977 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2978 __attribute__((unused)) struct cmdline *cl,
2981 struct cmd_set_promisc_mode_result *res = parsed_result;
2985 if (!strcmp(res->mode, "on"))
2992 for (i = 0; i < nb_ports; i++) {
2994 rte_eth_promiscuous_enable(i);
2996 rte_eth_promiscuous_disable(i);
3001 rte_eth_promiscuous_enable(res->port_num);
3003 rte_eth_promiscuous_disable(res->port_num);
3007 cmdline_parse_token_string_t cmd_setpromisc_set =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3009 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3010 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3012 cmdline_parse_token_string_t cmd_setpromisc_portall =
3013 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3015 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3016 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3018 cmdline_parse_token_string_t cmd_setpromisc_mode =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3022 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3023 .f = cmd_set_promisc_mode_parsed,
3025 .help_str = "set promisc all on|off: set promisc mode for all ports",
3027 (void *)&cmd_setpromisc_set,
3028 (void *)&cmd_setpromisc_promisc,
3029 (void *)&cmd_setpromisc_portall,
3030 (void *)&cmd_setpromisc_mode,
3035 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3036 .f = cmd_set_promisc_mode_parsed,
3038 .help_str = "set promisc X on|off: set promisc mode on port X",
3040 (void *)&cmd_setpromisc_set,
3041 (void *)&cmd_setpromisc_promisc,
3042 (void *)&cmd_setpromisc_portnum,
3043 (void *)&cmd_setpromisc_mode,
3048 /* *** SET ALLMULTI MODE *** */
3049 struct cmd_set_allmulti_mode_result {
3050 cmdline_fixed_string_t set;
3051 cmdline_fixed_string_t allmulti;
3052 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3053 uint8_t port_num; /* valid if "allports" argument == 0 */
3054 cmdline_fixed_string_t mode;
3057 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3061 struct cmd_set_allmulti_mode_result *res = parsed_result;
3065 if (!strcmp(res->mode, "on"))
3072 for (i = 0; i < nb_ports; i++) {
3074 rte_eth_allmulticast_enable(i);
3076 rte_eth_allmulticast_disable(i);
3081 rte_eth_allmulticast_enable(res->port_num);
3083 rte_eth_allmulticast_disable(res->port_num);
3087 cmdline_parse_token_string_t cmd_setallmulti_set =
3088 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3089 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3090 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3092 cmdline_parse_token_string_t cmd_setallmulti_portall =
3093 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3095 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3096 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3098 cmdline_parse_token_string_t cmd_setallmulti_mode =
3099 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3102 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3103 .f = cmd_set_allmulti_mode_parsed,
3105 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3107 (void *)&cmd_setallmulti_set,
3108 (void *)&cmd_setallmulti_allmulti,
3109 (void *)&cmd_setallmulti_portall,
3110 (void *)&cmd_setallmulti_mode,
3115 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3116 .f = cmd_set_allmulti_mode_parsed,
3118 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3120 (void *)&cmd_setallmulti_set,
3121 (void *)&cmd_setallmulti_allmulti,
3122 (void *)&cmd_setallmulti_portnum,
3123 (void *)&cmd_setallmulti_mode,
3128 /* *** ADD/REMOVE A PKT FILTER *** */
3129 struct cmd_pkt_filter_result {
3130 cmdline_fixed_string_t pkt_filter;
3132 cmdline_fixed_string_t protocol;
3133 cmdline_fixed_string_t src;
3134 cmdline_ipaddr_t ip_src;
3136 cmdline_fixed_string_t dst;
3137 cmdline_ipaddr_t ip_dst;
3139 cmdline_fixed_string_t flexbytes;
3140 uint16_t flexbytes_value;
3141 cmdline_fixed_string_t vlan;
3143 cmdline_fixed_string_t queue;
3145 cmdline_fixed_string_t soft;
3150 cmd_pkt_filter_parsed(void *parsed_result,
3151 __attribute__((unused)) struct cmdline *cl,
3152 __attribute__((unused)) void *data)
3154 struct rte_fdir_filter fdir_filter;
3155 struct cmd_pkt_filter_result *res = parsed_result;
3157 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3159 if (res->ip_src.family == AF_INET)
3160 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3162 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3163 &(res->ip_src.addr.ipv6),
3164 sizeof(struct in6_addr));
3166 if (res->ip_dst.family == AF_INET)
3167 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3169 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3170 &(res->ip_dst.addr.ipv6),
3171 sizeof(struct in6_addr));
3173 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3174 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3176 if (!strcmp(res->protocol, "udp"))
3177 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3178 else if (!strcmp(res->protocol, "tcp"))
3179 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3180 else if (!strcmp(res->protocol, "sctp"))
3181 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3182 else /* default only IP */
3183 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3185 if (res->ip_dst.family == AF_INET6)
3186 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3188 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3190 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3191 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3193 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3194 fdir_add_signature_filter(res->port_id, res->queue_id,
3196 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3197 fdir_update_signature_filter(res->port_id, res->queue_id,
3199 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3200 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3201 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3202 fdir_add_perfect_filter(res->port_id, res->soft_id,
3204 (uint8_t) (res->queue_id < 0),
3206 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3207 fdir_update_perfect_filter(res->port_id, res->soft_id,
3209 (uint8_t) (res->queue_id < 0),
3211 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3212 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3218 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3221 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3222 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3223 protocol, "ip#tcp#udp#sctp");
3224 cmdline_parse_token_string_t cmd_pkt_filter_src =
3225 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3227 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3228 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3230 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3231 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3233 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3234 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3236 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3237 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3239 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3240 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3242 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3243 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3244 flexbytes, "flexbytes");
3245 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3246 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3247 flexbytes_value, UINT16);
3248 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3249 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3251 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3252 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3254 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3255 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3257 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3258 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3260 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3261 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3263 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3264 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3268 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3269 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3270 pkt_filter, "add_signature_filter");
3271 cmdline_parse_inst_t cmd_add_signature_filter = {
3272 .f = cmd_pkt_filter_parsed,
3274 .help_str = "add a signature filter",
3276 (void *)&cmd_pkt_filter_add_signature_filter,
3277 (void *)&cmd_pkt_filter_port_id,
3278 (void *)&cmd_pkt_filter_protocol,
3279 (void *)&cmd_pkt_filter_src,
3280 (void *)&cmd_pkt_filter_ip_src,
3281 (void *)&cmd_pkt_filter_port_src,
3282 (void *)&cmd_pkt_filter_dst,
3283 (void *)&cmd_pkt_filter_ip_dst,
3284 (void *)&cmd_pkt_filter_port_dst,
3285 (void *)&cmd_pkt_filter_flexbytes,
3286 (void *)&cmd_pkt_filter_flexbytes_value,
3287 (void *)&cmd_pkt_filter_vlan,
3288 (void *)&cmd_pkt_filter_vlan_id,
3289 (void *)&cmd_pkt_filter_queue,
3290 (void *)&cmd_pkt_filter_queue_id,
3296 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3297 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3298 pkt_filter, "upd_signature_filter");
3299 cmdline_parse_inst_t cmd_upd_signature_filter = {
3300 .f = cmd_pkt_filter_parsed,
3302 .help_str = "update a signature filter",
3304 (void *)&cmd_pkt_filter_upd_signature_filter,
3305 (void *)&cmd_pkt_filter_port_id,
3306 (void *)&cmd_pkt_filter_protocol,
3307 (void *)&cmd_pkt_filter_src,
3308 (void *)&cmd_pkt_filter_ip_src,
3309 (void *)&cmd_pkt_filter_port_src,
3310 (void *)&cmd_pkt_filter_dst,
3311 (void *)&cmd_pkt_filter_ip_dst,
3312 (void *)&cmd_pkt_filter_port_dst,
3313 (void *)&cmd_pkt_filter_flexbytes,
3314 (void *)&cmd_pkt_filter_flexbytes_value,
3315 (void *)&cmd_pkt_filter_vlan,
3316 (void *)&cmd_pkt_filter_vlan_id,
3317 (void *)&cmd_pkt_filter_queue,
3318 (void *)&cmd_pkt_filter_queue_id,
3324 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3325 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3326 pkt_filter, "rm_signature_filter");
3327 cmdline_parse_inst_t cmd_rm_signature_filter = {
3328 .f = cmd_pkt_filter_parsed,
3330 .help_str = "remove a signature filter",
3332 (void *)&cmd_pkt_filter_rm_signature_filter,
3333 (void *)&cmd_pkt_filter_port_id,
3334 (void *)&cmd_pkt_filter_protocol,
3335 (void *)&cmd_pkt_filter_src,
3336 (void *)&cmd_pkt_filter_ip_src,
3337 (void *)&cmd_pkt_filter_port_src,
3338 (void *)&cmd_pkt_filter_dst,
3339 (void *)&cmd_pkt_filter_ip_dst,
3340 (void *)&cmd_pkt_filter_port_dst,
3341 (void *)&cmd_pkt_filter_flexbytes,
3342 (void *)&cmd_pkt_filter_flexbytes_value,
3343 (void *)&cmd_pkt_filter_vlan,
3344 (void *)&cmd_pkt_filter_vlan_id,
3350 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3351 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3352 pkt_filter, "add_perfect_filter");
3353 cmdline_parse_inst_t cmd_add_perfect_filter = {
3354 .f = cmd_pkt_filter_parsed,
3356 .help_str = "add a perfect filter",
3358 (void *)&cmd_pkt_filter_add_perfect_filter,
3359 (void *)&cmd_pkt_filter_port_id,
3360 (void *)&cmd_pkt_filter_protocol,
3361 (void *)&cmd_pkt_filter_src,
3362 (void *)&cmd_pkt_filter_ip_src,
3363 (void *)&cmd_pkt_filter_port_src,
3364 (void *)&cmd_pkt_filter_dst,
3365 (void *)&cmd_pkt_filter_ip_dst,
3366 (void *)&cmd_pkt_filter_port_dst,
3367 (void *)&cmd_pkt_filter_flexbytes,
3368 (void *)&cmd_pkt_filter_flexbytes_value,
3369 (void *)&cmd_pkt_filter_vlan,
3370 (void *)&cmd_pkt_filter_vlan_id,
3371 (void *)&cmd_pkt_filter_queue,
3372 (void *)&cmd_pkt_filter_queue_id,
3373 (void *)&cmd_pkt_filter_soft,
3374 (void *)&cmd_pkt_filter_soft_id,
3380 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3381 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3382 pkt_filter, "upd_perfect_filter");
3383 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3384 .f = cmd_pkt_filter_parsed,
3386 .help_str = "update a perfect filter",
3388 (void *)&cmd_pkt_filter_upd_perfect_filter,
3389 (void *)&cmd_pkt_filter_port_id,
3390 (void *)&cmd_pkt_filter_protocol,
3391 (void *)&cmd_pkt_filter_src,
3392 (void *)&cmd_pkt_filter_ip_src,
3393 (void *)&cmd_pkt_filter_port_src,
3394 (void *)&cmd_pkt_filter_dst,
3395 (void *)&cmd_pkt_filter_ip_dst,
3396 (void *)&cmd_pkt_filter_port_dst,
3397 (void *)&cmd_pkt_filter_flexbytes,
3398 (void *)&cmd_pkt_filter_flexbytes_value,
3399 (void *)&cmd_pkt_filter_vlan,
3400 (void *)&cmd_pkt_filter_vlan_id,
3401 (void *)&cmd_pkt_filter_queue,
3402 (void *)&cmd_pkt_filter_queue_id,
3403 (void *)&cmd_pkt_filter_soft,
3404 (void *)&cmd_pkt_filter_soft_id,
3410 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3411 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3412 pkt_filter, "rm_perfect_filter");
3413 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3414 .f = cmd_pkt_filter_parsed,
3416 .help_str = "remove a perfect filter",
3418 (void *)&cmd_pkt_filter_rm_perfect_filter,
3419 (void *)&cmd_pkt_filter_port_id,
3420 (void *)&cmd_pkt_filter_protocol,
3421 (void *)&cmd_pkt_filter_src,
3422 (void *)&cmd_pkt_filter_ip_src,
3423 (void *)&cmd_pkt_filter_port_src,
3424 (void *)&cmd_pkt_filter_dst,
3425 (void *)&cmd_pkt_filter_ip_dst,
3426 (void *)&cmd_pkt_filter_port_dst,
3427 (void *)&cmd_pkt_filter_flexbytes,
3428 (void *)&cmd_pkt_filter_flexbytes_value,
3429 (void *)&cmd_pkt_filter_vlan,
3430 (void *)&cmd_pkt_filter_vlan_id,
3431 (void *)&cmd_pkt_filter_soft,
3432 (void *)&cmd_pkt_filter_soft_id,
3437 /* *** SETUP MASKS FILTER *** */
3438 struct cmd_pkt_filter_masks_result {
3439 cmdline_fixed_string_t filter_mask;
3441 cmdline_fixed_string_t src_mask;
3442 uint32_t ip_src_mask;
3443 uint16_t ipv6_src_mask;
3444 uint16_t port_src_mask;
3445 cmdline_fixed_string_t dst_mask;
3446 uint32_t ip_dst_mask;
3447 uint16_t ipv6_dst_mask;
3448 uint16_t port_dst_mask;
3449 cmdline_fixed_string_t flexbytes;
3450 uint8_t flexbytes_value;
3451 cmdline_fixed_string_t vlan_id;
3452 uint8_t vlan_id_value;
3453 cmdline_fixed_string_t vlan_prio;
3454 uint8_t vlan_prio_value;
3455 cmdline_fixed_string_t only_ip_flow;
3456 uint8_t only_ip_flow_value;
3457 cmdline_fixed_string_t comp_ipv6_dst;
3458 uint8_t comp_ipv6_dst_value;
3462 cmd_pkt_filter_masks_parsed(void *parsed_result,
3463 __attribute__((unused)) struct cmdline *cl,
3464 __attribute__((unused)) void *data)
3466 struct rte_fdir_masks fdir_masks;
3467 struct cmd_pkt_filter_masks_result *res = parsed_result;
3469 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3471 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3472 fdir_masks.vlan_id = res->vlan_id_value;
3473 fdir_masks.vlan_prio = res->vlan_prio_value;
3474 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3475 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3476 fdir_masks.src_port_mask = res->port_src_mask;
3477 fdir_masks.dst_port_mask = res->port_dst_mask;
3478 fdir_masks.flexbytes = res->flexbytes_value;
3480 fdir_set_masks(res->port_id, &fdir_masks);
3483 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3484 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3485 filter_mask, "set_masks_filter");
3486 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3487 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3489 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3490 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3491 only_ip_flow, "only_ip_flow");
3492 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3493 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3494 only_ip_flow_value, UINT8);
3495 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3496 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3497 src_mask, "src_mask");
3498 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3499 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3500 ip_src_mask, UINT32);
3501 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3502 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3503 port_src_mask, UINT16);
3504 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3505 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3506 dst_mask, "dst_mask");
3507 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3508 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3509 ip_dst_mask, UINT32);
3510 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3511 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3512 port_dst_mask, UINT16);
3513 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3514 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3515 flexbytes, "flexbytes");
3516 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3517 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3518 flexbytes_value, UINT8);
3519 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3520 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3521 vlan_id, "vlan_id");
3522 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3523 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3524 vlan_id_value, UINT8);
3525 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3526 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3527 vlan_prio, "vlan_prio");
3528 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3529 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3530 vlan_prio_value, UINT8);
3532 cmdline_parse_inst_t cmd_set_masks_filter = {
3533 .f = cmd_pkt_filter_masks_parsed,
3535 .help_str = "setup masks filter",
3537 (void *)&cmd_pkt_filter_masks_filter_mask,
3538 (void *)&cmd_pkt_filter_masks_port_id,
3539 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3540 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3541 (void *)&cmd_pkt_filter_masks_src_mask,
3542 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3543 (void *)&cmd_pkt_filter_masks_port_src_mask,
3544 (void *)&cmd_pkt_filter_masks_dst_mask,
3545 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3546 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3547 (void *)&cmd_pkt_filter_masks_flexbytes,
3548 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3549 (void *)&cmd_pkt_filter_masks_vlan_id,
3550 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3551 (void *)&cmd_pkt_filter_masks_vlan_prio,
3552 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3558 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3559 __attribute__((unused)) struct cmdline *cl,
3560 __attribute__((unused)) void *data)
3562 struct rte_fdir_masks fdir_masks;
3563 struct cmd_pkt_filter_masks_result *res = parsed_result;
3565 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3567 fdir_masks.set_ipv6_mask = 1;
3568 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3569 fdir_masks.vlan_id = res->vlan_id_value;
3570 fdir_masks.vlan_prio = res->vlan_prio_value;
3571 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3572 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3573 fdir_masks.src_port_mask = res->port_src_mask;
3574 fdir_masks.dst_port_mask = res->port_dst_mask;
3575 fdir_masks.flexbytes = res->flexbytes_value;
3576 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3578 fdir_set_masks(res->port_id, &fdir_masks);
3581 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3582 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3583 filter_mask, "set_ipv6_masks_filter");
3584 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3585 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3586 ipv6_src_mask, UINT16);
3587 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3588 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3589 ipv6_dst_mask, UINT16);
3591 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3592 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3593 comp_ipv6_dst, "compare_dst");
3594 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3595 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3596 comp_ipv6_dst_value, UINT8);
3598 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3599 .f = cmd_pkt_filter_masks_ipv6_parsed,
3601 .help_str = "setup ipv6 masks filter",
3603 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3604 (void *)&cmd_pkt_filter_masks_port_id,
3605 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3606 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3607 (void *)&cmd_pkt_filter_masks_src_mask,
3608 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3609 (void *)&cmd_pkt_filter_masks_port_src_mask,
3610 (void *)&cmd_pkt_filter_masks_dst_mask,
3611 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3612 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3613 (void *)&cmd_pkt_filter_masks_flexbytes,
3614 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3615 (void *)&cmd_pkt_filter_masks_vlan_id,
3616 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3617 (void *)&cmd_pkt_filter_masks_vlan_prio,
3618 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3619 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3620 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3625 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3626 struct cmd_link_flow_ctrl_set_result {
3627 cmdline_fixed_string_t set;
3628 cmdline_fixed_string_t flow_ctrl;
3629 cmdline_fixed_string_t rx;
3630 cmdline_fixed_string_t rx_lfc_mode;
3631 cmdline_fixed_string_t tx;
3632 cmdline_fixed_string_t tx_lfc_mode;
3633 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3634 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3635 uint32_t high_water;
3637 uint16_t pause_time;
3643 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3648 struct rte_eth_fc_conf fc_conf;
3649 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3653 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3654 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3655 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3656 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3658 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3659 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3662 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3663 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3664 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3666 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3667 fc_conf.high_water = res->high_water;
3668 fc_conf.low_water = res->low_water;
3669 fc_conf.pause_time = res->pause_time;
3670 fc_conf.send_xon = res->send_xon;
3671 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3673 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3675 printf("bad flow contrl parameter, return code = %d \n", ret);
3678 cmdline_parse_token_string_t cmd_lfc_set_set =
3679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3681 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3682 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3683 flow_ctrl, "flow_ctrl");
3684 cmdline_parse_token_string_t cmd_lfc_set_rx =
3685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3687 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3689 rx_lfc_mode, "on#off");
3690 cmdline_parse_token_string_t cmd_lfc_set_tx =
3691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3693 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3695 tx_lfc_mode, "on#off");
3696 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3697 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3698 high_water, UINT32);
3699 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3700 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3702 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3703 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3704 pause_time, UINT16);
3705 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3706 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3708 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3710 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3711 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3713 mac_ctrl_frame_fwd_mode, "on#off");
3714 cmdline_parse_token_num_t cmd_lfc_set_portid =
3715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3718 cmdline_parse_inst_t cmd_link_flow_control_set = {
3719 .f = cmd_link_flow_ctrl_set_parsed,
3721 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3722 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3725 (void *)&cmd_lfc_set_set,
3726 (void *)&cmd_lfc_set_flow_ctrl,
3727 (void *)&cmd_lfc_set_rx,
3728 (void *)&cmd_lfc_set_rx_mode,
3729 (void *)&cmd_lfc_set_tx,
3730 (void *)&cmd_lfc_set_tx_mode,
3731 (void *)&cmd_lfc_set_high_water,
3732 (void *)&cmd_lfc_set_low_water,
3733 (void *)&cmd_lfc_set_pause_time,
3734 (void *)&cmd_lfc_set_send_xon,
3735 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3736 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3737 (void *)&cmd_lfc_set_portid,
3742 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3743 struct cmd_priority_flow_ctrl_set_result {
3744 cmdline_fixed_string_t set;
3745 cmdline_fixed_string_t pfc_ctrl;
3746 cmdline_fixed_string_t rx;
3747 cmdline_fixed_string_t rx_pfc_mode;
3748 cmdline_fixed_string_t tx;
3749 cmdline_fixed_string_t tx_pfc_mode;
3750 uint32_t high_water;
3752 uint16_t pause_time;
3758 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3759 __attribute__((unused)) struct cmdline *cl,
3760 __attribute__((unused)) void *data)
3762 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3763 struct rte_eth_pfc_conf pfc_conf;
3764 int rx_fc_enable, tx_fc_enable;
3768 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3769 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3770 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3771 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3773 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3774 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3777 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3778 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3779 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3780 pfc_conf.fc.high_water = res->high_water;
3781 pfc_conf.fc.low_water = res->low_water;
3782 pfc_conf.fc.pause_time = res->pause_time;
3783 pfc_conf.priority = res->priority;
3785 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3787 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3790 cmdline_parse_token_string_t cmd_pfc_set_set =
3791 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3793 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3794 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3795 pfc_ctrl, "pfc_ctrl");
3796 cmdline_parse_token_string_t cmd_pfc_set_rx =
3797 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3799 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3800 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3801 rx_pfc_mode, "on#off");
3802 cmdline_parse_token_string_t cmd_pfc_set_tx =
3803 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3805 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3806 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3807 tx_pfc_mode, "on#off");
3808 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3809 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3810 high_water, UINT32);
3811 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3812 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3814 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3815 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3816 pause_time, UINT16);
3817 cmdline_parse_token_num_t cmd_pfc_set_priority =
3818 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3820 cmdline_parse_token_num_t cmd_pfc_set_portid =
3821 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3824 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3825 .f = cmd_priority_flow_ctrl_set_parsed,
3827 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3828 tx on|off high_water low_water pause_time priority port_id",
3830 (void *)&cmd_pfc_set_set,
3831 (void *)&cmd_pfc_set_flow_ctrl,
3832 (void *)&cmd_pfc_set_rx,
3833 (void *)&cmd_pfc_set_rx_mode,
3834 (void *)&cmd_pfc_set_tx,
3835 (void *)&cmd_pfc_set_tx_mode,
3836 (void *)&cmd_pfc_set_high_water,
3837 (void *)&cmd_pfc_set_low_water,
3838 (void *)&cmd_pfc_set_pause_time,
3839 (void *)&cmd_pfc_set_priority,
3840 (void *)&cmd_pfc_set_portid,
3845 /* *** RESET CONFIGURATION *** */
3846 struct cmd_reset_result {
3847 cmdline_fixed_string_t reset;
3848 cmdline_fixed_string_t def;
3851 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3853 __attribute__((unused)) void *data)
3855 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3856 set_def_fwd_config();
3859 cmdline_parse_token_string_t cmd_reset_set =
3860 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3861 cmdline_parse_token_string_t cmd_reset_def =
3862 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3865 cmdline_parse_inst_t cmd_reset = {
3866 .f = cmd_reset_parsed,
3868 .help_str = "set default: reset default forwarding configuration",
3870 (void *)&cmd_reset_set,
3871 (void *)&cmd_reset_def,
3876 /* *** START FORWARDING *** */
3877 struct cmd_start_result {
3878 cmdline_fixed_string_t start;
3881 cmdline_parse_token_string_t cmd_start_start =
3882 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3884 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3885 __attribute__((unused)) struct cmdline *cl,
3886 __attribute__((unused)) void *data)
3888 start_packet_forwarding(0);
3891 cmdline_parse_inst_t cmd_start = {
3892 .f = cmd_start_parsed,
3894 .help_str = "start packet forwarding",
3896 (void *)&cmd_start_start,
3901 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3902 struct cmd_start_tx_first_result {
3903 cmdline_fixed_string_t start;
3904 cmdline_fixed_string_t tx_first;
3908 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3909 __attribute__((unused)) struct cmdline *cl,
3910 __attribute__((unused)) void *data)
3912 start_packet_forwarding(1);
3915 cmdline_parse_token_string_t cmd_start_tx_first_start =
3916 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3918 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3919 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3920 tx_first, "tx_first");
3922 cmdline_parse_inst_t cmd_start_tx_first = {
3923 .f = cmd_start_tx_first_parsed,
3925 .help_str = "start packet forwarding, after sending 1 burst of packets",
3927 (void *)&cmd_start_tx_first_start,
3928 (void *)&cmd_start_tx_first_tx_first,
3933 /* *** SHOW CFG *** */
3934 struct cmd_showcfg_result {
3935 cmdline_fixed_string_t show;
3936 cmdline_fixed_string_t cfg;
3937 cmdline_fixed_string_t what;
3940 static void cmd_showcfg_parsed(void *parsed_result,
3941 __attribute__((unused)) struct cmdline *cl,
3942 __attribute__((unused)) void *data)
3944 struct cmd_showcfg_result *res = parsed_result;
3945 if (!strcmp(res->what, "rxtx"))
3946 rxtx_config_display();
3947 else if (!strcmp(res->what, "cores"))
3948 fwd_lcores_config_display();
3949 else if (!strcmp(res->what, "fwd"))
3950 fwd_config_display();
3953 cmdline_parse_token_string_t cmd_showcfg_show =
3954 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3955 cmdline_parse_token_string_t cmd_showcfg_port =
3956 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3957 cmdline_parse_token_string_t cmd_showcfg_what =
3958 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3961 cmdline_parse_inst_t cmd_showcfg = {
3962 .f = cmd_showcfg_parsed,
3964 .help_str = "show config rxtx|cores|fwd",
3966 (void *)&cmd_showcfg_show,
3967 (void *)&cmd_showcfg_port,
3968 (void *)&cmd_showcfg_what,
3973 /* *** SHOW ALL PORT INFO *** */
3974 struct cmd_showportall_result {
3975 cmdline_fixed_string_t show;
3976 cmdline_fixed_string_t port;
3977 cmdline_fixed_string_t what;
3978 cmdline_fixed_string_t all;
3981 static void cmd_showportall_parsed(void *parsed_result,
3982 __attribute__((unused)) struct cmdline *cl,
3983 __attribute__((unused)) void *data)
3987 struct cmd_showportall_result *res = parsed_result;
3988 if (!strcmp(res->show, "clear")) {
3989 if (!strcmp(res->what, "stats"))
3990 for (i = 0; i < nb_ports; i++)
3992 } else if (!strcmp(res->what, "info"))
3993 for (i = 0; i < nb_ports; i++)
3994 port_infos_display(i);
3995 else if (!strcmp(res->what, "stats"))
3996 for (i = 0; i < nb_ports; i++)
3997 nic_stats_display(i);
3998 else if (!strcmp(res->what, "fdir"))
3999 for (i = 0; i < nb_ports; i++)
4001 else if (!strcmp(res->what, "stat_qmap"))
4002 for (i = 0; i < nb_ports; i++)
4003 nic_stats_mapping_display(i);
4006 cmdline_parse_token_string_t cmd_showportall_show =
4007 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4009 cmdline_parse_token_string_t cmd_showportall_port =
4010 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4011 cmdline_parse_token_string_t cmd_showportall_what =
4012 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4013 "info#stats#fdir#stat_qmap");
4014 cmdline_parse_token_string_t cmd_showportall_all =
4015 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4016 cmdline_parse_inst_t cmd_showportall = {
4017 .f = cmd_showportall_parsed,
4019 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4021 (void *)&cmd_showportall_show,
4022 (void *)&cmd_showportall_port,
4023 (void *)&cmd_showportall_what,
4024 (void *)&cmd_showportall_all,
4029 /* *** SHOW PORT INFO *** */
4030 struct cmd_showport_result {
4031 cmdline_fixed_string_t show;
4032 cmdline_fixed_string_t port;
4033 cmdline_fixed_string_t what;
4037 static void cmd_showport_parsed(void *parsed_result,
4038 __attribute__((unused)) struct cmdline *cl,
4039 __attribute__((unused)) void *data)
4041 struct cmd_showport_result *res = parsed_result;
4042 if (!strcmp(res->show, "clear")) {
4043 if (!strcmp(res->what, "stats"))
4044 nic_stats_clear(res->portnum);
4045 } else if (!strcmp(res->what, "info"))
4046 port_infos_display(res->portnum);
4047 else if (!strcmp(res->what, "stats"))
4048 nic_stats_display(res->portnum);
4049 else if (!strcmp(res->what, "fdir"))
4050 fdir_get_infos(res->portnum);
4051 else if (!strcmp(res->what, "stat_qmap"))
4052 nic_stats_mapping_display(res->portnum);
4055 cmdline_parse_token_string_t cmd_showport_show =
4056 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4058 cmdline_parse_token_string_t cmd_showport_port =
4059 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4060 cmdline_parse_token_string_t cmd_showport_what =
4061 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4062 "info#stats#fdir#stat_qmap");
4063 cmdline_parse_token_num_t cmd_showport_portnum =
4064 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4066 cmdline_parse_inst_t cmd_showport = {
4067 .f = cmd_showport_parsed,
4069 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4071 (void *)&cmd_showport_show,
4072 (void *)&cmd_showport_port,
4073 (void *)&cmd_showport_what,
4074 (void *)&cmd_showport_portnum,
4079 /* *** READ PORT REGISTER *** */
4080 struct cmd_read_reg_result {
4081 cmdline_fixed_string_t read;
4082 cmdline_fixed_string_t reg;
4088 cmd_read_reg_parsed(void *parsed_result,
4089 __attribute__((unused)) struct cmdline *cl,
4090 __attribute__((unused)) void *data)
4092 struct cmd_read_reg_result *res = parsed_result;
4093 port_reg_display(res->port_id, res->reg_off);
4096 cmdline_parse_token_string_t cmd_read_reg_read =
4097 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4098 cmdline_parse_token_string_t cmd_read_reg_reg =
4099 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4100 cmdline_parse_token_num_t cmd_read_reg_port_id =
4101 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4102 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4103 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4105 cmdline_parse_inst_t cmd_read_reg = {
4106 .f = cmd_read_reg_parsed,
4108 .help_str = "read reg port_id reg_off",
4110 (void *)&cmd_read_reg_read,
4111 (void *)&cmd_read_reg_reg,
4112 (void *)&cmd_read_reg_port_id,
4113 (void *)&cmd_read_reg_reg_off,
4118 /* *** READ PORT REGISTER BIT FIELD *** */
4119 struct cmd_read_reg_bit_field_result {
4120 cmdline_fixed_string_t read;
4121 cmdline_fixed_string_t regfield;
4129 cmd_read_reg_bit_field_parsed(void *parsed_result,
4130 __attribute__((unused)) struct cmdline *cl,
4131 __attribute__((unused)) void *data)
4133 struct cmd_read_reg_bit_field_result *res = parsed_result;
4134 port_reg_bit_field_display(res->port_id, res->reg_off,
4135 res->bit1_pos, res->bit2_pos);
4138 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4139 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4141 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4142 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4143 regfield, "regfield");
4144 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4145 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4147 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4148 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4150 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4151 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4153 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4154 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4157 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4158 .f = cmd_read_reg_bit_field_parsed,
4160 .help_str = "read regfield port_id reg_off bit_x bit_y "
4161 "(read register bit field between bit_x and bit_y included)",
4163 (void *)&cmd_read_reg_bit_field_read,
4164 (void *)&cmd_read_reg_bit_field_regfield,
4165 (void *)&cmd_read_reg_bit_field_port_id,
4166 (void *)&cmd_read_reg_bit_field_reg_off,
4167 (void *)&cmd_read_reg_bit_field_bit1_pos,
4168 (void *)&cmd_read_reg_bit_field_bit2_pos,
4173 /* *** READ PORT REGISTER BIT *** */
4174 struct cmd_read_reg_bit_result {
4175 cmdline_fixed_string_t read;
4176 cmdline_fixed_string_t regbit;
4183 cmd_read_reg_bit_parsed(void *parsed_result,
4184 __attribute__((unused)) struct cmdline *cl,
4185 __attribute__((unused)) void *data)
4187 struct cmd_read_reg_bit_result *res = parsed_result;
4188 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4191 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4192 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4193 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4194 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4196 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4197 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4198 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4199 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4200 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4201 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4203 cmdline_parse_inst_t cmd_read_reg_bit = {
4204 .f = cmd_read_reg_bit_parsed,
4206 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4208 (void *)&cmd_read_reg_bit_read,
4209 (void *)&cmd_read_reg_bit_regbit,
4210 (void *)&cmd_read_reg_bit_port_id,
4211 (void *)&cmd_read_reg_bit_reg_off,
4212 (void *)&cmd_read_reg_bit_bit_pos,
4217 /* *** WRITE PORT REGISTER *** */
4218 struct cmd_write_reg_result {
4219 cmdline_fixed_string_t write;
4220 cmdline_fixed_string_t reg;
4227 cmd_write_reg_parsed(void *parsed_result,
4228 __attribute__((unused)) struct cmdline *cl,
4229 __attribute__((unused)) void *data)
4231 struct cmd_write_reg_result *res = parsed_result;
4232 port_reg_set(res->port_id, res->reg_off, res->value);
4235 cmdline_parse_token_string_t cmd_write_reg_write =
4236 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4237 cmdline_parse_token_string_t cmd_write_reg_reg =
4238 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4239 cmdline_parse_token_num_t cmd_write_reg_port_id =
4240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4241 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4242 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4243 cmdline_parse_token_num_t cmd_write_reg_value =
4244 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4246 cmdline_parse_inst_t cmd_write_reg = {
4247 .f = cmd_write_reg_parsed,
4249 .help_str = "write reg port_id reg_off reg_value",
4251 (void *)&cmd_write_reg_write,
4252 (void *)&cmd_write_reg_reg,
4253 (void *)&cmd_write_reg_port_id,
4254 (void *)&cmd_write_reg_reg_off,
4255 (void *)&cmd_write_reg_value,
4260 /* *** WRITE PORT REGISTER BIT FIELD *** */
4261 struct cmd_write_reg_bit_field_result {
4262 cmdline_fixed_string_t write;
4263 cmdline_fixed_string_t regfield;
4272 cmd_write_reg_bit_field_parsed(void *parsed_result,
4273 __attribute__((unused)) struct cmdline *cl,
4274 __attribute__((unused)) void *data)
4276 struct cmd_write_reg_bit_field_result *res = parsed_result;
4277 port_reg_bit_field_set(res->port_id, res->reg_off,
4278 res->bit1_pos, res->bit2_pos, res->value);
4281 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4282 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4284 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4285 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4286 regfield, "regfield");
4287 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4288 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4290 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4291 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4293 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4294 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4296 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4297 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4299 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4300 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4303 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4304 .f = cmd_write_reg_bit_field_parsed,
4306 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4307 "(set register bit field between bit_x and bit_y included)",
4309 (void *)&cmd_write_reg_bit_field_write,
4310 (void *)&cmd_write_reg_bit_field_regfield,
4311 (void *)&cmd_write_reg_bit_field_port_id,
4312 (void *)&cmd_write_reg_bit_field_reg_off,
4313 (void *)&cmd_write_reg_bit_field_bit1_pos,
4314 (void *)&cmd_write_reg_bit_field_bit2_pos,
4315 (void *)&cmd_write_reg_bit_field_value,
4320 /* *** WRITE PORT REGISTER BIT *** */
4321 struct cmd_write_reg_bit_result {
4322 cmdline_fixed_string_t write;
4323 cmdline_fixed_string_t regbit;
4331 cmd_write_reg_bit_parsed(void *parsed_result,
4332 __attribute__((unused)) struct cmdline *cl,
4333 __attribute__((unused)) void *data)
4335 struct cmd_write_reg_bit_result *res = parsed_result;
4336 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4339 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4340 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4342 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4343 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4345 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4346 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4347 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4348 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4349 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4350 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4351 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4352 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4354 cmdline_parse_inst_t cmd_write_reg_bit = {
4355 .f = cmd_write_reg_bit_parsed,
4357 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4359 (void *)&cmd_write_reg_bit_write,
4360 (void *)&cmd_write_reg_bit_regbit,
4361 (void *)&cmd_write_reg_bit_port_id,
4362 (void *)&cmd_write_reg_bit_reg_off,
4363 (void *)&cmd_write_reg_bit_bit_pos,
4364 (void *)&cmd_write_reg_bit_value,
4369 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4370 struct cmd_read_rxd_txd_result {
4371 cmdline_fixed_string_t read;
4372 cmdline_fixed_string_t rxd_txd;
4379 cmd_read_rxd_txd_parsed(void *parsed_result,
4380 __attribute__((unused)) struct cmdline *cl,
4381 __attribute__((unused)) void *data)
4383 struct cmd_read_rxd_txd_result *res = parsed_result;
4385 if (!strcmp(res->rxd_txd, "rxd"))
4386 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4387 else if (!strcmp(res->rxd_txd, "txd"))
4388 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4391 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4392 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4393 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4394 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4396 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4397 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4398 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4399 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4400 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4401 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4403 cmdline_parse_inst_t cmd_read_rxd_txd = {
4404 .f = cmd_read_rxd_txd_parsed,
4406 .help_str = "read rxd|txd port_id queue_id rxd_id",
4408 (void *)&cmd_read_rxd_txd_read,
4409 (void *)&cmd_read_rxd_txd_rxd_txd,
4410 (void *)&cmd_read_rxd_txd_port_id,
4411 (void *)&cmd_read_rxd_txd_queue_id,
4412 (void *)&cmd_read_rxd_txd_desc_id,
4418 struct cmd_quit_result {
4419 cmdline_fixed_string_t quit;
4422 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4424 __attribute__((unused)) void *data)
4430 cmdline_parse_token_string_t cmd_quit_quit =
4431 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4433 cmdline_parse_inst_t cmd_quit = {
4434 .f = cmd_quit_parsed,
4436 .help_str = "exit application",
4438 (void *)&cmd_quit_quit,
4443 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4444 struct cmd_mac_addr_result {
4445 cmdline_fixed_string_t mac_addr_cmd;
4446 cmdline_fixed_string_t what;
4448 struct ether_addr address;
4451 static void cmd_mac_addr_parsed(void *parsed_result,
4452 __attribute__((unused)) struct cmdline *cl,
4453 __attribute__((unused)) void *data)
4455 struct cmd_mac_addr_result *res = parsed_result;
4458 if (strcmp(res->what, "add") == 0)
4459 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4461 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4463 /* check the return value and print it if is < 0 */
4465 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4469 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4470 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4472 cmdline_parse_token_string_t cmd_mac_addr_what =
4473 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4475 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4476 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4477 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4478 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4480 cmdline_parse_inst_t cmd_mac_addr = {
4481 .f = cmd_mac_addr_parsed,
4483 .help_str = "mac_addr add|remove X <address>: "
4484 "add/remove MAC address on port X",
4486 (void *)&cmd_mac_addr_cmd,
4487 (void *)&cmd_mac_addr_what,
4488 (void *)&cmd_mac_addr_portnum,
4489 (void *)&cmd_mac_addr_addr,
4495 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4496 struct cmd_set_qmap_result {
4497 cmdline_fixed_string_t set;
4498 cmdline_fixed_string_t qmap;
4499 cmdline_fixed_string_t what;
4506 cmd_set_qmap_parsed(void *parsed_result,
4507 __attribute__((unused)) struct cmdline *cl,
4508 __attribute__((unused)) void *data)
4510 struct cmd_set_qmap_result *res = parsed_result;
4511 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4513 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4516 cmdline_parse_token_string_t cmd_setqmap_set =
4517 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4519 cmdline_parse_token_string_t cmd_setqmap_qmap =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4522 cmdline_parse_token_string_t cmd_setqmap_what =
4523 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4525 cmdline_parse_token_num_t cmd_setqmap_portid =
4526 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4528 cmdline_parse_token_num_t cmd_setqmap_queueid =
4529 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4531 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4532 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4535 cmdline_parse_inst_t cmd_set_qmap = {
4536 .f = cmd_set_qmap_parsed,
4538 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4540 (void *)&cmd_setqmap_set,
4541 (void *)&cmd_setqmap_qmap,
4542 (void *)&cmd_setqmap_what,
4543 (void *)&cmd_setqmap_portid,
4544 (void *)&cmd_setqmap_queueid,
4545 (void *)&cmd_setqmap_mapvalue,
4550 /* *** CONFIGURE UNICAST HASH TABLE *** */
4551 struct cmd_set_uc_hash_table {
4552 cmdline_fixed_string_t set;
4553 cmdline_fixed_string_t port;
4555 cmdline_fixed_string_t what;
4556 struct ether_addr address;
4557 cmdline_fixed_string_t mode;
4561 cmd_set_uc_hash_parsed(void *parsed_result,
4562 __attribute__((unused)) struct cmdline *cl,
4563 __attribute__((unused)) void *data)
4566 struct cmd_set_uc_hash_table *res = parsed_result;
4568 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4570 if (strcmp(res->what, "uta") == 0)
4571 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4572 &res->address,(uint8_t)is_on);
4574 printf("bad unicast hash table parameter, return code = %d \n", ret);
4578 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4579 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4581 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4582 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4584 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4585 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4587 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4588 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4590 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4591 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4593 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4594 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4597 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4598 .f = cmd_set_uc_hash_parsed,
4600 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4602 (void *)&cmd_set_uc_hash_set,
4603 (void *)&cmd_set_uc_hash_port,
4604 (void *)&cmd_set_uc_hash_portid,
4605 (void *)&cmd_set_uc_hash_what,
4606 (void *)&cmd_set_uc_hash_mac,
4607 (void *)&cmd_set_uc_hash_mode,
4612 struct cmd_set_uc_all_hash_table {
4613 cmdline_fixed_string_t set;
4614 cmdline_fixed_string_t port;
4616 cmdline_fixed_string_t what;
4617 cmdline_fixed_string_t value;
4618 cmdline_fixed_string_t mode;
4622 cmd_set_uc_all_hash_parsed(void *parsed_result,
4623 __attribute__((unused)) struct cmdline *cl,
4624 __attribute__((unused)) void *data)
4627 struct cmd_set_uc_all_hash_table *res = parsed_result;
4629 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4631 if ((strcmp(res->what, "uta") == 0) &&
4632 (strcmp(res->value, "all") == 0))
4633 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4635 printf("bad unicast hash table parameter,"
4636 "return code = %d \n", ret);
4639 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4642 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4643 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4645 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4646 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4648 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4649 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4651 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4652 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4654 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4655 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4658 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4659 .f = cmd_set_uc_all_hash_parsed,
4661 .help_str = "set port X uta all on|off (X = port number)",
4663 (void *)&cmd_set_uc_all_hash_set,
4664 (void *)&cmd_set_uc_all_hash_port,
4665 (void *)&cmd_set_uc_all_hash_portid,
4666 (void *)&cmd_set_uc_all_hash_what,
4667 (void *)&cmd_set_uc_all_hash_value,
4668 (void *)&cmd_set_uc_all_hash_mode,
4673 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4674 struct cmd_set_vf_traffic {
4675 cmdline_fixed_string_t set;
4676 cmdline_fixed_string_t port;
4678 cmdline_fixed_string_t vf;
4680 cmdline_fixed_string_t what;
4681 cmdline_fixed_string_t mode;
4685 cmd_set_vf_traffic_parsed(void *parsed_result,
4686 __attribute__((unused)) struct cmdline *cl,
4687 __attribute__((unused)) void *data)
4689 struct cmd_set_vf_traffic *res = parsed_result;
4690 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4691 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4693 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4696 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4699 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4702 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4703 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4705 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4706 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4708 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4709 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4711 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4712 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4714 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4715 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4718 cmdline_parse_inst_t cmd_set_vf_traffic = {
4719 .f = cmd_set_vf_traffic_parsed,
4721 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4723 (void *)&cmd_setvf_traffic_set,
4724 (void *)&cmd_setvf_traffic_port,
4725 (void *)&cmd_setvf_traffic_portid,
4726 (void *)&cmd_setvf_traffic_vf,
4727 (void *)&cmd_setvf_traffic_vfid,
4728 (void *)&cmd_setvf_traffic_what,
4729 (void *)&cmd_setvf_traffic_mode,
4734 /* *** CONFIGURE VF RECEIVE MODE *** */
4735 struct cmd_set_vf_rxmode {
4736 cmdline_fixed_string_t set;
4737 cmdline_fixed_string_t port;
4739 cmdline_fixed_string_t vf;
4741 cmdline_fixed_string_t what;
4742 cmdline_fixed_string_t mode;
4743 cmdline_fixed_string_t on;
4747 cmd_set_vf_rxmode_parsed(void *parsed_result,
4748 __attribute__((unused)) struct cmdline *cl,
4749 __attribute__((unused)) void *data)
4752 uint16_t rx_mode = 0;
4753 struct cmd_set_vf_rxmode *res = parsed_result;
4755 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4756 if (!strcmp(res->what,"rxmode")) {
4757 if (!strcmp(res->mode, "AUPE"))
4758 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4759 else if (!strcmp(res->mode, "ROPE"))
4760 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4761 else if (!strcmp(res->mode, "BAM"))
4762 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4763 else if (!strncmp(res->mode, "MPE",3))
4764 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4767 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4769 printf("bad VF receive mode parameter, return code = %d \n",
4773 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4776 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4779 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4780 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4782 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4785 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4786 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4788 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4791 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4793 mode, "AUPE#ROPE#BAM#MPE");
4794 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4798 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4799 .f = cmd_set_vf_rxmode_parsed,
4801 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4803 (void *)&cmd_set_vf_rxmode_set,
4804 (void *)&cmd_set_vf_rxmode_port,
4805 (void *)&cmd_set_vf_rxmode_portid,
4806 (void *)&cmd_set_vf_rxmode_vf,
4807 (void *)&cmd_set_vf_rxmode_vfid,
4808 (void *)&cmd_set_vf_rxmode_what,
4809 (void *)&cmd_set_vf_rxmode_mode,
4810 (void *)&cmd_set_vf_rxmode_on,
4815 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4816 struct cmd_vf_mac_addr_result {
4817 cmdline_fixed_string_t mac_addr_cmd;
4818 cmdline_fixed_string_t what;
4819 cmdline_fixed_string_t port;
4821 cmdline_fixed_string_t vf;
4823 struct ether_addr address;
4826 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4827 __attribute__((unused)) struct cmdline *cl,
4828 __attribute__((unused)) void *data)
4830 struct cmd_vf_mac_addr_result *res = parsed_result;
4833 if (strcmp(res->what, "add") == 0)
4834 ret = rte_eth_dev_mac_addr_add(res->port_num,
4835 &res->address, res->vf_num);
4837 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4841 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4842 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4843 mac_addr_cmd,"mac_addr");
4844 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4845 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4847 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4848 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4850 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4851 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4853 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4854 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4856 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4857 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4859 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4860 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4863 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4864 .f = cmd_vf_mac_addr_parsed,
4866 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4867 "Y = VF number)add MAC address filtering for a VF on port X",
4869 (void *)&cmd_vf_mac_addr_cmd,
4870 (void *)&cmd_vf_mac_addr_what,
4871 (void *)&cmd_vf_mac_addr_port,
4872 (void *)&cmd_vf_mac_addr_portnum,
4873 (void *)&cmd_vf_mac_addr_vf,
4874 (void *)&cmd_vf_mac_addr_vfnum,
4875 (void *)&cmd_vf_mac_addr_addr,
4880 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4881 struct cmd_vf_rx_vlan_filter {
4882 cmdline_fixed_string_t rx_vlan;
4883 cmdline_fixed_string_t what;
4885 cmdline_fixed_string_t port;
4887 cmdline_fixed_string_t vf;
4892 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4893 __attribute__((unused)) struct cmdline *cl,
4894 __attribute__((unused)) void *data)
4896 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4898 if (!strcmp(res->what, "add"))
4899 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4901 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4904 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4905 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4906 rx_vlan, "rx_vlan");
4907 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4908 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4910 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4911 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4913 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4914 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4916 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4917 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4919 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4920 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4922 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4923 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4926 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4927 .f = cmd_vf_rx_vlan_filter_parsed,
4929 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4930 "Y = port number,Z = hexadecimal VF mask)",
4932 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4933 (void *)&cmd_vf_rx_vlan_filter_what,
4934 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4935 (void *)&cmd_vf_rx_vlan_filter_port,
4936 (void *)&cmd_vf_rx_vlan_filter_portid,
4937 (void *)&cmd_vf_rx_vlan_filter_vf,
4938 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4943 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4944 struct cmd_set_mirror_mask_result {
4945 cmdline_fixed_string_t set;
4946 cmdline_fixed_string_t port;
4948 cmdline_fixed_string_t mirror;
4950 cmdline_fixed_string_t what;
4951 cmdline_fixed_string_t value;
4952 cmdline_fixed_string_t dstpool;
4954 cmdline_fixed_string_t on;
4957 cmdline_parse_token_string_t cmd_mirror_mask_set =
4958 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4960 cmdline_parse_token_string_t cmd_mirror_mask_port =
4961 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4963 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4964 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4966 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4967 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4968 mirror, "mirror-rule");
4969 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4970 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4972 cmdline_parse_token_string_t cmd_mirror_mask_what =
4973 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4974 what, "pool-mirror#vlan-mirror");
4975 cmdline_parse_token_string_t cmd_mirror_mask_value =
4976 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4978 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4979 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4980 dstpool, "dst-pool");
4981 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4982 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4984 cmdline_parse_token_string_t cmd_mirror_mask_on =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4989 cmd_set_mirror_mask_parsed(void *parsed_result,
4990 __attribute__((unused)) struct cmdline *cl,
4991 __attribute__((unused)) void *data)
4994 struct cmd_set_mirror_mask_result *res = parsed_result;
4995 struct rte_eth_vmdq_mirror_conf mr_conf;
4997 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4999 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5001 mr_conf.dst_pool = res->dstpool_id;
5003 if (!strcmp(res->what, "pool-mirror")) {
5004 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5005 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5006 } else if(!strcmp(res->what, "vlan-mirror")) {
5007 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5008 nb_item = parse_item_list(res->value, "core",
5009 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5013 for(i=0; i < nb_item; i++) {
5014 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5015 printf("Invalid vlan_id: must be < 4096\n");
5019 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5020 mr_conf.vlan.vlan_mask |= 1ULL << i;
5024 if(!strcmp(res->on, "on"))
5025 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5028 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5031 printf("mirror rule add error: (%s)\n", strerror(-ret));
5034 cmdline_parse_inst_t cmd_set_mirror_mask = {
5035 .f = cmd_set_mirror_mask_parsed,
5037 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5038 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5040 (void *)&cmd_mirror_mask_set,
5041 (void *)&cmd_mirror_mask_port,
5042 (void *)&cmd_mirror_mask_portid,
5043 (void *)&cmd_mirror_mask_mirror,
5044 (void *)&cmd_mirror_mask_ruleid,
5045 (void *)&cmd_mirror_mask_what,
5046 (void *)&cmd_mirror_mask_value,
5047 (void *)&cmd_mirror_mask_dstpool,
5048 (void *)&cmd_mirror_mask_poolid,
5049 (void *)&cmd_mirror_mask_on,
5054 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5055 struct cmd_set_mirror_link_result {
5056 cmdline_fixed_string_t set;
5057 cmdline_fixed_string_t port;
5059 cmdline_fixed_string_t mirror;
5061 cmdline_fixed_string_t what;
5062 cmdline_fixed_string_t dstpool;
5064 cmdline_fixed_string_t on;
5067 cmdline_parse_token_string_t cmd_mirror_link_set =
5068 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5070 cmdline_parse_token_string_t cmd_mirror_link_port =
5071 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5073 cmdline_parse_token_string_t cmd_mirror_link_portid =
5074 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5076 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5077 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5078 mirror, "mirror-rule");
5079 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5080 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5082 cmdline_parse_token_string_t cmd_mirror_link_what =
5083 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5084 what, "uplink-mirror#downlink-mirror");
5085 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5086 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5087 dstpool, "dst-pool");
5088 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5089 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5091 cmdline_parse_token_string_t cmd_mirror_link_on =
5092 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5096 cmd_set_mirror_link_parsed(void *parsed_result,
5097 __attribute__((unused)) struct cmdline *cl,
5098 __attribute__((unused)) void *data)
5101 struct cmd_set_mirror_link_result *res = parsed_result;
5102 struct rte_eth_vmdq_mirror_conf mr_conf;
5104 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5105 if(!strcmp(res->what, "uplink-mirror")) {
5106 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5107 }else if(!strcmp(res->what, "downlink-mirror"))
5108 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5110 mr_conf.dst_pool = res->dstpool_id;
5112 if(!strcmp(res->on, "on"))
5113 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5116 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5119 /* check the return value and print it if is < 0 */
5121 printf("mirror rule add error: (%s)\n", strerror(-ret));
5125 cmdline_parse_inst_t cmd_set_mirror_link = {
5126 .f = cmd_set_mirror_link_parsed,
5128 .help_str = "set port X mirror-rule Y uplink-mirror|"
5129 "downlink-mirror dst-pool Z on|off",
5131 (void *)&cmd_mirror_link_set,
5132 (void *)&cmd_mirror_link_port,
5133 (void *)&cmd_mirror_link_portid,
5134 (void *)&cmd_mirror_link_mirror,
5135 (void *)&cmd_mirror_link_ruleid,
5136 (void *)&cmd_mirror_link_what,
5137 (void *)&cmd_mirror_link_dstpool,
5138 (void *)&cmd_mirror_link_poolid,
5139 (void *)&cmd_mirror_link_on,
5144 /* *** RESET VM MIRROR RULE *** */
5145 struct cmd_rm_mirror_rule_result {
5146 cmdline_fixed_string_t reset;
5147 cmdline_fixed_string_t port;
5149 cmdline_fixed_string_t mirror;
5153 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5154 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5156 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5157 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5159 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5160 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5162 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5163 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5164 mirror, "mirror-rule");
5165 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5166 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5170 cmd_reset_mirror_rule_parsed(void *parsed_result,
5171 __attribute__((unused)) struct cmdline *cl,
5172 __attribute__((unused)) void *data)
5175 struct cmd_set_mirror_link_result *res = parsed_result;
5177 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5179 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5182 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5183 .f = cmd_reset_mirror_rule_parsed,
5185 .help_str = "reset port X mirror-rule Y",
5187 (void *)&cmd_rm_mirror_rule_reset,
5188 (void *)&cmd_rm_mirror_rule_port,
5189 (void *)&cmd_rm_mirror_rule_portid,
5190 (void *)&cmd_rm_mirror_rule_mirror,
5191 (void *)&cmd_rm_mirror_rule_ruleid,
5196 /* ******************************************************************************** */
5198 struct cmd_dump_result {
5199 cmdline_fixed_string_t dump;
5203 dump_struct_sizes(void)
5205 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5206 DUMP_SIZE(struct rte_mbuf);
5207 DUMP_SIZE(struct rte_pktmbuf);
5208 DUMP_SIZE(struct rte_ctrlmbuf);
5209 DUMP_SIZE(struct rte_mempool);
5210 DUMP_SIZE(struct rte_ring);
5214 static void cmd_dump_parsed(void *parsed_result,
5215 __attribute__((unused)) struct cmdline *cl,
5216 __attribute__((unused)) void *data)
5218 struct cmd_dump_result *res = parsed_result;
5220 if (!strcmp(res->dump, "dump_physmem"))
5221 rte_dump_physmem_layout(stdout);
5222 else if (!strcmp(res->dump, "dump_memzone"))
5223 rte_memzone_dump(stdout);
5224 else if (!strcmp(res->dump, "dump_log_history"))
5225 rte_log_dump_history(stdout);
5226 else if (!strcmp(res->dump, "dump_struct_sizes"))
5227 dump_struct_sizes();
5228 else if (!strcmp(res->dump, "dump_ring"))
5229 rte_ring_list_dump(stdout);
5230 else if (!strcmp(res->dump, "dump_mempool"))
5231 rte_mempool_list_dump(stdout);
5232 else if (!strcmp(res->dump, "dump_devargs"))
5233 rte_eal_devargs_dump(stdout);
5236 cmdline_parse_token_string_t cmd_dump_dump =
5237 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5241 "dump_struct_sizes#"
5246 cmdline_parse_inst_t cmd_dump = {
5247 .f = cmd_dump_parsed, /* function to call */
5248 .data = NULL, /* 2nd arg of func */
5249 .help_str = "dump status",
5250 .tokens = { /* token list, NULL terminated */
5251 (void *)&cmd_dump_dump,
5256 /* ******************************************************************************** */
5258 struct cmd_dump_one_result {
5259 cmdline_fixed_string_t dump;
5260 cmdline_fixed_string_t name;
5263 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5264 __attribute__((unused)) void *data)
5266 struct cmd_dump_one_result *res = parsed_result;
5268 if (!strcmp(res->dump, "dump_ring")) {
5270 r = rte_ring_lookup(res->name);
5272 cmdline_printf(cl, "Cannot find ring\n");
5275 rte_ring_dump(stdout, r);
5276 } else if (!strcmp(res->dump, "dump_mempool")) {
5277 struct rte_mempool *mp;
5278 mp = rte_mempool_lookup(res->name);
5280 cmdline_printf(cl, "Cannot find mempool\n");
5283 rte_mempool_dump(stdout, mp);
5287 cmdline_parse_token_string_t cmd_dump_one_dump =
5288 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5289 "dump_ring#dump_mempool");
5291 cmdline_parse_token_string_t cmd_dump_one_name =
5292 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5294 cmdline_parse_inst_t cmd_dump_one = {
5295 .f = cmd_dump_one_parsed, /* function to call */
5296 .data = NULL, /* 2nd arg of func */
5297 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5298 .tokens = { /* token list, NULL terminated */
5299 (void *)&cmd_dump_one_dump,
5300 (void *)&cmd_dump_one_name,
5305 /* ******************************************************************************** */
5307 /* list of instructions */
5308 cmdline_parse_ctx_t main_ctx[] = {
5309 (cmdline_parse_inst_t *)&cmd_help_brief,
5310 (cmdline_parse_inst_t *)&cmd_help_long,
5311 (cmdline_parse_inst_t *)&cmd_quit,
5312 (cmdline_parse_inst_t *)&cmd_showport,
5313 (cmdline_parse_inst_t *)&cmd_showportall,
5314 (cmdline_parse_inst_t *)&cmd_showcfg,
5315 (cmdline_parse_inst_t *)&cmd_start,
5316 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5317 (cmdline_parse_inst_t *)&cmd_reset,
5318 (cmdline_parse_inst_t *)&cmd_set_numbers,
5319 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5320 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5321 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5322 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5323 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5324 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5325 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5326 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5327 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5328 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5329 (cmdline_parse_inst_t *)&cmd_set_link_check,
5330 #ifdef RTE_NIC_BYPASS
5331 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5332 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5333 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5334 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5336 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5337 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5338 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5339 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5340 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5341 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5342 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5344 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5345 (cmdline_parse_inst_t *)&cmd_config_dcb,
5346 (cmdline_parse_inst_t *)&cmd_read_reg,
5347 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5348 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5349 (cmdline_parse_inst_t *)&cmd_write_reg,
5350 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5351 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5352 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5353 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5354 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5355 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5356 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5357 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5358 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5359 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5360 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5361 (cmdline_parse_inst_t *)&cmd_stop,
5362 (cmdline_parse_inst_t *)&cmd_mac_addr,
5363 (cmdline_parse_inst_t *)&cmd_set_qmap,
5364 (cmdline_parse_inst_t *)&cmd_operate_port,
5365 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5366 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5367 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5368 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5369 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5370 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5371 (cmdline_parse_inst_t *)&cmd_config_rss,
5372 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5373 (cmdline_parse_inst_t *)&cmd_showport_reta,
5374 (cmdline_parse_inst_t *)&cmd_config_burst,
5375 (cmdline_parse_inst_t *)&cmd_config_thresh,
5376 (cmdline_parse_inst_t *)&cmd_config_threshold,
5377 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5378 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5379 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5380 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5381 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5382 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5383 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5384 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5385 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5386 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
5387 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
5388 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
5389 (cmdline_parse_inst_t *)&cmd_dump,
5390 (cmdline_parse_inst_t *)&cmd_dump_one,
5394 /* prompt function, called from main on MASTER lcore */
5400 /* initialize non-constant commands */
5401 cmd_set_fwd_mode_init();
5403 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5407 cmdline_interact(cl);
5408 cmdline_stdin_exit(cl);
5412 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5414 if (id < nb_ports) {
5415 /* check if need_reconfig has been set to 1 */
5416 if (ports[id].need_reconfig == 0)
5417 ports[id].need_reconfig = dev;
5418 /* check if need_reconfig_queues has been set to 1 */
5419 if (ports[id].need_reconfig_queues == 0)
5420 ports[id].need_reconfig_queues = queue;
5424 for (pid = 0; pid < nb_ports; pid++) {
5425 /* check if need_reconfig has been set to 1 */
5426 if (ports[pid].need_reconfig == 0)
5427 ports[pid].need_reconfig = dev;
5428 /* check if need_reconfig_queues has been set to 1 */
5429 if (ports[pid].need_reconfig_queues == 0)
5430 ports[pid].need_reconfig_queues = queue;
5435 #ifdef RTE_NIC_BYPASS
5437 bypass_is_supported(portid_t port_id)
5439 struct rte_port *port;
5440 struct rte_pci_id *pci_id;
5442 if (port_id >= nb_ports) {
5443 printf("\tPort id must be less than %d.\n", nb_ports);
5447 /* Get the device id. */
5448 port = &ports[port_id];
5449 pci_id = &port->dev_info.pci_dev->id;
5451 /* Check if NIC supports bypass. */
5452 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5456 printf("\tBypass not supported for port_id = %d.\n", port_id);