4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <net/socket.h>
46 #include <netinet/in.h>
48 #include <sys/queue.h>
50 #include <rte_common.h>
51 #include <rte_byteorder.h>
53 #include <rte_debug.h>
54 #include <rte_cycles.h>
55 #include <rte_memory.h>
56 #include <rte_memzone.h>
57 #include <rte_launch.h>
58 #include <rte_tailq.h>
60 #include <rte_per_lcore.h>
61 #include <rte_lcore.h>
62 #include <rte_atomic.h>
63 #include <rte_branch_prediction.h>
65 #include <rte_mempool.h>
66 #include <rte_interrupts.h>
68 #include <rte_ether.h>
69 #include <rte_ethdev.h>
70 #include <rte_string_fns.h>
72 #include <cmdline_rdline.h>
73 #include <cmdline_parse.h>
74 #include <cmdline_parse_num.h>
75 #include <cmdline_parse_string.h>
76 #include <cmdline_parse_ipaddr.h>
77 #include <cmdline_parse_etheraddr.h>
78 #include <cmdline_socket.h>
80 #include <rte_pci_dev_ids.h>
84 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
87 uint8_t bypass_is_supported(portid_t port_id);
90 /* *** Help command with introduction. *** */
91 struct cmd_help_brief_result {
92 cmdline_fixed_string_t help;
95 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
97 __attribute__((unused)) void *data)
102 "Help is available for the following sections:\n\n"
103 " help control : Start and stop forwarding.\n"
104 " help display : Displaying port, stats and config "
106 " help config : Configuration information.\n"
107 " help ports : Configuring ports.\n"
108 " help flowdir : Flow Director filter help.\n"
109 " help registers : Reading and setting port registers.\n"
110 " help all : All of the above sections.\n\n"
115 cmdline_parse_token_string_t cmd_help_brief_help =
116 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
118 cmdline_parse_inst_t cmd_help_brief = {
119 .f = cmd_help_brief_parsed,
121 .help_str = "show help",
123 (void *)&cmd_help_brief_help,
128 /* *** Help command with help sections. *** */
129 struct cmd_help_long_result {
130 cmdline_fixed_string_t help;
131 cmdline_fixed_string_t section;
134 static void cmd_help_long_parsed(void *parsed_result,
136 __attribute__((unused)) void *data)
139 struct cmd_help_long_result *res = parsed_result;
141 if (!strcmp(res->section, "all"))
144 if (show_all || !strcmp(res->section, "control")) {
149 "Control forwarding:\n"
150 "-------------------\n\n"
153 " Start packet forwarding with current configuration.\n\n"
156 " Start packet forwarding with current config"
157 " after sending one burst of packets.\n\n"
160 " Stop packet forwarding, and display accumulated"
164 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
168 if (show_all || !strcmp(res->section, "display")) {
176 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
177 " Display information for port_id, or all.\n\n"
179 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
180 " Clear information for port_id, or all.\n\n"
182 "show config (rxtx|cores|fwd)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
193 if (show_all || !strcmp(res->section, "config")) {
199 "Configuration changes only become active when"
200 " forwarding is started/restarted.\n\n"
203 " Reset forwarding to the default configuration.\n\n"
205 "set verbose (level)\n"
206 " Set the debug verbosity level X.\n\n"
209 " Set number of ports.\n\n"
212 " Set number of cores.\n\n"
214 "set coremask (mask)\n"
215 " Set the forwarding cores hexadecimal mask.\n\n"
217 "set portmask (mask)\n"
218 " Set the forwarding ports hexadecimal mask.\n\n"
221 " Set number of packets per burst.\n\n"
223 "set txpkts (x[,y]*)\n"
224 " Set the length of each segment of TXONLY"
227 "set corelist (x[,y]*)\n"
228 " Set the list of forwarding cores.\n\n"
230 "set portlist (x[,y]*)\n"
231 " Set the list of forwarding ports.\n\n"
233 "vlan set strip (on|off) (port_id)\n"
234 " Set the VLAN strip on a port.\n\n"
236 "vlan set filter (on|off) (port_id)\n"
237 " Set the VLAN filter on a port.\n\n"
239 "vlan set qinq (on|off) (port_id)\n"
240 " Set the VLAN QinQ (extended queue in queue)"
243 "vlan set tpid (value) (port_id)\n"
244 " Set the outer VLAN TPID for Packet Filtering on"
247 "rx_vlan add (vlan_id|all) (port_id)\n"
248 " Add a vlan_id, or all identifiers, to the set"
249 " of VLAN identifiers filtered by port_id.\n\n"
251 "rx_vlan rm (vlan_id|all) (port_id)\n"
252 " Remove a vlan_id, or all identifiers, from the set"
253 " of VLAN identifiers filtered by port_id.\n\n"
255 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
256 " Add a vlan_id, to the set of VLAN identifiers"
257 "filtered for VF(s) from port_id.\n\n"
259 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
260 " Remove a vlan_id, to the set of VLAN identifiers"
261 "filtered for VF(s) from port_id.\n\n"
263 "rx_vlan set tpid (value) (port_id)\n"
264 " Set the outer VLAN TPID for Packet Filtering on"
267 "tx_vlan set vlan_id (port_id)\n"
268 " Set hardware insertion of VLAN ID in packets sent"
271 "tx_vlan reset (port_id)\n"
272 " Disable hardware insertion of a VLAN header in"
273 " packets sent on a port.\n\n"
275 "tx_checksum set mask (port_id)\n"
276 " Enable hardware insertion of checksum offload with"
277 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
278 " bit 0 - insert ip checksum offload if set\n"
279 " bit 1 - insert udp checksum offload if set\n"
280 " bit 2 - insert tcp checksum offload if set\n"
281 " bit 3 - insert sctp checksum offload if set\n"
282 " Please check the NIC datasheet for HW limits.\n\n"
284 #ifdef RTE_LIBRTE_IEEE1588
285 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
286 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
287 " packet forwarding mode.\n\n"
290 "set fwd (io|mac|rxonly|txonly|csum)\n"
291 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
292 " forwarding mode.\n\n"
295 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
296 " Add a MAC address on port_id.\n\n"
298 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
299 " Remove a MAC address from port_id.\n\n"
301 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
302 " Add a MAC address for a VF on the port.\n\n"
304 "set port (port_id) uta (mac_address|all) (on|off)\n"
305 " Add/Remove a or all unicast hash filter(s)"
308 "set promisc (port_id|all) (on|off)\n"
309 " Set the promiscuous mode on port_id, or all.\n\n"
311 "set allmulti (port_id|all) (on|off)\n"
312 " Set the allmulti mode on port_id, or all.\n\n"
314 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
315 " (low_water) (pause_time) (send_xon) (port_id)\n"
316 " Set the link flow control parameter on a port.\n\n"
318 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
319 " (low_water) (pause_time) (priority) (port_id)\n"
320 " Set the priority flow control parameter on a"
323 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
324 " Set statistics mapping (qmapping 0..15) for RX/TX"
326 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
327 " on port 0 to mapping 5.\n\n"
329 "set port (port_id) vf (vf_id) rx|tx on|off \n"
330 " Enable/Disable a VF receive/tranmit from a port\n\n"
332 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
334 " AUPE:accepts untagged VLAN;"
335 "ROPE:accept unicast hash\n\n"
336 " BAM:accepts broadcast packets;"
337 "MPE:accepts all multicast packets\n\n"
338 " Enable/Disable a VF receive mode of a port\n\n"
340 "set port (port_id) mirror-rule (rule_id)"
341 "(pool-mirror|vlan-mirror)\n"
342 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
343 " Set pool or vlan type mirror rule on a port.\n"
344 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
345 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
348 "set port (port_id) mirror-rule (rule_id)"
349 "(uplink-mirror|downlink-mirror) dst-pool"
350 "(pool_id) (on|off)\n"
351 " Set uplink or downlink type mirror rule on a port.\n"
352 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
353 " 0 on' enable mirror income traffic to pool 0.\n\n"
355 "reset port (port_id) mirror-rule (rule_id)\n"
356 " Reset a mirror rule.\n\n"
358 "set flush_rx (on|off)\n"
359 " Flush (default) or don't flush RX streams before"
360 " forwarding. Mainly used with PCAP drivers.\n\n"
362 #ifdef RTE_NIC_BYPASS
363 "set bypass mode (normal|bypass|isolate) (port_id)\n"
364 " Set the bypass mode for the lowest port on bypass enabled"
367 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
368 "mode (normal|bypass|isolate) (port_id)\n"
369 " Set the event required to initiate specified bypass mode for"
370 " the lowest port on a bypass enabled NIC where:\n"
371 " timeout = enable bypass after watchdog timeout.\n"
372 " os_on = enable bypass when OS/board is powered on.\n"
373 " os_off = enable bypass when OS/board is powered off.\n"
374 " power_on = enable bypass when power supply is turned on.\n"
375 " power_off = enable bypass when power supply is turned off."
378 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
379 " Set the bypass watchdog timeout to 'n' seconds"
380 " where 0 = instant.\n\n"
382 "show bypass config (port_id)\n"
383 " Show the bypass configuration for a bypass enabled NIC"
384 " using the lowest port on the NIC.\n\n"
391 if (show_all || !strcmp(res->section, "flowdir")) {
396 "Flow director mode:\n"
397 "-------------------\n\n"
399 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
400 " src (src_ip_address) (src_port)"
401 " dst (dst_ip_address) (dst_port)"
402 " flexbytes (flexbytes_values) vlan (vlan_id)"
403 " queue (queue_id)\n"
404 " Add a signature filter.\n\n"
406 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
407 " src (src_ip_address) (src_port)"
408 " dst (dst_ip_address) (dst_port)"
409 " flexbytes (flexbytes_values) vlan (vlan_id)"
410 " queue (queue_id)\n"
411 " Update a signature filter.\n\n"
413 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
414 " src (src_ip_address) (src_port)"
415 " dst (dst_ip_address) (dst_port)"
416 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
417 " Remove a signature filter.\n\n"
419 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
420 " src (src_ip_address) (src_port)"
421 " dst (dst_ip_address) (dst_port)"
422 " flexbytes (flexbytes_values) vlan (vlan_id)"
423 " queue (queue_id) soft (soft_id)\n"
424 " Add a perfect filter.\n\n"
426 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
427 " src (src_ip_address) (src_port)"
428 " dst (dst_ip_address) (dst_port)"
429 " flexbytes (flexbytes_values) vlan (vlan_id)"
430 " queue (queue_id)\n"
431 " Update a perfect filter.\n\n"
433 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
434 " src (src_ip_address) (src_port)"
435 " dst (dst_ip_address) (dst_port)"
436 " flexbytes (flexbytes_values) vlan (vlan_id)"
438 " Remove a perfect filter.\n\n"
440 "set_masks_filter (port_id) only_ip_flow (0|1)"
441 " src_mask (ip_src_mask) (src_port_mask)"
442 " dst_mask (ip_dst_mask) (dst_port_mask)"
443 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
444 " Set IPv4 filter masks.\n\n"
446 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
447 " src_mask (ip_src_mask) (src_port_mask)"
448 " dst_mask (ip_dst_mask) (dst_port_mask)"
449 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
450 " compare_dst (0|1)\n"
451 " Set IPv6 filter masks.\n\n"
455 if (show_all || !strcmp(res->section, "ports")) {
461 "----------------\n\n"
463 "port start (port_id|all)\n"
464 " Start all ports or port_id.\n\n"
466 "port stop (port_id|all)\n"
467 " Stop all ports or port_id.\n\n"
469 "port close (port_id|all)\n"
470 " Close all ports or port_id.\n\n"
472 "port config (port_id|all) speed (10|100|1000|10000|auto)"
473 " duplex (half|full|auto)\n"
474 " Set speed and duplex for all ports or port_id\n\n"
476 "port config all (rxq|txq|rxd|txd) (value)\n"
477 " Set number for rxq/txq/rxd/txd.\n\n"
479 "port config all max-pkt-len (value)\n"
480 " Set the max packet length.\n\n"
482 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
484 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
487 "port config all rss (ip|udp|none)\n"
488 " Set the RSS mode.\n\n"
490 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
491 " Set the RSS redirection table.\n\n"
493 "port config (port_id) dcb vt (on|off) (traffic_class)"
495 " Set the DCB mode.\n\n"
497 "port config all burst (value)\n"
498 " Set the number of packets per burst.\n\n"
500 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
502 " Set the ring prefetch/host/writeback threshold"
503 " for tx/rx queue.\n\n"
505 "port config all (txfreet|txrst|rxfreet) (value)\n"
506 " Set free threshold for rx/tx, or set"
507 " tx rs bit threshold.\n\n"
511 if (show_all || !strcmp(res->section, "registers")) {
519 "read reg (port_id) (address)\n"
520 " Display value of a port register.\n\n"
522 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
523 " Display a port register bit field.\n\n"
525 "read regbit (port_id) (address) (bit_x)\n"
526 " Display a single port register bit.\n\n"
528 "write reg (port_id) (address) (value)\n"
529 " Set value of a port register.\n\n"
531 "write regfield (port_id) (address) (bit_x) (bit_y)"
533 " Set bit field of a port register.\n\n"
535 "write regbit (port_id) (address) (bit_x) (value)\n"
536 " Set single bit value of a port register.\n\n"
541 cmdline_parse_token_string_t cmd_help_long_help =
542 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
544 cmdline_parse_token_string_t cmd_help_long_section =
545 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
546 "all#control#display#config#flowdir#"
549 cmdline_parse_inst_t cmd_help_long = {
550 .f = cmd_help_long_parsed,
552 .help_str = "show help",
554 (void *)&cmd_help_long_help,
555 (void *)&cmd_help_long_section,
561 /* *** start/stop/close all ports *** */
562 struct cmd_operate_port_result {
563 cmdline_fixed_string_t keyword;
564 cmdline_fixed_string_t name;
565 cmdline_fixed_string_t value;
568 static void cmd_operate_port_parsed(void *parsed_result,
569 __attribute__((unused)) struct cmdline *cl,
570 __attribute__((unused)) void *data)
572 struct cmd_operate_port_result *res = parsed_result;
574 if (!strcmp(res->name, "start"))
575 start_port(RTE_PORT_ALL);
576 else if (!strcmp(res->name, "stop"))
577 stop_port(RTE_PORT_ALL);
578 else if (!strcmp(res->name, "close"))
579 close_port(RTE_PORT_ALL);
581 printf("Unknown parameter\n");
584 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
585 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
587 cmdline_parse_token_string_t cmd_operate_port_all_port =
588 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
590 cmdline_parse_token_string_t cmd_operate_port_all_all =
591 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
593 cmdline_parse_inst_t cmd_operate_port = {
594 .f = cmd_operate_port_parsed,
596 .help_str = "port start|stop|close all: start/stop/close all ports",
598 (void *)&cmd_operate_port_all_cmd,
599 (void *)&cmd_operate_port_all_port,
600 (void *)&cmd_operate_port_all_all,
605 /* *** start/stop/close specific port *** */
606 struct cmd_operate_specific_port_result {
607 cmdline_fixed_string_t keyword;
608 cmdline_fixed_string_t name;
612 static void cmd_operate_specific_port_parsed(void *parsed_result,
613 __attribute__((unused)) struct cmdline *cl,
614 __attribute__((unused)) void *data)
616 struct cmd_operate_specific_port_result *res = parsed_result;
618 if (!strcmp(res->name, "start"))
619 start_port(res->value);
620 else if (!strcmp(res->name, "stop"))
621 stop_port(res->value);
622 else if (!strcmp(res->name, "close"))
623 close_port(res->value);
625 printf("Unknown parameter\n");
628 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
629 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
631 cmdline_parse_token_string_t cmd_operate_specific_port_port =
632 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
633 name, "start#stop#close");
634 cmdline_parse_token_num_t cmd_operate_specific_port_id =
635 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
638 cmdline_parse_inst_t cmd_operate_specific_port = {
639 .f = cmd_operate_specific_port_parsed,
641 .help_str = "port start|stop|close X: start/stop/close port X",
643 (void *)&cmd_operate_specific_port_cmd,
644 (void *)&cmd_operate_specific_port_port,
645 (void *)&cmd_operate_specific_port_id,
650 /* *** configure speed for all ports *** */
651 struct cmd_config_speed_all {
652 cmdline_fixed_string_t port;
653 cmdline_fixed_string_t keyword;
654 cmdline_fixed_string_t all;
655 cmdline_fixed_string_t item1;
656 cmdline_fixed_string_t item2;
657 cmdline_fixed_string_t value1;
658 cmdline_fixed_string_t value2;
662 cmd_config_speed_all_parsed(void *parsed_result,
663 __attribute__((unused)) struct cmdline *cl,
664 __attribute__((unused)) void *data)
666 struct cmd_config_speed_all *res = parsed_result;
667 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
668 uint16_t link_duplex = 0;
671 if (!all_ports_stopped()) {
672 printf("Please stop all ports first\n");
676 if (!strcmp(res->value1, "10"))
677 link_speed = ETH_LINK_SPEED_10;
678 else if (!strcmp(res->value1, "100"))
679 link_speed = ETH_LINK_SPEED_100;
680 else if (!strcmp(res->value1, "1000"))
681 link_speed = ETH_LINK_SPEED_1000;
682 else if (!strcmp(res->value1, "10000"))
683 link_speed = ETH_LINK_SPEED_10000;
684 else if (!strcmp(res->value1, "auto"))
685 link_speed = ETH_LINK_SPEED_AUTONEG;
687 printf("Unknown parameter\n");
691 if (!strcmp(res->value2, "half"))
692 link_duplex = ETH_LINK_HALF_DUPLEX;
693 else if (!strcmp(res->value2, "full"))
694 link_duplex = ETH_LINK_FULL_DUPLEX;
695 else if (!strcmp(res->value2, "auto"))
696 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
698 printf("Unknown parameter\n");
702 for (pid = 0; pid < nb_ports; pid++) {
703 ports[pid].dev_conf.link_speed = link_speed;
704 ports[pid].dev_conf.link_duplex = link_duplex;
707 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
710 cmdline_parse_token_string_t cmd_config_speed_all_port =
711 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
712 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
713 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
715 cmdline_parse_token_string_t cmd_config_speed_all_all =
716 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
717 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
719 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
721 "10#100#1000#10000#auto");
722 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
724 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
728 cmdline_parse_inst_t cmd_config_speed_all = {
729 .f = cmd_config_speed_all_parsed,
731 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
734 (void *)&cmd_config_speed_all_port,
735 (void *)&cmd_config_speed_all_keyword,
736 (void *)&cmd_config_speed_all_all,
737 (void *)&cmd_config_speed_all_item1,
738 (void *)&cmd_config_speed_all_value1,
739 (void *)&cmd_config_speed_all_item2,
740 (void *)&cmd_config_speed_all_value2,
745 /* *** configure speed for specific port *** */
746 struct cmd_config_speed_specific {
747 cmdline_fixed_string_t port;
748 cmdline_fixed_string_t keyword;
750 cmdline_fixed_string_t item1;
751 cmdline_fixed_string_t item2;
752 cmdline_fixed_string_t value1;
753 cmdline_fixed_string_t value2;
757 cmd_config_speed_specific_parsed(void *parsed_result,
758 __attribute__((unused)) struct cmdline *cl,
759 __attribute__((unused)) void *data)
761 struct cmd_config_speed_specific *res = parsed_result;
762 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
763 uint16_t link_duplex = 0;
765 if (!all_ports_stopped()) {
766 printf("Please stop all ports first\n");
770 if (res->id >= nb_ports) {
771 printf("Port id %d must be less than %d\n", res->id, nb_ports);
775 if (!strcmp(res->value1, "10"))
776 link_speed = ETH_LINK_SPEED_10;
777 else if (!strcmp(res->value1, "100"))
778 link_speed = ETH_LINK_SPEED_100;
779 else if (!strcmp(res->value1, "1000"))
780 link_speed = ETH_LINK_SPEED_1000;
781 else if (!strcmp(res->value1, "10000"))
782 link_speed = ETH_LINK_SPEED_10000;
783 else if (!strcmp(res->value1, "auto"))
784 link_speed = ETH_LINK_SPEED_AUTONEG;
786 printf("Unknown parameter\n");
790 if (!strcmp(res->value2, "half"))
791 link_duplex = ETH_LINK_HALF_DUPLEX;
792 else if (!strcmp(res->value2, "full"))
793 link_duplex = ETH_LINK_FULL_DUPLEX;
794 else if (!strcmp(res->value2, "auto"))
795 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
797 printf("Unknown parameter\n");
801 ports[res->id].dev_conf.link_speed = link_speed;
802 ports[res->id].dev_conf.link_duplex = link_duplex;
804 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
808 cmdline_parse_token_string_t cmd_config_speed_specific_port =
809 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
811 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
812 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
814 cmdline_parse_token_num_t cmd_config_speed_specific_id =
815 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
816 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
817 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
819 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
820 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
821 "10#100#1000#10000#auto");
822 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
823 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
825 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
826 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
829 cmdline_parse_inst_t cmd_config_speed_specific = {
830 .f = cmd_config_speed_specific_parsed,
832 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
835 (void *)&cmd_config_speed_specific_port,
836 (void *)&cmd_config_speed_specific_keyword,
837 (void *)&cmd_config_speed_specific_id,
838 (void *)&cmd_config_speed_specific_item1,
839 (void *)&cmd_config_speed_specific_value1,
840 (void *)&cmd_config_speed_specific_item2,
841 (void *)&cmd_config_speed_specific_value2,
846 /* *** configure txq/rxq, txd/rxd *** */
847 struct cmd_config_rx_tx {
848 cmdline_fixed_string_t port;
849 cmdline_fixed_string_t keyword;
850 cmdline_fixed_string_t all;
851 cmdline_fixed_string_t name;
856 cmd_config_rx_tx_parsed(void *parsed_result,
857 __attribute__((unused)) struct cmdline *cl,
858 __attribute__((unused)) void *data)
860 struct cmd_config_rx_tx *res = parsed_result;
862 if (!all_ports_stopped()) {
863 printf("Please stop all ports first\n");
867 if (!strcmp(res->name, "rxq")) {
868 if (res->value <= 0) {
869 printf("rxq %d invalid - must be > 0\n", res->value);
874 else if (!strcmp(res->name, "txq")) {
875 if (res->value <= 0) {
876 printf("txq %d invalid - must be > 0\n", res->value);
881 else if (!strcmp(res->name, "rxd")) {
882 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
883 printf("rxd %d invalid - must be > 0 && <= %d\n",
884 res->value, RTE_TEST_RX_DESC_MAX);
888 } else if (!strcmp(res->name, "txd")) {
889 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
890 printf("txd %d invalid - must be > 0 && <= %d\n",
891 res->value, RTE_TEST_TX_DESC_MAX);
896 printf("Unknown parameter\n");
902 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
905 cmdline_parse_token_string_t cmd_config_rx_tx_port =
906 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
907 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
908 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
909 cmdline_parse_token_string_t cmd_config_rx_tx_all =
910 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
911 cmdline_parse_token_string_t cmd_config_rx_tx_name =
912 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
914 cmdline_parse_token_num_t cmd_config_rx_tx_value =
915 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
917 cmdline_parse_inst_t cmd_config_rx_tx = {
918 .f = cmd_config_rx_tx_parsed,
920 .help_str = "port config all rxq|txq|rxd|txd value",
922 (void *)&cmd_config_rx_tx_port,
923 (void *)&cmd_config_rx_tx_keyword,
924 (void *)&cmd_config_rx_tx_all,
925 (void *)&cmd_config_rx_tx_name,
926 (void *)&cmd_config_rx_tx_value,
931 /* *** config max packet length *** */
932 struct cmd_config_max_pkt_len_result {
933 cmdline_fixed_string_t port;
934 cmdline_fixed_string_t keyword;
935 cmdline_fixed_string_t all;
936 cmdline_fixed_string_t name;
941 cmd_config_max_pkt_len_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_config_max_pkt_len_result *res = parsed_result;
947 if (!all_ports_stopped()) {
948 printf("Please stop all ports first\n");
952 if (!strcmp(res->name, "max-pkt-len")) {
953 if (res->value < ETHER_MIN_LEN) {
954 printf("max-pkt-len can not be less than %d\n",
958 if (res->value == rx_mode.max_rx_pkt_len)
961 rx_mode.max_rx_pkt_len = res->value;
962 if (res->value > ETHER_MAX_LEN)
963 rx_mode.jumbo_frame = 1;
965 rx_mode.jumbo_frame = 0;
967 printf("Unknown parameter\n");
973 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
976 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
977 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
979 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
980 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
982 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
983 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
985 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
986 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
988 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
989 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
992 cmdline_parse_inst_t cmd_config_max_pkt_len = {
993 .f = cmd_config_max_pkt_len_parsed,
995 .help_str = "port config all max-pkt-len value",
997 (void *)&cmd_config_max_pkt_len_port,
998 (void *)&cmd_config_max_pkt_len_keyword,
999 (void *)&cmd_config_max_pkt_len_all,
1000 (void *)&cmd_config_max_pkt_len_name,
1001 (void *)&cmd_config_max_pkt_len_value,
1006 /* *** configure rx mode *** */
1007 struct cmd_config_rx_mode_flag {
1008 cmdline_fixed_string_t port;
1009 cmdline_fixed_string_t keyword;
1010 cmdline_fixed_string_t all;
1011 cmdline_fixed_string_t name;
1012 cmdline_fixed_string_t value;
1016 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1017 __attribute__((unused)) struct cmdline *cl,
1018 __attribute__((unused)) void *data)
1020 struct cmd_config_rx_mode_flag *res = parsed_result;
1022 if (!all_ports_stopped()) {
1023 printf("Please stop all ports first\n");
1027 if (!strcmp(res->name, "crc-strip")) {
1028 if (!strcmp(res->value, "on"))
1029 rx_mode.hw_strip_crc = 1;
1030 else if (!strcmp(res->value, "off"))
1031 rx_mode.hw_strip_crc = 0;
1033 printf("Unknown parameter\n");
1036 } else if (!strcmp(res->name, "rx-cksum")) {
1037 if (!strcmp(res->value, "on"))
1038 rx_mode.hw_ip_checksum = 1;
1039 else if (!strcmp(res->value, "off"))
1040 rx_mode.hw_ip_checksum = 0;
1042 printf("Unknown parameter\n");
1045 } else if (!strcmp(res->name, "hw-vlan")) {
1046 if (!strcmp(res->value, "on")) {
1047 rx_mode.hw_vlan_filter = 1;
1048 rx_mode.hw_vlan_strip = 1;
1050 else if (!strcmp(res->value, "off")) {
1051 rx_mode.hw_vlan_filter = 0;
1052 rx_mode.hw_vlan_strip = 0;
1055 printf("Unknown parameter\n");
1058 } else if (!strcmp(res->name, "drop-en")) {
1059 if (!strcmp(res->value, "on"))
1061 else if (!strcmp(res->value, "off"))
1064 printf("Unknown parameter\n");
1068 printf("Unknown parameter\n");
1074 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1077 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1078 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1079 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1080 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1082 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1083 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1084 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1085 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1086 "crc-strip#rx-cksum#hw-vlan");
1087 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1088 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1091 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1092 .f = cmd_config_rx_mode_flag_parsed,
1094 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1096 (void *)&cmd_config_rx_mode_flag_port,
1097 (void *)&cmd_config_rx_mode_flag_keyword,
1098 (void *)&cmd_config_rx_mode_flag_all,
1099 (void *)&cmd_config_rx_mode_flag_name,
1100 (void *)&cmd_config_rx_mode_flag_value,
1105 /* *** configure rss *** */
1106 struct cmd_config_rss {
1107 cmdline_fixed_string_t port;
1108 cmdline_fixed_string_t keyword;
1109 cmdline_fixed_string_t all;
1110 cmdline_fixed_string_t name;
1111 cmdline_fixed_string_t value;
1115 cmd_config_rss_parsed(void *parsed_result,
1116 __attribute__((unused)) struct cmdline *cl,
1117 __attribute__((unused)) void *data)
1119 struct cmd_config_rss *res = parsed_result;
1121 if (!all_ports_stopped()) {
1122 printf("Please stop all ports first\n");
1126 if (!strcmp(res->value, "ip"))
1127 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1128 else if (!strcmp(res->value, "udp"))
1129 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1130 else if (!strcmp(res->value, "none"))
1133 printf("Unknown parameter\n");
1139 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1142 cmdline_parse_token_string_t cmd_config_rss_port =
1143 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1144 cmdline_parse_token_string_t cmd_config_rss_keyword =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1146 cmdline_parse_token_string_t cmd_config_rss_all =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1148 cmdline_parse_token_string_t cmd_config_rss_name =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1150 cmdline_parse_token_string_t cmd_config_rss_value =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1153 cmdline_parse_inst_t cmd_config_rss = {
1154 .f = cmd_config_rss_parsed,
1156 .help_str = "port config all rss ip|udp|none",
1158 (void *)&cmd_config_rss_port,
1159 (void *)&cmd_config_rss_keyword,
1160 (void *)&cmd_config_rss_all,
1161 (void *)&cmd_config_rss_name,
1162 (void *)&cmd_config_rss_value,
1167 /* *** Configure RSS RETA *** */
1168 struct cmd_config_rss_reta {
1169 cmdline_fixed_string_t port;
1170 cmdline_fixed_string_t keyword;
1172 cmdline_fixed_string_t name;
1173 cmdline_fixed_string_t list_name;
1174 cmdline_fixed_string_t list_of_items;
1178 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1185 const char *p, *p0 = str;
1192 unsigned long int_fld[_NUM_FLD];
1193 char *str_fld[_NUM_FLD];
1195 while ((p = strchr(p0,'(')) != NULL) {
1197 if((p0 = strchr(p,')')) == NULL)
1201 if(size >= sizeof(s))
1204 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1205 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1207 for (i = 0; i < _NUM_FLD; i++) {
1209 int_fld[i] = strtoul(str_fld[i], &end, 0);
1210 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1214 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1215 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1217 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1218 printf("Invalid RETA hash index=%d",hash_index);
1222 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1223 reta_conf->mask_lo |= (1ULL << hash_index);
1225 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1227 reta_conf->reta[hash_index] = nb_queue;
1234 cmd_set_rss_reta_parsed(void *parsed_result,
1235 __attribute__((unused)) struct cmdline *cl,
1236 __attribute__((unused)) void *data)
1239 struct rte_eth_rss_reta reta_conf;
1240 struct cmd_config_rss_reta *res = parsed_result;
1242 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1243 if (!strcmp(res->list_name, "reta")) {
1244 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1245 printf("Invalid RSS Redirection Table config entered\n");
1248 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1250 printf("Bad redirection table parameter, return code = %d \n",ret);
1254 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1255 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1256 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1257 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1258 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1259 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1260 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1262 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1263 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1264 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1267 cmdline_parse_inst_t cmd_config_rss_reta = {
1268 .f = cmd_set_rss_reta_parsed,
1270 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1272 (void *)&cmd_config_rss_reta_port,
1273 (void *)&cmd_config_rss_reta_keyword,
1274 (void *)&cmd_config_rss_reta_port_id,
1275 (void *)&cmd_config_rss_reta_name,
1276 (void *)&cmd_config_rss_reta_list_name,
1277 (void *)&cmd_config_rss_reta_list_of_items,
1282 /* *** SHOW PORT INFO *** */
1283 struct cmd_showport_reta {
1284 cmdline_fixed_string_t show;
1285 cmdline_fixed_string_t port;
1287 cmdline_fixed_string_t rss;
1288 cmdline_fixed_string_t reta;
1293 static void cmd_showport_reta_parsed(void *parsed_result,
1294 __attribute__((unused)) struct cmdline *cl,
1295 __attribute__((unused)) void *data)
1297 struct cmd_showport_reta *res = parsed_result;
1298 struct rte_eth_rss_reta reta_conf;
1300 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1301 printf("Invalid RSS Redirection Table config entered\n");
1305 reta_conf.mask_lo = res->mask_lo;
1306 reta_conf.mask_hi = res->mask_hi;
1308 port_rss_reta_info(res->port_id,&reta_conf);
1311 cmdline_parse_token_string_t cmd_showport_reta_show =
1312 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1313 cmdline_parse_token_string_t cmd_showport_reta_port =
1314 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1315 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1316 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1317 cmdline_parse_token_string_t cmd_showport_reta_rss =
1318 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1319 cmdline_parse_token_string_t cmd_showport_reta_reta =
1320 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1321 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1322 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1323 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1324 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1326 cmdline_parse_inst_t cmd_showport_reta = {
1327 .f = cmd_showport_reta_parsed,
1329 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1330 (mask_lo and mask_hi is UINT64)",
1332 (void *)&cmd_showport_reta_show,
1333 (void *)&cmd_showport_reta_port,
1334 (void *)&cmd_showport_reta_port_id,
1335 (void *)&cmd_showport_reta_rss,
1336 (void *)&cmd_showport_reta_reta,
1337 (void *)&cmd_showport_reta_mask_lo,
1338 (void *)&cmd_showport_reta_mask_hi,
1343 /* *** Configure DCB *** */
1344 struct cmd_config_dcb {
1345 cmdline_fixed_string_t port;
1346 cmdline_fixed_string_t config;
1348 cmdline_fixed_string_t dcb;
1349 cmdline_fixed_string_t vt;
1350 cmdline_fixed_string_t vt_en;
1352 cmdline_fixed_string_t pfc;
1353 cmdline_fixed_string_t pfc_en;
1357 cmd_config_dcb_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_config_dcb *res = parsed_result;
1362 struct dcb_config dcb_conf;
1363 portid_t port_id = res->port_id;
1364 struct rte_port *port;
1366 port = &ports[port_id];
1367 /** Check if the port is not started **/
1368 if (port->port_status != RTE_PORT_STOPPED) {
1369 printf("Please stop port %d first\n",port_id);
1373 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1374 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1375 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1379 /* DCB in VT mode */
1380 if (!strncmp(res->vt_en, "on",2))
1381 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1383 dcb_conf.dcb_mode = DCB_ENABLED;
1385 if (!strncmp(res->pfc_en, "on",2)) {
1386 dcb_conf.pfc_en = 1;
1389 dcb_conf.pfc_en = 0;
1391 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1392 printf("Cannot initialize network ports\n");
1396 cmd_reconfig_device_queue(port_id, 1, 1);
1399 cmdline_parse_token_string_t cmd_config_dcb_port =
1400 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1401 cmdline_parse_token_string_t cmd_config_dcb_config =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1403 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1404 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1405 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1407 cmdline_parse_token_string_t cmd_config_dcb_vt =
1408 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1409 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1411 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1412 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1413 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1415 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1416 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1418 cmdline_parse_inst_t cmd_config_dcb = {
1419 .f = cmd_config_dcb_parsed,
1421 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1423 (void *)&cmd_config_dcb_port,
1424 (void *)&cmd_config_dcb_config,
1425 (void *)&cmd_config_dcb_port_id,
1426 (void *)&cmd_config_dcb_dcb,
1427 (void *)&cmd_config_dcb_vt,
1428 (void *)&cmd_config_dcb_vt_en,
1429 (void *)&cmd_config_dcb_num_tcs,
1430 (void *)&cmd_config_dcb_pfc,
1431 (void *)&cmd_config_dcb_pfc_en,
1436 /* *** configure number of packets per burst *** */
1437 struct cmd_config_burst {
1438 cmdline_fixed_string_t port;
1439 cmdline_fixed_string_t keyword;
1440 cmdline_fixed_string_t all;
1441 cmdline_fixed_string_t name;
1446 cmd_config_burst_parsed(void *parsed_result,
1447 __attribute__((unused)) struct cmdline *cl,
1448 __attribute__((unused)) void *data)
1450 struct cmd_config_burst *res = parsed_result;
1452 if (!all_ports_stopped()) {
1453 printf("Please stop all ports first\n");
1457 if (!strcmp(res->name, "burst")) {
1458 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1459 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1462 nb_pkt_per_burst = res->value;
1464 printf("Unknown parameter\n");
1470 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1473 cmdline_parse_token_string_t cmd_config_burst_port =
1474 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1475 cmdline_parse_token_string_t cmd_config_burst_keyword =
1476 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1477 cmdline_parse_token_string_t cmd_config_burst_all =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1479 cmdline_parse_token_string_t cmd_config_burst_name =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1481 cmdline_parse_token_num_t cmd_config_burst_value =
1482 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1484 cmdline_parse_inst_t cmd_config_burst = {
1485 .f = cmd_config_burst_parsed,
1487 .help_str = "port config all burst value",
1489 (void *)&cmd_config_burst_port,
1490 (void *)&cmd_config_burst_keyword,
1491 (void *)&cmd_config_burst_all,
1492 (void *)&cmd_config_burst_name,
1493 (void *)&cmd_config_burst_value,
1498 /* *** configure rx/tx queues *** */
1499 struct cmd_config_thresh {
1500 cmdline_fixed_string_t port;
1501 cmdline_fixed_string_t keyword;
1502 cmdline_fixed_string_t all;
1503 cmdline_fixed_string_t name;
1508 cmd_config_thresh_parsed(void *parsed_result,
1509 __attribute__((unused)) struct cmdline *cl,
1510 __attribute__((unused)) void *data)
1512 struct cmd_config_thresh *res = parsed_result;
1514 if (!all_ports_stopped()) {
1515 printf("Please stop all ports first\n");
1519 if (!strcmp(res->name, "txpt"))
1520 tx_thresh.pthresh = res->value;
1521 else if(!strcmp(res->name, "txht"))
1522 tx_thresh.hthresh = res->value;
1523 else if(!strcmp(res->name, "txwt"))
1524 tx_thresh.wthresh = res->value;
1525 else if(!strcmp(res->name, "rxpt"))
1526 rx_thresh.pthresh = res->value;
1527 else if(!strcmp(res->name, "rxht"))
1528 rx_thresh.hthresh = res->value;
1529 else if(!strcmp(res->name, "rxwt"))
1530 rx_thresh.wthresh = res->value;
1532 printf("Unknown parameter\n");
1538 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1541 cmdline_parse_token_string_t cmd_config_thresh_port =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1543 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1545 cmdline_parse_token_string_t cmd_config_thresh_all =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1547 cmdline_parse_token_string_t cmd_config_thresh_name =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1549 "txpt#txht#txwt#rxpt#rxht#rxwt");
1550 cmdline_parse_token_num_t cmd_config_thresh_value =
1551 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1553 cmdline_parse_inst_t cmd_config_thresh = {
1554 .f = cmd_config_thresh_parsed,
1556 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1558 (void *)&cmd_config_thresh_port,
1559 (void *)&cmd_config_thresh_keyword,
1560 (void *)&cmd_config_thresh_all,
1561 (void *)&cmd_config_thresh_name,
1562 (void *)&cmd_config_thresh_value,
1567 /* *** configure free/rs threshold *** */
1568 struct cmd_config_threshold {
1569 cmdline_fixed_string_t port;
1570 cmdline_fixed_string_t keyword;
1571 cmdline_fixed_string_t all;
1572 cmdline_fixed_string_t name;
1577 cmd_config_threshold_parsed(void *parsed_result,
1578 __attribute__((unused)) struct cmdline *cl,
1579 __attribute__((unused)) void *data)
1581 struct cmd_config_threshold *res = parsed_result;
1583 if (!all_ports_stopped()) {
1584 printf("Please stop all ports first\n");
1588 if (!strcmp(res->name, "txfreet"))
1589 tx_free_thresh = res->value;
1590 else if (!strcmp(res->name, "txrst"))
1591 tx_rs_thresh = res->value;
1592 else if (!strcmp(res->name, "rxfreet"))
1593 rx_free_thresh = res->value;
1595 printf("Unknown parameter\n");
1601 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1604 cmdline_parse_token_string_t cmd_config_threshold_port =
1605 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1606 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1609 cmdline_parse_token_string_t cmd_config_threshold_all =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1611 cmdline_parse_token_string_t cmd_config_threshold_name =
1612 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1613 "txfreet#txrst#rxfreet");
1614 cmdline_parse_token_num_t cmd_config_threshold_value =
1615 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1617 cmdline_parse_inst_t cmd_config_threshold = {
1618 .f = cmd_config_threshold_parsed,
1620 .help_str = "port config all txfreet|txrst|rxfreet value",
1622 (void *)&cmd_config_threshold_port,
1623 (void *)&cmd_config_threshold_keyword,
1624 (void *)&cmd_config_threshold_all,
1625 (void *)&cmd_config_threshold_name,
1626 (void *)&cmd_config_threshold_value,
1632 struct cmd_stop_result {
1633 cmdline_fixed_string_t stop;
1636 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1637 __attribute__((unused)) struct cmdline *cl,
1638 __attribute__((unused)) void *data)
1640 stop_packet_forwarding();
1643 cmdline_parse_token_string_t cmd_stop_stop =
1644 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1646 cmdline_parse_inst_t cmd_stop = {
1647 .f = cmd_stop_parsed,
1649 .help_str = "stop - stop packet forwarding",
1651 (void *)&cmd_stop_stop,
1656 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1659 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1660 unsigned int *parsed_items, int check_unique_values)
1662 unsigned int nb_item;
1670 * First parse all items in the list and store their value.
1675 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1677 if ((c >= '0') && (c <= '9')) {
1678 value = (unsigned int) (value * 10 + (c - '0'));
1683 printf("character %c is not a decimal digit\n", c);
1687 printf("No valid value before comma\n");
1690 if (nb_item < max_items) {
1691 parsed_items[nb_item] = value;
1697 if (nb_item >= max_items) {
1698 printf("Number of %s = %u > %u (maximum items)\n",
1699 item_name, nb_item + 1, max_items);
1702 parsed_items[nb_item++] = value;
1703 if (! check_unique_values)
1707 * Then, check that all values in the list are differents.
1708 * No optimization here...
1710 for (i = 0; i < nb_item; i++) {
1711 for (j = i + 1; j < nb_item; j++) {
1712 if (parsed_items[j] == parsed_items[i]) {
1713 printf("duplicated %s %u at index %u and %u\n",
1714 item_name, parsed_items[i], i, j);
1722 struct cmd_set_list_result {
1723 cmdline_fixed_string_t cmd_keyword;
1724 cmdline_fixed_string_t list_name;
1725 cmdline_fixed_string_t list_of_items;
1728 static void cmd_set_list_parsed(void *parsed_result,
1729 __attribute__((unused)) struct cmdline *cl,
1730 __attribute__((unused)) void *data)
1732 struct cmd_set_list_result *res;
1734 unsigned int lcorelist[RTE_MAX_LCORE];
1735 unsigned int portlist[RTE_MAX_ETHPORTS];
1737 unsigned int nb_item;
1739 res = parsed_result;
1740 if (!strcmp(res->list_name, "corelist")) {
1741 nb_item = parse_item_list(res->list_of_items, "core",
1743 parsed_items.lcorelist, 1);
1745 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1748 if (!strcmp(res->list_name, "portlist")) {
1749 nb_item = parse_item_list(res->list_of_items, "port",
1751 parsed_items.portlist, 1);
1753 set_fwd_ports_list(parsed_items.portlist, nb_item);
1757 cmdline_parse_token_string_t cmd_set_list_keyword =
1758 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1760 cmdline_parse_token_string_t cmd_set_list_name =
1761 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1762 "corelist#portlist");
1763 cmdline_parse_token_string_t cmd_set_list_of_items =
1764 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1767 cmdline_parse_inst_t cmd_set_fwd_list = {
1768 .f = cmd_set_list_parsed,
1770 .help_str = "set corelist|portlist x[,y]*",
1772 (void *)&cmd_set_list_keyword,
1773 (void *)&cmd_set_list_name,
1774 (void *)&cmd_set_list_of_items,
1779 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1781 struct cmd_setmask_result {
1782 cmdline_fixed_string_t set;
1783 cmdline_fixed_string_t mask;
1787 static void cmd_set_mask_parsed(void *parsed_result,
1788 __attribute__((unused)) struct cmdline *cl,
1789 __attribute__((unused)) void *data)
1791 struct cmd_setmask_result *res = parsed_result;
1793 if (!strcmp(res->mask, "coremask"))
1794 set_fwd_lcores_mask(res->hexavalue);
1795 else if (!strcmp(res->mask, "portmask"))
1796 set_fwd_ports_mask(res->hexavalue);
1799 cmdline_parse_token_string_t cmd_setmask_set =
1800 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1801 cmdline_parse_token_string_t cmd_setmask_mask =
1802 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1803 "coremask#portmask");
1804 cmdline_parse_token_num_t cmd_setmask_value =
1805 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1807 cmdline_parse_inst_t cmd_set_fwd_mask = {
1808 .f = cmd_set_mask_parsed,
1810 .help_str = "set coremask|portmask hexadecimal value",
1812 (void *)&cmd_setmask_set,
1813 (void *)&cmd_setmask_mask,
1814 (void *)&cmd_setmask_value,
1820 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1822 struct cmd_set_result {
1823 cmdline_fixed_string_t set;
1824 cmdline_fixed_string_t what;
1828 static void cmd_set_parsed(void *parsed_result,
1829 __attribute__((unused)) struct cmdline *cl,
1830 __attribute__((unused)) void *data)
1832 struct cmd_set_result *res = parsed_result;
1833 if (!strcmp(res->what, "nbport"))
1834 set_fwd_ports_number(res->value);
1835 else if (!strcmp(res->what, "nbcore"))
1836 set_fwd_lcores_number(res->value);
1837 else if (!strcmp(res->what, "burst"))
1838 set_nb_pkt_per_burst(res->value);
1839 else if (!strcmp(res->what, "verbose"))
1840 set_verbose_level(res->value);
1843 cmdline_parse_token_string_t cmd_set_set =
1844 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1845 cmdline_parse_token_string_t cmd_set_what =
1846 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1847 "nbport#nbcore#burst#verbose");
1848 cmdline_parse_token_num_t cmd_set_value =
1849 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1851 cmdline_parse_inst_t cmd_set_numbers = {
1852 .f = cmd_set_parsed,
1854 .help_str = "set nbport|nbcore|burst|verbose value",
1856 (void *)&cmd_set_set,
1857 (void *)&cmd_set_what,
1858 (void *)&cmd_set_value,
1863 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1865 struct cmd_set_txpkts_result {
1866 cmdline_fixed_string_t cmd_keyword;
1867 cmdline_fixed_string_t txpkts;
1868 cmdline_fixed_string_t seg_lengths;
1872 cmd_set_txpkts_parsed(void *parsed_result,
1873 __attribute__((unused)) struct cmdline *cl,
1874 __attribute__((unused)) void *data)
1876 struct cmd_set_txpkts_result *res;
1877 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1878 unsigned int nb_segs;
1880 res = parsed_result;
1881 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1882 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1884 set_tx_pkt_segments(seg_lengths, nb_segs);
1887 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1888 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1889 cmd_keyword, "set");
1890 cmdline_parse_token_string_t cmd_set_txpkts_name =
1891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1893 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1897 cmdline_parse_inst_t cmd_set_txpkts = {
1898 .f = cmd_set_txpkts_parsed,
1900 .help_str = "set txpkts x[,y]*",
1902 (void *)&cmd_set_txpkts_keyword,
1903 (void *)&cmd_set_txpkts_name,
1904 (void *)&cmd_set_txpkts_lengths,
1909 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1910 struct cmd_rx_vlan_filter_all_result {
1911 cmdline_fixed_string_t rx_vlan;
1912 cmdline_fixed_string_t what;
1913 cmdline_fixed_string_t all;
1918 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1919 __attribute__((unused)) struct cmdline *cl,
1920 __attribute__((unused)) void *data)
1922 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1924 if (!strcmp(res->what, "add"))
1925 rx_vlan_all_filter_set(res->port_id, 1);
1927 rx_vlan_all_filter_set(res->port_id, 0);
1930 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1931 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1932 rx_vlan, "rx_vlan");
1933 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1934 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1936 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1937 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1939 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1940 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1943 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1944 .f = cmd_rx_vlan_filter_all_parsed,
1946 .help_str = "add/remove all identifiers to/from the set of VLAN "
1947 "Identifiers filtered by a port",
1949 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1950 (void *)&cmd_rx_vlan_filter_all_what,
1951 (void *)&cmd_rx_vlan_filter_all_all,
1952 (void *)&cmd_rx_vlan_filter_all_portid,
1957 /* *** VLAN OFFLOAD SET ON A PORT *** */
1958 struct cmd_vlan_offload_result {
1959 cmdline_fixed_string_t vlan;
1960 cmdline_fixed_string_t set;
1961 cmdline_fixed_string_t what;
1962 cmdline_fixed_string_t on;
1963 cmdline_fixed_string_t port_id;
1967 cmd_vlan_offload_parsed(void *parsed_result,
1968 __attribute__((unused)) struct cmdline *cl,
1969 __attribute__((unused)) void *data)
1972 struct cmd_vlan_offload_result *res = parsed_result;
1975 portid_t port_id = 0;
1979 len = strnlen(str, STR_TOKEN_SIZE);
1981 /* Get port_id first */
1989 tmp = strtoul(str, NULL, 0);
1990 /* If port_id greater that what portid_t can represent, return */
1991 if(tmp >= RTE_MAX_ETHPORTS)
1993 port_id = (portid_t)tmp;
1995 if (!strcmp(res->on, "on"))
2000 if (!strcmp(res->what, "strip"))
2001 rx_vlan_strip_set(port_id, on);
2002 else if(!strcmp(res->what, "stripq")){
2003 uint16_t queue_id = 0;
2005 /* No queue_id, return */
2008 tmp = strtoul(str + i + 1, NULL, 0);
2009 /* If queue_id greater that what 16-bits can represent, return */
2013 queue_id = (uint16_t)tmp;
2014 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2016 else if (!strcmp(res->what, "filter"))
2017 rx_vlan_filter_set(port_id, on);
2019 vlan_extend_set(port_id, on);
2024 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2025 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2027 cmdline_parse_token_string_t cmd_vlan_offload_set =
2028 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2030 cmdline_parse_token_string_t cmd_vlan_offload_what =
2031 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2032 what, "strip#filter#qinq#stripq");
2033 cmdline_parse_token_string_t cmd_vlan_offload_on =
2034 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2036 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2037 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2040 cmdline_parse_inst_t cmd_vlan_offload = {
2041 .f = cmd_vlan_offload_parsed,
2043 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2044 " qinq(extended) for both rx/tx sides ",
2046 (void *)&cmd_vlan_offload_vlan,
2047 (void *)&cmd_vlan_offload_set,
2048 (void *)&cmd_vlan_offload_what,
2049 (void *)&cmd_vlan_offload_on,
2050 (void *)&cmd_vlan_offload_portid,
2055 /* *** VLAN TPID SET ON A PORT *** */
2056 struct cmd_vlan_tpid_result {
2057 cmdline_fixed_string_t vlan;
2058 cmdline_fixed_string_t set;
2059 cmdline_fixed_string_t what;
2065 cmd_vlan_tpid_parsed(void *parsed_result,
2066 __attribute__((unused)) struct cmdline *cl,
2067 __attribute__((unused)) void *data)
2069 struct cmd_vlan_tpid_result *res = parsed_result;
2070 vlan_tpid_set(res->port_id, res->tp_id);
2074 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2075 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2077 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2078 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2080 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2083 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2084 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2086 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2087 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2090 cmdline_parse_inst_t cmd_vlan_tpid = {
2091 .f = cmd_vlan_tpid_parsed,
2093 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2095 (void *)&cmd_vlan_tpid_vlan,
2096 (void *)&cmd_vlan_tpid_set,
2097 (void *)&cmd_vlan_tpid_what,
2098 (void *)&cmd_vlan_tpid_tpid,
2099 (void *)&cmd_vlan_tpid_portid,
2104 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2105 struct cmd_rx_vlan_filter_result {
2106 cmdline_fixed_string_t rx_vlan;
2107 cmdline_fixed_string_t what;
2113 cmd_rx_vlan_filter_parsed(void *parsed_result,
2114 __attribute__((unused)) struct cmdline *cl,
2115 __attribute__((unused)) void *data)
2117 struct cmd_rx_vlan_filter_result *res = parsed_result;
2119 if (!strcmp(res->what, "add"))
2120 rx_vft_set(res->port_id, res->vlan_id, 1);
2122 rx_vft_set(res->port_id, res->vlan_id, 0);
2125 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2126 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2127 rx_vlan, "rx_vlan");
2128 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2129 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2131 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2132 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2134 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2135 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2138 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2139 .f = cmd_rx_vlan_filter_parsed,
2141 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2142 "Identifiers filtered by a port",
2144 (void *)&cmd_rx_vlan_filter_rx_vlan,
2145 (void *)&cmd_rx_vlan_filter_what,
2146 (void *)&cmd_rx_vlan_filter_vlanid,
2147 (void *)&cmd_rx_vlan_filter_portid,
2152 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2153 struct cmd_tx_vlan_set_result {
2154 cmdline_fixed_string_t tx_vlan;
2155 cmdline_fixed_string_t set;
2161 cmd_tx_vlan_set_parsed(void *parsed_result,
2162 __attribute__((unused)) struct cmdline *cl,
2163 __attribute__((unused)) void *data)
2165 struct cmd_tx_vlan_set_result *res = parsed_result;
2166 tx_vlan_set(res->port_id, res->vlan_id);
2169 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2170 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2171 tx_vlan, "tx_vlan");
2172 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2173 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2175 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2176 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2178 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2179 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2182 cmdline_parse_inst_t cmd_tx_vlan_set = {
2183 .f = cmd_tx_vlan_set_parsed,
2185 .help_str = "enable hardware insertion of a VLAN header with a given "
2186 "TAG Identifier in packets sent on a port",
2188 (void *)&cmd_tx_vlan_set_tx_vlan,
2189 (void *)&cmd_tx_vlan_set_set,
2190 (void *)&cmd_tx_vlan_set_vlanid,
2191 (void *)&cmd_tx_vlan_set_portid,
2196 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2197 struct cmd_tx_vlan_reset_result {
2198 cmdline_fixed_string_t tx_vlan;
2199 cmdline_fixed_string_t reset;
2204 cmd_tx_vlan_reset_parsed(void *parsed_result,
2205 __attribute__((unused)) struct cmdline *cl,
2206 __attribute__((unused)) void *data)
2208 struct cmd_tx_vlan_reset_result *res = parsed_result;
2210 tx_vlan_reset(res->port_id);
2213 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2214 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2215 tx_vlan, "tx_vlan");
2216 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2217 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2219 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2220 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2223 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2224 .f = cmd_tx_vlan_reset_parsed,
2226 .help_str = "disable hardware insertion of a VLAN header in packets "
2229 (void *)&cmd_tx_vlan_reset_tx_vlan,
2230 (void *)&cmd_tx_vlan_reset_reset,
2231 (void *)&cmd_tx_vlan_reset_portid,
2237 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2238 struct cmd_tx_cksum_set_result {
2239 cmdline_fixed_string_t tx_cksum;
2240 cmdline_fixed_string_t set;
2246 cmd_tx_cksum_set_parsed(void *parsed_result,
2247 __attribute__((unused)) struct cmdline *cl,
2248 __attribute__((unused)) void *data)
2250 struct cmd_tx_cksum_set_result *res = parsed_result;
2252 tx_cksum_set(res->port_id, res->cksum_mask);
2255 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2256 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2257 tx_cksum, "tx_checksum");
2258 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2259 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2261 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2262 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2264 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2265 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2268 cmdline_parse_inst_t cmd_tx_cksum_set = {
2269 .f = cmd_tx_cksum_set_parsed,
2271 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2272 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2273 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2275 (void *)&cmd_tx_cksum_set_tx_cksum,
2276 (void *)&cmd_tx_cksum_set_set,
2277 (void *)&cmd_tx_cksum_set_cksum_mask,
2278 (void *)&cmd_tx_cksum_set_portid,
2283 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2284 struct cmd_set_flush_rx {
2285 cmdline_fixed_string_t set;
2286 cmdline_fixed_string_t flush_rx;
2287 cmdline_fixed_string_t mode;
2291 cmd_set_flush_rx_parsed(void *parsed_result,
2292 __attribute__((unused)) struct cmdline *cl,
2293 __attribute__((unused)) void *data)
2295 struct cmd_set_flush_rx *res = parsed_result;
2296 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2299 cmdline_parse_token_string_t cmd_setflushrx_set =
2300 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2302 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2303 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2304 flush_rx, "flush_rx");
2305 cmdline_parse_token_string_t cmd_setflushrx_mode =
2306 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2310 cmdline_parse_inst_t cmd_set_flush_rx = {
2311 .f = cmd_set_flush_rx_parsed,
2312 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2315 (void *)&cmd_setflushrx_set,
2316 (void *)&cmd_setflushrx_flush_rx,
2317 (void *)&cmd_setflushrx_mode,
2322 #ifdef RTE_NIC_BYPASS
2323 /* *** SET NIC BYPASS MODE *** */
2324 struct cmd_set_bypass_mode_result {
2325 cmdline_fixed_string_t set;
2326 cmdline_fixed_string_t bypass;
2327 cmdline_fixed_string_t mode;
2328 cmdline_fixed_string_t value;
2333 cmd_set_bypass_mode_parsed(void *parsed_result,
2334 __attribute__((unused)) struct cmdline *cl,
2335 __attribute__((unused)) void *data)
2337 struct cmd_set_bypass_mode_result *res = parsed_result;
2338 portid_t port_id = res->port_id;
2339 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2341 if (!bypass_is_supported(port_id))
2344 if (!strcmp(res->value, "bypass"))
2345 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2346 else if (!strcmp(res->value, "isolate"))
2347 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2349 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2351 /* Set the bypass mode for the relevant port. */
2352 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2353 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2357 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2360 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2363 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2366 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2368 value, "normal#bypass#isolate");
2369 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2370 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2373 cmdline_parse_inst_t cmd_set_bypass_mode = {
2374 .f = cmd_set_bypass_mode_parsed,
2375 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2376 "Set the NIC bypass mode for port_id",
2379 (void *)&cmd_setbypass_mode_set,
2380 (void *)&cmd_setbypass_mode_bypass,
2381 (void *)&cmd_setbypass_mode_mode,
2382 (void *)&cmd_setbypass_mode_value,
2383 (void *)&cmd_setbypass_mode_port,
2388 /* *** SET NIC BYPASS EVENT *** */
2389 struct cmd_set_bypass_event_result {
2390 cmdline_fixed_string_t set;
2391 cmdline_fixed_string_t bypass;
2392 cmdline_fixed_string_t event;
2393 cmdline_fixed_string_t event_value;
2394 cmdline_fixed_string_t mode;
2395 cmdline_fixed_string_t mode_value;
2400 cmd_set_bypass_event_parsed(void *parsed_result,
2401 __attribute__((unused)) struct cmdline *cl,
2402 __attribute__((unused)) void *data)
2405 struct cmd_set_bypass_event_result *res = parsed_result;
2406 portid_t port_id = res->port_id;
2407 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2408 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2410 if (!bypass_is_supported(port_id))
2413 if (!strcmp(res->event_value, "timeout"))
2414 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2415 else if (!strcmp(res->event_value, "os_on"))
2416 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2417 else if (!strcmp(res->event_value, "os_off"))
2418 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2419 else if (!strcmp(res->event_value, "power_on"))
2420 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2421 else if (!strcmp(res->event_value, "power_off"))
2422 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2424 bypass_event = RTE_BYPASS_EVENT_NONE;
2426 if (!strcmp(res->mode_value, "bypass"))
2427 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2428 else if (!strcmp(res->mode_value, "isolate"))
2429 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2431 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2433 /* Set the watchdog timeout. */
2434 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2437 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2438 (rc = rte_eth_dev_wd_timeout_store(port_id,
2439 bypass_timeout)) != 0) {
2440 printf("Failed to set timeout value %u "
2441 "for port %d, errto code: %d.\n",
2442 bypass_timeout, port_id, rc);
2446 /* Set the bypass event to transition to bypass mode. */
2447 if (0 != rte_eth_dev_bypass_event_store(port_id,
2448 bypass_event, bypass_mode)) {
2449 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2454 cmdline_parse_token_string_t cmd_setbypass_event_set =
2455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2457 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2458 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2460 cmdline_parse_token_string_t cmd_setbypass_event_event =
2461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2463 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2464 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2465 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2466 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2469 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2471 mode_value, "normal#bypass#isolate");
2472 cmdline_parse_token_num_t cmd_setbypass_event_port =
2473 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2476 cmdline_parse_inst_t cmd_set_bypass_event = {
2477 .f = cmd_set_bypass_event_parsed,
2478 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2479 "mode (normal|bypass|isolate) (port_id): "
2480 "Set the NIC bypass event mode for port_id",
2483 (void *)&cmd_setbypass_event_set,
2484 (void *)&cmd_setbypass_event_bypass,
2485 (void *)&cmd_setbypass_event_event,
2486 (void *)&cmd_setbypass_event_event_value,
2487 (void *)&cmd_setbypass_event_mode,
2488 (void *)&cmd_setbypass_event_mode_value,
2489 (void *)&cmd_setbypass_event_port,
2495 /* *** SET NIC BYPASS TIMEOUT *** */
2496 struct cmd_set_bypass_timeout_result {
2497 cmdline_fixed_string_t set;
2498 cmdline_fixed_string_t bypass;
2499 cmdline_fixed_string_t timeout;
2500 cmdline_fixed_string_t value;
2504 cmd_set_bypass_timeout_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_set_bypass_timeout_result *res = parsed_result;
2510 if (!strcmp(res->value, "1.5"))
2511 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2512 else if (!strcmp(res->value, "2"))
2513 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2514 else if (!strcmp(res->value, "3"))
2515 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2516 else if (!strcmp(res->value, "4"))
2517 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2518 else if (!strcmp(res->value, "8"))
2519 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2520 else if (!strcmp(res->value, "16"))
2521 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2522 else if (!strcmp(res->value, "32"))
2523 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2525 bypass_timeout = RTE_BYPASS_TMT_OFF;
2528 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2529 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2531 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2534 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2536 timeout, "timeout");
2537 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2539 value, "0#1.5#2#3#4#8#16#32");
2541 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2542 .f = cmd_set_bypass_timeout_parsed,
2543 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2544 "Set the NIC bypass watchdog timeout",
2547 (void *)&cmd_setbypass_timeout_set,
2548 (void *)&cmd_setbypass_timeout_bypass,
2549 (void *)&cmd_setbypass_timeout_timeout,
2550 (void *)&cmd_setbypass_timeout_value,
2555 /* *** SHOW NIC BYPASS MODE *** */
2556 struct cmd_show_bypass_config_result {
2557 cmdline_fixed_string_t show;
2558 cmdline_fixed_string_t bypass;
2559 cmdline_fixed_string_t config;
2564 cmd_show_bypass_config_parsed(void *parsed_result,
2565 __attribute__((unused)) struct cmdline *cl,
2566 __attribute__((unused)) void *data)
2568 struct cmd_show_bypass_config_result *res = parsed_result;
2569 uint32_t event_mode;
2570 uint32_t bypass_mode;
2571 portid_t port_id = res->port_id;
2572 uint32_t timeout = bypass_timeout;
2575 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2576 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2577 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2578 {"UNKNOWN", "normal", "bypass", "isolate"};
2579 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2586 int num_events = (sizeof events) / (sizeof events[0]);
2588 if (!bypass_is_supported(port_id))
2591 /* Display the bypass mode.*/
2592 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2593 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2597 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2598 bypass_mode = RTE_BYPASS_MODE_NONE;
2600 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2603 /* Display the bypass timeout.*/
2604 if (!RTE_BYPASS_TMT_VALID(timeout))
2605 timeout = RTE_BYPASS_TMT_OFF;
2607 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2609 /* Display the bypass events and associated modes. */
2610 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2612 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2613 printf("\tFailed to get bypass mode for event = %s\n",
2616 if (!RTE_BYPASS_MODE_VALID(event_mode))
2617 event_mode = RTE_BYPASS_MODE_NONE;
2619 printf("\tbypass event: %-16s = %s\n", events[i],
2625 cmdline_parse_token_string_t cmd_showbypass_config_show =
2626 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2628 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2629 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2631 cmdline_parse_token_string_t cmd_showbypass_config_config =
2632 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2634 cmdline_parse_token_num_t cmd_showbypass_config_port =
2635 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2638 cmdline_parse_inst_t cmd_show_bypass_config = {
2639 .f = cmd_show_bypass_config_parsed,
2640 .help_str = "show bypass config (port_id): "
2641 "Show the NIC bypass config for port_id",
2644 (void *)&cmd_showbypass_config_show,
2645 (void *)&cmd_showbypass_config_bypass,
2646 (void *)&cmd_showbypass_config_config,
2647 (void *)&cmd_showbypass_config_port,
2653 /* *** SET FORWARDING MODE *** */
2654 struct cmd_set_fwd_mode_result {
2655 cmdline_fixed_string_t set;
2656 cmdline_fixed_string_t fwd;
2657 cmdline_fixed_string_t mode;
2660 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2661 __attribute__((unused)) struct cmdline *cl,
2662 __attribute__((unused)) void *data)
2664 struct cmd_set_fwd_mode_result *res = parsed_result;
2666 set_pkt_forwarding_mode(res->mode);
2669 cmdline_parse_token_string_t cmd_setfwd_set =
2670 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2671 cmdline_parse_token_string_t cmd_setfwd_fwd =
2672 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2673 cmdline_parse_token_string_t cmd_setfwd_mode =
2674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2675 #ifdef RTE_LIBRTE_IEEE1588
2676 "io#mac#rxonly#txonly#csum#ieee1588");
2678 "io#mac#rxonly#txonly#csum");
2681 cmdline_parse_inst_t cmd_set_fwd_mode = {
2682 .f = cmd_set_fwd_mode_parsed,
2684 #ifdef RTE_LIBRTE_IEEE1588
2685 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2686 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2688 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2689 " RXONLY, CSUM or TXONLY packet forwarding mode",
2692 (void *)&cmd_setfwd_set,
2693 (void *)&cmd_setfwd_fwd,
2694 (void *)&cmd_setfwd_mode,
2699 /* *** SET PROMISC MODE *** */
2700 struct cmd_set_promisc_mode_result {
2701 cmdline_fixed_string_t set;
2702 cmdline_fixed_string_t promisc;
2703 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2704 uint8_t port_num; /* valid if "allports" argument == 0 */
2705 cmdline_fixed_string_t mode;
2708 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2709 __attribute__((unused)) struct cmdline *cl,
2712 struct cmd_set_promisc_mode_result *res = parsed_result;
2716 if (!strcmp(res->mode, "on"))
2723 for (i = 0; i < nb_ports; i++) {
2725 rte_eth_promiscuous_enable(i);
2727 rte_eth_promiscuous_disable(i);
2732 rte_eth_promiscuous_enable(res->port_num);
2734 rte_eth_promiscuous_disable(res->port_num);
2738 cmdline_parse_token_string_t cmd_setpromisc_set =
2739 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2740 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2741 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2743 cmdline_parse_token_string_t cmd_setpromisc_portall =
2744 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2746 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2747 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2749 cmdline_parse_token_string_t cmd_setpromisc_mode =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2753 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2754 .f = cmd_set_promisc_mode_parsed,
2756 .help_str = "set promisc all on|off: set promisc mode for all ports",
2758 (void *)&cmd_setpromisc_set,
2759 (void *)&cmd_setpromisc_promisc,
2760 (void *)&cmd_setpromisc_portall,
2761 (void *)&cmd_setpromisc_mode,
2766 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2767 .f = cmd_set_promisc_mode_parsed,
2769 .help_str = "set promisc X on|off: set promisc mode on port X",
2771 (void *)&cmd_setpromisc_set,
2772 (void *)&cmd_setpromisc_promisc,
2773 (void *)&cmd_setpromisc_portnum,
2774 (void *)&cmd_setpromisc_mode,
2779 /* *** SET ALLMULTI MODE *** */
2780 struct cmd_set_allmulti_mode_result {
2781 cmdline_fixed_string_t set;
2782 cmdline_fixed_string_t allmulti;
2783 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2784 uint8_t port_num; /* valid if "allports" argument == 0 */
2785 cmdline_fixed_string_t mode;
2788 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2789 __attribute__((unused)) struct cmdline *cl,
2792 struct cmd_set_allmulti_mode_result *res = parsed_result;
2796 if (!strcmp(res->mode, "on"))
2803 for (i = 0; i < nb_ports; i++) {
2805 rte_eth_allmulticast_enable(i);
2807 rte_eth_allmulticast_disable(i);
2812 rte_eth_allmulticast_enable(res->port_num);
2814 rte_eth_allmulticast_disable(res->port_num);
2818 cmdline_parse_token_string_t cmd_setallmulti_set =
2819 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2820 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2821 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2823 cmdline_parse_token_string_t cmd_setallmulti_portall =
2824 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2826 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2827 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2829 cmdline_parse_token_string_t cmd_setallmulti_mode =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2833 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2834 .f = cmd_set_allmulti_mode_parsed,
2836 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2838 (void *)&cmd_setallmulti_set,
2839 (void *)&cmd_setallmulti_allmulti,
2840 (void *)&cmd_setallmulti_portall,
2841 (void *)&cmd_setallmulti_mode,
2846 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2847 .f = cmd_set_allmulti_mode_parsed,
2849 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2851 (void *)&cmd_setallmulti_set,
2852 (void *)&cmd_setallmulti_allmulti,
2853 (void *)&cmd_setallmulti_portnum,
2854 (void *)&cmd_setallmulti_mode,
2859 /* *** ADD/REMOVE A PKT FILTER *** */
2860 struct cmd_pkt_filter_result {
2861 cmdline_fixed_string_t pkt_filter;
2863 cmdline_fixed_string_t protocol;
2864 cmdline_fixed_string_t src;
2865 cmdline_ipaddr_t ip_src;
2867 cmdline_fixed_string_t dst;
2868 cmdline_ipaddr_t ip_dst;
2870 cmdline_fixed_string_t flexbytes;
2871 uint16_t flexbytes_value;
2872 cmdline_fixed_string_t vlan;
2874 cmdline_fixed_string_t queue;
2876 cmdline_fixed_string_t soft;
2881 cmd_pkt_filter_parsed(void *parsed_result,
2882 __attribute__((unused)) struct cmdline *cl,
2883 __attribute__((unused)) void *data)
2885 struct rte_fdir_filter fdir_filter;
2886 struct cmd_pkt_filter_result *res = parsed_result;
2888 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2890 if (res->ip_src.family == AF_INET)
2891 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2893 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2894 &(res->ip_src.addr.ipv6),
2895 sizeof(struct in6_addr));
2897 if (res->ip_dst.family == AF_INET)
2898 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2900 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2901 &(res->ip_dst.addr.ipv6),
2902 sizeof(struct in6_addr));
2904 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2905 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2907 if (!strcmp(res->protocol, "udp"))
2908 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2909 else if (!strcmp(res->protocol, "tcp"))
2910 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2911 else if (!strcmp(res->protocol, "sctp"))
2912 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2913 else /* default only IP */
2914 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2916 if (res->ip_dst.family == AF_INET6)
2917 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2919 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2921 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2922 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2924 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2925 fdir_add_signature_filter(res->port_id, res->queue_id,
2927 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2928 fdir_update_signature_filter(res->port_id, res->queue_id,
2930 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2931 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2932 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2933 fdir_add_perfect_filter(res->port_id, res->soft_id,
2935 (uint8_t) (res->queue_id < 0),
2937 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2938 fdir_update_perfect_filter(res->port_id, res->soft_id,
2940 (uint8_t) (res->queue_id < 0),
2942 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2943 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2949 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2950 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2952 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2953 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2954 protocol, "ip#tcp#udp#sctp");
2955 cmdline_parse_token_string_t cmd_pkt_filter_src =
2956 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2958 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2959 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2961 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2962 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2964 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2965 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2967 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2968 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2970 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2971 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2973 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2974 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2975 flexbytes, "flexbytes");
2976 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2977 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2978 flexbytes_value, UINT16);
2979 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2980 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2982 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2983 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2985 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2986 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2988 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2989 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2991 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2992 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2994 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2995 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2999 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3000 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3001 pkt_filter, "add_signature_filter");
3002 cmdline_parse_inst_t cmd_add_signature_filter = {
3003 .f = cmd_pkt_filter_parsed,
3005 .help_str = "add a signature filter",
3007 (void *)&cmd_pkt_filter_add_signature_filter,
3008 (void *)&cmd_pkt_filter_port_id,
3009 (void *)&cmd_pkt_filter_protocol,
3010 (void *)&cmd_pkt_filter_src,
3011 (void *)&cmd_pkt_filter_ip_src,
3012 (void *)&cmd_pkt_filter_port_src,
3013 (void *)&cmd_pkt_filter_dst,
3014 (void *)&cmd_pkt_filter_ip_dst,
3015 (void *)&cmd_pkt_filter_port_dst,
3016 (void *)&cmd_pkt_filter_flexbytes,
3017 (void *)&cmd_pkt_filter_flexbytes_value,
3018 (void *)&cmd_pkt_filter_vlan,
3019 (void *)&cmd_pkt_filter_vlan_id,
3020 (void *)&cmd_pkt_filter_queue,
3021 (void *)&cmd_pkt_filter_queue_id,
3027 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3028 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3029 pkt_filter, "upd_signature_filter");
3030 cmdline_parse_inst_t cmd_upd_signature_filter = {
3031 .f = cmd_pkt_filter_parsed,
3033 .help_str = "update a signature filter",
3035 (void *)&cmd_pkt_filter_upd_signature_filter,
3036 (void *)&cmd_pkt_filter_port_id,
3037 (void *)&cmd_pkt_filter_protocol,
3038 (void *)&cmd_pkt_filter_src,
3039 (void *)&cmd_pkt_filter_ip_src,
3040 (void *)&cmd_pkt_filter_port_src,
3041 (void *)&cmd_pkt_filter_dst,
3042 (void *)&cmd_pkt_filter_ip_dst,
3043 (void *)&cmd_pkt_filter_port_dst,
3044 (void *)&cmd_pkt_filter_flexbytes,
3045 (void *)&cmd_pkt_filter_flexbytes_value,
3046 (void *)&cmd_pkt_filter_vlan,
3047 (void *)&cmd_pkt_filter_vlan_id,
3048 (void *)&cmd_pkt_filter_queue,
3049 (void *)&cmd_pkt_filter_queue_id,
3055 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3056 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3057 pkt_filter, "rm_signature_filter");
3058 cmdline_parse_inst_t cmd_rm_signature_filter = {
3059 .f = cmd_pkt_filter_parsed,
3061 .help_str = "remove a signature filter",
3063 (void *)&cmd_pkt_filter_rm_signature_filter,
3064 (void *)&cmd_pkt_filter_port_id,
3065 (void *)&cmd_pkt_filter_protocol,
3066 (void *)&cmd_pkt_filter_src,
3067 (void *)&cmd_pkt_filter_ip_src,
3068 (void *)&cmd_pkt_filter_port_src,
3069 (void *)&cmd_pkt_filter_dst,
3070 (void *)&cmd_pkt_filter_ip_dst,
3071 (void *)&cmd_pkt_filter_port_dst,
3072 (void *)&cmd_pkt_filter_flexbytes,
3073 (void *)&cmd_pkt_filter_flexbytes_value,
3074 (void *)&cmd_pkt_filter_vlan,
3075 (void *)&cmd_pkt_filter_vlan_id,
3081 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3082 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3083 pkt_filter, "add_perfect_filter");
3084 cmdline_parse_inst_t cmd_add_perfect_filter = {
3085 .f = cmd_pkt_filter_parsed,
3087 .help_str = "add a perfect filter",
3089 (void *)&cmd_pkt_filter_add_perfect_filter,
3090 (void *)&cmd_pkt_filter_port_id,
3091 (void *)&cmd_pkt_filter_protocol,
3092 (void *)&cmd_pkt_filter_src,
3093 (void *)&cmd_pkt_filter_ip_src,
3094 (void *)&cmd_pkt_filter_port_src,
3095 (void *)&cmd_pkt_filter_dst,
3096 (void *)&cmd_pkt_filter_ip_dst,
3097 (void *)&cmd_pkt_filter_port_dst,
3098 (void *)&cmd_pkt_filter_flexbytes,
3099 (void *)&cmd_pkt_filter_flexbytes_value,
3100 (void *)&cmd_pkt_filter_vlan,
3101 (void *)&cmd_pkt_filter_vlan_id,
3102 (void *)&cmd_pkt_filter_queue,
3103 (void *)&cmd_pkt_filter_queue_id,
3104 (void *)&cmd_pkt_filter_soft,
3105 (void *)&cmd_pkt_filter_soft_id,
3111 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3112 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3113 pkt_filter, "upd_perfect_filter");
3114 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3115 .f = cmd_pkt_filter_parsed,
3117 .help_str = "update a perfect filter",
3119 (void *)&cmd_pkt_filter_upd_perfect_filter,
3120 (void *)&cmd_pkt_filter_port_id,
3121 (void *)&cmd_pkt_filter_protocol,
3122 (void *)&cmd_pkt_filter_src,
3123 (void *)&cmd_pkt_filter_ip_src,
3124 (void *)&cmd_pkt_filter_port_src,
3125 (void *)&cmd_pkt_filter_dst,
3126 (void *)&cmd_pkt_filter_ip_dst,
3127 (void *)&cmd_pkt_filter_port_dst,
3128 (void *)&cmd_pkt_filter_flexbytes,
3129 (void *)&cmd_pkt_filter_flexbytes_value,
3130 (void *)&cmd_pkt_filter_vlan,
3131 (void *)&cmd_pkt_filter_vlan_id,
3132 (void *)&cmd_pkt_filter_queue,
3133 (void *)&cmd_pkt_filter_queue_id,
3134 (void *)&cmd_pkt_filter_soft,
3135 (void *)&cmd_pkt_filter_soft_id,
3141 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3142 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3143 pkt_filter, "rm_perfect_filter");
3144 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3145 .f = cmd_pkt_filter_parsed,
3147 .help_str = "remove a perfect filter",
3149 (void *)&cmd_pkt_filter_rm_perfect_filter,
3150 (void *)&cmd_pkt_filter_port_id,
3151 (void *)&cmd_pkt_filter_protocol,
3152 (void *)&cmd_pkt_filter_src,
3153 (void *)&cmd_pkt_filter_ip_src,
3154 (void *)&cmd_pkt_filter_port_src,
3155 (void *)&cmd_pkt_filter_dst,
3156 (void *)&cmd_pkt_filter_ip_dst,
3157 (void *)&cmd_pkt_filter_port_dst,
3158 (void *)&cmd_pkt_filter_flexbytes,
3159 (void *)&cmd_pkt_filter_flexbytes_value,
3160 (void *)&cmd_pkt_filter_vlan,
3161 (void *)&cmd_pkt_filter_vlan_id,
3162 (void *)&cmd_pkt_filter_soft,
3163 (void *)&cmd_pkt_filter_soft_id,
3168 /* *** SETUP MASKS FILTER *** */
3169 struct cmd_pkt_filter_masks_result {
3170 cmdline_fixed_string_t filter_mask;
3172 cmdline_fixed_string_t src_mask;
3173 uint32_t ip_src_mask;
3174 uint16_t ipv6_src_mask;
3175 uint16_t port_src_mask;
3176 cmdline_fixed_string_t dst_mask;
3177 uint32_t ip_dst_mask;
3178 uint16_t ipv6_dst_mask;
3179 uint16_t port_dst_mask;
3180 cmdline_fixed_string_t flexbytes;
3181 uint8_t flexbytes_value;
3182 cmdline_fixed_string_t vlan_id;
3183 uint8_t vlan_id_value;
3184 cmdline_fixed_string_t vlan_prio;
3185 uint8_t vlan_prio_value;
3186 cmdline_fixed_string_t only_ip_flow;
3187 uint8_t only_ip_flow_value;
3188 cmdline_fixed_string_t comp_ipv6_dst;
3189 uint8_t comp_ipv6_dst_value;
3193 cmd_pkt_filter_masks_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct rte_fdir_masks fdir_masks;
3198 struct cmd_pkt_filter_masks_result *res = parsed_result;
3200 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3202 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3203 fdir_masks.vlan_id = res->vlan_id_value;
3204 fdir_masks.vlan_prio = res->vlan_prio_value;
3205 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3206 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3207 fdir_masks.src_port_mask = res->port_src_mask;
3208 fdir_masks.dst_port_mask = res->port_dst_mask;
3209 fdir_masks.flexbytes = res->flexbytes_value;
3211 fdir_set_masks(res->port_id, &fdir_masks);
3214 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3215 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3216 filter_mask, "set_masks_filter");
3217 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3218 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3220 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3221 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3222 only_ip_flow, "only_ip_flow");
3223 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3224 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3225 only_ip_flow_value, UINT8);
3226 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3227 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3228 src_mask, "src_mask");
3229 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3230 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3231 ip_src_mask, UINT32);
3232 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3233 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3234 port_src_mask, UINT16);
3235 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3236 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3237 dst_mask, "dst_mask");
3238 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3239 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3240 ip_dst_mask, UINT32);
3241 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3242 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3243 port_dst_mask, UINT16);
3244 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3245 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3246 flexbytes, "flexbytes");
3247 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3248 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3249 flexbytes_value, UINT8);
3250 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3251 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3252 vlan_id, "vlan_id");
3253 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3254 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3255 vlan_id_value, UINT8);
3256 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3257 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3258 vlan_prio, "vlan_prio");
3259 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3260 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3261 vlan_prio_value, UINT8);
3263 cmdline_parse_inst_t cmd_set_masks_filter = {
3264 .f = cmd_pkt_filter_masks_parsed,
3266 .help_str = "setup masks filter",
3268 (void *)&cmd_pkt_filter_masks_filter_mask,
3269 (void *)&cmd_pkt_filter_masks_port_id,
3270 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3271 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3272 (void *)&cmd_pkt_filter_masks_src_mask,
3273 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3274 (void *)&cmd_pkt_filter_masks_port_src_mask,
3275 (void *)&cmd_pkt_filter_masks_dst_mask,
3276 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3277 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3278 (void *)&cmd_pkt_filter_masks_flexbytes,
3279 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3280 (void *)&cmd_pkt_filter_masks_vlan_id,
3281 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3282 (void *)&cmd_pkt_filter_masks_vlan_prio,
3283 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3289 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3290 __attribute__((unused)) struct cmdline *cl,
3291 __attribute__((unused)) void *data)
3293 struct rte_fdir_masks fdir_masks;
3294 struct cmd_pkt_filter_masks_result *res = parsed_result;
3296 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3298 fdir_masks.set_ipv6_mask = 1;
3299 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3300 fdir_masks.vlan_id = res->vlan_id_value;
3301 fdir_masks.vlan_prio = res->vlan_prio_value;
3302 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3303 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3304 fdir_masks.src_port_mask = res->port_src_mask;
3305 fdir_masks.dst_port_mask = res->port_dst_mask;
3306 fdir_masks.flexbytes = res->flexbytes_value;
3307 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3309 fdir_set_masks(res->port_id, &fdir_masks);
3312 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3313 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3314 filter_mask, "set_ipv6_masks_filter");
3315 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3316 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3317 ipv6_src_mask, UINT16);
3318 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3319 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3320 ipv6_dst_mask, UINT16);
3322 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3323 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3324 comp_ipv6_dst, "compare_dst");
3325 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3326 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3327 comp_ipv6_dst_value, UINT8);
3329 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3330 .f = cmd_pkt_filter_masks_ipv6_parsed,
3332 .help_str = "setup ipv6 masks filter",
3334 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3335 (void *)&cmd_pkt_filter_masks_port_id,
3336 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3337 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3338 (void *)&cmd_pkt_filter_masks_src_mask,
3339 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3340 (void *)&cmd_pkt_filter_masks_port_src_mask,
3341 (void *)&cmd_pkt_filter_masks_dst_mask,
3342 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3343 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3344 (void *)&cmd_pkt_filter_masks_flexbytes,
3345 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3346 (void *)&cmd_pkt_filter_masks_vlan_id,
3347 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3348 (void *)&cmd_pkt_filter_masks_vlan_prio,
3349 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3350 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3351 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3356 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3357 struct cmd_link_flow_ctrl_set_result {
3358 cmdline_fixed_string_t set;
3359 cmdline_fixed_string_t flow_ctrl;
3360 cmdline_fixed_string_t rx;
3361 cmdline_fixed_string_t rx_lfc_mode;
3362 cmdline_fixed_string_t tx;
3363 cmdline_fixed_string_t tx_lfc_mode;
3364 uint32_t high_water;
3366 uint16_t pause_time;
3372 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3373 __attribute__((unused)) struct cmdline *cl,
3374 __attribute__((unused)) void *data)
3376 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3377 struct rte_eth_fc_conf fc_conf;
3378 int rx_fc_enable, tx_fc_enable;
3382 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3383 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3384 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3385 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3387 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3388 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3391 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3392 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3394 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3395 fc_conf.high_water = res->high_water;
3396 fc_conf.low_water = res->low_water;
3397 fc_conf.pause_time = res->pause_time;
3398 fc_conf.send_xon = res->send_xon;
3400 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3402 printf("bad flow contrl parameter, return code = %d \n", ret);
3405 cmdline_parse_token_string_t cmd_lfc_set_set =
3406 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3408 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3409 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3410 flow_ctrl, "flow_ctrl");
3411 cmdline_parse_token_string_t cmd_lfc_set_rx =
3412 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3414 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3416 rx_lfc_mode, "on#off");
3417 cmdline_parse_token_string_t cmd_lfc_set_tx =
3418 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3420 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3421 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3422 tx_lfc_mode, "on#off");
3423 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3424 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3425 high_water, UINT32);
3426 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3427 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3429 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3430 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3431 pause_time, UINT16);
3432 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3433 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3435 cmdline_parse_token_num_t cmd_lfc_set_portid =
3436 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3439 cmdline_parse_inst_t cmd_link_flow_control_set = {
3440 .f = cmd_link_flow_ctrl_set_parsed,
3442 .help_str = "Configure the Ethernet link flow control...",
3444 (void *)&cmd_lfc_set_set,
3445 (void *)&cmd_lfc_set_flow_ctrl,
3446 (void *)&cmd_lfc_set_rx,
3447 (void *)&cmd_lfc_set_rx_mode,
3448 (void *)&cmd_lfc_set_tx,
3449 (void *)&cmd_lfc_set_tx_mode,
3450 (void *)&cmd_lfc_set_high_water,
3451 (void *)&cmd_lfc_set_low_water,
3452 (void *)&cmd_lfc_set_pause_time,
3453 (void *)&cmd_lfc_set_send_xon,
3454 (void *)&cmd_lfc_set_portid,
3459 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3460 struct cmd_priority_flow_ctrl_set_result {
3461 cmdline_fixed_string_t set;
3462 cmdline_fixed_string_t pfc_ctrl;
3463 cmdline_fixed_string_t rx;
3464 cmdline_fixed_string_t rx_pfc_mode;
3465 cmdline_fixed_string_t tx;
3466 cmdline_fixed_string_t tx_pfc_mode;
3467 uint32_t high_water;
3469 uint16_t pause_time;
3475 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3476 __attribute__((unused)) struct cmdline *cl,
3477 __attribute__((unused)) void *data)
3479 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3480 struct rte_eth_pfc_conf pfc_conf;
3481 int rx_fc_enable, tx_fc_enable;
3485 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3486 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3487 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3488 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3490 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3491 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3494 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3495 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3496 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3497 pfc_conf.fc.high_water = res->high_water;
3498 pfc_conf.fc.low_water = res->low_water;
3499 pfc_conf.fc.pause_time = res->pause_time;
3500 pfc_conf.priority = res->priority;
3502 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3504 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3507 cmdline_parse_token_string_t cmd_pfc_set_set =
3508 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3510 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3511 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3512 pfc_ctrl, "pfc_ctrl");
3513 cmdline_parse_token_string_t cmd_pfc_set_rx =
3514 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3516 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3517 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3518 rx_pfc_mode, "on#off");
3519 cmdline_parse_token_string_t cmd_pfc_set_tx =
3520 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3522 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3523 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3524 tx_pfc_mode, "on#off");
3525 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3526 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3527 high_water, UINT32);
3528 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3529 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3531 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3532 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3533 pause_time, UINT16);
3534 cmdline_parse_token_num_t cmd_pfc_set_priority =
3535 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3537 cmdline_parse_token_num_t cmd_pfc_set_portid =
3538 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3541 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3542 .f = cmd_priority_flow_ctrl_set_parsed,
3544 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3545 tx on|off high_water low_water pause_time priority port_id",
3547 (void *)&cmd_pfc_set_set,
3548 (void *)&cmd_pfc_set_flow_ctrl,
3549 (void *)&cmd_pfc_set_rx,
3550 (void *)&cmd_pfc_set_rx_mode,
3551 (void *)&cmd_pfc_set_tx,
3552 (void *)&cmd_pfc_set_tx_mode,
3553 (void *)&cmd_pfc_set_high_water,
3554 (void *)&cmd_pfc_set_low_water,
3555 (void *)&cmd_pfc_set_pause_time,
3556 (void *)&cmd_pfc_set_priority,
3557 (void *)&cmd_pfc_set_portid,
3562 /* *** RESET CONFIGURATION *** */
3563 struct cmd_reset_result {
3564 cmdline_fixed_string_t reset;
3565 cmdline_fixed_string_t def;
3568 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3570 __attribute__((unused)) void *data)
3572 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3573 set_def_fwd_config();
3576 cmdline_parse_token_string_t cmd_reset_set =
3577 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3578 cmdline_parse_token_string_t cmd_reset_def =
3579 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3582 cmdline_parse_inst_t cmd_reset = {
3583 .f = cmd_reset_parsed,
3585 .help_str = "set default: reset default forwarding configuration",
3587 (void *)&cmd_reset_set,
3588 (void *)&cmd_reset_def,
3593 /* *** START FORWARDING *** */
3594 struct cmd_start_result {
3595 cmdline_fixed_string_t start;
3598 cmdline_parse_token_string_t cmd_start_start =
3599 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3601 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3602 __attribute__((unused)) struct cmdline *cl,
3603 __attribute__((unused)) void *data)
3605 start_packet_forwarding(0);
3608 cmdline_parse_inst_t cmd_start = {
3609 .f = cmd_start_parsed,
3611 .help_str = "start packet forwarding",
3613 (void *)&cmd_start_start,
3618 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3619 struct cmd_start_tx_first_result {
3620 cmdline_fixed_string_t start;
3621 cmdline_fixed_string_t tx_first;
3625 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3626 __attribute__((unused)) struct cmdline *cl,
3627 __attribute__((unused)) void *data)
3629 start_packet_forwarding(1);
3632 cmdline_parse_token_string_t cmd_start_tx_first_start =
3633 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3635 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3636 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3637 tx_first, "tx_first");
3639 cmdline_parse_inst_t cmd_start_tx_first = {
3640 .f = cmd_start_tx_first_parsed,
3642 .help_str = "start packet forwarding, after sending 1 burst of packets",
3644 (void *)&cmd_start_tx_first_start,
3645 (void *)&cmd_start_tx_first_tx_first,
3650 /* *** SHOW CFG *** */
3651 struct cmd_showcfg_result {
3652 cmdline_fixed_string_t show;
3653 cmdline_fixed_string_t cfg;
3654 cmdline_fixed_string_t what;
3657 static void cmd_showcfg_parsed(void *parsed_result,
3658 __attribute__((unused)) struct cmdline *cl,
3659 __attribute__((unused)) void *data)
3661 struct cmd_showcfg_result *res = parsed_result;
3662 if (!strcmp(res->what, "rxtx"))
3663 rxtx_config_display();
3664 else if (!strcmp(res->what, "cores"))
3665 fwd_lcores_config_display();
3666 else if (!strcmp(res->what, "fwd"))
3667 fwd_config_display();
3670 cmdline_parse_token_string_t cmd_showcfg_show =
3671 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3672 cmdline_parse_token_string_t cmd_showcfg_port =
3673 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3674 cmdline_parse_token_string_t cmd_showcfg_what =
3675 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3678 cmdline_parse_inst_t cmd_showcfg = {
3679 .f = cmd_showcfg_parsed,
3681 .help_str = "show config rxtx|cores|fwd",
3683 (void *)&cmd_showcfg_show,
3684 (void *)&cmd_showcfg_port,
3685 (void *)&cmd_showcfg_what,
3690 /* *** SHOW ALL PORT INFO *** */
3691 struct cmd_showportall_result {
3692 cmdline_fixed_string_t show;
3693 cmdline_fixed_string_t port;
3694 cmdline_fixed_string_t what;
3695 cmdline_fixed_string_t all;
3698 static void cmd_showportall_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3704 struct cmd_showportall_result *res = parsed_result;
3705 if (!strcmp(res->show, "clear")) {
3706 if (!strcmp(res->what, "stats"))
3707 for (i = 0; i < nb_ports; i++)
3709 } else if (!strcmp(res->what, "info"))
3710 for (i = 0; i < nb_ports; i++)
3711 port_infos_display(i);
3712 else if (!strcmp(res->what, "stats"))
3713 for (i = 0; i < nb_ports; i++)
3714 nic_stats_display(i);
3715 else if (!strcmp(res->what, "fdir"))
3716 for (i = 0; i < nb_ports; i++)
3718 else if (!strcmp(res->what, "stat_qmap"))
3719 for (i = 0; i < nb_ports; i++)
3720 nic_stats_mapping_display(i);
3723 cmdline_parse_token_string_t cmd_showportall_show =
3724 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3726 cmdline_parse_token_string_t cmd_showportall_port =
3727 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3728 cmdline_parse_token_string_t cmd_showportall_what =
3729 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3730 "info#stats#fdir#stat_qmap");
3731 cmdline_parse_token_string_t cmd_showportall_all =
3732 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3733 cmdline_parse_inst_t cmd_showportall = {
3734 .f = cmd_showportall_parsed,
3736 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3738 (void *)&cmd_showportall_show,
3739 (void *)&cmd_showportall_port,
3740 (void *)&cmd_showportall_what,
3741 (void *)&cmd_showportall_all,
3746 /* *** SHOW PORT INFO *** */
3747 struct cmd_showport_result {
3748 cmdline_fixed_string_t show;
3749 cmdline_fixed_string_t port;
3750 cmdline_fixed_string_t what;
3754 static void cmd_showport_parsed(void *parsed_result,
3755 __attribute__((unused)) struct cmdline *cl,
3756 __attribute__((unused)) void *data)
3758 struct cmd_showport_result *res = parsed_result;
3759 if (!strcmp(res->show, "clear")) {
3760 if (!strcmp(res->what, "stats"))
3761 nic_stats_clear(res->portnum);
3762 } else if (!strcmp(res->what, "info"))
3763 port_infos_display(res->portnum);
3764 else if (!strcmp(res->what, "stats"))
3765 nic_stats_display(res->portnum);
3766 else if (!strcmp(res->what, "fdir"))
3767 fdir_get_infos(res->portnum);
3768 else if (!strcmp(res->what, "stat_qmap"))
3769 nic_stats_mapping_display(res->portnum);
3772 cmdline_parse_token_string_t cmd_showport_show =
3773 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3775 cmdline_parse_token_string_t cmd_showport_port =
3776 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3777 cmdline_parse_token_string_t cmd_showport_what =
3778 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3779 "info#stats#fdir#stat_qmap");
3780 cmdline_parse_token_num_t cmd_showport_portnum =
3781 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3783 cmdline_parse_inst_t cmd_showport = {
3784 .f = cmd_showport_parsed,
3786 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3788 (void *)&cmd_showport_show,
3789 (void *)&cmd_showport_port,
3790 (void *)&cmd_showport_what,
3791 (void *)&cmd_showport_portnum,
3796 /* *** READ PORT REGISTER *** */
3797 struct cmd_read_reg_result {
3798 cmdline_fixed_string_t read;
3799 cmdline_fixed_string_t reg;
3805 cmd_read_reg_parsed(void *parsed_result,
3806 __attribute__((unused)) struct cmdline *cl,
3807 __attribute__((unused)) void *data)
3809 struct cmd_read_reg_result *res = parsed_result;
3810 port_reg_display(res->port_id, res->reg_off);
3813 cmdline_parse_token_string_t cmd_read_reg_read =
3814 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3815 cmdline_parse_token_string_t cmd_read_reg_reg =
3816 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3817 cmdline_parse_token_num_t cmd_read_reg_port_id =
3818 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3819 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3820 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3822 cmdline_parse_inst_t cmd_read_reg = {
3823 .f = cmd_read_reg_parsed,
3825 .help_str = "read reg port_id reg_off",
3827 (void *)&cmd_read_reg_read,
3828 (void *)&cmd_read_reg_reg,
3829 (void *)&cmd_read_reg_port_id,
3830 (void *)&cmd_read_reg_reg_off,
3835 /* *** READ PORT REGISTER BIT FIELD *** */
3836 struct cmd_read_reg_bit_field_result {
3837 cmdline_fixed_string_t read;
3838 cmdline_fixed_string_t regfield;
3846 cmd_read_reg_bit_field_parsed(void *parsed_result,
3847 __attribute__((unused)) struct cmdline *cl,
3848 __attribute__((unused)) void *data)
3850 struct cmd_read_reg_bit_field_result *res = parsed_result;
3851 port_reg_bit_field_display(res->port_id, res->reg_off,
3852 res->bit1_pos, res->bit2_pos);
3855 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3856 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3858 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3859 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3860 regfield, "regfield");
3861 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3862 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3864 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3865 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3867 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3868 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3870 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3871 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3874 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3875 .f = cmd_read_reg_bit_field_parsed,
3877 .help_str = "read regfield port_id reg_off bit_x bit_y "
3878 "(read register bit field between bit_x and bit_y included)",
3880 (void *)&cmd_read_reg_bit_field_read,
3881 (void *)&cmd_read_reg_bit_field_regfield,
3882 (void *)&cmd_read_reg_bit_field_port_id,
3883 (void *)&cmd_read_reg_bit_field_reg_off,
3884 (void *)&cmd_read_reg_bit_field_bit1_pos,
3885 (void *)&cmd_read_reg_bit_field_bit2_pos,
3890 /* *** READ PORT REGISTER BIT *** */
3891 struct cmd_read_reg_bit_result {
3892 cmdline_fixed_string_t read;
3893 cmdline_fixed_string_t regbit;
3900 cmd_read_reg_bit_parsed(void *parsed_result,
3901 __attribute__((unused)) struct cmdline *cl,
3902 __attribute__((unused)) void *data)
3904 struct cmd_read_reg_bit_result *res = parsed_result;
3905 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3908 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3909 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3910 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3911 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3913 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3914 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3915 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3916 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3917 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3918 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3920 cmdline_parse_inst_t cmd_read_reg_bit = {
3921 .f = cmd_read_reg_bit_parsed,
3923 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3925 (void *)&cmd_read_reg_bit_read,
3926 (void *)&cmd_read_reg_bit_regbit,
3927 (void *)&cmd_read_reg_bit_port_id,
3928 (void *)&cmd_read_reg_bit_reg_off,
3929 (void *)&cmd_read_reg_bit_bit_pos,
3934 /* *** WRITE PORT REGISTER *** */
3935 struct cmd_write_reg_result {
3936 cmdline_fixed_string_t write;
3937 cmdline_fixed_string_t reg;
3944 cmd_write_reg_parsed(void *parsed_result,
3945 __attribute__((unused)) struct cmdline *cl,
3946 __attribute__((unused)) void *data)
3948 struct cmd_write_reg_result *res = parsed_result;
3949 port_reg_set(res->port_id, res->reg_off, res->value);
3952 cmdline_parse_token_string_t cmd_write_reg_write =
3953 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3954 cmdline_parse_token_string_t cmd_write_reg_reg =
3955 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3956 cmdline_parse_token_num_t cmd_write_reg_port_id =
3957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3958 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3960 cmdline_parse_token_num_t cmd_write_reg_value =
3961 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3963 cmdline_parse_inst_t cmd_write_reg = {
3964 .f = cmd_write_reg_parsed,
3966 .help_str = "write reg port_id reg_off reg_value",
3968 (void *)&cmd_write_reg_write,
3969 (void *)&cmd_write_reg_reg,
3970 (void *)&cmd_write_reg_port_id,
3971 (void *)&cmd_write_reg_reg_off,
3972 (void *)&cmd_write_reg_value,
3977 /* *** WRITE PORT REGISTER BIT FIELD *** */
3978 struct cmd_write_reg_bit_field_result {
3979 cmdline_fixed_string_t write;
3980 cmdline_fixed_string_t regfield;
3989 cmd_write_reg_bit_field_parsed(void *parsed_result,
3990 __attribute__((unused)) struct cmdline *cl,
3991 __attribute__((unused)) void *data)
3993 struct cmd_write_reg_bit_field_result *res = parsed_result;
3994 port_reg_bit_field_set(res->port_id, res->reg_off,
3995 res->bit1_pos, res->bit2_pos, res->value);
3998 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3999 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4001 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4002 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4003 regfield, "regfield");
4004 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4005 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4007 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4008 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4010 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4011 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4013 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4014 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4016 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4017 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4020 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4021 .f = cmd_write_reg_bit_field_parsed,
4023 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4024 "(set register bit field between bit_x and bit_y included)",
4026 (void *)&cmd_write_reg_bit_field_write,
4027 (void *)&cmd_write_reg_bit_field_regfield,
4028 (void *)&cmd_write_reg_bit_field_port_id,
4029 (void *)&cmd_write_reg_bit_field_reg_off,
4030 (void *)&cmd_write_reg_bit_field_bit1_pos,
4031 (void *)&cmd_write_reg_bit_field_bit2_pos,
4032 (void *)&cmd_write_reg_bit_field_value,
4037 /* *** WRITE PORT REGISTER BIT *** */
4038 struct cmd_write_reg_bit_result {
4039 cmdline_fixed_string_t write;
4040 cmdline_fixed_string_t regbit;
4048 cmd_write_reg_bit_parsed(void *parsed_result,
4049 __attribute__((unused)) struct cmdline *cl,
4050 __attribute__((unused)) void *data)
4052 struct cmd_write_reg_bit_result *res = parsed_result;
4053 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4056 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4057 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4059 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4060 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4062 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4063 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4064 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4065 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4066 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4067 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4068 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4069 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4071 cmdline_parse_inst_t cmd_write_reg_bit = {
4072 .f = cmd_write_reg_bit_parsed,
4074 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4076 (void *)&cmd_write_reg_bit_write,
4077 (void *)&cmd_write_reg_bit_regbit,
4078 (void *)&cmd_write_reg_bit_port_id,
4079 (void *)&cmd_write_reg_bit_reg_off,
4080 (void *)&cmd_write_reg_bit_bit_pos,
4081 (void *)&cmd_write_reg_bit_value,
4086 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4087 struct cmd_read_rxd_txd_result {
4088 cmdline_fixed_string_t read;
4089 cmdline_fixed_string_t rxd_txd;
4096 cmd_read_rxd_txd_parsed(void *parsed_result,
4097 __attribute__((unused)) struct cmdline *cl,
4098 __attribute__((unused)) void *data)
4100 struct cmd_read_rxd_txd_result *res = parsed_result;
4102 if (!strcmp(res->rxd_txd, "rxd"))
4103 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4104 else if (!strcmp(res->rxd_txd, "txd"))
4105 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4108 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4109 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4110 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4111 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4113 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4114 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4115 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4116 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4117 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4118 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4120 cmdline_parse_inst_t cmd_read_rxd_txd = {
4121 .f = cmd_read_rxd_txd_parsed,
4123 .help_str = "read rxd|txd port_id queue_id rxd_id",
4125 (void *)&cmd_read_rxd_txd_read,
4126 (void *)&cmd_read_rxd_txd_rxd_txd,
4127 (void *)&cmd_read_rxd_txd_port_id,
4128 (void *)&cmd_read_rxd_txd_queue_id,
4129 (void *)&cmd_read_rxd_txd_desc_id,
4135 struct cmd_quit_result {
4136 cmdline_fixed_string_t quit;
4139 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4141 __attribute__((unused)) void *data)
4147 cmdline_parse_token_string_t cmd_quit_quit =
4148 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4150 cmdline_parse_inst_t cmd_quit = {
4151 .f = cmd_quit_parsed,
4153 .help_str = "exit application",
4155 (void *)&cmd_quit_quit,
4160 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4161 struct cmd_mac_addr_result {
4162 cmdline_fixed_string_t mac_addr_cmd;
4163 cmdline_fixed_string_t what;
4165 struct ether_addr address;
4168 static void cmd_mac_addr_parsed(void *parsed_result,
4169 __attribute__((unused)) struct cmdline *cl,
4170 __attribute__((unused)) void *data)
4172 struct cmd_mac_addr_result *res = parsed_result;
4175 if (strcmp(res->what, "add") == 0)
4176 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4178 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4180 /* check the return value and print it if is < 0 */
4182 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4186 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4187 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4189 cmdline_parse_token_string_t cmd_mac_addr_what =
4190 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4192 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4193 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4194 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4197 cmdline_parse_inst_t cmd_mac_addr = {
4198 .f = cmd_mac_addr_parsed,
4200 .help_str = "mac_addr add|remove X <address>: "
4201 "add/remove MAC address on port X",
4203 (void *)&cmd_mac_addr_cmd,
4204 (void *)&cmd_mac_addr_what,
4205 (void *)&cmd_mac_addr_portnum,
4206 (void *)&cmd_mac_addr_addr,
4212 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4213 struct cmd_set_qmap_result {
4214 cmdline_fixed_string_t set;
4215 cmdline_fixed_string_t qmap;
4216 cmdline_fixed_string_t what;
4223 cmd_set_qmap_parsed(void *parsed_result,
4224 __attribute__((unused)) struct cmdline *cl,
4225 __attribute__((unused)) void *data)
4227 struct cmd_set_qmap_result *res = parsed_result;
4228 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4230 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4233 cmdline_parse_token_string_t cmd_setqmap_set =
4234 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4236 cmdline_parse_token_string_t cmd_setqmap_qmap =
4237 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4239 cmdline_parse_token_string_t cmd_setqmap_what =
4240 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4242 cmdline_parse_token_num_t cmd_setqmap_portid =
4243 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4245 cmdline_parse_token_num_t cmd_setqmap_queueid =
4246 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4248 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4249 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4252 cmdline_parse_inst_t cmd_set_qmap = {
4253 .f = cmd_set_qmap_parsed,
4255 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4257 (void *)&cmd_setqmap_set,
4258 (void *)&cmd_setqmap_qmap,
4259 (void *)&cmd_setqmap_what,
4260 (void *)&cmd_setqmap_portid,
4261 (void *)&cmd_setqmap_queueid,
4262 (void *)&cmd_setqmap_mapvalue,
4267 /* *** CONFIGURE UNICAST HASH TABLE *** */
4268 struct cmd_set_uc_hash_table {
4269 cmdline_fixed_string_t set;
4270 cmdline_fixed_string_t port;
4272 cmdline_fixed_string_t what;
4273 struct ether_addr address;
4274 cmdline_fixed_string_t mode;
4278 cmd_set_uc_hash_parsed(void *parsed_result,
4279 __attribute__((unused)) struct cmdline *cl,
4280 __attribute__((unused)) void *data)
4283 struct cmd_set_uc_hash_table *res = parsed_result;
4285 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4287 if (strcmp(res->what, "uta") == 0)
4288 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4289 &res->address,(uint8_t)is_on);
4291 printf("bad unicast hash table parameter, return code = %d \n", ret);
4295 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4296 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4298 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4299 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4301 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4302 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4304 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4305 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4307 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4308 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4310 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4311 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4314 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4315 .f = cmd_set_uc_hash_parsed,
4317 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4319 (void *)&cmd_set_uc_hash_set,
4320 (void *)&cmd_set_uc_hash_port,
4321 (void *)&cmd_set_uc_hash_portid,
4322 (void *)&cmd_set_uc_hash_what,
4323 (void *)&cmd_set_uc_hash_mac,
4324 (void *)&cmd_set_uc_hash_mode,
4329 struct cmd_set_uc_all_hash_table {
4330 cmdline_fixed_string_t set;
4331 cmdline_fixed_string_t port;
4333 cmdline_fixed_string_t what;
4334 cmdline_fixed_string_t value;
4335 cmdline_fixed_string_t mode;
4339 cmd_set_uc_all_hash_parsed(void *parsed_result,
4340 __attribute__((unused)) struct cmdline *cl,
4341 __attribute__((unused)) void *data)
4344 struct cmd_set_uc_all_hash_table *res = parsed_result;
4346 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4348 if ((strcmp(res->what, "uta") == 0) &&
4349 (strcmp(res->value, "all") == 0))
4350 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4352 printf("bad unicast hash table parameter,"
4353 "return code = %d \n", ret);
4356 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4357 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4359 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4360 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4362 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4365 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4366 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4368 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4369 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4371 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4372 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4375 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4376 .f = cmd_set_uc_all_hash_parsed,
4378 .help_str = "set port X uta all on|off (X = port number)",
4380 (void *)&cmd_set_uc_all_hash_set,
4381 (void *)&cmd_set_uc_all_hash_port,
4382 (void *)&cmd_set_uc_all_hash_portid,
4383 (void *)&cmd_set_uc_all_hash_what,
4384 (void *)&cmd_set_uc_all_hash_value,
4385 (void *)&cmd_set_uc_all_hash_mode,
4390 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4391 struct cmd_set_vf_traffic {
4392 cmdline_fixed_string_t set;
4393 cmdline_fixed_string_t port;
4395 cmdline_fixed_string_t vf;
4397 cmdline_fixed_string_t what;
4398 cmdline_fixed_string_t mode;
4402 cmd_set_vf_traffic_parsed(void *parsed_result,
4403 __attribute__((unused)) struct cmdline *cl,
4404 __attribute__((unused)) void *data)
4406 struct cmd_set_vf_traffic *res = parsed_result;
4407 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4408 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4410 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4413 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4416 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4419 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4420 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4422 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4425 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4426 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4428 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4431 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4435 cmdline_parse_inst_t cmd_set_vf_traffic = {
4436 .f = cmd_set_vf_traffic_parsed,
4438 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4440 (void *)&cmd_setvf_traffic_set,
4441 (void *)&cmd_setvf_traffic_port,
4442 (void *)&cmd_setvf_traffic_portid,
4443 (void *)&cmd_setvf_traffic_vf,
4444 (void *)&cmd_setvf_traffic_vfid,
4445 (void *)&cmd_setvf_traffic_what,
4446 (void *)&cmd_setvf_traffic_mode,
4451 /* *** CONFIGURE VF RECEIVE MODE *** */
4452 struct cmd_set_vf_rxmode {
4453 cmdline_fixed_string_t set;
4454 cmdline_fixed_string_t port;
4456 cmdline_fixed_string_t vf;
4458 cmdline_fixed_string_t what;
4459 cmdline_fixed_string_t mode;
4460 cmdline_fixed_string_t on;
4464 cmd_set_vf_rxmode_parsed(void *parsed_result,
4465 __attribute__((unused)) struct cmdline *cl,
4466 __attribute__((unused)) void *data)
4469 uint16_t rx_mode = 0;
4470 struct cmd_set_vf_rxmode *res = parsed_result;
4472 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4473 if (!strcmp(res->what,"rxmode")) {
4474 if (!strcmp(res->mode, "AUPE"))
4475 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4476 else if (!strcmp(res->mode, "ROPE"))
4477 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4478 else if (!strcmp(res->mode, "BAM"))
4479 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4480 else if (!strncmp(res->mode, "MPE",3))
4481 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4484 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4486 printf("bad VF receive mode parameter, return code = %d \n",
4490 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4493 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4494 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4496 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4497 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4499 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4500 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4502 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4503 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4505 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4506 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4508 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4510 mode, "AUPE#ROPE#BAM#MPE");
4511 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4512 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4515 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4516 .f = cmd_set_vf_rxmode_parsed,
4518 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4520 (void *)&cmd_set_vf_rxmode_set,
4521 (void *)&cmd_set_vf_rxmode_port,
4522 (void *)&cmd_set_vf_rxmode_portid,
4523 (void *)&cmd_set_vf_rxmode_vf,
4524 (void *)&cmd_set_vf_rxmode_vfid,
4525 (void *)&cmd_set_vf_rxmode_what,
4526 (void *)&cmd_set_vf_rxmode_mode,
4527 (void *)&cmd_set_vf_rxmode_on,
4532 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4533 struct cmd_vf_mac_addr_result {
4534 cmdline_fixed_string_t mac_addr_cmd;
4535 cmdline_fixed_string_t what;
4536 cmdline_fixed_string_t port;
4538 cmdline_fixed_string_t vf;
4540 struct ether_addr address;
4543 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4544 __attribute__((unused)) struct cmdline *cl,
4545 __attribute__((unused)) void *data)
4547 struct cmd_vf_mac_addr_result *res = parsed_result;
4550 if (strcmp(res->what, "add") == 0)
4551 ret = rte_eth_dev_mac_addr_add(res->port_num,
4552 &res->address, res->vf_num);
4554 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4558 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4559 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4560 mac_addr_cmd,"mac_addr");
4561 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4562 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4564 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4565 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4567 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4568 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4570 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4571 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4573 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4574 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4576 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4577 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4580 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4581 .f = cmd_vf_mac_addr_parsed,
4583 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4584 "Y = VF number)add MAC address filtering for a VF on port X",
4586 (void *)&cmd_vf_mac_addr_cmd,
4587 (void *)&cmd_vf_mac_addr_what,
4588 (void *)&cmd_vf_mac_addr_port,
4589 (void *)&cmd_vf_mac_addr_portnum,
4590 (void *)&cmd_vf_mac_addr_vf,
4591 (void *)&cmd_vf_mac_addr_vfnum,
4592 (void *)&cmd_vf_mac_addr_addr,
4597 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4598 struct cmd_vf_rx_vlan_filter {
4599 cmdline_fixed_string_t rx_vlan;
4600 cmdline_fixed_string_t what;
4602 cmdline_fixed_string_t port;
4604 cmdline_fixed_string_t vf;
4609 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4610 __attribute__((unused)) struct cmdline *cl,
4611 __attribute__((unused)) void *data)
4613 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4615 if (!strcmp(res->what, "add"))
4616 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4618 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4621 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4623 rx_vlan, "rx_vlan");
4624 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4625 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4627 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4628 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4630 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4631 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4633 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4634 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4636 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4637 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4639 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4640 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4643 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4644 .f = cmd_vf_rx_vlan_filter_parsed,
4646 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4647 "Y = port number,Z = hexadecimal VF mask)",
4649 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4650 (void *)&cmd_vf_rx_vlan_filter_what,
4651 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4652 (void *)&cmd_vf_rx_vlan_filter_port,
4653 (void *)&cmd_vf_rx_vlan_filter_portid,
4654 (void *)&cmd_vf_rx_vlan_filter_vf,
4655 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4660 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4661 struct cmd_set_mirror_mask_result {
4662 cmdline_fixed_string_t set;
4663 cmdline_fixed_string_t port;
4665 cmdline_fixed_string_t mirror;
4667 cmdline_fixed_string_t what;
4668 cmdline_fixed_string_t value;
4669 cmdline_fixed_string_t dstpool;
4671 cmdline_fixed_string_t on;
4674 cmdline_parse_token_string_t cmd_mirror_mask_set =
4675 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4677 cmdline_parse_token_string_t cmd_mirror_mask_port =
4678 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4680 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4681 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4683 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4684 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4685 mirror, "mirror-rule");
4686 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4687 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4689 cmdline_parse_token_string_t cmd_mirror_mask_what =
4690 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4691 what, "pool-mirror#vlan-mirror");
4692 cmdline_parse_token_string_t cmd_mirror_mask_value =
4693 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4695 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4696 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4697 dstpool, "dst-pool");
4698 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4699 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4701 cmdline_parse_token_string_t cmd_mirror_mask_on =
4702 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4706 cmd_set_mirror_mask_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4711 struct cmd_set_mirror_mask_result *res = parsed_result;
4712 struct rte_eth_vmdq_mirror_conf mr_conf;
4714 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4716 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4718 mr_conf.dst_pool = res->dstpool_id;
4720 if (!strcmp(res->what, "pool-mirror")) {
4721 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4722 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4723 } else if(!strcmp(res->what, "vlan-mirror")) {
4724 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4725 nb_item = parse_item_list(res->value, "core",
4726 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4730 for(i=0; i < nb_item; i++) {
4731 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4732 printf("Invalid vlan_id: must be < 4096\n");
4736 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4737 mr_conf.vlan.vlan_mask |= 1ULL << i;
4741 if(!strcmp(res->on, "on"))
4742 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4745 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4748 printf("mirror rule add error: (%s)\n", strerror(-ret));
4751 cmdline_parse_inst_t cmd_set_mirror_mask = {
4752 .f = cmd_set_mirror_mask_parsed,
4754 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4755 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4757 (void *)&cmd_mirror_mask_set,
4758 (void *)&cmd_mirror_mask_port,
4759 (void *)&cmd_mirror_mask_portid,
4760 (void *)&cmd_mirror_mask_mirror,
4761 (void *)&cmd_mirror_mask_ruleid,
4762 (void *)&cmd_mirror_mask_what,
4763 (void *)&cmd_mirror_mask_value,
4764 (void *)&cmd_mirror_mask_dstpool,
4765 (void *)&cmd_mirror_mask_poolid,
4766 (void *)&cmd_mirror_mask_on,
4771 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4772 struct cmd_set_mirror_link_result {
4773 cmdline_fixed_string_t set;
4774 cmdline_fixed_string_t port;
4776 cmdline_fixed_string_t mirror;
4778 cmdline_fixed_string_t what;
4779 cmdline_fixed_string_t dstpool;
4781 cmdline_fixed_string_t on;
4784 cmdline_parse_token_string_t cmd_mirror_link_set =
4785 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4787 cmdline_parse_token_string_t cmd_mirror_link_port =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4790 cmdline_parse_token_string_t cmd_mirror_link_portid =
4791 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4793 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4795 mirror, "mirror-rule");
4796 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4797 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4799 cmdline_parse_token_string_t cmd_mirror_link_what =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4801 what, "uplink-mirror#downlink-mirror");
4802 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4804 dstpool, "dst-pool");
4805 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4806 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4808 cmdline_parse_token_string_t cmd_mirror_link_on =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4813 cmd_set_mirror_link_parsed(void *parsed_result,
4814 __attribute__((unused)) struct cmdline *cl,
4815 __attribute__((unused)) void *data)
4818 struct cmd_set_mirror_link_result *res = parsed_result;
4819 struct rte_eth_vmdq_mirror_conf mr_conf;
4821 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4822 if(!strcmp(res->what, "uplink-mirror")) {
4823 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4824 }else if(!strcmp(res->what, "downlink-mirror"))
4825 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4827 mr_conf.dst_pool = res->dstpool_id;
4829 if(!strcmp(res->on, "on"))
4830 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4833 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4836 /* check the return value and print it if is < 0 */
4838 printf("mirror rule add error: (%s)\n", strerror(-ret));
4842 cmdline_parse_inst_t cmd_set_mirror_link = {
4843 .f = cmd_set_mirror_link_parsed,
4845 .help_str = "set port X mirror-rule Y uplink-mirror|"
4846 "downlink-mirror dst-pool Z on|off",
4848 (void *)&cmd_mirror_link_set,
4849 (void *)&cmd_mirror_link_port,
4850 (void *)&cmd_mirror_link_portid,
4851 (void *)&cmd_mirror_link_mirror,
4852 (void *)&cmd_mirror_link_ruleid,
4853 (void *)&cmd_mirror_link_what,
4854 (void *)&cmd_mirror_link_dstpool,
4855 (void *)&cmd_mirror_link_poolid,
4856 (void *)&cmd_mirror_link_on,
4861 /* *** RESET VM MIRROR RULE *** */
4862 struct cmd_rm_mirror_rule_result {
4863 cmdline_fixed_string_t reset;
4864 cmdline_fixed_string_t port;
4866 cmdline_fixed_string_t mirror;
4870 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4871 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4873 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4874 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4876 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4879 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4880 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4881 mirror, "mirror-rule");
4882 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4883 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4887 cmd_reset_mirror_rule_parsed(void *parsed_result,
4888 __attribute__((unused)) struct cmdline *cl,
4889 __attribute__((unused)) void *data)
4892 struct cmd_set_mirror_link_result *res = parsed_result;
4894 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4896 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4899 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4900 .f = cmd_reset_mirror_rule_parsed,
4902 .help_str = "reset port X mirror-rule Y",
4904 (void *)&cmd_rm_mirror_rule_reset,
4905 (void *)&cmd_rm_mirror_rule_port,
4906 (void *)&cmd_rm_mirror_rule_portid,
4907 (void *)&cmd_rm_mirror_rule_mirror,
4908 (void *)&cmd_rm_mirror_rule_ruleid,
4913 /* ******************************************************************************** */
4915 /* list of instructions */
4916 cmdline_parse_ctx_t main_ctx[] = {
4917 (cmdline_parse_inst_t *)&cmd_help_brief,
4918 (cmdline_parse_inst_t *)&cmd_help_long,
4919 (cmdline_parse_inst_t *)&cmd_quit,
4920 (cmdline_parse_inst_t *)&cmd_showport,
4921 (cmdline_parse_inst_t *)&cmd_showportall,
4922 (cmdline_parse_inst_t *)&cmd_showcfg,
4923 (cmdline_parse_inst_t *)&cmd_start,
4924 (cmdline_parse_inst_t *)&cmd_start_tx_first,
4925 (cmdline_parse_inst_t *)&cmd_reset,
4926 (cmdline_parse_inst_t *)&cmd_set_numbers,
4927 (cmdline_parse_inst_t *)&cmd_set_txpkts,
4928 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4929 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4930 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4931 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4932 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4933 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4934 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4935 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4936 #ifdef RTE_NIC_BYPASS
4937 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
4938 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
4939 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
4940 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
4942 (cmdline_parse_inst_t *)&cmd_vlan_offload,
4943 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4944 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4945 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4946 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4947 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4948 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4949 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4950 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4951 (cmdline_parse_inst_t *)&cmd_config_dcb,
4952 (cmdline_parse_inst_t *)&cmd_read_reg,
4953 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4954 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4955 (cmdline_parse_inst_t *)&cmd_write_reg,
4956 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4957 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4958 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4959 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4960 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4961 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4962 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4963 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4964 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4965 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4966 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4967 (cmdline_parse_inst_t *)&cmd_stop,
4968 (cmdline_parse_inst_t *)&cmd_mac_addr,
4969 (cmdline_parse_inst_t *)&cmd_set_qmap,
4970 (cmdline_parse_inst_t *)&cmd_operate_port,
4971 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4972 (cmdline_parse_inst_t *)&cmd_config_speed_all,
4973 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4974 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4975 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
4976 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
4977 (cmdline_parse_inst_t *)&cmd_config_rss,
4978 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
4979 (cmdline_parse_inst_t *)&cmd_showport_reta,
4980 (cmdline_parse_inst_t *)&cmd_config_burst,
4981 (cmdline_parse_inst_t *)&cmd_config_thresh,
4982 (cmdline_parse_inst_t *)&cmd_config_threshold,
4983 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
4984 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
4985 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
4986 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
4987 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
4988 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
4989 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
4990 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
4991 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
4995 /* prompt function, called from main on MASTER lcore */
5001 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5005 cmdline_interact(cl);
5006 cmdline_stdin_exit(cl);
5010 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5012 if (id < nb_ports) {
5013 /* check if need_reconfig has been set to 1 */
5014 if (ports[id].need_reconfig == 0)
5015 ports[id].need_reconfig = dev;
5016 /* check if need_reconfig_queues has been set to 1 */
5017 if (ports[id].need_reconfig_queues == 0)
5018 ports[id].need_reconfig_queues = queue;
5022 for (pid = 0; pid < nb_ports; pid++) {
5023 /* check if need_reconfig has been set to 1 */
5024 if (ports[pid].need_reconfig == 0)
5025 ports[pid].need_reconfig = dev;
5026 /* check if need_reconfig_queues has been set to 1 */
5027 if (ports[pid].need_reconfig_queues == 0)
5028 ports[pid].need_reconfig_queues = queue;
5033 #ifdef RTE_NIC_BYPASS
5035 bypass_is_supported(portid_t port_id)
5037 struct rte_port *port;
5038 struct rte_pci_id *pci_id;
5040 if (port_id >= nb_ports) {
5041 printf("\tPort id must be less than %d.\n", nb_ports);
5045 /* Get the device id. */
5046 port = &ports[port_id];
5047 pci_id = &port->dev_info.pci_dev->id;
5049 /* Check if NIC supports bypass. */
5050 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5054 printf("\tBypass not supported for port_id = %d.\n", port_id);