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) queue (queue_id) rate (rate_num)\n"
351 " Set rate limit for a queue of a port\n\n"
353 "set port (port_id) vf (vf_id) rate (rate_num) "
354 "queue_mask (queue_mask_value)\n"
355 " Set rate limit for queues in VF of a port\n\n"
357 "set port (port_id) mirror-rule (rule_id)"
358 "(pool-mirror|vlan-mirror)\n"
359 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
360 " Set pool or vlan type mirror rule on a port.\n"
361 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
362 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
365 "set port (port_id) mirror-rule (rule_id)"
366 " (uplink-mirror|downlink-mirror) dst-pool"
367 " (pool_id) (on|off)\n"
368 " Set uplink or downlink type mirror rule on a port.\n"
369 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
370 " 0 on' enable mirror income traffic to pool 0.\n\n"
372 "reset port (port_id) mirror-rule (rule_id)\n"
373 " Reset a mirror rule.\n\n"
375 "set flush_rx (on|off)\n"
376 " Flush (default) or don't flush RX streams before"
377 " forwarding. Mainly used with PCAP drivers.\n\n"
379 #ifdef RTE_NIC_BYPASS
380 "set bypass mode (normal|bypass|isolate) (port_id)\n"
381 " Set the bypass mode for the lowest port on bypass enabled"
384 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
385 "mode (normal|bypass|isolate) (port_id)\n"
386 " Set the event required to initiate specified bypass mode for"
387 " the lowest port on a bypass enabled NIC where:\n"
388 " timeout = enable bypass after watchdog timeout.\n"
389 " os_on = enable bypass when OS/board is powered on.\n"
390 " os_off = enable bypass when OS/board is powered off.\n"
391 " power_on = enable bypass when power supply is turned on.\n"
392 " power_off = enable bypass when power supply is turned off."
395 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
396 " Set the bypass watchdog timeout to 'n' seconds"
397 " where 0 = instant.\n\n"
399 "show bypass config (port_id)\n"
400 " Show the bypass configuration for a bypass enabled NIC"
401 " using the lowest port on the NIC.\n\n"
404 , list_pkt_forwarding_modes()
409 if (show_all || !strcmp(res->section, "flowdir")) {
414 "Flow director mode:\n"
415 "-------------------\n\n"
417 "add_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 " Add a signature filter.\n\n"
424 "upd_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)"
428 " queue (queue_id)\n"
429 " Update a signature filter.\n\n"
431 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
432 " src (src_ip_address) (src_port)"
433 " dst (dst_ip_address) (dst_port)"
434 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
435 " Remove a signature filter.\n\n"
437 "add_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) soft (soft_id)\n"
442 " Add a perfect filter.\n\n"
444 "upd_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)"
448 " queue (queue_id)\n"
449 " Update a perfect filter.\n\n"
451 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
452 " src (src_ip_address) (src_port)"
453 " dst (dst_ip_address) (dst_port)"
454 " flexbytes (flexbytes_values) vlan (vlan_id)"
456 " Remove a perfect filter.\n\n"
458 "set_masks_filter (port_id) only_ip_flow (0|1)"
459 " src_mask (ip_src_mask) (src_port_mask)"
460 " dst_mask (ip_dst_mask) (dst_port_mask)"
461 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
462 " Set IPv4 filter masks.\n\n"
464 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
465 " src_mask (ip_src_mask) (src_port_mask)"
466 " dst_mask (ip_dst_mask) (dst_port_mask)"
467 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
468 " compare_dst (0|1)\n"
469 " Set IPv6 filter masks.\n\n"
473 if (show_all || !strcmp(res->section, "ports")) {
479 "----------------\n\n"
481 "port start (port_id|all)\n"
482 " Start all ports or port_id.\n\n"
484 "port stop (port_id|all)\n"
485 " Stop all ports or port_id.\n\n"
487 "port close (port_id|all)\n"
488 " Close all ports or port_id.\n\n"
490 "port config (port_id|all) speed (10|100|1000|10000|auto)"
491 " duplex (half|full|auto)\n"
492 " Set speed and duplex for all ports or port_id\n\n"
494 "port config all (rxq|txq|rxd|txd) (value)\n"
495 " Set number for rxq/txq/rxd/txd.\n\n"
497 "port config all max-pkt-len (value)\n"
498 " Set the max packet length.\n\n"
500 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
502 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
505 "port config all rss (ip|udp|none)\n"
506 " Set the RSS mode.\n\n"
508 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
509 " Set the RSS redirection table.\n\n"
511 "port config (port_id) dcb vt (on|off) (traffic_class)"
513 " Set the DCB mode.\n\n"
515 "port config all burst (value)\n"
516 " Set the number of packets per burst.\n\n"
518 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
520 " Set the ring prefetch/host/writeback threshold"
521 " for tx/rx queue.\n\n"
523 "port config all (txfreet|txrst|rxfreet) (value)\n"
524 " Set free threshold for rx/tx, or set"
525 " tx rs bit threshold.\n\n"
529 if (show_all || !strcmp(res->section, "registers")) {
537 "read reg (port_id) (address)\n"
538 " Display value of a port register.\n\n"
540 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
541 " Display a port register bit field.\n\n"
543 "read regbit (port_id) (address) (bit_x)\n"
544 " Display a single port register bit.\n\n"
546 "write reg (port_id) (address) (value)\n"
547 " Set value of a port register.\n\n"
549 "write regfield (port_id) (address) (bit_x) (bit_y)"
551 " Set bit field of a port register.\n\n"
553 "write regbit (port_id) (address) (bit_x) (value)\n"
554 " Set single bit value of a port register.\n\n"
559 cmdline_parse_token_string_t cmd_help_long_help =
560 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
562 cmdline_parse_token_string_t cmd_help_long_section =
563 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
564 "all#control#display#config#flowdir#"
567 cmdline_parse_inst_t cmd_help_long = {
568 .f = cmd_help_long_parsed,
570 .help_str = "show help",
572 (void *)&cmd_help_long_help,
573 (void *)&cmd_help_long_section,
579 /* *** start/stop/close all ports *** */
580 struct cmd_operate_port_result {
581 cmdline_fixed_string_t keyword;
582 cmdline_fixed_string_t name;
583 cmdline_fixed_string_t value;
586 static void cmd_operate_port_parsed(void *parsed_result,
587 __attribute__((unused)) struct cmdline *cl,
588 __attribute__((unused)) void *data)
590 struct cmd_operate_port_result *res = parsed_result;
592 if (!strcmp(res->name, "start"))
593 start_port(RTE_PORT_ALL);
594 else if (!strcmp(res->name, "stop"))
595 stop_port(RTE_PORT_ALL);
596 else if (!strcmp(res->name, "close"))
597 close_port(RTE_PORT_ALL);
599 printf("Unknown parameter\n");
602 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
603 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
605 cmdline_parse_token_string_t cmd_operate_port_all_port =
606 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
608 cmdline_parse_token_string_t cmd_operate_port_all_all =
609 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
611 cmdline_parse_inst_t cmd_operate_port = {
612 .f = cmd_operate_port_parsed,
614 .help_str = "port start|stop|close all: start/stop/close all ports",
616 (void *)&cmd_operate_port_all_cmd,
617 (void *)&cmd_operate_port_all_port,
618 (void *)&cmd_operate_port_all_all,
623 /* *** start/stop/close specific port *** */
624 struct cmd_operate_specific_port_result {
625 cmdline_fixed_string_t keyword;
626 cmdline_fixed_string_t name;
630 static void cmd_operate_specific_port_parsed(void *parsed_result,
631 __attribute__((unused)) struct cmdline *cl,
632 __attribute__((unused)) void *data)
634 struct cmd_operate_specific_port_result *res = parsed_result;
636 if (!strcmp(res->name, "start"))
637 start_port(res->value);
638 else if (!strcmp(res->name, "stop"))
639 stop_port(res->value);
640 else if (!strcmp(res->name, "close"))
641 close_port(res->value);
643 printf("Unknown parameter\n");
646 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
647 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
649 cmdline_parse_token_string_t cmd_operate_specific_port_port =
650 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
651 name, "start#stop#close");
652 cmdline_parse_token_num_t cmd_operate_specific_port_id =
653 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
656 cmdline_parse_inst_t cmd_operate_specific_port = {
657 .f = cmd_operate_specific_port_parsed,
659 .help_str = "port start|stop|close X: start/stop/close port X",
661 (void *)&cmd_operate_specific_port_cmd,
662 (void *)&cmd_operate_specific_port_port,
663 (void *)&cmd_operate_specific_port_id,
668 /* *** configure speed for all ports *** */
669 struct cmd_config_speed_all {
670 cmdline_fixed_string_t port;
671 cmdline_fixed_string_t keyword;
672 cmdline_fixed_string_t all;
673 cmdline_fixed_string_t item1;
674 cmdline_fixed_string_t item2;
675 cmdline_fixed_string_t value1;
676 cmdline_fixed_string_t value2;
680 cmd_config_speed_all_parsed(void *parsed_result,
681 __attribute__((unused)) struct cmdline *cl,
682 __attribute__((unused)) void *data)
684 struct cmd_config_speed_all *res = parsed_result;
685 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
686 uint16_t link_duplex = 0;
689 if (!all_ports_stopped()) {
690 printf("Please stop all ports first\n");
694 if (!strcmp(res->value1, "10"))
695 link_speed = ETH_LINK_SPEED_10;
696 else if (!strcmp(res->value1, "100"))
697 link_speed = ETH_LINK_SPEED_100;
698 else if (!strcmp(res->value1, "1000"))
699 link_speed = ETH_LINK_SPEED_1000;
700 else if (!strcmp(res->value1, "10000"))
701 link_speed = ETH_LINK_SPEED_10000;
702 else if (!strcmp(res->value1, "auto"))
703 link_speed = ETH_LINK_SPEED_AUTONEG;
705 printf("Unknown parameter\n");
709 if (!strcmp(res->value2, "half"))
710 link_duplex = ETH_LINK_HALF_DUPLEX;
711 else if (!strcmp(res->value2, "full"))
712 link_duplex = ETH_LINK_FULL_DUPLEX;
713 else if (!strcmp(res->value2, "auto"))
714 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
716 printf("Unknown parameter\n");
720 for (pid = 0; pid < nb_ports; pid++) {
721 ports[pid].dev_conf.link_speed = link_speed;
722 ports[pid].dev_conf.link_duplex = link_duplex;
725 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
728 cmdline_parse_token_string_t cmd_config_speed_all_port =
729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
730 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
733 cmdline_parse_token_string_t cmd_config_speed_all_all =
734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
735 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
736 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
737 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
739 "10#100#1000#10000#auto");
740 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
742 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
746 cmdline_parse_inst_t cmd_config_speed_all = {
747 .f = cmd_config_speed_all_parsed,
749 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
752 (void *)&cmd_config_speed_all_port,
753 (void *)&cmd_config_speed_all_keyword,
754 (void *)&cmd_config_speed_all_all,
755 (void *)&cmd_config_speed_all_item1,
756 (void *)&cmd_config_speed_all_value1,
757 (void *)&cmd_config_speed_all_item2,
758 (void *)&cmd_config_speed_all_value2,
763 /* *** configure speed for specific port *** */
764 struct cmd_config_speed_specific {
765 cmdline_fixed_string_t port;
766 cmdline_fixed_string_t keyword;
768 cmdline_fixed_string_t item1;
769 cmdline_fixed_string_t item2;
770 cmdline_fixed_string_t value1;
771 cmdline_fixed_string_t value2;
775 cmd_config_speed_specific_parsed(void *parsed_result,
776 __attribute__((unused)) struct cmdline *cl,
777 __attribute__((unused)) void *data)
779 struct cmd_config_speed_specific *res = parsed_result;
780 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
781 uint16_t link_duplex = 0;
783 if (!all_ports_stopped()) {
784 printf("Please stop all ports first\n");
788 if (res->id >= nb_ports) {
789 printf("Port id %d must be less than %d\n", res->id, nb_ports);
793 if (!strcmp(res->value1, "10"))
794 link_speed = ETH_LINK_SPEED_10;
795 else if (!strcmp(res->value1, "100"))
796 link_speed = ETH_LINK_SPEED_100;
797 else if (!strcmp(res->value1, "1000"))
798 link_speed = ETH_LINK_SPEED_1000;
799 else if (!strcmp(res->value1, "10000"))
800 link_speed = ETH_LINK_SPEED_10000;
801 else if (!strcmp(res->value1, "auto"))
802 link_speed = ETH_LINK_SPEED_AUTONEG;
804 printf("Unknown parameter\n");
808 if (!strcmp(res->value2, "half"))
809 link_duplex = ETH_LINK_HALF_DUPLEX;
810 else if (!strcmp(res->value2, "full"))
811 link_duplex = ETH_LINK_FULL_DUPLEX;
812 else if (!strcmp(res->value2, "auto"))
813 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
815 printf("Unknown parameter\n");
819 ports[res->id].dev_conf.link_speed = link_speed;
820 ports[res->id].dev_conf.link_duplex = link_duplex;
822 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
826 cmdline_parse_token_string_t cmd_config_speed_specific_port =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
829 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
830 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
832 cmdline_parse_token_num_t cmd_config_speed_specific_id =
833 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
834 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
835 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
837 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
838 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
839 "10#100#1000#10000#auto");
840 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
841 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
843 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
844 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
847 cmdline_parse_inst_t cmd_config_speed_specific = {
848 .f = cmd_config_speed_specific_parsed,
850 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
853 (void *)&cmd_config_speed_specific_port,
854 (void *)&cmd_config_speed_specific_keyword,
855 (void *)&cmd_config_speed_specific_id,
856 (void *)&cmd_config_speed_specific_item1,
857 (void *)&cmd_config_speed_specific_value1,
858 (void *)&cmd_config_speed_specific_item2,
859 (void *)&cmd_config_speed_specific_value2,
864 /* *** configure txq/rxq, txd/rxd *** */
865 struct cmd_config_rx_tx {
866 cmdline_fixed_string_t port;
867 cmdline_fixed_string_t keyword;
868 cmdline_fixed_string_t all;
869 cmdline_fixed_string_t name;
874 cmd_config_rx_tx_parsed(void *parsed_result,
875 __attribute__((unused)) struct cmdline *cl,
876 __attribute__((unused)) void *data)
878 struct cmd_config_rx_tx *res = parsed_result;
880 if (!all_ports_stopped()) {
881 printf("Please stop all ports first\n");
885 if (!strcmp(res->name, "rxq")) {
886 if (res->value <= 0) {
887 printf("rxq %d invalid - must be > 0\n", res->value);
892 else if (!strcmp(res->name, "txq")) {
893 if (res->value <= 0) {
894 printf("txq %d invalid - must be > 0\n", res->value);
899 else if (!strcmp(res->name, "rxd")) {
900 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
901 printf("rxd %d invalid - must be > 0 && <= %d\n",
902 res->value, RTE_TEST_RX_DESC_MAX);
906 } else if (!strcmp(res->name, "txd")) {
907 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
908 printf("txd %d invalid - must be > 0 && <= %d\n",
909 res->value, RTE_TEST_TX_DESC_MAX);
914 printf("Unknown parameter\n");
920 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
923 cmdline_parse_token_string_t cmd_config_rx_tx_port =
924 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
925 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
926 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
927 cmdline_parse_token_string_t cmd_config_rx_tx_all =
928 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
929 cmdline_parse_token_string_t cmd_config_rx_tx_name =
930 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
932 cmdline_parse_token_num_t cmd_config_rx_tx_value =
933 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
935 cmdline_parse_inst_t cmd_config_rx_tx = {
936 .f = cmd_config_rx_tx_parsed,
938 .help_str = "port config all rxq|txq|rxd|txd value",
940 (void *)&cmd_config_rx_tx_port,
941 (void *)&cmd_config_rx_tx_keyword,
942 (void *)&cmd_config_rx_tx_all,
943 (void *)&cmd_config_rx_tx_name,
944 (void *)&cmd_config_rx_tx_value,
949 /* *** config max packet length *** */
950 struct cmd_config_max_pkt_len_result {
951 cmdline_fixed_string_t port;
952 cmdline_fixed_string_t keyword;
953 cmdline_fixed_string_t all;
954 cmdline_fixed_string_t name;
959 cmd_config_max_pkt_len_parsed(void *parsed_result,
960 __attribute__((unused)) struct cmdline *cl,
961 __attribute__((unused)) void *data)
963 struct cmd_config_max_pkt_len_result *res = parsed_result;
965 if (!all_ports_stopped()) {
966 printf("Please stop all ports first\n");
970 if (!strcmp(res->name, "max-pkt-len")) {
971 if (res->value < ETHER_MIN_LEN) {
972 printf("max-pkt-len can not be less than %d\n",
976 if (res->value == rx_mode.max_rx_pkt_len)
979 rx_mode.max_rx_pkt_len = res->value;
980 if (res->value > ETHER_MAX_LEN)
981 rx_mode.jumbo_frame = 1;
983 rx_mode.jumbo_frame = 0;
985 printf("Unknown parameter\n");
991 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
994 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
997 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
998 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1000 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1001 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1003 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1004 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1006 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1007 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1010 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1011 .f = cmd_config_max_pkt_len_parsed,
1013 .help_str = "port config all max-pkt-len value",
1015 (void *)&cmd_config_max_pkt_len_port,
1016 (void *)&cmd_config_max_pkt_len_keyword,
1017 (void *)&cmd_config_max_pkt_len_all,
1018 (void *)&cmd_config_max_pkt_len_name,
1019 (void *)&cmd_config_max_pkt_len_value,
1024 /* *** configure rx mode *** */
1025 struct cmd_config_rx_mode_flag {
1026 cmdline_fixed_string_t port;
1027 cmdline_fixed_string_t keyword;
1028 cmdline_fixed_string_t all;
1029 cmdline_fixed_string_t name;
1030 cmdline_fixed_string_t value;
1034 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1035 __attribute__((unused)) struct cmdline *cl,
1036 __attribute__((unused)) void *data)
1038 struct cmd_config_rx_mode_flag *res = parsed_result;
1040 if (!all_ports_stopped()) {
1041 printf("Please stop all ports first\n");
1045 if (!strcmp(res->name, "crc-strip")) {
1046 if (!strcmp(res->value, "on"))
1047 rx_mode.hw_strip_crc = 1;
1048 else if (!strcmp(res->value, "off"))
1049 rx_mode.hw_strip_crc = 0;
1051 printf("Unknown parameter\n");
1054 } else if (!strcmp(res->name, "rx-cksum")) {
1055 if (!strcmp(res->value, "on"))
1056 rx_mode.hw_ip_checksum = 1;
1057 else if (!strcmp(res->value, "off"))
1058 rx_mode.hw_ip_checksum = 0;
1060 printf("Unknown parameter\n");
1063 } else if (!strcmp(res->name, "hw-vlan")) {
1064 if (!strcmp(res->value, "on")) {
1065 rx_mode.hw_vlan_filter = 1;
1066 rx_mode.hw_vlan_strip = 1;
1068 else if (!strcmp(res->value, "off")) {
1069 rx_mode.hw_vlan_filter = 0;
1070 rx_mode.hw_vlan_strip = 0;
1073 printf("Unknown parameter\n");
1076 } else if (!strcmp(res->name, "drop-en")) {
1077 if (!strcmp(res->value, "on"))
1079 else if (!strcmp(res->value, "off"))
1082 printf("Unknown parameter\n");
1086 printf("Unknown parameter\n");
1092 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1095 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1096 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1097 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1098 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1100 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1101 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1102 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1103 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1104 "crc-strip#rx-cksum#hw-vlan");
1105 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1106 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1109 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1110 .f = cmd_config_rx_mode_flag_parsed,
1112 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1114 (void *)&cmd_config_rx_mode_flag_port,
1115 (void *)&cmd_config_rx_mode_flag_keyword,
1116 (void *)&cmd_config_rx_mode_flag_all,
1117 (void *)&cmd_config_rx_mode_flag_name,
1118 (void *)&cmd_config_rx_mode_flag_value,
1123 /* *** configure rss *** */
1124 struct cmd_config_rss {
1125 cmdline_fixed_string_t port;
1126 cmdline_fixed_string_t keyword;
1127 cmdline_fixed_string_t all;
1128 cmdline_fixed_string_t name;
1129 cmdline_fixed_string_t value;
1133 cmd_config_rss_parsed(void *parsed_result,
1134 __attribute__((unused)) struct cmdline *cl,
1135 __attribute__((unused)) void *data)
1137 struct cmd_config_rss *res = parsed_result;
1138 struct rte_eth_rss_conf rss_conf;
1141 if (!strcmp(res->value, "ip"))
1142 rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1143 else if (!strcmp(res->value, "udp"))
1144 rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
1145 else if (!strcmp(res->value, "none"))
1146 rss_conf.rss_hf = 0;
1148 printf("Unknown parameter\n");
1151 rss_conf.rss_key = NULL;
1152 for (i = 0; i < rte_eth_dev_count(); i++)
1153 rte_eth_dev_rss_hash_update(i, &rss_conf);
1156 cmdline_parse_token_string_t cmd_config_rss_port =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1158 cmdline_parse_token_string_t cmd_config_rss_keyword =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1160 cmdline_parse_token_string_t cmd_config_rss_all =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1162 cmdline_parse_token_string_t cmd_config_rss_name =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1164 cmdline_parse_token_string_t cmd_config_rss_value =
1165 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1167 cmdline_parse_inst_t cmd_config_rss = {
1168 .f = cmd_config_rss_parsed,
1170 .help_str = "port config all rss ip|udp|none",
1172 (void *)&cmd_config_rss_port,
1173 (void *)&cmd_config_rss_keyword,
1174 (void *)&cmd_config_rss_all,
1175 (void *)&cmd_config_rss_name,
1176 (void *)&cmd_config_rss_value,
1181 /* *** configure rss hash key *** */
1182 struct cmd_config_rss_hash_key {
1183 cmdline_fixed_string_t port;
1184 cmdline_fixed_string_t config;
1186 cmdline_fixed_string_t rss_hash_key;
1187 cmdline_fixed_string_t key;
1190 #define RSS_HASH_KEY_LENGTH 40
1192 hexa_digit_to_value(char hexa_digit)
1194 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1195 return (uint8_t) (hexa_digit - '0');
1196 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1197 return (uint8_t) ((hexa_digit - 'a') + 10);
1198 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1199 return (uint8_t) ((hexa_digit - 'A') + 10);
1200 /* Invalid hexa digit */
1205 parse_and_check_key_hexa_digit(char *key, int idx)
1209 hexa_v = hexa_digit_to_value(key[idx]);
1211 printf("invalid key: character %c at position %d is not a "
1212 "valid hexa digit\n", key[idx], idx);
1217 cmd_config_rss_hash_key_parsed(void *parsed_result,
1218 __attribute__((unused)) struct cmdline *cl,
1219 __attribute__((unused)) void *data)
1221 struct cmd_config_rss_hash_key *res = parsed_result;
1222 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1227 /* Check the length of the RSS hash key */
1228 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1229 printf("key length: %d invalid - key must be a string of %d"
1230 "hexa-decimal numbers\n", (int) strlen(res->key),
1231 RSS_HASH_KEY_LENGTH * 2);
1234 /* Translate RSS hash key into binary representation */
1235 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1236 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1239 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1242 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1244 port_rss_hash_key_update(res->port_id, hash_key);
1247 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1249 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1252 cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
1253 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1254 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1256 rss_hash_key, "rss-hash-key");
1257 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1260 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1261 .f = cmd_config_rss_hash_key_parsed,
1263 .help_str = "port config X rss-hash-key 80 hexa digits",
1265 (void *)&cmd_config_rss_hash_key_port,
1266 (void *)&cmd_config_rss_hash_key_config,
1267 (void *)&cmd_config_rss_hash_key_port_id,
1268 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1269 (void *)&cmd_config_rss_hash_key_value,
1274 /* *** Configure RSS RETA *** */
1275 struct cmd_config_rss_reta {
1276 cmdline_fixed_string_t port;
1277 cmdline_fixed_string_t keyword;
1279 cmdline_fixed_string_t name;
1280 cmdline_fixed_string_t list_name;
1281 cmdline_fixed_string_t list_of_items;
1285 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1292 const char *p, *p0 = str;
1299 unsigned long int_fld[_NUM_FLD];
1300 char *str_fld[_NUM_FLD];
1302 while ((p = strchr(p0,'(')) != NULL) {
1304 if((p0 = strchr(p,')')) == NULL)
1308 if(size >= sizeof(s))
1311 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1312 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1314 for (i = 0; i < _NUM_FLD; i++) {
1316 int_fld[i] = strtoul(str_fld[i], &end, 0);
1317 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1321 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1322 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1324 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1325 printf("Invalid RETA hash index=%d",hash_index);
1329 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1330 reta_conf->mask_lo |= (1ULL << hash_index);
1332 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1334 reta_conf->reta[hash_index] = nb_queue;
1341 cmd_set_rss_reta_parsed(void *parsed_result,
1342 __attribute__((unused)) struct cmdline *cl,
1343 __attribute__((unused)) void *data)
1346 struct rte_eth_rss_reta reta_conf;
1347 struct cmd_config_rss_reta *res = parsed_result;
1349 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1350 if (!strcmp(res->list_name, "reta")) {
1351 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1352 printf("Invalid RSS Redirection Table config entered\n");
1355 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1357 printf("Bad redirection table parameter, return code = %d \n",ret);
1361 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1362 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1363 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1364 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1365 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1366 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1367 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1369 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1371 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1374 cmdline_parse_inst_t cmd_config_rss_reta = {
1375 .f = cmd_set_rss_reta_parsed,
1377 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1379 (void *)&cmd_config_rss_reta_port,
1380 (void *)&cmd_config_rss_reta_keyword,
1381 (void *)&cmd_config_rss_reta_port_id,
1382 (void *)&cmd_config_rss_reta_name,
1383 (void *)&cmd_config_rss_reta_list_name,
1384 (void *)&cmd_config_rss_reta_list_of_items,
1389 /* *** SHOW PORT RETA INFO *** */
1390 struct cmd_showport_reta {
1391 cmdline_fixed_string_t show;
1392 cmdline_fixed_string_t port;
1394 cmdline_fixed_string_t rss;
1395 cmdline_fixed_string_t reta;
1400 static void cmd_showport_reta_parsed(void *parsed_result,
1401 __attribute__((unused)) struct cmdline *cl,
1402 __attribute__((unused)) void *data)
1404 struct cmd_showport_reta *res = parsed_result;
1405 struct rte_eth_rss_reta reta_conf;
1407 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1408 printf("Invalid RSS Redirection Table config entered\n");
1412 reta_conf.mask_lo = res->mask_lo;
1413 reta_conf.mask_hi = res->mask_hi;
1415 port_rss_reta_info(res->port_id,&reta_conf);
1418 cmdline_parse_token_string_t cmd_showport_reta_show =
1419 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1420 cmdline_parse_token_string_t cmd_showport_reta_port =
1421 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1422 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1423 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1424 cmdline_parse_token_string_t cmd_showport_reta_rss =
1425 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1426 cmdline_parse_token_string_t cmd_showport_reta_reta =
1427 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1428 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1429 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1430 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1431 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1433 cmdline_parse_inst_t cmd_showport_reta = {
1434 .f = cmd_showport_reta_parsed,
1436 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1437 (mask_lo and mask_hi is UINT64)",
1439 (void *)&cmd_showport_reta_show,
1440 (void *)&cmd_showport_reta_port,
1441 (void *)&cmd_showport_reta_port_id,
1442 (void *)&cmd_showport_reta_rss,
1443 (void *)&cmd_showport_reta_reta,
1444 (void *)&cmd_showport_reta_mask_lo,
1445 (void *)&cmd_showport_reta_mask_hi,
1450 /* *** Show RSS hash configuration *** */
1451 struct cmd_showport_rss_hash {
1452 cmdline_fixed_string_t show;
1453 cmdline_fixed_string_t port;
1455 cmdline_fixed_string_t rss_hash;
1456 cmdline_fixed_string_t key; /* optional argument */
1459 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1460 __attribute__((unused)) struct cmdline *cl,
1463 struct cmd_showport_rss_hash *res = parsed_result;
1465 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1468 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1469 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1470 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1471 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1472 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1473 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1474 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1475 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1477 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1478 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1480 cmdline_parse_inst_t cmd_showport_rss_hash = {
1481 .f = cmd_showport_rss_hash_parsed,
1483 .help_str = "show port X rss-hash (X = port number)\n",
1485 (void *)&cmd_showport_rss_hash_show,
1486 (void *)&cmd_showport_rss_hash_port,
1487 (void *)&cmd_showport_rss_hash_port_id,
1488 (void *)&cmd_showport_rss_hash_rss_hash,
1493 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1494 .f = cmd_showport_rss_hash_parsed,
1496 .help_str = "show port X rss-hash key (X = port number)\n",
1498 (void *)&cmd_showport_rss_hash_show,
1499 (void *)&cmd_showport_rss_hash_port,
1500 (void *)&cmd_showport_rss_hash_port_id,
1501 (void *)&cmd_showport_rss_hash_rss_hash,
1502 (void *)&cmd_showport_rss_hash_rss_key,
1507 /* *** Configure DCB *** */
1508 struct cmd_config_dcb {
1509 cmdline_fixed_string_t port;
1510 cmdline_fixed_string_t config;
1512 cmdline_fixed_string_t dcb;
1513 cmdline_fixed_string_t vt;
1514 cmdline_fixed_string_t vt_en;
1516 cmdline_fixed_string_t pfc;
1517 cmdline_fixed_string_t pfc_en;
1521 cmd_config_dcb_parsed(void *parsed_result,
1522 __attribute__((unused)) struct cmdline *cl,
1523 __attribute__((unused)) void *data)
1525 struct cmd_config_dcb *res = parsed_result;
1526 struct dcb_config dcb_conf;
1527 portid_t port_id = res->port_id;
1528 struct rte_port *port;
1530 port = &ports[port_id];
1531 /** Check if the port is not started **/
1532 if (port->port_status != RTE_PORT_STOPPED) {
1533 printf("Please stop port %d first\n",port_id);
1537 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1538 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1539 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1543 /* DCB in VT mode */
1544 if (!strncmp(res->vt_en, "on",2))
1545 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1547 dcb_conf.dcb_mode = DCB_ENABLED;
1549 if (!strncmp(res->pfc_en, "on",2)) {
1550 dcb_conf.pfc_en = 1;
1553 dcb_conf.pfc_en = 0;
1555 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1556 printf("Cannot initialize network ports\n");
1560 cmd_reconfig_device_queue(port_id, 1, 1);
1563 cmdline_parse_token_string_t cmd_config_dcb_port =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1565 cmdline_parse_token_string_t cmd_config_dcb_config =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1567 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1568 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1569 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1571 cmdline_parse_token_string_t cmd_config_dcb_vt =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1573 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1575 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1576 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1577 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1579 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1582 cmdline_parse_inst_t cmd_config_dcb = {
1583 .f = cmd_config_dcb_parsed,
1585 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1587 (void *)&cmd_config_dcb_port,
1588 (void *)&cmd_config_dcb_config,
1589 (void *)&cmd_config_dcb_port_id,
1590 (void *)&cmd_config_dcb_dcb,
1591 (void *)&cmd_config_dcb_vt,
1592 (void *)&cmd_config_dcb_vt_en,
1593 (void *)&cmd_config_dcb_num_tcs,
1594 (void *)&cmd_config_dcb_pfc,
1595 (void *)&cmd_config_dcb_pfc_en,
1600 /* *** configure number of packets per burst *** */
1601 struct cmd_config_burst {
1602 cmdline_fixed_string_t port;
1603 cmdline_fixed_string_t keyword;
1604 cmdline_fixed_string_t all;
1605 cmdline_fixed_string_t name;
1610 cmd_config_burst_parsed(void *parsed_result,
1611 __attribute__((unused)) struct cmdline *cl,
1612 __attribute__((unused)) void *data)
1614 struct cmd_config_burst *res = parsed_result;
1616 if (!all_ports_stopped()) {
1617 printf("Please stop all ports first\n");
1621 if (!strcmp(res->name, "burst")) {
1622 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1623 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1626 nb_pkt_per_burst = res->value;
1628 printf("Unknown parameter\n");
1634 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1637 cmdline_parse_token_string_t cmd_config_burst_port =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1639 cmdline_parse_token_string_t cmd_config_burst_keyword =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1641 cmdline_parse_token_string_t cmd_config_burst_all =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1643 cmdline_parse_token_string_t cmd_config_burst_name =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1645 cmdline_parse_token_num_t cmd_config_burst_value =
1646 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1648 cmdline_parse_inst_t cmd_config_burst = {
1649 .f = cmd_config_burst_parsed,
1651 .help_str = "port config all burst value",
1653 (void *)&cmd_config_burst_port,
1654 (void *)&cmd_config_burst_keyword,
1655 (void *)&cmd_config_burst_all,
1656 (void *)&cmd_config_burst_name,
1657 (void *)&cmd_config_burst_value,
1662 /* *** configure rx/tx queues *** */
1663 struct cmd_config_thresh {
1664 cmdline_fixed_string_t port;
1665 cmdline_fixed_string_t keyword;
1666 cmdline_fixed_string_t all;
1667 cmdline_fixed_string_t name;
1672 cmd_config_thresh_parsed(void *parsed_result,
1673 __attribute__((unused)) struct cmdline *cl,
1674 __attribute__((unused)) void *data)
1676 struct cmd_config_thresh *res = parsed_result;
1678 if (!all_ports_stopped()) {
1679 printf("Please stop all ports first\n");
1683 if (!strcmp(res->name, "txpt"))
1684 tx_thresh.pthresh = res->value;
1685 else if(!strcmp(res->name, "txht"))
1686 tx_thresh.hthresh = res->value;
1687 else if(!strcmp(res->name, "txwt"))
1688 tx_thresh.wthresh = res->value;
1689 else if(!strcmp(res->name, "rxpt"))
1690 rx_thresh.pthresh = res->value;
1691 else if(!strcmp(res->name, "rxht"))
1692 rx_thresh.hthresh = res->value;
1693 else if(!strcmp(res->name, "rxwt"))
1694 rx_thresh.wthresh = res->value;
1696 printf("Unknown parameter\n");
1702 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1705 cmdline_parse_token_string_t cmd_config_thresh_port =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1707 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1709 cmdline_parse_token_string_t cmd_config_thresh_all =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1711 cmdline_parse_token_string_t cmd_config_thresh_name =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1713 "txpt#txht#txwt#rxpt#rxht#rxwt");
1714 cmdline_parse_token_num_t cmd_config_thresh_value =
1715 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1717 cmdline_parse_inst_t cmd_config_thresh = {
1718 .f = cmd_config_thresh_parsed,
1720 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1722 (void *)&cmd_config_thresh_port,
1723 (void *)&cmd_config_thresh_keyword,
1724 (void *)&cmd_config_thresh_all,
1725 (void *)&cmd_config_thresh_name,
1726 (void *)&cmd_config_thresh_value,
1731 /* *** configure free/rs threshold *** */
1732 struct cmd_config_threshold {
1733 cmdline_fixed_string_t port;
1734 cmdline_fixed_string_t keyword;
1735 cmdline_fixed_string_t all;
1736 cmdline_fixed_string_t name;
1741 cmd_config_threshold_parsed(void *parsed_result,
1742 __attribute__((unused)) struct cmdline *cl,
1743 __attribute__((unused)) void *data)
1745 struct cmd_config_threshold *res = parsed_result;
1747 if (!all_ports_stopped()) {
1748 printf("Please stop all ports first\n");
1752 if (!strcmp(res->name, "txfreet"))
1753 tx_free_thresh = res->value;
1754 else if (!strcmp(res->name, "txrst"))
1755 tx_rs_thresh = res->value;
1756 else if (!strcmp(res->name, "rxfreet"))
1757 rx_free_thresh = res->value;
1759 printf("Unknown parameter\n");
1765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1768 cmdline_parse_token_string_t cmd_config_threshold_port =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1770 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1773 cmdline_parse_token_string_t cmd_config_threshold_all =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1775 cmdline_parse_token_string_t cmd_config_threshold_name =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1777 "txfreet#txrst#rxfreet");
1778 cmdline_parse_token_num_t cmd_config_threshold_value =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1781 cmdline_parse_inst_t cmd_config_threshold = {
1782 .f = cmd_config_threshold_parsed,
1784 .help_str = "port config all txfreet|txrst|rxfreet value",
1786 (void *)&cmd_config_threshold_port,
1787 (void *)&cmd_config_threshold_keyword,
1788 (void *)&cmd_config_threshold_all,
1789 (void *)&cmd_config_threshold_name,
1790 (void *)&cmd_config_threshold_value,
1796 struct cmd_stop_result {
1797 cmdline_fixed_string_t stop;
1800 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1801 __attribute__((unused)) struct cmdline *cl,
1802 __attribute__((unused)) void *data)
1804 stop_packet_forwarding();
1807 cmdline_parse_token_string_t cmd_stop_stop =
1808 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1810 cmdline_parse_inst_t cmd_stop = {
1811 .f = cmd_stop_parsed,
1813 .help_str = "stop - stop packet forwarding",
1815 (void *)&cmd_stop_stop,
1820 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1823 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1824 unsigned int *parsed_items, int check_unique_values)
1826 unsigned int nb_item;
1834 * First parse all items in the list and store their value.
1839 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1841 if ((c >= '0') && (c <= '9')) {
1842 value = (unsigned int) (value * 10 + (c - '0'));
1847 printf("character %c is not a decimal digit\n", c);
1851 printf("No valid value before comma\n");
1854 if (nb_item < max_items) {
1855 parsed_items[nb_item] = value;
1861 if (nb_item >= max_items) {
1862 printf("Number of %s = %u > %u (maximum items)\n",
1863 item_name, nb_item + 1, max_items);
1866 parsed_items[nb_item++] = value;
1867 if (! check_unique_values)
1871 * Then, check that all values in the list are differents.
1872 * No optimization here...
1874 for (i = 0; i < nb_item; i++) {
1875 for (j = i + 1; j < nb_item; j++) {
1876 if (parsed_items[j] == parsed_items[i]) {
1877 printf("duplicated %s %u at index %u and %u\n",
1878 item_name, parsed_items[i], i, j);
1886 struct cmd_set_list_result {
1887 cmdline_fixed_string_t cmd_keyword;
1888 cmdline_fixed_string_t list_name;
1889 cmdline_fixed_string_t list_of_items;
1892 static void cmd_set_list_parsed(void *parsed_result,
1893 __attribute__((unused)) struct cmdline *cl,
1894 __attribute__((unused)) void *data)
1896 struct cmd_set_list_result *res;
1898 unsigned int lcorelist[RTE_MAX_LCORE];
1899 unsigned int portlist[RTE_MAX_ETHPORTS];
1901 unsigned int nb_item;
1903 res = parsed_result;
1904 if (!strcmp(res->list_name, "corelist")) {
1905 nb_item = parse_item_list(res->list_of_items, "core",
1907 parsed_items.lcorelist, 1);
1909 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1912 if (!strcmp(res->list_name, "portlist")) {
1913 nb_item = parse_item_list(res->list_of_items, "port",
1915 parsed_items.portlist, 1);
1917 set_fwd_ports_list(parsed_items.portlist, nb_item);
1921 cmdline_parse_token_string_t cmd_set_list_keyword =
1922 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1924 cmdline_parse_token_string_t cmd_set_list_name =
1925 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1926 "corelist#portlist");
1927 cmdline_parse_token_string_t cmd_set_list_of_items =
1928 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1931 cmdline_parse_inst_t cmd_set_fwd_list = {
1932 .f = cmd_set_list_parsed,
1934 .help_str = "set corelist|portlist x[,y]*",
1936 (void *)&cmd_set_list_keyword,
1937 (void *)&cmd_set_list_name,
1938 (void *)&cmd_set_list_of_items,
1943 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1945 struct cmd_setmask_result {
1946 cmdline_fixed_string_t set;
1947 cmdline_fixed_string_t mask;
1951 static void cmd_set_mask_parsed(void *parsed_result,
1952 __attribute__((unused)) struct cmdline *cl,
1953 __attribute__((unused)) void *data)
1955 struct cmd_setmask_result *res = parsed_result;
1957 if (!strcmp(res->mask, "coremask"))
1958 set_fwd_lcores_mask(res->hexavalue);
1959 else if (!strcmp(res->mask, "portmask"))
1960 set_fwd_ports_mask(res->hexavalue);
1963 cmdline_parse_token_string_t cmd_setmask_set =
1964 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1965 cmdline_parse_token_string_t cmd_setmask_mask =
1966 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1967 "coremask#portmask");
1968 cmdline_parse_token_num_t cmd_setmask_value =
1969 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1971 cmdline_parse_inst_t cmd_set_fwd_mask = {
1972 .f = cmd_set_mask_parsed,
1974 .help_str = "set coremask|portmask hexadecimal value",
1976 (void *)&cmd_setmask_set,
1977 (void *)&cmd_setmask_mask,
1978 (void *)&cmd_setmask_value,
1984 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1986 struct cmd_set_result {
1987 cmdline_fixed_string_t set;
1988 cmdline_fixed_string_t what;
1992 static void cmd_set_parsed(void *parsed_result,
1993 __attribute__((unused)) struct cmdline *cl,
1994 __attribute__((unused)) void *data)
1996 struct cmd_set_result *res = parsed_result;
1997 if (!strcmp(res->what, "nbport"))
1998 set_fwd_ports_number(res->value);
1999 else if (!strcmp(res->what, "nbcore"))
2000 set_fwd_lcores_number(res->value);
2001 else if (!strcmp(res->what, "burst"))
2002 set_nb_pkt_per_burst(res->value);
2003 else if (!strcmp(res->what, "verbose"))
2004 set_verbose_level(res->value);
2007 cmdline_parse_token_string_t cmd_set_set =
2008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2009 cmdline_parse_token_string_t cmd_set_what =
2010 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2011 "nbport#nbcore#burst#verbose");
2012 cmdline_parse_token_num_t cmd_set_value =
2013 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2015 cmdline_parse_inst_t cmd_set_numbers = {
2016 .f = cmd_set_parsed,
2018 .help_str = "set nbport|nbcore|burst|verbose value",
2020 (void *)&cmd_set_set,
2021 (void *)&cmd_set_what,
2022 (void *)&cmd_set_value,
2027 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2029 struct cmd_set_txpkts_result {
2030 cmdline_fixed_string_t cmd_keyword;
2031 cmdline_fixed_string_t txpkts;
2032 cmdline_fixed_string_t seg_lengths;
2036 cmd_set_txpkts_parsed(void *parsed_result,
2037 __attribute__((unused)) struct cmdline *cl,
2038 __attribute__((unused)) void *data)
2040 struct cmd_set_txpkts_result *res;
2041 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2042 unsigned int nb_segs;
2044 res = parsed_result;
2045 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2046 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2048 set_tx_pkt_segments(seg_lengths, nb_segs);
2051 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2052 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2053 cmd_keyword, "set");
2054 cmdline_parse_token_string_t cmd_set_txpkts_name =
2055 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2057 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2058 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2061 cmdline_parse_inst_t cmd_set_txpkts = {
2062 .f = cmd_set_txpkts_parsed,
2064 .help_str = "set txpkts x[,y]*",
2066 (void *)&cmd_set_txpkts_keyword,
2067 (void *)&cmd_set_txpkts_name,
2068 (void *)&cmd_set_txpkts_lengths,
2073 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2074 struct cmd_rx_vlan_filter_all_result {
2075 cmdline_fixed_string_t rx_vlan;
2076 cmdline_fixed_string_t what;
2077 cmdline_fixed_string_t all;
2082 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2083 __attribute__((unused)) struct cmdline *cl,
2084 __attribute__((unused)) void *data)
2086 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2088 if (!strcmp(res->what, "add"))
2089 rx_vlan_all_filter_set(res->port_id, 1);
2091 rx_vlan_all_filter_set(res->port_id, 0);
2094 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2095 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2096 rx_vlan, "rx_vlan");
2097 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2098 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2100 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2101 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2103 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2104 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2107 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2108 .f = cmd_rx_vlan_filter_all_parsed,
2110 .help_str = "add/remove all identifiers to/from the set of VLAN "
2111 "Identifiers filtered by a port",
2113 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2114 (void *)&cmd_rx_vlan_filter_all_what,
2115 (void *)&cmd_rx_vlan_filter_all_all,
2116 (void *)&cmd_rx_vlan_filter_all_portid,
2121 /* *** VLAN OFFLOAD SET ON A PORT *** */
2122 struct cmd_vlan_offload_result {
2123 cmdline_fixed_string_t vlan;
2124 cmdline_fixed_string_t set;
2125 cmdline_fixed_string_t what;
2126 cmdline_fixed_string_t on;
2127 cmdline_fixed_string_t port_id;
2131 cmd_vlan_offload_parsed(void *parsed_result,
2132 __attribute__((unused)) struct cmdline *cl,
2133 __attribute__((unused)) void *data)
2136 struct cmd_vlan_offload_result *res = parsed_result;
2139 portid_t port_id = 0;
2143 len = strnlen(str, STR_TOKEN_SIZE);
2145 /* Get port_id first */
2153 tmp = strtoul(str, NULL, 0);
2154 /* If port_id greater that what portid_t can represent, return */
2155 if(tmp >= RTE_MAX_ETHPORTS)
2157 port_id = (portid_t)tmp;
2159 if (!strcmp(res->on, "on"))
2164 if (!strcmp(res->what, "strip"))
2165 rx_vlan_strip_set(port_id, on);
2166 else if(!strcmp(res->what, "stripq")){
2167 uint16_t queue_id = 0;
2169 /* No queue_id, return */
2171 printf("must specify (port,queue_id)\n");
2174 tmp = strtoul(str + i + 1, NULL, 0);
2175 /* If queue_id greater that what 16-bits can represent, return */
2179 queue_id = (uint16_t)tmp;
2180 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2182 else if (!strcmp(res->what, "filter"))
2183 rx_vlan_filter_set(port_id, on);
2185 vlan_extend_set(port_id, on);
2190 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2191 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2193 cmdline_parse_token_string_t cmd_vlan_offload_set =
2194 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2196 cmdline_parse_token_string_t cmd_vlan_offload_what =
2197 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2198 what, "strip#filter#qinq#stripq");
2199 cmdline_parse_token_string_t cmd_vlan_offload_on =
2200 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2202 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2203 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2206 cmdline_parse_inst_t cmd_vlan_offload = {
2207 .f = cmd_vlan_offload_parsed,
2209 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2210 " qinq(extended) for both rx/tx sides ",
2212 (void *)&cmd_vlan_offload_vlan,
2213 (void *)&cmd_vlan_offload_set,
2214 (void *)&cmd_vlan_offload_what,
2215 (void *)&cmd_vlan_offload_on,
2216 (void *)&cmd_vlan_offload_portid,
2221 /* *** VLAN TPID SET ON A PORT *** */
2222 struct cmd_vlan_tpid_result {
2223 cmdline_fixed_string_t vlan;
2224 cmdline_fixed_string_t set;
2225 cmdline_fixed_string_t what;
2231 cmd_vlan_tpid_parsed(void *parsed_result,
2232 __attribute__((unused)) struct cmdline *cl,
2233 __attribute__((unused)) void *data)
2235 struct cmd_vlan_tpid_result *res = parsed_result;
2236 vlan_tpid_set(res->port_id, res->tp_id);
2240 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2241 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2243 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2246 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2247 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2249 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2250 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2252 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2253 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2256 cmdline_parse_inst_t cmd_vlan_tpid = {
2257 .f = cmd_vlan_tpid_parsed,
2259 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2261 (void *)&cmd_vlan_tpid_vlan,
2262 (void *)&cmd_vlan_tpid_set,
2263 (void *)&cmd_vlan_tpid_what,
2264 (void *)&cmd_vlan_tpid_tpid,
2265 (void *)&cmd_vlan_tpid_portid,
2270 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2271 struct cmd_rx_vlan_filter_result {
2272 cmdline_fixed_string_t rx_vlan;
2273 cmdline_fixed_string_t what;
2279 cmd_rx_vlan_filter_parsed(void *parsed_result,
2280 __attribute__((unused)) struct cmdline *cl,
2281 __attribute__((unused)) void *data)
2283 struct cmd_rx_vlan_filter_result *res = parsed_result;
2285 if (!strcmp(res->what, "add"))
2286 rx_vft_set(res->port_id, res->vlan_id, 1);
2288 rx_vft_set(res->port_id, res->vlan_id, 0);
2291 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2292 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2293 rx_vlan, "rx_vlan");
2294 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2295 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2297 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2298 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2300 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2301 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2304 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2305 .f = cmd_rx_vlan_filter_parsed,
2307 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2308 "Identifiers filtered by a port",
2310 (void *)&cmd_rx_vlan_filter_rx_vlan,
2311 (void *)&cmd_rx_vlan_filter_what,
2312 (void *)&cmd_rx_vlan_filter_vlanid,
2313 (void *)&cmd_rx_vlan_filter_portid,
2318 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2319 struct cmd_tx_vlan_set_result {
2320 cmdline_fixed_string_t tx_vlan;
2321 cmdline_fixed_string_t set;
2327 cmd_tx_vlan_set_parsed(void *parsed_result,
2328 __attribute__((unused)) struct cmdline *cl,
2329 __attribute__((unused)) void *data)
2331 struct cmd_tx_vlan_set_result *res = parsed_result;
2332 tx_vlan_set(res->port_id, res->vlan_id);
2335 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2337 tx_vlan, "tx_vlan");
2338 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2341 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2344 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2348 cmdline_parse_inst_t cmd_tx_vlan_set = {
2349 .f = cmd_tx_vlan_set_parsed,
2351 .help_str = "enable hardware insertion of a VLAN header with a given "
2352 "TAG Identifier in packets sent on a port",
2354 (void *)&cmd_tx_vlan_set_tx_vlan,
2355 (void *)&cmd_tx_vlan_set_set,
2356 (void *)&cmd_tx_vlan_set_vlanid,
2357 (void *)&cmd_tx_vlan_set_portid,
2362 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2363 struct cmd_tx_vlan_reset_result {
2364 cmdline_fixed_string_t tx_vlan;
2365 cmdline_fixed_string_t reset;
2370 cmd_tx_vlan_reset_parsed(void *parsed_result,
2371 __attribute__((unused)) struct cmdline *cl,
2372 __attribute__((unused)) void *data)
2374 struct cmd_tx_vlan_reset_result *res = parsed_result;
2376 tx_vlan_reset(res->port_id);
2379 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2380 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2381 tx_vlan, "tx_vlan");
2382 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2383 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2385 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2386 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2389 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2390 .f = cmd_tx_vlan_reset_parsed,
2392 .help_str = "disable hardware insertion of a VLAN header in packets "
2395 (void *)&cmd_tx_vlan_reset_tx_vlan,
2396 (void *)&cmd_tx_vlan_reset_reset,
2397 (void *)&cmd_tx_vlan_reset_portid,
2403 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2404 struct cmd_tx_cksum_set_result {
2405 cmdline_fixed_string_t tx_cksum;
2406 cmdline_fixed_string_t set;
2412 cmd_tx_cksum_set_parsed(void *parsed_result,
2413 __attribute__((unused)) struct cmdline *cl,
2414 __attribute__((unused)) void *data)
2416 struct cmd_tx_cksum_set_result *res = parsed_result;
2418 tx_cksum_set(res->port_id, res->cksum_mask);
2421 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2422 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2423 tx_cksum, "tx_checksum");
2424 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2425 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2427 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2428 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2430 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2431 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2434 cmdline_parse_inst_t cmd_tx_cksum_set = {
2435 .f = cmd_tx_cksum_set_parsed,
2437 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2438 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2439 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2441 (void *)&cmd_tx_cksum_set_tx_cksum,
2442 (void *)&cmd_tx_cksum_set_set,
2443 (void *)&cmd_tx_cksum_set_cksum_mask,
2444 (void *)&cmd_tx_cksum_set_portid,
2449 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2450 struct cmd_set_flush_rx {
2451 cmdline_fixed_string_t set;
2452 cmdline_fixed_string_t flush_rx;
2453 cmdline_fixed_string_t mode;
2457 cmd_set_flush_rx_parsed(void *parsed_result,
2458 __attribute__((unused)) struct cmdline *cl,
2459 __attribute__((unused)) void *data)
2461 struct cmd_set_flush_rx *res = parsed_result;
2462 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2465 cmdline_parse_token_string_t cmd_setflushrx_set =
2466 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2468 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2469 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2470 flush_rx, "flush_rx");
2471 cmdline_parse_token_string_t cmd_setflushrx_mode =
2472 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2476 cmdline_parse_inst_t cmd_set_flush_rx = {
2477 .f = cmd_set_flush_rx_parsed,
2478 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2481 (void *)&cmd_setflushrx_set,
2482 (void *)&cmd_setflushrx_flush_rx,
2483 (void *)&cmd_setflushrx_mode,
2488 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2489 struct cmd_set_link_check {
2490 cmdline_fixed_string_t set;
2491 cmdline_fixed_string_t link_check;
2492 cmdline_fixed_string_t mode;
2496 cmd_set_link_check_parsed(void *parsed_result,
2497 __attribute__((unused)) struct cmdline *cl,
2498 __attribute__((unused)) void *data)
2500 struct cmd_set_link_check *res = parsed_result;
2501 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2504 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2505 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2507 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2508 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2509 link_check, "link_check");
2510 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2511 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2515 cmdline_parse_inst_t cmd_set_link_check = {
2516 .f = cmd_set_link_check_parsed,
2517 .help_str = "set link_check on|off: enable/disable link status check "
2518 "when starting/stopping a port",
2521 (void *)&cmd_setlinkcheck_set,
2522 (void *)&cmd_setlinkcheck_link_check,
2523 (void *)&cmd_setlinkcheck_mode,
2528 #ifdef RTE_NIC_BYPASS
2529 /* *** SET NIC BYPASS MODE *** */
2530 struct cmd_set_bypass_mode_result {
2531 cmdline_fixed_string_t set;
2532 cmdline_fixed_string_t bypass;
2533 cmdline_fixed_string_t mode;
2534 cmdline_fixed_string_t value;
2539 cmd_set_bypass_mode_parsed(void *parsed_result,
2540 __attribute__((unused)) struct cmdline *cl,
2541 __attribute__((unused)) void *data)
2543 struct cmd_set_bypass_mode_result *res = parsed_result;
2544 portid_t port_id = res->port_id;
2545 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2547 if (!bypass_is_supported(port_id))
2550 if (!strcmp(res->value, "bypass"))
2551 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2552 else if (!strcmp(res->value, "isolate"))
2553 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2555 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2557 /* Set the bypass mode for the relevant port. */
2558 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2559 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2563 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2566 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2569 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2570 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2572 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2574 value, "normal#bypass#isolate");
2575 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2576 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2579 cmdline_parse_inst_t cmd_set_bypass_mode = {
2580 .f = cmd_set_bypass_mode_parsed,
2581 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2582 "Set the NIC bypass mode for port_id",
2585 (void *)&cmd_setbypass_mode_set,
2586 (void *)&cmd_setbypass_mode_bypass,
2587 (void *)&cmd_setbypass_mode_mode,
2588 (void *)&cmd_setbypass_mode_value,
2589 (void *)&cmd_setbypass_mode_port,
2594 /* *** SET NIC BYPASS EVENT *** */
2595 struct cmd_set_bypass_event_result {
2596 cmdline_fixed_string_t set;
2597 cmdline_fixed_string_t bypass;
2598 cmdline_fixed_string_t event;
2599 cmdline_fixed_string_t event_value;
2600 cmdline_fixed_string_t mode;
2601 cmdline_fixed_string_t mode_value;
2606 cmd_set_bypass_event_parsed(void *parsed_result,
2607 __attribute__((unused)) struct cmdline *cl,
2608 __attribute__((unused)) void *data)
2611 struct cmd_set_bypass_event_result *res = parsed_result;
2612 portid_t port_id = res->port_id;
2613 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2614 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2616 if (!bypass_is_supported(port_id))
2619 if (!strcmp(res->event_value, "timeout"))
2620 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2621 else if (!strcmp(res->event_value, "os_on"))
2622 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2623 else if (!strcmp(res->event_value, "os_off"))
2624 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2625 else if (!strcmp(res->event_value, "power_on"))
2626 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2627 else if (!strcmp(res->event_value, "power_off"))
2628 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2630 bypass_event = RTE_BYPASS_EVENT_NONE;
2632 if (!strcmp(res->mode_value, "bypass"))
2633 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2634 else if (!strcmp(res->mode_value, "isolate"))
2635 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2637 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2639 /* Set the watchdog timeout. */
2640 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2643 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2644 (rc = rte_eth_dev_wd_timeout_store(port_id,
2645 bypass_timeout)) != 0) {
2646 printf("Failed to set timeout value %u "
2647 "for port %d, errto code: %d.\n",
2648 bypass_timeout, port_id, rc);
2652 /* Set the bypass event to transition to bypass mode. */
2653 if (0 != rte_eth_dev_bypass_event_store(port_id,
2654 bypass_event, bypass_mode)) {
2655 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2660 cmdline_parse_token_string_t cmd_setbypass_event_set =
2661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2663 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2666 cmdline_parse_token_string_t cmd_setbypass_event_event =
2667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2669 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2671 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2672 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2675 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2676 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2677 mode_value, "normal#bypass#isolate");
2678 cmdline_parse_token_num_t cmd_setbypass_event_port =
2679 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2682 cmdline_parse_inst_t cmd_set_bypass_event = {
2683 .f = cmd_set_bypass_event_parsed,
2684 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2685 "mode (normal|bypass|isolate) (port_id): "
2686 "Set the NIC bypass event mode for port_id",
2689 (void *)&cmd_setbypass_event_set,
2690 (void *)&cmd_setbypass_event_bypass,
2691 (void *)&cmd_setbypass_event_event,
2692 (void *)&cmd_setbypass_event_event_value,
2693 (void *)&cmd_setbypass_event_mode,
2694 (void *)&cmd_setbypass_event_mode_value,
2695 (void *)&cmd_setbypass_event_port,
2701 /* *** SET NIC BYPASS TIMEOUT *** */
2702 struct cmd_set_bypass_timeout_result {
2703 cmdline_fixed_string_t set;
2704 cmdline_fixed_string_t bypass;
2705 cmdline_fixed_string_t timeout;
2706 cmdline_fixed_string_t value;
2710 cmd_set_bypass_timeout_parsed(void *parsed_result,
2711 __attribute__((unused)) struct cmdline *cl,
2712 __attribute__((unused)) void *data)
2714 struct cmd_set_bypass_timeout_result *res = parsed_result;
2716 if (!strcmp(res->value, "1.5"))
2717 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2718 else if (!strcmp(res->value, "2"))
2719 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2720 else if (!strcmp(res->value, "3"))
2721 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2722 else if (!strcmp(res->value, "4"))
2723 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2724 else if (!strcmp(res->value, "8"))
2725 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2726 else if (!strcmp(res->value, "16"))
2727 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2728 else if (!strcmp(res->value, "32"))
2729 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2731 bypass_timeout = RTE_BYPASS_TMT_OFF;
2734 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2735 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2737 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2738 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2740 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2741 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2742 timeout, "timeout");
2743 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2745 value, "0#1.5#2#3#4#8#16#32");
2747 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2748 .f = cmd_set_bypass_timeout_parsed,
2749 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2750 "Set the NIC bypass watchdog timeout",
2753 (void *)&cmd_setbypass_timeout_set,
2754 (void *)&cmd_setbypass_timeout_bypass,
2755 (void *)&cmd_setbypass_timeout_timeout,
2756 (void *)&cmd_setbypass_timeout_value,
2761 /* *** SHOW NIC BYPASS MODE *** */
2762 struct cmd_show_bypass_config_result {
2763 cmdline_fixed_string_t show;
2764 cmdline_fixed_string_t bypass;
2765 cmdline_fixed_string_t config;
2770 cmd_show_bypass_config_parsed(void *parsed_result,
2771 __attribute__((unused)) struct cmdline *cl,
2772 __attribute__((unused)) void *data)
2774 struct cmd_show_bypass_config_result *res = parsed_result;
2775 uint32_t event_mode;
2776 uint32_t bypass_mode;
2777 portid_t port_id = res->port_id;
2778 uint32_t timeout = bypass_timeout;
2781 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2782 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2783 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2784 {"UNKNOWN", "normal", "bypass", "isolate"};
2785 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2792 int num_events = (sizeof events) / (sizeof events[0]);
2794 if (!bypass_is_supported(port_id))
2797 /* Display the bypass mode.*/
2798 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2799 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2803 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2804 bypass_mode = RTE_BYPASS_MODE_NONE;
2806 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2809 /* Display the bypass timeout.*/
2810 if (!RTE_BYPASS_TMT_VALID(timeout))
2811 timeout = RTE_BYPASS_TMT_OFF;
2813 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2815 /* Display the bypass events and associated modes. */
2816 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2818 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2819 printf("\tFailed to get bypass mode for event = %s\n",
2822 if (!RTE_BYPASS_MODE_VALID(event_mode))
2823 event_mode = RTE_BYPASS_MODE_NONE;
2825 printf("\tbypass event: %-16s = %s\n", events[i],
2831 cmdline_parse_token_string_t cmd_showbypass_config_show =
2832 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2834 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2835 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2837 cmdline_parse_token_string_t cmd_showbypass_config_config =
2838 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2840 cmdline_parse_token_num_t cmd_showbypass_config_port =
2841 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2844 cmdline_parse_inst_t cmd_show_bypass_config = {
2845 .f = cmd_show_bypass_config_parsed,
2846 .help_str = "show bypass config (port_id): "
2847 "Show the NIC bypass config for port_id",
2850 (void *)&cmd_showbypass_config_show,
2851 (void *)&cmd_showbypass_config_bypass,
2852 (void *)&cmd_showbypass_config_config,
2853 (void *)&cmd_showbypass_config_port,
2859 /* *** SET FORWARDING MODE *** */
2860 struct cmd_set_fwd_mode_result {
2861 cmdline_fixed_string_t set;
2862 cmdline_fixed_string_t fwd;
2863 cmdline_fixed_string_t mode;
2866 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2867 __attribute__((unused)) struct cmdline *cl,
2868 __attribute__((unused)) void *data)
2870 struct cmd_set_fwd_mode_result *res = parsed_result;
2872 set_pkt_forwarding_mode(res->mode);
2875 cmdline_parse_token_string_t cmd_setfwd_set =
2876 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2877 cmdline_parse_token_string_t cmd_setfwd_fwd =
2878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2879 cmdline_parse_token_string_t cmd_setfwd_mode =
2880 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2881 "" /* defined at init */);
2883 cmdline_parse_inst_t cmd_set_fwd_mode = {
2884 .f = cmd_set_fwd_mode_parsed,
2886 .help_str = NULL, /* defined at init */
2888 (void *)&cmd_setfwd_set,
2889 (void *)&cmd_setfwd_fwd,
2890 (void *)&cmd_setfwd_mode,
2895 static void cmd_set_fwd_mode_init(void)
2898 static char token[128];
2899 static char help[256];
2900 cmdline_parse_token_string_t *token_struct;
2902 modes = list_pkt_forwarding_modes();
2903 rte_snprintf(help, sizeof help, "set fwd %s - "
2904 "set packet forwarding mode", modes);
2905 cmd_set_fwd_mode.help_str = help;
2907 /* string token separator is # */
2908 for (c = token; *modes != '\0'; modes++)
2913 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2914 token_struct->string_data.str = token;
2917 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2918 struct cmd_set_burst_tx_retry_result {
2919 cmdline_fixed_string_t set;
2920 cmdline_fixed_string_t burst;
2921 cmdline_fixed_string_t tx;
2922 cmdline_fixed_string_t delay;
2924 cmdline_fixed_string_t retry;
2928 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2929 __attribute__((unused)) struct cmdline *cl,
2930 __attribute__((unused)) void *data)
2932 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2934 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2935 && !strcmp(res->tx, "tx")) {
2936 if (!strcmp(res->delay, "delay"))
2937 burst_tx_delay_time = res->time;
2938 if (!strcmp(res->retry, "retry"))
2939 burst_tx_retry_num = res->retry_num;
2944 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2945 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2946 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2947 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2949 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2950 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2951 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2952 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2953 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2954 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2955 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2956 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2957 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2958 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2960 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2961 .f = cmd_set_burst_tx_retry_parsed,
2962 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2964 (void *)&cmd_set_burst_tx_retry_set,
2965 (void *)&cmd_set_burst_tx_retry_burst,
2966 (void *)&cmd_set_burst_tx_retry_tx,
2967 (void *)&cmd_set_burst_tx_retry_delay,
2968 (void *)&cmd_set_burst_tx_retry_time,
2969 (void *)&cmd_set_burst_tx_retry_retry,
2970 (void *)&cmd_set_burst_tx_retry_retry_num,
2975 /* *** SET PROMISC MODE *** */
2976 struct cmd_set_promisc_mode_result {
2977 cmdline_fixed_string_t set;
2978 cmdline_fixed_string_t promisc;
2979 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2980 uint8_t port_num; /* valid if "allports" argument == 0 */
2981 cmdline_fixed_string_t mode;
2984 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2985 __attribute__((unused)) struct cmdline *cl,
2988 struct cmd_set_promisc_mode_result *res = parsed_result;
2992 if (!strcmp(res->mode, "on"))
2999 for (i = 0; i < nb_ports; i++) {
3001 rte_eth_promiscuous_enable(i);
3003 rte_eth_promiscuous_disable(i);
3008 rte_eth_promiscuous_enable(res->port_num);
3010 rte_eth_promiscuous_disable(res->port_num);
3014 cmdline_parse_token_string_t cmd_setpromisc_set =
3015 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3016 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3017 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3019 cmdline_parse_token_string_t cmd_setpromisc_portall =
3020 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3022 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3023 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3025 cmdline_parse_token_string_t cmd_setpromisc_mode =
3026 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3029 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3030 .f = cmd_set_promisc_mode_parsed,
3032 .help_str = "set promisc all on|off: set promisc mode for all ports",
3034 (void *)&cmd_setpromisc_set,
3035 (void *)&cmd_setpromisc_promisc,
3036 (void *)&cmd_setpromisc_portall,
3037 (void *)&cmd_setpromisc_mode,
3042 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3043 .f = cmd_set_promisc_mode_parsed,
3045 .help_str = "set promisc X on|off: set promisc mode on port X",
3047 (void *)&cmd_setpromisc_set,
3048 (void *)&cmd_setpromisc_promisc,
3049 (void *)&cmd_setpromisc_portnum,
3050 (void *)&cmd_setpromisc_mode,
3055 /* *** SET ALLMULTI MODE *** */
3056 struct cmd_set_allmulti_mode_result {
3057 cmdline_fixed_string_t set;
3058 cmdline_fixed_string_t allmulti;
3059 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3060 uint8_t port_num; /* valid if "allports" argument == 0 */
3061 cmdline_fixed_string_t mode;
3064 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3065 __attribute__((unused)) struct cmdline *cl,
3068 struct cmd_set_allmulti_mode_result *res = parsed_result;
3072 if (!strcmp(res->mode, "on"))
3079 for (i = 0; i < nb_ports; i++) {
3081 rte_eth_allmulticast_enable(i);
3083 rte_eth_allmulticast_disable(i);
3088 rte_eth_allmulticast_enable(res->port_num);
3090 rte_eth_allmulticast_disable(res->port_num);
3094 cmdline_parse_token_string_t cmd_setallmulti_set =
3095 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3096 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3099 cmdline_parse_token_string_t cmd_setallmulti_portall =
3100 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3102 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3103 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3105 cmdline_parse_token_string_t cmd_setallmulti_mode =
3106 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3109 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3110 .f = cmd_set_allmulti_mode_parsed,
3112 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3114 (void *)&cmd_setallmulti_set,
3115 (void *)&cmd_setallmulti_allmulti,
3116 (void *)&cmd_setallmulti_portall,
3117 (void *)&cmd_setallmulti_mode,
3122 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3123 .f = cmd_set_allmulti_mode_parsed,
3125 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3127 (void *)&cmd_setallmulti_set,
3128 (void *)&cmd_setallmulti_allmulti,
3129 (void *)&cmd_setallmulti_portnum,
3130 (void *)&cmd_setallmulti_mode,
3135 /* *** ADD/REMOVE A PKT FILTER *** */
3136 struct cmd_pkt_filter_result {
3137 cmdline_fixed_string_t pkt_filter;
3139 cmdline_fixed_string_t protocol;
3140 cmdline_fixed_string_t src;
3141 cmdline_ipaddr_t ip_src;
3143 cmdline_fixed_string_t dst;
3144 cmdline_ipaddr_t ip_dst;
3146 cmdline_fixed_string_t flexbytes;
3147 uint16_t flexbytes_value;
3148 cmdline_fixed_string_t vlan;
3150 cmdline_fixed_string_t queue;
3152 cmdline_fixed_string_t soft;
3157 cmd_pkt_filter_parsed(void *parsed_result,
3158 __attribute__((unused)) struct cmdline *cl,
3159 __attribute__((unused)) void *data)
3161 struct rte_fdir_filter fdir_filter;
3162 struct cmd_pkt_filter_result *res = parsed_result;
3164 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3166 if (res->ip_src.family == AF_INET)
3167 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3169 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3170 &(res->ip_src.addr.ipv6),
3171 sizeof(struct in6_addr));
3173 if (res->ip_dst.family == AF_INET)
3174 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3176 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3177 &(res->ip_dst.addr.ipv6),
3178 sizeof(struct in6_addr));
3180 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3181 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3183 if (!strcmp(res->protocol, "udp"))
3184 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3185 else if (!strcmp(res->protocol, "tcp"))
3186 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3187 else if (!strcmp(res->protocol, "sctp"))
3188 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3189 else /* default only IP */
3190 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3192 if (res->ip_dst.family == AF_INET6)
3193 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3195 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3197 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3198 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3200 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3201 fdir_add_signature_filter(res->port_id, res->queue_id,
3203 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3204 fdir_update_signature_filter(res->port_id, res->queue_id,
3206 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3207 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3208 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3209 fdir_add_perfect_filter(res->port_id, res->soft_id,
3211 (uint8_t) (res->queue_id < 0),
3213 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3214 fdir_update_perfect_filter(res->port_id, res->soft_id,
3216 (uint8_t) (res->queue_id < 0),
3218 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3219 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3225 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3226 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3228 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3229 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3230 protocol, "ip#tcp#udp#sctp");
3231 cmdline_parse_token_string_t cmd_pkt_filter_src =
3232 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3234 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3235 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3237 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3238 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3240 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3241 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3243 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3244 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3246 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3247 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3249 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3250 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3251 flexbytes, "flexbytes");
3252 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3253 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3254 flexbytes_value, UINT16);
3255 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3256 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3258 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3259 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3261 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3262 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3264 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3265 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3267 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3268 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3270 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3271 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3275 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3276 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3277 pkt_filter, "add_signature_filter");
3278 cmdline_parse_inst_t cmd_add_signature_filter = {
3279 .f = cmd_pkt_filter_parsed,
3281 .help_str = "add a signature filter",
3283 (void *)&cmd_pkt_filter_add_signature_filter,
3284 (void *)&cmd_pkt_filter_port_id,
3285 (void *)&cmd_pkt_filter_protocol,
3286 (void *)&cmd_pkt_filter_src,
3287 (void *)&cmd_pkt_filter_ip_src,
3288 (void *)&cmd_pkt_filter_port_src,
3289 (void *)&cmd_pkt_filter_dst,
3290 (void *)&cmd_pkt_filter_ip_dst,
3291 (void *)&cmd_pkt_filter_port_dst,
3292 (void *)&cmd_pkt_filter_flexbytes,
3293 (void *)&cmd_pkt_filter_flexbytes_value,
3294 (void *)&cmd_pkt_filter_vlan,
3295 (void *)&cmd_pkt_filter_vlan_id,
3296 (void *)&cmd_pkt_filter_queue,
3297 (void *)&cmd_pkt_filter_queue_id,
3303 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3304 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3305 pkt_filter, "upd_signature_filter");
3306 cmdline_parse_inst_t cmd_upd_signature_filter = {
3307 .f = cmd_pkt_filter_parsed,
3309 .help_str = "update a signature filter",
3311 (void *)&cmd_pkt_filter_upd_signature_filter,
3312 (void *)&cmd_pkt_filter_port_id,
3313 (void *)&cmd_pkt_filter_protocol,
3314 (void *)&cmd_pkt_filter_src,
3315 (void *)&cmd_pkt_filter_ip_src,
3316 (void *)&cmd_pkt_filter_port_src,
3317 (void *)&cmd_pkt_filter_dst,
3318 (void *)&cmd_pkt_filter_ip_dst,
3319 (void *)&cmd_pkt_filter_port_dst,
3320 (void *)&cmd_pkt_filter_flexbytes,
3321 (void *)&cmd_pkt_filter_flexbytes_value,
3322 (void *)&cmd_pkt_filter_vlan,
3323 (void *)&cmd_pkt_filter_vlan_id,
3324 (void *)&cmd_pkt_filter_queue,
3325 (void *)&cmd_pkt_filter_queue_id,
3331 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3332 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3333 pkt_filter, "rm_signature_filter");
3334 cmdline_parse_inst_t cmd_rm_signature_filter = {
3335 .f = cmd_pkt_filter_parsed,
3337 .help_str = "remove a signature filter",
3339 (void *)&cmd_pkt_filter_rm_signature_filter,
3340 (void *)&cmd_pkt_filter_port_id,
3341 (void *)&cmd_pkt_filter_protocol,
3342 (void *)&cmd_pkt_filter_src,
3343 (void *)&cmd_pkt_filter_ip_src,
3344 (void *)&cmd_pkt_filter_port_src,
3345 (void *)&cmd_pkt_filter_dst,
3346 (void *)&cmd_pkt_filter_ip_dst,
3347 (void *)&cmd_pkt_filter_port_dst,
3348 (void *)&cmd_pkt_filter_flexbytes,
3349 (void *)&cmd_pkt_filter_flexbytes_value,
3350 (void *)&cmd_pkt_filter_vlan,
3351 (void *)&cmd_pkt_filter_vlan_id,
3357 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3358 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3359 pkt_filter, "add_perfect_filter");
3360 cmdline_parse_inst_t cmd_add_perfect_filter = {
3361 .f = cmd_pkt_filter_parsed,
3363 .help_str = "add a perfect filter",
3365 (void *)&cmd_pkt_filter_add_perfect_filter,
3366 (void *)&cmd_pkt_filter_port_id,
3367 (void *)&cmd_pkt_filter_protocol,
3368 (void *)&cmd_pkt_filter_src,
3369 (void *)&cmd_pkt_filter_ip_src,
3370 (void *)&cmd_pkt_filter_port_src,
3371 (void *)&cmd_pkt_filter_dst,
3372 (void *)&cmd_pkt_filter_ip_dst,
3373 (void *)&cmd_pkt_filter_port_dst,
3374 (void *)&cmd_pkt_filter_flexbytes,
3375 (void *)&cmd_pkt_filter_flexbytes_value,
3376 (void *)&cmd_pkt_filter_vlan,
3377 (void *)&cmd_pkt_filter_vlan_id,
3378 (void *)&cmd_pkt_filter_queue,
3379 (void *)&cmd_pkt_filter_queue_id,
3380 (void *)&cmd_pkt_filter_soft,
3381 (void *)&cmd_pkt_filter_soft_id,
3387 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3388 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3389 pkt_filter, "upd_perfect_filter");
3390 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3391 .f = cmd_pkt_filter_parsed,
3393 .help_str = "update a perfect filter",
3395 (void *)&cmd_pkt_filter_upd_perfect_filter,
3396 (void *)&cmd_pkt_filter_port_id,
3397 (void *)&cmd_pkt_filter_protocol,
3398 (void *)&cmd_pkt_filter_src,
3399 (void *)&cmd_pkt_filter_ip_src,
3400 (void *)&cmd_pkt_filter_port_src,
3401 (void *)&cmd_pkt_filter_dst,
3402 (void *)&cmd_pkt_filter_ip_dst,
3403 (void *)&cmd_pkt_filter_port_dst,
3404 (void *)&cmd_pkt_filter_flexbytes,
3405 (void *)&cmd_pkt_filter_flexbytes_value,
3406 (void *)&cmd_pkt_filter_vlan,
3407 (void *)&cmd_pkt_filter_vlan_id,
3408 (void *)&cmd_pkt_filter_queue,
3409 (void *)&cmd_pkt_filter_queue_id,
3410 (void *)&cmd_pkt_filter_soft,
3411 (void *)&cmd_pkt_filter_soft_id,
3417 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3418 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3419 pkt_filter, "rm_perfect_filter");
3420 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3421 .f = cmd_pkt_filter_parsed,
3423 .help_str = "remove a perfect filter",
3425 (void *)&cmd_pkt_filter_rm_perfect_filter,
3426 (void *)&cmd_pkt_filter_port_id,
3427 (void *)&cmd_pkt_filter_protocol,
3428 (void *)&cmd_pkt_filter_src,
3429 (void *)&cmd_pkt_filter_ip_src,
3430 (void *)&cmd_pkt_filter_port_src,
3431 (void *)&cmd_pkt_filter_dst,
3432 (void *)&cmd_pkt_filter_ip_dst,
3433 (void *)&cmd_pkt_filter_port_dst,
3434 (void *)&cmd_pkt_filter_flexbytes,
3435 (void *)&cmd_pkt_filter_flexbytes_value,
3436 (void *)&cmd_pkt_filter_vlan,
3437 (void *)&cmd_pkt_filter_vlan_id,
3438 (void *)&cmd_pkt_filter_soft,
3439 (void *)&cmd_pkt_filter_soft_id,
3444 /* *** SETUP MASKS FILTER *** */
3445 struct cmd_pkt_filter_masks_result {
3446 cmdline_fixed_string_t filter_mask;
3448 cmdline_fixed_string_t src_mask;
3449 uint32_t ip_src_mask;
3450 uint16_t ipv6_src_mask;
3451 uint16_t port_src_mask;
3452 cmdline_fixed_string_t dst_mask;
3453 uint32_t ip_dst_mask;
3454 uint16_t ipv6_dst_mask;
3455 uint16_t port_dst_mask;
3456 cmdline_fixed_string_t flexbytes;
3457 uint8_t flexbytes_value;
3458 cmdline_fixed_string_t vlan_id;
3459 uint8_t vlan_id_value;
3460 cmdline_fixed_string_t vlan_prio;
3461 uint8_t vlan_prio_value;
3462 cmdline_fixed_string_t only_ip_flow;
3463 uint8_t only_ip_flow_value;
3464 cmdline_fixed_string_t comp_ipv6_dst;
3465 uint8_t comp_ipv6_dst_value;
3469 cmd_pkt_filter_masks_parsed(void *parsed_result,
3470 __attribute__((unused)) struct cmdline *cl,
3471 __attribute__((unused)) void *data)
3473 struct rte_fdir_masks fdir_masks;
3474 struct cmd_pkt_filter_masks_result *res = parsed_result;
3476 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3478 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3479 fdir_masks.vlan_id = res->vlan_id_value;
3480 fdir_masks.vlan_prio = res->vlan_prio_value;
3481 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3482 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3483 fdir_masks.src_port_mask = res->port_src_mask;
3484 fdir_masks.dst_port_mask = res->port_dst_mask;
3485 fdir_masks.flexbytes = res->flexbytes_value;
3487 fdir_set_masks(res->port_id, &fdir_masks);
3490 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3491 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3492 filter_mask, "set_masks_filter");
3493 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3494 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3496 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3497 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3498 only_ip_flow, "only_ip_flow");
3499 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3500 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3501 only_ip_flow_value, UINT8);
3502 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3503 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3504 src_mask, "src_mask");
3505 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3506 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3507 ip_src_mask, UINT32);
3508 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3509 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3510 port_src_mask, UINT16);
3511 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3512 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3513 dst_mask, "dst_mask");
3514 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3515 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3516 ip_dst_mask, UINT32);
3517 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3518 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3519 port_dst_mask, UINT16);
3520 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3521 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3522 flexbytes, "flexbytes");
3523 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3524 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3525 flexbytes_value, UINT8);
3526 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3527 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3528 vlan_id, "vlan_id");
3529 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3530 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3531 vlan_id_value, UINT8);
3532 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3533 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3534 vlan_prio, "vlan_prio");
3535 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3536 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3537 vlan_prio_value, UINT8);
3539 cmdline_parse_inst_t cmd_set_masks_filter = {
3540 .f = cmd_pkt_filter_masks_parsed,
3542 .help_str = "setup masks filter",
3544 (void *)&cmd_pkt_filter_masks_filter_mask,
3545 (void *)&cmd_pkt_filter_masks_port_id,
3546 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3547 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3548 (void *)&cmd_pkt_filter_masks_src_mask,
3549 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3550 (void *)&cmd_pkt_filter_masks_port_src_mask,
3551 (void *)&cmd_pkt_filter_masks_dst_mask,
3552 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3553 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3554 (void *)&cmd_pkt_filter_masks_flexbytes,
3555 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3556 (void *)&cmd_pkt_filter_masks_vlan_id,
3557 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3558 (void *)&cmd_pkt_filter_masks_vlan_prio,
3559 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3565 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3566 __attribute__((unused)) struct cmdline *cl,
3567 __attribute__((unused)) void *data)
3569 struct rte_fdir_masks fdir_masks;
3570 struct cmd_pkt_filter_masks_result *res = parsed_result;
3572 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3574 fdir_masks.set_ipv6_mask = 1;
3575 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3576 fdir_masks.vlan_id = res->vlan_id_value;
3577 fdir_masks.vlan_prio = res->vlan_prio_value;
3578 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3579 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3580 fdir_masks.src_port_mask = res->port_src_mask;
3581 fdir_masks.dst_port_mask = res->port_dst_mask;
3582 fdir_masks.flexbytes = res->flexbytes_value;
3583 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3585 fdir_set_masks(res->port_id, &fdir_masks);
3588 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3589 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3590 filter_mask, "set_ipv6_masks_filter");
3591 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3592 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3593 ipv6_src_mask, UINT16);
3594 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3595 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3596 ipv6_dst_mask, UINT16);
3598 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3599 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3600 comp_ipv6_dst, "compare_dst");
3601 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3602 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3603 comp_ipv6_dst_value, UINT8);
3605 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3606 .f = cmd_pkt_filter_masks_ipv6_parsed,
3608 .help_str = "setup ipv6 masks filter",
3610 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3611 (void *)&cmd_pkt_filter_masks_port_id,
3612 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3613 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3614 (void *)&cmd_pkt_filter_masks_src_mask,
3615 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3616 (void *)&cmd_pkt_filter_masks_port_src_mask,
3617 (void *)&cmd_pkt_filter_masks_dst_mask,
3618 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3619 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3620 (void *)&cmd_pkt_filter_masks_flexbytes,
3621 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3622 (void *)&cmd_pkt_filter_masks_vlan_id,
3623 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3624 (void *)&cmd_pkt_filter_masks_vlan_prio,
3625 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3626 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3627 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3632 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3633 struct cmd_link_flow_ctrl_set_result {
3634 cmdline_fixed_string_t set;
3635 cmdline_fixed_string_t flow_ctrl;
3636 cmdline_fixed_string_t rx;
3637 cmdline_fixed_string_t rx_lfc_mode;
3638 cmdline_fixed_string_t tx;
3639 cmdline_fixed_string_t tx_lfc_mode;
3640 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3641 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3642 uint32_t high_water;
3644 uint16_t pause_time;
3650 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3651 __attribute__((unused)) struct cmdline *cl,
3652 __attribute__((unused)) void *data)
3654 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3655 struct rte_eth_fc_conf fc_conf;
3656 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3660 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3661 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3662 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3663 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3665 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3666 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3669 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3670 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3671 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3673 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3674 fc_conf.high_water = res->high_water;
3675 fc_conf.low_water = res->low_water;
3676 fc_conf.pause_time = res->pause_time;
3677 fc_conf.send_xon = res->send_xon;
3678 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3680 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3682 printf("bad flow contrl parameter, return code = %d \n", ret);
3685 cmdline_parse_token_string_t cmd_lfc_set_set =
3686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3688 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3690 flow_ctrl, "flow_ctrl");
3691 cmdline_parse_token_string_t cmd_lfc_set_rx =
3692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3694 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3696 rx_lfc_mode, "on#off");
3697 cmdline_parse_token_string_t cmd_lfc_set_tx =
3698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3700 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3702 tx_lfc_mode, "on#off");
3703 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3704 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3705 high_water, UINT32);
3706 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3707 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3709 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3710 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3711 pause_time, UINT16);
3712 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3713 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3715 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3717 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3718 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3719 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3720 mac_ctrl_frame_fwd_mode, "on#off");
3721 cmdline_parse_token_num_t cmd_lfc_set_portid =
3722 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3725 cmdline_parse_inst_t cmd_link_flow_control_set = {
3726 .f = cmd_link_flow_ctrl_set_parsed,
3728 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3729 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3732 (void *)&cmd_lfc_set_set,
3733 (void *)&cmd_lfc_set_flow_ctrl,
3734 (void *)&cmd_lfc_set_rx,
3735 (void *)&cmd_lfc_set_rx_mode,
3736 (void *)&cmd_lfc_set_tx,
3737 (void *)&cmd_lfc_set_tx_mode,
3738 (void *)&cmd_lfc_set_high_water,
3739 (void *)&cmd_lfc_set_low_water,
3740 (void *)&cmd_lfc_set_pause_time,
3741 (void *)&cmd_lfc_set_send_xon,
3742 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3743 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3744 (void *)&cmd_lfc_set_portid,
3749 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3750 struct cmd_priority_flow_ctrl_set_result {
3751 cmdline_fixed_string_t set;
3752 cmdline_fixed_string_t pfc_ctrl;
3753 cmdline_fixed_string_t rx;
3754 cmdline_fixed_string_t rx_pfc_mode;
3755 cmdline_fixed_string_t tx;
3756 cmdline_fixed_string_t tx_pfc_mode;
3757 uint32_t high_water;
3759 uint16_t pause_time;
3765 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3766 __attribute__((unused)) struct cmdline *cl,
3767 __attribute__((unused)) void *data)
3769 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3770 struct rte_eth_pfc_conf pfc_conf;
3771 int rx_fc_enable, tx_fc_enable;
3775 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3776 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3777 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3778 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3780 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3781 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3784 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3785 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3786 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3787 pfc_conf.fc.high_water = res->high_water;
3788 pfc_conf.fc.low_water = res->low_water;
3789 pfc_conf.fc.pause_time = res->pause_time;
3790 pfc_conf.priority = res->priority;
3792 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3794 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3797 cmdline_parse_token_string_t cmd_pfc_set_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3800 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3801 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3802 pfc_ctrl, "pfc_ctrl");
3803 cmdline_parse_token_string_t cmd_pfc_set_rx =
3804 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3806 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3807 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3808 rx_pfc_mode, "on#off");
3809 cmdline_parse_token_string_t cmd_pfc_set_tx =
3810 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3812 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3813 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3814 tx_pfc_mode, "on#off");
3815 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3816 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3817 high_water, UINT32);
3818 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3819 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3821 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3822 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3823 pause_time, UINT16);
3824 cmdline_parse_token_num_t cmd_pfc_set_priority =
3825 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3827 cmdline_parse_token_num_t cmd_pfc_set_portid =
3828 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3831 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3832 .f = cmd_priority_flow_ctrl_set_parsed,
3834 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3835 tx on|off high_water low_water pause_time priority port_id",
3837 (void *)&cmd_pfc_set_set,
3838 (void *)&cmd_pfc_set_flow_ctrl,
3839 (void *)&cmd_pfc_set_rx,
3840 (void *)&cmd_pfc_set_rx_mode,
3841 (void *)&cmd_pfc_set_tx,
3842 (void *)&cmd_pfc_set_tx_mode,
3843 (void *)&cmd_pfc_set_high_water,
3844 (void *)&cmd_pfc_set_low_water,
3845 (void *)&cmd_pfc_set_pause_time,
3846 (void *)&cmd_pfc_set_priority,
3847 (void *)&cmd_pfc_set_portid,
3852 /* *** RESET CONFIGURATION *** */
3853 struct cmd_reset_result {
3854 cmdline_fixed_string_t reset;
3855 cmdline_fixed_string_t def;
3858 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3860 __attribute__((unused)) void *data)
3862 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3863 set_def_fwd_config();
3866 cmdline_parse_token_string_t cmd_reset_set =
3867 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3868 cmdline_parse_token_string_t cmd_reset_def =
3869 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3872 cmdline_parse_inst_t cmd_reset = {
3873 .f = cmd_reset_parsed,
3875 .help_str = "set default: reset default forwarding configuration",
3877 (void *)&cmd_reset_set,
3878 (void *)&cmd_reset_def,
3883 /* *** START FORWARDING *** */
3884 struct cmd_start_result {
3885 cmdline_fixed_string_t start;
3888 cmdline_parse_token_string_t cmd_start_start =
3889 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3891 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3892 __attribute__((unused)) struct cmdline *cl,
3893 __attribute__((unused)) void *data)
3895 start_packet_forwarding(0);
3898 cmdline_parse_inst_t cmd_start = {
3899 .f = cmd_start_parsed,
3901 .help_str = "start packet forwarding",
3903 (void *)&cmd_start_start,
3908 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3909 struct cmd_start_tx_first_result {
3910 cmdline_fixed_string_t start;
3911 cmdline_fixed_string_t tx_first;
3915 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3916 __attribute__((unused)) struct cmdline *cl,
3917 __attribute__((unused)) void *data)
3919 start_packet_forwarding(1);
3922 cmdline_parse_token_string_t cmd_start_tx_first_start =
3923 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3925 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3926 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3927 tx_first, "tx_first");
3929 cmdline_parse_inst_t cmd_start_tx_first = {
3930 .f = cmd_start_tx_first_parsed,
3932 .help_str = "start packet forwarding, after sending 1 burst of packets",
3934 (void *)&cmd_start_tx_first_start,
3935 (void *)&cmd_start_tx_first_tx_first,
3940 /* *** SET LINK UP *** */
3941 struct cmd_set_link_up_result {
3942 cmdline_fixed_string_t set;
3943 cmdline_fixed_string_t link_up;
3944 cmdline_fixed_string_t port;
3948 cmdline_parse_token_string_t cmd_set_link_up_set =
3949 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
3950 cmdline_parse_token_string_t cmd_set_link_up_link_up =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
3953 cmdline_parse_token_string_t cmd_set_link_up_port =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
3955 cmdline_parse_token_num_t cmd_set_link_up_port_id =
3956 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
3958 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
3959 __attribute__((unused)) struct cmdline *cl,
3960 __attribute__((unused)) void *data)
3962 struct cmd_set_link_up_result *res = parsed_result;
3963 dev_set_link_up(res->port_id);
3966 cmdline_parse_inst_t cmd_set_link_up = {
3967 .f = cmd_set_link_up_parsed,
3969 .help_str = "set link-up port (port id)",
3971 (void *)&cmd_set_link_up_set,
3972 (void *)&cmd_set_link_up_link_up,
3973 (void *)&cmd_set_link_up_port,
3974 (void *)&cmd_set_link_up_port_id,
3979 /* *** SET LINK DOWN *** */
3980 struct cmd_set_link_down_result {
3981 cmdline_fixed_string_t set;
3982 cmdline_fixed_string_t link_down;
3983 cmdline_fixed_string_t port;
3987 cmdline_parse_token_string_t cmd_set_link_down_set =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
3989 cmdline_parse_token_string_t cmd_set_link_down_link_down =
3990 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
3992 cmdline_parse_token_string_t cmd_set_link_down_port =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
3994 cmdline_parse_token_num_t cmd_set_link_down_port_id =
3995 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
3997 static void cmd_set_link_down_parsed(
3998 __attribute__((unused)) void *parsed_result,
3999 __attribute__((unused)) struct cmdline *cl,
4000 __attribute__((unused)) void *data)
4002 struct cmd_set_link_down_result *res = parsed_result;
4003 dev_set_link_down(res->port_id);
4006 cmdline_parse_inst_t cmd_set_link_down = {
4007 .f = cmd_set_link_down_parsed,
4009 .help_str = "set link-down port (port id)",
4011 (void *)&cmd_set_link_down_set,
4012 (void *)&cmd_set_link_down_link_down,
4013 (void *)&cmd_set_link_down_port,
4014 (void *)&cmd_set_link_down_port_id,
4019 /* *** SHOW CFG *** */
4020 struct cmd_showcfg_result {
4021 cmdline_fixed_string_t show;
4022 cmdline_fixed_string_t cfg;
4023 cmdline_fixed_string_t what;
4026 static void cmd_showcfg_parsed(void *parsed_result,
4027 __attribute__((unused)) struct cmdline *cl,
4028 __attribute__((unused)) void *data)
4030 struct cmd_showcfg_result *res = parsed_result;
4031 if (!strcmp(res->what, "rxtx"))
4032 rxtx_config_display();
4033 else if (!strcmp(res->what, "cores"))
4034 fwd_lcores_config_display();
4035 else if (!strcmp(res->what, "fwd"))
4036 fwd_config_display();
4039 cmdline_parse_token_string_t cmd_showcfg_show =
4040 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4041 cmdline_parse_token_string_t cmd_showcfg_port =
4042 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4043 cmdline_parse_token_string_t cmd_showcfg_what =
4044 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4047 cmdline_parse_inst_t cmd_showcfg = {
4048 .f = cmd_showcfg_parsed,
4050 .help_str = "show config rxtx|cores|fwd",
4052 (void *)&cmd_showcfg_show,
4053 (void *)&cmd_showcfg_port,
4054 (void *)&cmd_showcfg_what,
4059 /* *** SHOW ALL PORT INFO *** */
4060 struct cmd_showportall_result {
4061 cmdline_fixed_string_t show;
4062 cmdline_fixed_string_t port;
4063 cmdline_fixed_string_t what;
4064 cmdline_fixed_string_t all;
4067 static void cmd_showportall_parsed(void *parsed_result,
4068 __attribute__((unused)) struct cmdline *cl,
4069 __attribute__((unused)) void *data)
4073 struct cmd_showportall_result *res = parsed_result;
4074 if (!strcmp(res->show, "clear")) {
4075 if (!strcmp(res->what, "stats"))
4076 for (i = 0; i < nb_ports; i++)
4078 } else if (!strcmp(res->what, "info"))
4079 for (i = 0; i < nb_ports; i++)
4080 port_infos_display(i);
4081 else if (!strcmp(res->what, "stats"))
4082 for (i = 0; i < nb_ports; i++)
4083 nic_stats_display(i);
4084 else if (!strcmp(res->what, "fdir"))
4085 for (i = 0; i < nb_ports; i++)
4087 else if (!strcmp(res->what, "stat_qmap"))
4088 for (i = 0; i < nb_ports; i++)
4089 nic_stats_mapping_display(i);
4092 cmdline_parse_token_string_t cmd_showportall_show =
4093 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4095 cmdline_parse_token_string_t cmd_showportall_port =
4096 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4097 cmdline_parse_token_string_t cmd_showportall_what =
4098 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4099 "info#stats#fdir#stat_qmap");
4100 cmdline_parse_token_string_t cmd_showportall_all =
4101 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4102 cmdline_parse_inst_t cmd_showportall = {
4103 .f = cmd_showportall_parsed,
4105 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4107 (void *)&cmd_showportall_show,
4108 (void *)&cmd_showportall_port,
4109 (void *)&cmd_showportall_what,
4110 (void *)&cmd_showportall_all,
4115 /* *** SHOW PORT INFO *** */
4116 struct cmd_showport_result {
4117 cmdline_fixed_string_t show;
4118 cmdline_fixed_string_t port;
4119 cmdline_fixed_string_t what;
4123 static void cmd_showport_parsed(void *parsed_result,
4124 __attribute__((unused)) struct cmdline *cl,
4125 __attribute__((unused)) void *data)
4127 struct cmd_showport_result *res = parsed_result;
4128 if (!strcmp(res->show, "clear")) {
4129 if (!strcmp(res->what, "stats"))
4130 nic_stats_clear(res->portnum);
4131 } else if (!strcmp(res->what, "info"))
4132 port_infos_display(res->portnum);
4133 else if (!strcmp(res->what, "stats"))
4134 nic_stats_display(res->portnum);
4135 else if (!strcmp(res->what, "fdir"))
4136 fdir_get_infos(res->portnum);
4137 else if (!strcmp(res->what, "stat_qmap"))
4138 nic_stats_mapping_display(res->portnum);
4141 cmdline_parse_token_string_t cmd_showport_show =
4142 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4144 cmdline_parse_token_string_t cmd_showport_port =
4145 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4146 cmdline_parse_token_string_t cmd_showport_what =
4147 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4148 "info#stats#fdir#stat_qmap");
4149 cmdline_parse_token_num_t cmd_showport_portnum =
4150 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4152 cmdline_parse_inst_t cmd_showport = {
4153 .f = cmd_showport_parsed,
4155 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4157 (void *)&cmd_showport_show,
4158 (void *)&cmd_showport_port,
4159 (void *)&cmd_showport_what,
4160 (void *)&cmd_showport_portnum,
4165 /* *** READ PORT REGISTER *** */
4166 struct cmd_read_reg_result {
4167 cmdline_fixed_string_t read;
4168 cmdline_fixed_string_t reg;
4174 cmd_read_reg_parsed(void *parsed_result,
4175 __attribute__((unused)) struct cmdline *cl,
4176 __attribute__((unused)) void *data)
4178 struct cmd_read_reg_result *res = parsed_result;
4179 port_reg_display(res->port_id, res->reg_off);
4182 cmdline_parse_token_string_t cmd_read_reg_read =
4183 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4184 cmdline_parse_token_string_t cmd_read_reg_reg =
4185 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4186 cmdline_parse_token_num_t cmd_read_reg_port_id =
4187 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4188 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4189 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4191 cmdline_parse_inst_t cmd_read_reg = {
4192 .f = cmd_read_reg_parsed,
4194 .help_str = "read reg port_id reg_off",
4196 (void *)&cmd_read_reg_read,
4197 (void *)&cmd_read_reg_reg,
4198 (void *)&cmd_read_reg_port_id,
4199 (void *)&cmd_read_reg_reg_off,
4204 /* *** READ PORT REGISTER BIT FIELD *** */
4205 struct cmd_read_reg_bit_field_result {
4206 cmdline_fixed_string_t read;
4207 cmdline_fixed_string_t regfield;
4215 cmd_read_reg_bit_field_parsed(void *parsed_result,
4216 __attribute__((unused)) struct cmdline *cl,
4217 __attribute__((unused)) void *data)
4219 struct cmd_read_reg_bit_field_result *res = parsed_result;
4220 port_reg_bit_field_display(res->port_id, res->reg_off,
4221 res->bit1_pos, res->bit2_pos);
4224 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4225 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4227 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4228 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4229 regfield, "regfield");
4230 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4231 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4233 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4234 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4236 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4237 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4239 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4240 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4243 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4244 .f = cmd_read_reg_bit_field_parsed,
4246 .help_str = "read regfield port_id reg_off bit_x bit_y "
4247 "(read register bit field between bit_x and bit_y included)",
4249 (void *)&cmd_read_reg_bit_field_read,
4250 (void *)&cmd_read_reg_bit_field_regfield,
4251 (void *)&cmd_read_reg_bit_field_port_id,
4252 (void *)&cmd_read_reg_bit_field_reg_off,
4253 (void *)&cmd_read_reg_bit_field_bit1_pos,
4254 (void *)&cmd_read_reg_bit_field_bit2_pos,
4259 /* *** READ PORT REGISTER BIT *** */
4260 struct cmd_read_reg_bit_result {
4261 cmdline_fixed_string_t read;
4262 cmdline_fixed_string_t regbit;
4269 cmd_read_reg_bit_parsed(void *parsed_result,
4270 __attribute__((unused)) struct cmdline *cl,
4271 __attribute__((unused)) void *data)
4273 struct cmd_read_reg_bit_result *res = parsed_result;
4274 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4277 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4278 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4279 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4280 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4282 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4283 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4284 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4285 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4286 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4287 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4289 cmdline_parse_inst_t cmd_read_reg_bit = {
4290 .f = cmd_read_reg_bit_parsed,
4292 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4294 (void *)&cmd_read_reg_bit_read,
4295 (void *)&cmd_read_reg_bit_regbit,
4296 (void *)&cmd_read_reg_bit_port_id,
4297 (void *)&cmd_read_reg_bit_reg_off,
4298 (void *)&cmd_read_reg_bit_bit_pos,
4303 /* *** WRITE PORT REGISTER *** */
4304 struct cmd_write_reg_result {
4305 cmdline_fixed_string_t write;
4306 cmdline_fixed_string_t reg;
4313 cmd_write_reg_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4317 struct cmd_write_reg_result *res = parsed_result;
4318 port_reg_set(res->port_id, res->reg_off, res->value);
4321 cmdline_parse_token_string_t cmd_write_reg_write =
4322 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4323 cmdline_parse_token_string_t cmd_write_reg_reg =
4324 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4325 cmdline_parse_token_num_t cmd_write_reg_port_id =
4326 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4327 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4328 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4329 cmdline_parse_token_num_t cmd_write_reg_value =
4330 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4332 cmdline_parse_inst_t cmd_write_reg = {
4333 .f = cmd_write_reg_parsed,
4335 .help_str = "write reg port_id reg_off reg_value",
4337 (void *)&cmd_write_reg_write,
4338 (void *)&cmd_write_reg_reg,
4339 (void *)&cmd_write_reg_port_id,
4340 (void *)&cmd_write_reg_reg_off,
4341 (void *)&cmd_write_reg_value,
4346 /* *** WRITE PORT REGISTER BIT FIELD *** */
4347 struct cmd_write_reg_bit_field_result {
4348 cmdline_fixed_string_t write;
4349 cmdline_fixed_string_t regfield;
4358 cmd_write_reg_bit_field_parsed(void *parsed_result,
4359 __attribute__((unused)) struct cmdline *cl,
4360 __attribute__((unused)) void *data)
4362 struct cmd_write_reg_bit_field_result *res = parsed_result;
4363 port_reg_bit_field_set(res->port_id, res->reg_off,
4364 res->bit1_pos, res->bit2_pos, res->value);
4367 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4368 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4370 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4371 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4372 regfield, "regfield");
4373 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4374 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4376 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4377 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4379 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4380 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4382 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4385 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4386 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4389 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4390 .f = cmd_write_reg_bit_field_parsed,
4392 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4393 "(set register bit field between bit_x and bit_y included)",
4395 (void *)&cmd_write_reg_bit_field_write,
4396 (void *)&cmd_write_reg_bit_field_regfield,
4397 (void *)&cmd_write_reg_bit_field_port_id,
4398 (void *)&cmd_write_reg_bit_field_reg_off,
4399 (void *)&cmd_write_reg_bit_field_bit1_pos,
4400 (void *)&cmd_write_reg_bit_field_bit2_pos,
4401 (void *)&cmd_write_reg_bit_field_value,
4406 /* *** WRITE PORT REGISTER BIT *** */
4407 struct cmd_write_reg_bit_result {
4408 cmdline_fixed_string_t write;
4409 cmdline_fixed_string_t regbit;
4417 cmd_write_reg_bit_parsed(void *parsed_result,
4418 __attribute__((unused)) struct cmdline *cl,
4419 __attribute__((unused)) void *data)
4421 struct cmd_write_reg_bit_result *res = parsed_result;
4422 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4425 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4426 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4428 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4429 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4431 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4432 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4433 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4434 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4435 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4437 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4438 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4440 cmdline_parse_inst_t cmd_write_reg_bit = {
4441 .f = cmd_write_reg_bit_parsed,
4443 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4445 (void *)&cmd_write_reg_bit_write,
4446 (void *)&cmd_write_reg_bit_regbit,
4447 (void *)&cmd_write_reg_bit_port_id,
4448 (void *)&cmd_write_reg_bit_reg_off,
4449 (void *)&cmd_write_reg_bit_bit_pos,
4450 (void *)&cmd_write_reg_bit_value,
4455 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4456 struct cmd_read_rxd_txd_result {
4457 cmdline_fixed_string_t read;
4458 cmdline_fixed_string_t rxd_txd;
4465 cmd_read_rxd_txd_parsed(void *parsed_result,
4466 __attribute__((unused)) struct cmdline *cl,
4467 __attribute__((unused)) void *data)
4469 struct cmd_read_rxd_txd_result *res = parsed_result;
4471 if (!strcmp(res->rxd_txd, "rxd"))
4472 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4473 else if (!strcmp(res->rxd_txd, "txd"))
4474 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4477 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4478 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4479 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4480 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4482 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4483 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4484 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4485 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4486 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4487 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4489 cmdline_parse_inst_t cmd_read_rxd_txd = {
4490 .f = cmd_read_rxd_txd_parsed,
4492 .help_str = "read rxd|txd port_id queue_id rxd_id",
4494 (void *)&cmd_read_rxd_txd_read,
4495 (void *)&cmd_read_rxd_txd_rxd_txd,
4496 (void *)&cmd_read_rxd_txd_port_id,
4497 (void *)&cmd_read_rxd_txd_queue_id,
4498 (void *)&cmd_read_rxd_txd_desc_id,
4504 struct cmd_quit_result {
4505 cmdline_fixed_string_t quit;
4508 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4510 __attribute__((unused)) void *data)
4516 cmdline_parse_token_string_t cmd_quit_quit =
4517 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4519 cmdline_parse_inst_t cmd_quit = {
4520 .f = cmd_quit_parsed,
4522 .help_str = "exit application",
4524 (void *)&cmd_quit_quit,
4529 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4530 struct cmd_mac_addr_result {
4531 cmdline_fixed_string_t mac_addr_cmd;
4532 cmdline_fixed_string_t what;
4534 struct ether_addr address;
4537 static void cmd_mac_addr_parsed(void *parsed_result,
4538 __attribute__((unused)) struct cmdline *cl,
4539 __attribute__((unused)) void *data)
4541 struct cmd_mac_addr_result *res = parsed_result;
4544 if (strcmp(res->what, "add") == 0)
4545 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4547 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4549 /* check the return value and print it if is < 0 */
4551 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4555 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4556 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4558 cmdline_parse_token_string_t cmd_mac_addr_what =
4559 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4561 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4562 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4563 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4566 cmdline_parse_inst_t cmd_mac_addr = {
4567 .f = cmd_mac_addr_parsed,
4569 .help_str = "mac_addr add|remove X <address>: "
4570 "add/remove MAC address on port X",
4572 (void *)&cmd_mac_addr_cmd,
4573 (void *)&cmd_mac_addr_what,
4574 (void *)&cmd_mac_addr_portnum,
4575 (void *)&cmd_mac_addr_addr,
4581 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4582 struct cmd_set_qmap_result {
4583 cmdline_fixed_string_t set;
4584 cmdline_fixed_string_t qmap;
4585 cmdline_fixed_string_t what;
4592 cmd_set_qmap_parsed(void *parsed_result,
4593 __attribute__((unused)) struct cmdline *cl,
4594 __attribute__((unused)) void *data)
4596 struct cmd_set_qmap_result *res = parsed_result;
4597 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4599 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4602 cmdline_parse_token_string_t cmd_setqmap_set =
4603 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4605 cmdline_parse_token_string_t cmd_setqmap_qmap =
4606 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4608 cmdline_parse_token_string_t cmd_setqmap_what =
4609 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4611 cmdline_parse_token_num_t cmd_setqmap_portid =
4612 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4614 cmdline_parse_token_num_t cmd_setqmap_queueid =
4615 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4617 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4618 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4621 cmdline_parse_inst_t cmd_set_qmap = {
4622 .f = cmd_set_qmap_parsed,
4624 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4626 (void *)&cmd_setqmap_set,
4627 (void *)&cmd_setqmap_qmap,
4628 (void *)&cmd_setqmap_what,
4629 (void *)&cmd_setqmap_portid,
4630 (void *)&cmd_setqmap_queueid,
4631 (void *)&cmd_setqmap_mapvalue,
4636 /* *** CONFIGURE UNICAST HASH TABLE *** */
4637 struct cmd_set_uc_hash_table {
4638 cmdline_fixed_string_t set;
4639 cmdline_fixed_string_t port;
4641 cmdline_fixed_string_t what;
4642 struct ether_addr address;
4643 cmdline_fixed_string_t mode;
4647 cmd_set_uc_hash_parsed(void *parsed_result,
4648 __attribute__((unused)) struct cmdline *cl,
4649 __attribute__((unused)) void *data)
4652 struct cmd_set_uc_hash_table *res = parsed_result;
4654 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4656 if (strcmp(res->what, "uta") == 0)
4657 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4658 &res->address,(uint8_t)is_on);
4660 printf("bad unicast hash table parameter, return code = %d \n", ret);
4664 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4665 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4667 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4668 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4670 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4671 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4673 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4674 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4676 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4677 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4679 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4680 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4683 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4684 .f = cmd_set_uc_hash_parsed,
4686 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4688 (void *)&cmd_set_uc_hash_set,
4689 (void *)&cmd_set_uc_hash_port,
4690 (void *)&cmd_set_uc_hash_portid,
4691 (void *)&cmd_set_uc_hash_what,
4692 (void *)&cmd_set_uc_hash_mac,
4693 (void *)&cmd_set_uc_hash_mode,
4698 struct cmd_set_uc_all_hash_table {
4699 cmdline_fixed_string_t set;
4700 cmdline_fixed_string_t port;
4702 cmdline_fixed_string_t what;
4703 cmdline_fixed_string_t value;
4704 cmdline_fixed_string_t mode;
4708 cmd_set_uc_all_hash_parsed(void *parsed_result,
4709 __attribute__((unused)) struct cmdline *cl,
4710 __attribute__((unused)) void *data)
4713 struct cmd_set_uc_all_hash_table *res = parsed_result;
4715 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4717 if ((strcmp(res->what, "uta") == 0) &&
4718 (strcmp(res->value, "all") == 0))
4719 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4721 printf("bad unicast hash table parameter,"
4722 "return code = %d \n", ret);
4725 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4726 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4728 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4729 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4731 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4732 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4734 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4735 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4737 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4738 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4740 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4741 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4744 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4745 .f = cmd_set_uc_all_hash_parsed,
4747 .help_str = "set port X uta all on|off (X = port number)",
4749 (void *)&cmd_set_uc_all_hash_set,
4750 (void *)&cmd_set_uc_all_hash_port,
4751 (void *)&cmd_set_uc_all_hash_portid,
4752 (void *)&cmd_set_uc_all_hash_what,
4753 (void *)&cmd_set_uc_all_hash_value,
4754 (void *)&cmd_set_uc_all_hash_mode,
4759 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4760 struct cmd_set_vf_traffic {
4761 cmdline_fixed_string_t set;
4762 cmdline_fixed_string_t port;
4764 cmdline_fixed_string_t vf;
4766 cmdline_fixed_string_t what;
4767 cmdline_fixed_string_t mode;
4771 cmd_set_vf_traffic_parsed(void *parsed_result,
4772 __attribute__((unused)) struct cmdline *cl,
4773 __attribute__((unused)) void *data)
4775 struct cmd_set_vf_traffic *res = parsed_result;
4776 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4777 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4779 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4782 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4785 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4786 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4788 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4789 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4791 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4794 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4795 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4797 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4798 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4800 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4801 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4804 cmdline_parse_inst_t cmd_set_vf_traffic = {
4805 .f = cmd_set_vf_traffic_parsed,
4807 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4809 (void *)&cmd_setvf_traffic_set,
4810 (void *)&cmd_setvf_traffic_port,
4811 (void *)&cmd_setvf_traffic_portid,
4812 (void *)&cmd_setvf_traffic_vf,
4813 (void *)&cmd_setvf_traffic_vfid,
4814 (void *)&cmd_setvf_traffic_what,
4815 (void *)&cmd_setvf_traffic_mode,
4820 /* *** CONFIGURE VF RECEIVE MODE *** */
4821 struct cmd_set_vf_rxmode {
4822 cmdline_fixed_string_t set;
4823 cmdline_fixed_string_t port;
4825 cmdline_fixed_string_t vf;
4827 cmdline_fixed_string_t what;
4828 cmdline_fixed_string_t mode;
4829 cmdline_fixed_string_t on;
4833 cmd_set_vf_rxmode_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4838 uint16_t rx_mode = 0;
4839 struct cmd_set_vf_rxmode *res = parsed_result;
4841 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4842 if (!strcmp(res->what,"rxmode")) {
4843 if (!strcmp(res->mode, "AUPE"))
4844 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4845 else if (!strcmp(res->mode, "ROPE"))
4846 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4847 else if (!strcmp(res->mode, "BAM"))
4848 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4849 else if (!strncmp(res->mode, "MPE",3))
4850 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4853 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4855 printf("bad VF receive mode parameter, return code = %d \n",
4859 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4862 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4865 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4866 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4868 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4871 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4872 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4874 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4877 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4879 mode, "AUPE#ROPE#BAM#MPE");
4880 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4881 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4884 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4885 .f = cmd_set_vf_rxmode_parsed,
4887 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4889 (void *)&cmd_set_vf_rxmode_set,
4890 (void *)&cmd_set_vf_rxmode_port,
4891 (void *)&cmd_set_vf_rxmode_portid,
4892 (void *)&cmd_set_vf_rxmode_vf,
4893 (void *)&cmd_set_vf_rxmode_vfid,
4894 (void *)&cmd_set_vf_rxmode_what,
4895 (void *)&cmd_set_vf_rxmode_mode,
4896 (void *)&cmd_set_vf_rxmode_on,
4901 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4902 struct cmd_vf_mac_addr_result {
4903 cmdline_fixed_string_t mac_addr_cmd;
4904 cmdline_fixed_string_t what;
4905 cmdline_fixed_string_t port;
4907 cmdline_fixed_string_t vf;
4909 struct ether_addr address;
4912 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4913 __attribute__((unused)) struct cmdline *cl,
4914 __attribute__((unused)) void *data)
4916 struct cmd_vf_mac_addr_result *res = parsed_result;
4919 if (strcmp(res->what, "add") == 0)
4920 ret = rte_eth_dev_mac_addr_add(res->port_num,
4921 &res->address, res->vf_num);
4923 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4927 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4928 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4929 mac_addr_cmd,"mac_addr");
4930 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4931 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4933 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4934 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4936 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4937 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4939 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4940 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4942 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4943 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4945 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4946 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4949 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4950 .f = cmd_vf_mac_addr_parsed,
4952 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4953 "Y = VF number)add MAC address filtering for a VF on port X",
4955 (void *)&cmd_vf_mac_addr_cmd,
4956 (void *)&cmd_vf_mac_addr_what,
4957 (void *)&cmd_vf_mac_addr_port,
4958 (void *)&cmd_vf_mac_addr_portnum,
4959 (void *)&cmd_vf_mac_addr_vf,
4960 (void *)&cmd_vf_mac_addr_vfnum,
4961 (void *)&cmd_vf_mac_addr_addr,
4966 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4967 struct cmd_vf_rx_vlan_filter {
4968 cmdline_fixed_string_t rx_vlan;
4969 cmdline_fixed_string_t what;
4971 cmdline_fixed_string_t port;
4973 cmdline_fixed_string_t vf;
4978 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4979 __attribute__((unused)) struct cmdline *cl,
4980 __attribute__((unused)) void *data)
4982 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4984 if (!strcmp(res->what, "add"))
4985 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4987 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4990 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4991 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4992 rx_vlan, "rx_vlan");
4993 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4994 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4996 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4997 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4999 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5000 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5002 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5003 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5005 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5006 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5008 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5009 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5012 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5013 .f = cmd_vf_rx_vlan_filter_parsed,
5015 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5016 "Y = port number,Z = hexadecimal VF mask)",
5018 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5019 (void *)&cmd_vf_rx_vlan_filter_what,
5020 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5021 (void *)&cmd_vf_rx_vlan_filter_port,
5022 (void *)&cmd_vf_rx_vlan_filter_portid,
5023 (void *)&cmd_vf_rx_vlan_filter_vf,
5024 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5029 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5030 struct cmd_queue_rate_limit_result {
5031 cmdline_fixed_string_t set;
5032 cmdline_fixed_string_t port;
5034 cmdline_fixed_string_t queue;
5036 cmdline_fixed_string_t rate;
5040 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5041 __attribute__((unused)) struct cmdline *cl,
5042 __attribute__((unused)) void *data)
5044 struct cmd_queue_rate_limit_result *res = parsed_result;
5047 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5048 && (strcmp(res->queue, "queue") == 0)
5049 && (strcmp(res->rate, "rate") == 0))
5050 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5053 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5057 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5058 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5060 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5061 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5063 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5064 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5066 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5067 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5069 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5070 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5072 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5073 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5075 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5076 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5079 cmdline_parse_inst_t cmd_queue_rate_limit = {
5080 .f = cmd_queue_rate_limit_parsed,
5082 .help_str = "set port X queue Y rate Z:(X = port number,"
5083 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5085 (void *)&cmd_queue_rate_limit_set,
5086 (void *)&cmd_queue_rate_limit_port,
5087 (void *)&cmd_queue_rate_limit_portnum,
5088 (void *)&cmd_queue_rate_limit_queue,
5089 (void *)&cmd_queue_rate_limit_queuenum,
5090 (void *)&cmd_queue_rate_limit_rate,
5091 (void *)&cmd_queue_rate_limit_ratenum,
5096 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5097 struct cmd_vf_rate_limit_result {
5098 cmdline_fixed_string_t set;
5099 cmdline_fixed_string_t port;
5101 cmdline_fixed_string_t vf;
5103 cmdline_fixed_string_t rate;
5105 cmdline_fixed_string_t q_msk;
5109 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5110 __attribute__((unused)) struct cmdline *cl,
5111 __attribute__((unused)) void *data)
5113 struct cmd_vf_rate_limit_result *res = parsed_result;
5116 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5117 && (strcmp(res->vf, "vf") == 0)
5118 && (strcmp(res->rate, "rate") == 0)
5119 && (strcmp(res->q_msk, "queue_mask") == 0))
5120 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5121 res->rate_num, res->q_msk_val);
5123 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5127 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5128 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5130 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5131 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5133 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5134 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5136 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5137 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5139 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5140 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5142 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5143 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5145 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5146 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5148 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5149 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5150 q_msk, "queue_mask");
5151 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5152 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5155 cmdline_parse_inst_t cmd_vf_rate_limit = {
5156 .f = cmd_vf_rate_limit_parsed,
5158 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5159 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5160 "for queues of VF on port X",
5162 (void *)&cmd_vf_rate_limit_set,
5163 (void *)&cmd_vf_rate_limit_port,
5164 (void *)&cmd_vf_rate_limit_portnum,
5165 (void *)&cmd_vf_rate_limit_vf,
5166 (void *)&cmd_vf_rate_limit_vfnum,
5167 (void *)&cmd_vf_rate_limit_rate,
5168 (void *)&cmd_vf_rate_limit_ratenum,
5169 (void *)&cmd_vf_rate_limit_q_msk,
5170 (void *)&cmd_vf_rate_limit_q_msk_val,
5175 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5176 struct cmd_set_mirror_mask_result {
5177 cmdline_fixed_string_t set;
5178 cmdline_fixed_string_t port;
5180 cmdline_fixed_string_t mirror;
5182 cmdline_fixed_string_t what;
5183 cmdline_fixed_string_t value;
5184 cmdline_fixed_string_t dstpool;
5186 cmdline_fixed_string_t on;
5189 cmdline_parse_token_string_t cmd_mirror_mask_set =
5190 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5192 cmdline_parse_token_string_t cmd_mirror_mask_port =
5193 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5195 cmdline_parse_token_string_t cmd_mirror_mask_portid =
5196 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5198 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5199 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5200 mirror, "mirror-rule");
5201 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5202 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5204 cmdline_parse_token_string_t cmd_mirror_mask_what =
5205 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5206 what, "pool-mirror#vlan-mirror");
5207 cmdline_parse_token_string_t cmd_mirror_mask_value =
5208 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5210 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5211 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5212 dstpool, "dst-pool");
5213 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5214 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5216 cmdline_parse_token_string_t cmd_mirror_mask_on =
5217 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5221 cmd_set_mirror_mask_parsed(void *parsed_result,
5222 __attribute__((unused)) struct cmdline *cl,
5223 __attribute__((unused)) void *data)
5226 struct cmd_set_mirror_mask_result *res = parsed_result;
5227 struct rte_eth_vmdq_mirror_conf mr_conf;
5229 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5231 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5233 mr_conf.dst_pool = res->dstpool_id;
5235 if (!strcmp(res->what, "pool-mirror")) {
5236 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5237 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5238 } else if(!strcmp(res->what, "vlan-mirror")) {
5239 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5240 nb_item = parse_item_list(res->value, "core",
5241 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5245 for(i=0; i < nb_item; i++) {
5246 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5247 printf("Invalid vlan_id: must be < 4096\n");
5251 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5252 mr_conf.vlan.vlan_mask |= 1ULL << i;
5256 if(!strcmp(res->on, "on"))
5257 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5260 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5263 printf("mirror rule add error: (%s)\n", strerror(-ret));
5266 cmdline_parse_inst_t cmd_set_mirror_mask = {
5267 .f = cmd_set_mirror_mask_parsed,
5269 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5270 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5272 (void *)&cmd_mirror_mask_set,
5273 (void *)&cmd_mirror_mask_port,
5274 (void *)&cmd_mirror_mask_portid,
5275 (void *)&cmd_mirror_mask_mirror,
5276 (void *)&cmd_mirror_mask_ruleid,
5277 (void *)&cmd_mirror_mask_what,
5278 (void *)&cmd_mirror_mask_value,
5279 (void *)&cmd_mirror_mask_dstpool,
5280 (void *)&cmd_mirror_mask_poolid,
5281 (void *)&cmd_mirror_mask_on,
5286 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5287 struct cmd_set_mirror_link_result {
5288 cmdline_fixed_string_t set;
5289 cmdline_fixed_string_t port;
5291 cmdline_fixed_string_t mirror;
5293 cmdline_fixed_string_t what;
5294 cmdline_fixed_string_t dstpool;
5296 cmdline_fixed_string_t on;
5299 cmdline_parse_token_string_t cmd_mirror_link_set =
5300 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5302 cmdline_parse_token_string_t cmd_mirror_link_port =
5303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5305 cmdline_parse_token_string_t cmd_mirror_link_portid =
5306 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5308 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5309 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5310 mirror, "mirror-rule");
5311 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5312 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5314 cmdline_parse_token_string_t cmd_mirror_link_what =
5315 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5316 what, "uplink-mirror#downlink-mirror");
5317 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5319 dstpool, "dst-pool");
5320 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5321 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5323 cmdline_parse_token_string_t cmd_mirror_link_on =
5324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5328 cmd_set_mirror_link_parsed(void *parsed_result,
5329 __attribute__((unused)) struct cmdline *cl,
5330 __attribute__((unused)) void *data)
5333 struct cmd_set_mirror_link_result *res = parsed_result;
5334 struct rte_eth_vmdq_mirror_conf mr_conf;
5336 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5337 if(!strcmp(res->what, "uplink-mirror")) {
5338 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5339 }else if(!strcmp(res->what, "downlink-mirror"))
5340 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5342 mr_conf.dst_pool = res->dstpool_id;
5344 if(!strcmp(res->on, "on"))
5345 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5348 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5351 /* check the return value and print it if is < 0 */
5353 printf("mirror rule add error: (%s)\n", strerror(-ret));
5357 cmdline_parse_inst_t cmd_set_mirror_link = {
5358 .f = cmd_set_mirror_link_parsed,
5360 .help_str = "set port X mirror-rule Y uplink-mirror|"
5361 "downlink-mirror dst-pool Z on|off",
5363 (void *)&cmd_mirror_link_set,
5364 (void *)&cmd_mirror_link_port,
5365 (void *)&cmd_mirror_link_portid,
5366 (void *)&cmd_mirror_link_mirror,
5367 (void *)&cmd_mirror_link_ruleid,
5368 (void *)&cmd_mirror_link_what,
5369 (void *)&cmd_mirror_link_dstpool,
5370 (void *)&cmd_mirror_link_poolid,
5371 (void *)&cmd_mirror_link_on,
5376 /* *** RESET VM MIRROR RULE *** */
5377 struct cmd_rm_mirror_rule_result {
5378 cmdline_fixed_string_t reset;
5379 cmdline_fixed_string_t port;
5381 cmdline_fixed_string_t mirror;
5385 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5386 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5388 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5389 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5391 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5392 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5394 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5395 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5396 mirror, "mirror-rule");
5397 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5398 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5402 cmd_reset_mirror_rule_parsed(void *parsed_result,
5403 __attribute__((unused)) struct cmdline *cl,
5404 __attribute__((unused)) void *data)
5407 struct cmd_set_mirror_link_result *res = parsed_result;
5409 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5411 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5414 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5415 .f = cmd_reset_mirror_rule_parsed,
5417 .help_str = "reset port X mirror-rule Y",
5419 (void *)&cmd_rm_mirror_rule_reset,
5420 (void *)&cmd_rm_mirror_rule_port,
5421 (void *)&cmd_rm_mirror_rule_portid,
5422 (void *)&cmd_rm_mirror_rule_mirror,
5423 (void *)&cmd_rm_mirror_rule_ruleid,
5428 /* ******************************************************************************** */
5430 struct cmd_dump_result {
5431 cmdline_fixed_string_t dump;
5435 dump_struct_sizes(void)
5437 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5438 DUMP_SIZE(struct rte_mbuf);
5439 DUMP_SIZE(struct rte_pktmbuf);
5440 DUMP_SIZE(struct rte_ctrlmbuf);
5441 DUMP_SIZE(struct rte_mempool);
5442 DUMP_SIZE(struct rte_ring);
5446 static void cmd_dump_parsed(void *parsed_result,
5447 __attribute__((unused)) struct cmdline *cl,
5448 __attribute__((unused)) void *data)
5450 struct cmd_dump_result *res = parsed_result;
5452 if (!strcmp(res->dump, "dump_physmem"))
5453 rte_dump_physmem_layout(stdout);
5454 else if (!strcmp(res->dump, "dump_memzone"))
5455 rte_memzone_dump(stdout);
5456 else if (!strcmp(res->dump, "dump_log_history"))
5457 rte_log_dump_history(stdout);
5458 else if (!strcmp(res->dump, "dump_struct_sizes"))
5459 dump_struct_sizes();
5460 else if (!strcmp(res->dump, "dump_ring"))
5461 rte_ring_list_dump(stdout);
5462 else if (!strcmp(res->dump, "dump_mempool"))
5463 rte_mempool_list_dump(stdout);
5464 else if (!strcmp(res->dump, "dump_devargs"))
5465 rte_eal_devargs_dump(stdout);
5468 cmdline_parse_token_string_t cmd_dump_dump =
5469 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5473 "dump_struct_sizes#"
5478 cmdline_parse_inst_t cmd_dump = {
5479 .f = cmd_dump_parsed, /* function to call */
5480 .data = NULL, /* 2nd arg of func */
5481 .help_str = "dump status",
5482 .tokens = { /* token list, NULL terminated */
5483 (void *)&cmd_dump_dump,
5488 /* ******************************************************************************** */
5490 struct cmd_dump_one_result {
5491 cmdline_fixed_string_t dump;
5492 cmdline_fixed_string_t name;
5495 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5498 struct cmd_dump_one_result *res = parsed_result;
5500 if (!strcmp(res->dump, "dump_ring")) {
5502 r = rte_ring_lookup(res->name);
5504 cmdline_printf(cl, "Cannot find ring\n");
5507 rte_ring_dump(stdout, r);
5508 } else if (!strcmp(res->dump, "dump_mempool")) {
5509 struct rte_mempool *mp;
5510 mp = rte_mempool_lookup(res->name);
5512 cmdline_printf(cl, "Cannot find mempool\n");
5515 rte_mempool_dump(stdout, mp);
5519 cmdline_parse_token_string_t cmd_dump_one_dump =
5520 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5521 "dump_ring#dump_mempool");
5523 cmdline_parse_token_string_t cmd_dump_one_name =
5524 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5526 cmdline_parse_inst_t cmd_dump_one = {
5527 .f = cmd_dump_one_parsed, /* function to call */
5528 .data = NULL, /* 2nd arg of func */
5529 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5530 .tokens = { /* token list, NULL terminated */
5531 (void *)&cmd_dump_one_dump,
5532 (void *)&cmd_dump_one_name,
5537 /* ******************************************************************************** */
5539 /* list of instructions */
5540 cmdline_parse_ctx_t main_ctx[] = {
5541 (cmdline_parse_inst_t *)&cmd_help_brief,
5542 (cmdline_parse_inst_t *)&cmd_help_long,
5543 (cmdline_parse_inst_t *)&cmd_quit,
5544 (cmdline_parse_inst_t *)&cmd_showport,
5545 (cmdline_parse_inst_t *)&cmd_showportall,
5546 (cmdline_parse_inst_t *)&cmd_showcfg,
5547 (cmdline_parse_inst_t *)&cmd_start,
5548 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5549 (cmdline_parse_inst_t *)&cmd_set_link_up,
5550 (cmdline_parse_inst_t *)&cmd_set_link_down,
5551 (cmdline_parse_inst_t *)&cmd_reset,
5552 (cmdline_parse_inst_t *)&cmd_set_numbers,
5553 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5554 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5555 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5556 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5557 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5558 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5559 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5560 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5561 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5562 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5563 (cmdline_parse_inst_t *)&cmd_set_link_check,
5564 #ifdef RTE_NIC_BYPASS
5565 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5566 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5567 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5568 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5570 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5571 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5572 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5573 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5574 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5575 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5576 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5577 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5578 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5579 (cmdline_parse_inst_t *)&cmd_config_dcb,
5580 (cmdline_parse_inst_t *)&cmd_read_reg,
5581 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5582 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5583 (cmdline_parse_inst_t *)&cmd_write_reg,
5584 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5585 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5586 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5587 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5588 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5589 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5590 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5591 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5592 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5593 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5594 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5595 (cmdline_parse_inst_t *)&cmd_stop,
5596 (cmdline_parse_inst_t *)&cmd_mac_addr,
5597 (cmdline_parse_inst_t *)&cmd_set_qmap,
5598 (cmdline_parse_inst_t *)&cmd_operate_port,
5599 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5600 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5601 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5602 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5603 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5604 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5605 (cmdline_parse_inst_t *)&cmd_config_rss,
5606 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5607 (cmdline_parse_inst_t *)&cmd_showport_reta,
5608 (cmdline_parse_inst_t *)&cmd_config_burst,
5609 (cmdline_parse_inst_t *)&cmd_config_thresh,
5610 (cmdline_parse_inst_t *)&cmd_config_threshold,
5611 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5612 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5613 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5614 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5615 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5616 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5617 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
5618 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
5619 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5620 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5621 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5622 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
5623 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
5624 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
5625 (cmdline_parse_inst_t *)&cmd_dump,
5626 (cmdline_parse_inst_t *)&cmd_dump_one,
5630 /* prompt function, called from main on MASTER lcore */
5636 /* initialize non-constant commands */
5637 cmd_set_fwd_mode_init();
5639 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5643 cmdline_interact(cl);
5644 cmdline_stdin_exit(cl);
5648 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5650 if (id < nb_ports) {
5651 /* check if need_reconfig has been set to 1 */
5652 if (ports[id].need_reconfig == 0)
5653 ports[id].need_reconfig = dev;
5654 /* check if need_reconfig_queues has been set to 1 */
5655 if (ports[id].need_reconfig_queues == 0)
5656 ports[id].need_reconfig_queues = queue;
5660 for (pid = 0; pid < nb_ports; pid++) {
5661 /* check if need_reconfig has been set to 1 */
5662 if (ports[pid].need_reconfig == 0)
5663 ports[pid].need_reconfig = dev;
5664 /* check if need_reconfig_queues has been set to 1 */
5665 if (ports[pid].need_reconfig_queues == 0)
5666 ports[pid].need_reconfig_queues = queue;
5671 #ifdef RTE_NIC_BYPASS
5673 bypass_is_supported(portid_t port_id)
5675 struct rte_port *port;
5676 struct rte_pci_id *pci_id;
5678 if (port_id >= nb_ports) {
5679 printf("\tPort id must be less than %d.\n", nb_ports);
5683 /* Get the device id. */
5684 port = &ports[port_id];
5685 pci_id = &port->dev_info.pci_dev->id;
5687 /* Check if NIC supports bypass. */
5688 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5692 printf("\tBypass not supported for port_id = %d.\n", port_id);