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) mac_ctrl_frame_fwd"
316 " (on|off) (port_id)\n"
317 " Set the link flow control parameter on a port.\n\n"
319 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
320 " (low_water) (pause_time) (priority) (port_id)\n"
321 " Set the priority flow control parameter on a"
324 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
325 " Set statistics mapping (qmapping 0..15) for RX/TX"
327 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
328 " on port 0 to mapping 5.\n\n"
330 "set port (port_id) vf (vf_id) rx|tx on|off \n"
331 " Enable/Disable a VF receive/tranmit from a port\n\n"
333 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
335 " AUPE:accepts untagged VLAN;"
336 "ROPE:accept unicast hash\n\n"
337 " BAM:accepts broadcast packets;"
338 "MPE:accepts all multicast packets\n\n"
339 " Enable/Disable a VF receive mode of a port\n\n"
341 "set port (port_id) mirror-rule (rule_id)"
342 "(pool-mirror|vlan-mirror)\n"
343 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
344 " Set pool or vlan type mirror rule on a port.\n"
345 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
346 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
349 "set port (port_id) mirror-rule (rule_id)"
350 "(uplink-mirror|downlink-mirror) dst-pool"
351 "(pool_id) (on|off)\n"
352 " Set uplink or downlink type mirror rule on a port.\n"
353 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
354 " 0 on' enable mirror income traffic to pool 0.\n\n"
356 "reset port (port_id) mirror-rule (rule_id)\n"
357 " Reset a mirror rule.\n\n"
359 "set flush_rx (on|off)\n"
360 " Flush (default) or don't flush RX streams before"
361 " forwarding. Mainly used with PCAP drivers.\n\n"
363 #ifdef RTE_NIC_BYPASS
364 "set bypass mode (normal|bypass|isolate) (port_id)\n"
365 " Set the bypass mode for the lowest port on bypass enabled"
368 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
369 "mode (normal|bypass|isolate) (port_id)\n"
370 " Set the event required to initiate specified bypass mode for"
371 " the lowest port on a bypass enabled NIC where:\n"
372 " timeout = enable bypass after watchdog timeout.\n"
373 " os_on = enable bypass when OS/board is powered on.\n"
374 " os_off = enable bypass when OS/board is powered off.\n"
375 " power_on = enable bypass when power supply is turned on.\n"
376 " power_off = enable bypass when power supply is turned off."
379 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
380 " Set the bypass watchdog timeout to 'n' seconds"
381 " where 0 = instant.\n\n"
383 "show bypass config (port_id)\n"
384 " Show the bypass configuration for a bypass enabled NIC"
385 " using the lowest port on the NIC.\n\n"
392 if (show_all || !strcmp(res->section, "flowdir")) {
397 "Flow director mode:\n"
398 "-------------------\n\n"
400 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
401 " src (src_ip_address) (src_port)"
402 " dst (dst_ip_address) (dst_port)"
403 " flexbytes (flexbytes_values) vlan (vlan_id)"
404 " queue (queue_id)\n"
405 " Add a signature filter.\n\n"
407 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
408 " src (src_ip_address) (src_port)"
409 " dst (dst_ip_address) (dst_port)"
410 " flexbytes (flexbytes_values) vlan (vlan_id)"
411 " queue (queue_id)\n"
412 " Update a signature filter.\n\n"
414 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
415 " src (src_ip_address) (src_port)"
416 " dst (dst_ip_address) (dst_port)"
417 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
418 " Remove a signature filter.\n\n"
420 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
421 " src (src_ip_address) (src_port)"
422 " dst (dst_ip_address) (dst_port)"
423 " flexbytes (flexbytes_values) vlan (vlan_id)"
424 " queue (queue_id) soft (soft_id)\n"
425 " Add a perfect filter.\n\n"
427 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
428 " src (src_ip_address) (src_port)"
429 " dst (dst_ip_address) (dst_port)"
430 " flexbytes (flexbytes_values) vlan (vlan_id)"
431 " queue (queue_id)\n"
432 " Update a perfect filter.\n\n"
434 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
435 " src (src_ip_address) (src_port)"
436 " dst (dst_ip_address) (dst_port)"
437 " flexbytes (flexbytes_values) vlan (vlan_id)"
439 " Remove a perfect filter.\n\n"
441 "set_masks_filter (port_id) only_ip_flow (0|1)"
442 " src_mask (ip_src_mask) (src_port_mask)"
443 " dst_mask (ip_dst_mask) (dst_port_mask)"
444 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
445 " Set IPv4 filter masks.\n\n"
447 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
448 " src_mask (ip_src_mask) (src_port_mask)"
449 " dst_mask (ip_dst_mask) (dst_port_mask)"
450 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
451 " compare_dst (0|1)\n"
452 " Set IPv6 filter masks.\n\n"
456 if (show_all || !strcmp(res->section, "ports")) {
462 "----------------\n\n"
464 "port start (port_id|all)\n"
465 " Start all ports or port_id.\n\n"
467 "port stop (port_id|all)\n"
468 " Stop all ports or port_id.\n\n"
470 "port close (port_id|all)\n"
471 " Close all ports or port_id.\n\n"
473 "port config (port_id|all) speed (10|100|1000|10000|auto)"
474 " duplex (half|full|auto)\n"
475 " Set speed and duplex for all ports or port_id\n\n"
477 "port config all (rxq|txq|rxd|txd) (value)\n"
478 " Set number for rxq/txq/rxd/txd.\n\n"
480 "port config all max-pkt-len (value)\n"
481 " Set the max packet length.\n\n"
483 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
485 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
488 "port config all rss (ip|udp|none)\n"
489 " Set the RSS mode.\n\n"
491 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
492 " Set the RSS redirection table.\n\n"
494 "port config (port_id) dcb vt (on|off) (traffic_class)"
496 " Set the DCB mode.\n\n"
498 "port config all burst (value)\n"
499 " Set the number of packets per burst.\n\n"
501 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
503 " Set the ring prefetch/host/writeback threshold"
504 " for tx/rx queue.\n\n"
506 "port config all (txfreet|txrst|rxfreet) (value)\n"
507 " Set free threshold for rx/tx, or set"
508 " tx rs bit threshold.\n\n"
512 if (show_all || !strcmp(res->section, "registers")) {
520 "read reg (port_id) (address)\n"
521 " Display value of a port register.\n\n"
523 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
524 " Display a port register bit field.\n\n"
526 "read regbit (port_id) (address) (bit_x)\n"
527 " Display a single port register bit.\n\n"
529 "write reg (port_id) (address) (value)\n"
530 " Set value of a port register.\n\n"
532 "write regfield (port_id) (address) (bit_x) (bit_y)"
534 " Set bit field of a port register.\n\n"
536 "write regbit (port_id) (address) (bit_x) (value)\n"
537 " Set single bit value of a port register.\n\n"
542 cmdline_parse_token_string_t cmd_help_long_help =
543 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
545 cmdline_parse_token_string_t cmd_help_long_section =
546 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
547 "all#control#display#config#flowdir#"
550 cmdline_parse_inst_t cmd_help_long = {
551 .f = cmd_help_long_parsed,
553 .help_str = "show help",
555 (void *)&cmd_help_long_help,
556 (void *)&cmd_help_long_section,
562 /* *** start/stop/close all ports *** */
563 struct cmd_operate_port_result {
564 cmdline_fixed_string_t keyword;
565 cmdline_fixed_string_t name;
566 cmdline_fixed_string_t value;
569 static void cmd_operate_port_parsed(void *parsed_result,
570 __attribute__((unused)) struct cmdline *cl,
571 __attribute__((unused)) void *data)
573 struct cmd_operate_port_result *res = parsed_result;
575 if (!strcmp(res->name, "start"))
576 start_port(RTE_PORT_ALL);
577 else if (!strcmp(res->name, "stop"))
578 stop_port(RTE_PORT_ALL);
579 else if (!strcmp(res->name, "close"))
580 close_port(RTE_PORT_ALL);
582 printf("Unknown parameter\n");
585 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
586 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
588 cmdline_parse_token_string_t cmd_operate_port_all_port =
589 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
591 cmdline_parse_token_string_t cmd_operate_port_all_all =
592 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
594 cmdline_parse_inst_t cmd_operate_port = {
595 .f = cmd_operate_port_parsed,
597 .help_str = "port start|stop|close all: start/stop/close all ports",
599 (void *)&cmd_operate_port_all_cmd,
600 (void *)&cmd_operate_port_all_port,
601 (void *)&cmd_operate_port_all_all,
606 /* *** start/stop/close specific port *** */
607 struct cmd_operate_specific_port_result {
608 cmdline_fixed_string_t keyword;
609 cmdline_fixed_string_t name;
613 static void cmd_operate_specific_port_parsed(void *parsed_result,
614 __attribute__((unused)) struct cmdline *cl,
615 __attribute__((unused)) void *data)
617 struct cmd_operate_specific_port_result *res = parsed_result;
619 if (!strcmp(res->name, "start"))
620 start_port(res->value);
621 else if (!strcmp(res->name, "stop"))
622 stop_port(res->value);
623 else if (!strcmp(res->name, "close"))
624 close_port(res->value);
626 printf("Unknown parameter\n");
629 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
630 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
632 cmdline_parse_token_string_t cmd_operate_specific_port_port =
633 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
634 name, "start#stop#close");
635 cmdline_parse_token_num_t cmd_operate_specific_port_id =
636 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
639 cmdline_parse_inst_t cmd_operate_specific_port = {
640 .f = cmd_operate_specific_port_parsed,
642 .help_str = "port start|stop|close X: start/stop/close port X",
644 (void *)&cmd_operate_specific_port_cmd,
645 (void *)&cmd_operate_specific_port_port,
646 (void *)&cmd_operate_specific_port_id,
651 /* *** configure speed for all ports *** */
652 struct cmd_config_speed_all {
653 cmdline_fixed_string_t port;
654 cmdline_fixed_string_t keyword;
655 cmdline_fixed_string_t all;
656 cmdline_fixed_string_t item1;
657 cmdline_fixed_string_t item2;
658 cmdline_fixed_string_t value1;
659 cmdline_fixed_string_t value2;
663 cmd_config_speed_all_parsed(void *parsed_result,
664 __attribute__((unused)) struct cmdline *cl,
665 __attribute__((unused)) void *data)
667 struct cmd_config_speed_all *res = parsed_result;
668 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
669 uint16_t link_duplex = 0;
672 if (!all_ports_stopped()) {
673 printf("Please stop all ports first\n");
677 if (!strcmp(res->value1, "10"))
678 link_speed = ETH_LINK_SPEED_10;
679 else if (!strcmp(res->value1, "100"))
680 link_speed = ETH_LINK_SPEED_100;
681 else if (!strcmp(res->value1, "1000"))
682 link_speed = ETH_LINK_SPEED_1000;
683 else if (!strcmp(res->value1, "10000"))
684 link_speed = ETH_LINK_SPEED_10000;
685 else if (!strcmp(res->value1, "auto"))
686 link_speed = ETH_LINK_SPEED_AUTONEG;
688 printf("Unknown parameter\n");
692 if (!strcmp(res->value2, "half"))
693 link_duplex = ETH_LINK_HALF_DUPLEX;
694 else if (!strcmp(res->value2, "full"))
695 link_duplex = ETH_LINK_FULL_DUPLEX;
696 else if (!strcmp(res->value2, "auto"))
697 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
699 printf("Unknown parameter\n");
703 for (pid = 0; pid < nb_ports; pid++) {
704 ports[pid].dev_conf.link_speed = link_speed;
705 ports[pid].dev_conf.link_duplex = link_duplex;
708 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
711 cmdline_parse_token_string_t cmd_config_speed_all_port =
712 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
713 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
716 cmdline_parse_token_string_t cmd_config_speed_all_all =
717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
718 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
719 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
720 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
722 "10#100#1000#10000#auto");
723 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
725 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
729 cmdline_parse_inst_t cmd_config_speed_all = {
730 .f = cmd_config_speed_all_parsed,
732 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
735 (void *)&cmd_config_speed_all_port,
736 (void *)&cmd_config_speed_all_keyword,
737 (void *)&cmd_config_speed_all_all,
738 (void *)&cmd_config_speed_all_item1,
739 (void *)&cmd_config_speed_all_value1,
740 (void *)&cmd_config_speed_all_item2,
741 (void *)&cmd_config_speed_all_value2,
746 /* *** configure speed for specific port *** */
747 struct cmd_config_speed_specific {
748 cmdline_fixed_string_t port;
749 cmdline_fixed_string_t keyword;
751 cmdline_fixed_string_t item1;
752 cmdline_fixed_string_t item2;
753 cmdline_fixed_string_t value1;
754 cmdline_fixed_string_t value2;
758 cmd_config_speed_specific_parsed(void *parsed_result,
759 __attribute__((unused)) struct cmdline *cl,
760 __attribute__((unused)) void *data)
762 struct cmd_config_speed_specific *res = parsed_result;
763 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
764 uint16_t link_duplex = 0;
766 if (!all_ports_stopped()) {
767 printf("Please stop all ports first\n");
771 if (res->id >= nb_ports) {
772 printf("Port id %d must be less than %d\n", res->id, nb_ports);
776 if (!strcmp(res->value1, "10"))
777 link_speed = ETH_LINK_SPEED_10;
778 else if (!strcmp(res->value1, "100"))
779 link_speed = ETH_LINK_SPEED_100;
780 else if (!strcmp(res->value1, "1000"))
781 link_speed = ETH_LINK_SPEED_1000;
782 else if (!strcmp(res->value1, "10000"))
783 link_speed = ETH_LINK_SPEED_10000;
784 else if (!strcmp(res->value1, "auto"))
785 link_speed = ETH_LINK_SPEED_AUTONEG;
787 printf("Unknown parameter\n");
791 if (!strcmp(res->value2, "half"))
792 link_duplex = ETH_LINK_HALF_DUPLEX;
793 else if (!strcmp(res->value2, "full"))
794 link_duplex = ETH_LINK_FULL_DUPLEX;
795 else if (!strcmp(res->value2, "auto"))
796 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
798 printf("Unknown parameter\n");
802 ports[res->id].dev_conf.link_speed = link_speed;
803 ports[res->id].dev_conf.link_duplex = link_duplex;
805 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
809 cmdline_parse_token_string_t cmd_config_speed_specific_port =
810 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
812 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
813 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
815 cmdline_parse_token_num_t cmd_config_speed_specific_id =
816 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
817 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
818 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
820 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
821 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
822 "10#100#1000#10000#auto");
823 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
824 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
826 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
830 cmdline_parse_inst_t cmd_config_speed_specific = {
831 .f = cmd_config_speed_specific_parsed,
833 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
836 (void *)&cmd_config_speed_specific_port,
837 (void *)&cmd_config_speed_specific_keyword,
838 (void *)&cmd_config_speed_specific_id,
839 (void *)&cmd_config_speed_specific_item1,
840 (void *)&cmd_config_speed_specific_value1,
841 (void *)&cmd_config_speed_specific_item2,
842 (void *)&cmd_config_speed_specific_value2,
847 /* *** configure txq/rxq, txd/rxd *** */
848 struct cmd_config_rx_tx {
849 cmdline_fixed_string_t port;
850 cmdline_fixed_string_t keyword;
851 cmdline_fixed_string_t all;
852 cmdline_fixed_string_t name;
857 cmd_config_rx_tx_parsed(void *parsed_result,
858 __attribute__((unused)) struct cmdline *cl,
859 __attribute__((unused)) void *data)
861 struct cmd_config_rx_tx *res = parsed_result;
863 if (!all_ports_stopped()) {
864 printf("Please stop all ports first\n");
868 if (!strcmp(res->name, "rxq")) {
869 if (res->value <= 0) {
870 printf("rxq %d invalid - must be > 0\n", res->value);
875 else if (!strcmp(res->name, "txq")) {
876 if (res->value <= 0) {
877 printf("txq %d invalid - must be > 0\n", res->value);
882 else if (!strcmp(res->name, "rxd")) {
883 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
884 printf("rxd %d invalid - must be > 0 && <= %d\n",
885 res->value, RTE_TEST_RX_DESC_MAX);
889 } else if (!strcmp(res->name, "txd")) {
890 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
891 printf("txd %d invalid - must be > 0 && <= %d\n",
892 res->value, RTE_TEST_TX_DESC_MAX);
897 printf("Unknown parameter\n");
903 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
906 cmdline_parse_token_string_t cmd_config_rx_tx_port =
907 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
908 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
909 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
910 cmdline_parse_token_string_t cmd_config_rx_tx_all =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
912 cmdline_parse_token_string_t cmd_config_rx_tx_name =
913 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
915 cmdline_parse_token_num_t cmd_config_rx_tx_value =
916 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
918 cmdline_parse_inst_t cmd_config_rx_tx = {
919 .f = cmd_config_rx_tx_parsed,
921 .help_str = "port config all rxq|txq|rxd|txd value",
923 (void *)&cmd_config_rx_tx_port,
924 (void *)&cmd_config_rx_tx_keyword,
925 (void *)&cmd_config_rx_tx_all,
926 (void *)&cmd_config_rx_tx_name,
927 (void *)&cmd_config_rx_tx_value,
932 /* *** config max packet length *** */
933 struct cmd_config_max_pkt_len_result {
934 cmdline_fixed_string_t port;
935 cmdline_fixed_string_t keyword;
936 cmdline_fixed_string_t all;
937 cmdline_fixed_string_t name;
942 cmd_config_max_pkt_len_parsed(void *parsed_result,
943 __attribute__((unused)) struct cmdline *cl,
944 __attribute__((unused)) void *data)
946 struct cmd_config_max_pkt_len_result *res = parsed_result;
948 if (!all_ports_stopped()) {
949 printf("Please stop all ports first\n");
953 if (!strcmp(res->name, "max-pkt-len")) {
954 if (res->value < ETHER_MIN_LEN) {
955 printf("max-pkt-len can not be less than %d\n",
959 if (res->value == rx_mode.max_rx_pkt_len)
962 rx_mode.max_rx_pkt_len = res->value;
963 if (res->value > ETHER_MAX_LEN)
964 rx_mode.jumbo_frame = 1;
966 rx_mode.jumbo_frame = 0;
968 printf("Unknown parameter\n");
974 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
977 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
978 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
980 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
981 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
983 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
986 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
989 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
990 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
993 cmdline_parse_inst_t cmd_config_max_pkt_len = {
994 .f = cmd_config_max_pkt_len_parsed,
996 .help_str = "port config all max-pkt-len value",
998 (void *)&cmd_config_max_pkt_len_port,
999 (void *)&cmd_config_max_pkt_len_keyword,
1000 (void *)&cmd_config_max_pkt_len_all,
1001 (void *)&cmd_config_max_pkt_len_name,
1002 (void *)&cmd_config_max_pkt_len_value,
1007 /* *** configure rx mode *** */
1008 struct cmd_config_rx_mode_flag {
1009 cmdline_fixed_string_t port;
1010 cmdline_fixed_string_t keyword;
1011 cmdline_fixed_string_t all;
1012 cmdline_fixed_string_t name;
1013 cmdline_fixed_string_t value;
1017 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1018 __attribute__((unused)) struct cmdline *cl,
1019 __attribute__((unused)) void *data)
1021 struct cmd_config_rx_mode_flag *res = parsed_result;
1023 if (!all_ports_stopped()) {
1024 printf("Please stop all ports first\n");
1028 if (!strcmp(res->name, "crc-strip")) {
1029 if (!strcmp(res->value, "on"))
1030 rx_mode.hw_strip_crc = 1;
1031 else if (!strcmp(res->value, "off"))
1032 rx_mode.hw_strip_crc = 0;
1034 printf("Unknown parameter\n");
1037 } else if (!strcmp(res->name, "rx-cksum")) {
1038 if (!strcmp(res->value, "on"))
1039 rx_mode.hw_ip_checksum = 1;
1040 else if (!strcmp(res->value, "off"))
1041 rx_mode.hw_ip_checksum = 0;
1043 printf("Unknown parameter\n");
1046 } else if (!strcmp(res->name, "hw-vlan")) {
1047 if (!strcmp(res->value, "on")) {
1048 rx_mode.hw_vlan_filter = 1;
1049 rx_mode.hw_vlan_strip = 1;
1051 else if (!strcmp(res->value, "off")) {
1052 rx_mode.hw_vlan_filter = 0;
1053 rx_mode.hw_vlan_strip = 0;
1056 printf("Unknown parameter\n");
1059 } else if (!strcmp(res->name, "drop-en")) {
1060 if (!strcmp(res->value, "on"))
1062 else if (!strcmp(res->value, "off"))
1065 printf("Unknown parameter\n");
1069 printf("Unknown parameter\n");
1075 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1078 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1079 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1080 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1081 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1083 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1084 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1085 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1086 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1087 "crc-strip#rx-cksum#hw-vlan");
1088 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1089 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1092 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1093 .f = cmd_config_rx_mode_flag_parsed,
1095 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1097 (void *)&cmd_config_rx_mode_flag_port,
1098 (void *)&cmd_config_rx_mode_flag_keyword,
1099 (void *)&cmd_config_rx_mode_flag_all,
1100 (void *)&cmd_config_rx_mode_flag_name,
1101 (void *)&cmd_config_rx_mode_flag_value,
1106 /* *** configure rss *** */
1107 struct cmd_config_rss {
1108 cmdline_fixed_string_t port;
1109 cmdline_fixed_string_t keyword;
1110 cmdline_fixed_string_t all;
1111 cmdline_fixed_string_t name;
1112 cmdline_fixed_string_t value;
1116 cmd_config_rss_parsed(void *parsed_result,
1117 __attribute__((unused)) struct cmdline *cl,
1118 __attribute__((unused)) void *data)
1120 struct cmd_config_rss *res = parsed_result;
1122 if (!all_ports_stopped()) {
1123 printf("Please stop all ports first\n");
1127 if (!strcmp(res->value, "ip"))
1128 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1129 else if (!strcmp(res->value, "udp"))
1130 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1131 else if (!strcmp(res->value, "none"))
1134 printf("Unknown parameter\n");
1140 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1143 cmdline_parse_token_string_t cmd_config_rss_port =
1144 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1145 cmdline_parse_token_string_t cmd_config_rss_keyword =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1147 cmdline_parse_token_string_t cmd_config_rss_all =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1149 cmdline_parse_token_string_t cmd_config_rss_name =
1150 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1151 cmdline_parse_token_string_t cmd_config_rss_value =
1152 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1154 cmdline_parse_inst_t cmd_config_rss = {
1155 .f = cmd_config_rss_parsed,
1157 .help_str = "port config all rss ip|udp|none",
1159 (void *)&cmd_config_rss_port,
1160 (void *)&cmd_config_rss_keyword,
1161 (void *)&cmd_config_rss_all,
1162 (void *)&cmd_config_rss_name,
1163 (void *)&cmd_config_rss_value,
1168 /* *** Configure RSS RETA *** */
1169 struct cmd_config_rss_reta {
1170 cmdline_fixed_string_t port;
1171 cmdline_fixed_string_t keyword;
1173 cmdline_fixed_string_t name;
1174 cmdline_fixed_string_t list_name;
1175 cmdline_fixed_string_t list_of_items;
1179 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1186 const char *p, *p0 = str;
1193 unsigned long int_fld[_NUM_FLD];
1194 char *str_fld[_NUM_FLD];
1196 while ((p = strchr(p0,'(')) != NULL) {
1198 if((p0 = strchr(p,')')) == NULL)
1202 if(size >= sizeof(s))
1205 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1206 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1208 for (i = 0; i < _NUM_FLD; i++) {
1210 int_fld[i] = strtoul(str_fld[i], &end, 0);
1211 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1215 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1216 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1218 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1219 printf("Invalid RETA hash index=%d",hash_index);
1223 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1224 reta_conf->mask_lo |= (1ULL << hash_index);
1226 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1228 reta_conf->reta[hash_index] = nb_queue;
1235 cmd_set_rss_reta_parsed(void *parsed_result,
1236 __attribute__((unused)) struct cmdline *cl,
1237 __attribute__((unused)) void *data)
1240 struct rte_eth_rss_reta reta_conf;
1241 struct cmd_config_rss_reta *res = parsed_result;
1243 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1244 if (!strcmp(res->list_name, "reta")) {
1245 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1246 printf("Invalid RSS Redirection Table config entered\n");
1249 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1251 printf("Bad redirection table parameter, return code = %d \n",ret);
1255 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1257 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1259 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1260 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1261 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1262 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1263 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1265 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1268 cmdline_parse_inst_t cmd_config_rss_reta = {
1269 .f = cmd_set_rss_reta_parsed,
1271 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1273 (void *)&cmd_config_rss_reta_port,
1274 (void *)&cmd_config_rss_reta_keyword,
1275 (void *)&cmd_config_rss_reta_port_id,
1276 (void *)&cmd_config_rss_reta_name,
1277 (void *)&cmd_config_rss_reta_list_name,
1278 (void *)&cmd_config_rss_reta_list_of_items,
1283 /* *** SHOW PORT INFO *** */
1284 struct cmd_showport_reta {
1285 cmdline_fixed_string_t show;
1286 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t rss;
1289 cmdline_fixed_string_t reta;
1294 static void cmd_showport_reta_parsed(void *parsed_result,
1295 __attribute__((unused)) struct cmdline *cl,
1296 __attribute__((unused)) void *data)
1298 struct cmd_showport_reta *res = parsed_result;
1299 struct rte_eth_rss_reta reta_conf;
1301 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1302 printf("Invalid RSS Redirection Table config entered\n");
1306 reta_conf.mask_lo = res->mask_lo;
1307 reta_conf.mask_hi = res->mask_hi;
1309 port_rss_reta_info(res->port_id,&reta_conf);
1312 cmdline_parse_token_string_t cmd_showport_reta_show =
1313 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1314 cmdline_parse_token_string_t cmd_showport_reta_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1316 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1317 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1318 cmdline_parse_token_string_t cmd_showport_reta_rss =
1319 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1320 cmdline_parse_token_string_t cmd_showport_reta_reta =
1321 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1322 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1323 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1324 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1325 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1327 cmdline_parse_inst_t cmd_showport_reta = {
1328 .f = cmd_showport_reta_parsed,
1330 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1331 (mask_lo and mask_hi is UINT64)",
1333 (void *)&cmd_showport_reta_show,
1334 (void *)&cmd_showport_reta_port,
1335 (void *)&cmd_showport_reta_port_id,
1336 (void *)&cmd_showport_reta_rss,
1337 (void *)&cmd_showport_reta_reta,
1338 (void *)&cmd_showport_reta_mask_lo,
1339 (void *)&cmd_showport_reta_mask_hi,
1344 /* *** Configure DCB *** */
1345 struct cmd_config_dcb {
1346 cmdline_fixed_string_t port;
1347 cmdline_fixed_string_t config;
1349 cmdline_fixed_string_t dcb;
1350 cmdline_fixed_string_t vt;
1351 cmdline_fixed_string_t vt_en;
1353 cmdline_fixed_string_t pfc;
1354 cmdline_fixed_string_t pfc_en;
1358 cmd_config_dcb_parsed(void *parsed_result,
1359 __attribute__((unused)) struct cmdline *cl,
1360 __attribute__((unused)) void *data)
1362 struct cmd_config_dcb *res = parsed_result;
1363 struct dcb_config dcb_conf;
1364 portid_t port_id = res->port_id;
1365 struct rte_port *port;
1367 port = &ports[port_id];
1368 /** Check if the port is not started **/
1369 if (port->port_status != RTE_PORT_STOPPED) {
1370 printf("Please stop port %d first\n",port_id);
1374 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1375 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1376 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1380 /* DCB in VT mode */
1381 if (!strncmp(res->vt_en, "on",2))
1382 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1384 dcb_conf.dcb_mode = DCB_ENABLED;
1386 if (!strncmp(res->pfc_en, "on",2)) {
1387 dcb_conf.pfc_en = 1;
1390 dcb_conf.pfc_en = 0;
1392 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1393 printf("Cannot initialize network ports\n");
1397 cmd_reconfig_device_queue(port_id, 1, 1);
1400 cmdline_parse_token_string_t cmd_config_dcb_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1402 cmdline_parse_token_string_t cmd_config_dcb_config =
1403 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1404 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1405 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1406 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1407 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1408 cmdline_parse_token_string_t cmd_config_dcb_vt =
1409 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1410 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1411 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1412 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1413 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1414 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1416 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1417 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1419 cmdline_parse_inst_t cmd_config_dcb = {
1420 .f = cmd_config_dcb_parsed,
1422 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1424 (void *)&cmd_config_dcb_port,
1425 (void *)&cmd_config_dcb_config,
1426 (void *)&cmd_config_dcb_port_id,
1427 (void *)&cmd_config_dcb_dcb,
1428 (void *)&cmd_config_dcb_vt,
1429 (void *)&cmd_config_dcb_vt_en,
1430 (void *)&cmd_config_dcb_num_tcs,
1431 (void *)&cmd_config_dcb_pfc,
1432 (void *)&cmd_config_dcb_pfc_en,
1437 /* *** configure number of packets per burst *** */
1438 struct cmd_config_burst {
1439 cmdline_fixed_string_t port;
1440 cmdline_fixed_string_t keyword;
1441 cmdline_fixed_string_t all;
1442 cmdline_fixed_string_t name;
1447 cmd_config_burst_parsed(void *parsed_result,
1448 __attribute__((unused)) struct cmdline *cl,
1449 __attribute__((unused)) void *data)
1451 struct cmd_config_burst *res = parsed_result;
1453 if (!all_ports_stopped()) {
1454 printf("Please stop all ports first\n");
1458 if (!strcmp(res->name, "burst")) {
1459 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1460 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1463 nb_pkt_per_burst = res->value;
1465 printf("Unknown parameter\n");
1471 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1474 cmdline_parse_token_string_t cmd_config_burst_port =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1476 cmdline_parse_token_string_t cmd_config_burst_keyword =
1477 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1478 cmdline_parse_token_string_t cmd_config_burst_all =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1480 cmdline_parse_token_string_t cmd_config_burst_name =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1482 cmdline_parse_token_num_t cmd_config_burst_value =
1483 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1485 cmdline_parse_inst_t cmd_config_burst = {
1486 .f = cmd_config_burst_parsed,
1488 .help_str = "port config all burst value",
1490 (void *)&cmd_config_burst_port,
1491 (void *)&cmd_config_burst_keyword,
1492 (void *)&cmd_config_burst_all,
1493 (void *)&cmd_config_burst_name,
1494 (void *)&cmd_config_burst_value,
1499 /* *** configure rx/tx queues *** */
1500 struct cmd_config_thresh {
1501 cmdline_fixed_string_t port;
1502 cmdline_fixed_string_t keyword;
1503 cmdline_fixed_string_t all;
1504 cmdline_fixed_string_t name;
1509 cmd_config_thresh_parsed(void *parsed_result,
1510 __attribute__((unused)) struct cmdline *cl,
1511 __attribute__((unused)) void *data)
1513 struct cmd_config_thresh *res = parsed_result;
1515 if (!all_ports_stopped()) {
1516 printf("Please stop all ports first\n");
1520 if (!strcmp(res->name, "txpt"))
1521 tx_thresh.pthresh = res->value;
1522 else if(!strcmp(res->name, "txht"))
1523 tx_thresh.hthresh = res->value;
1524 else if(!strcmp(res->name, "txwt"))
1525 tx_thresh.wthresh = res->value;
1526 else if(!strcmp(res->name, "rxpt"))
1527 rx_thresh.pthresh = res->value;
1528 else if(!strcmp(res->name, "rxht"))
1529 rx_thresh.hthresh = res->value;
1530 else if(!strcmp(res->name, "rxwt"))
1531 rx_thresh.wthresh = res->value;
1533 printf("Unknown parameter\n");
1539 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1542 cmdline_parse_token_string_t cmd_config_thresh_port =
1543 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1544 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1545 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1546 cmdline_parse_token_string_t cmd_config_thresh_all =
1547 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1548 cmdline_parse_token_string_t cmd_config_thresh_name =
1549 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1550 "txpt#txht#txwt#rxpt#rxht#rxwt");
1551 cmdline_parse_token_num_t cmd_config_thresh_value =
1552 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1554 cmdline_parse_inst_t cmd_config_thresh = {
1555 .f = cmd_config_thresh_parsed,
1557 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1559 (void *)&cmd_config_thresh_port,
1560 (void *)&cmd_config_thresh_keyword,
1561 (void *)&cmd_config_thresh_all,
1562 (void *)&cmd_config_thresh_name,
1563 (void *)&cmd_config_thresh_value,
1568 /* *** configure free/rs threshold *** */
1569 struct cmd_config_threshold {
1570 cmdline_fixed_string_t port;
1571 cmdline_fixed_string_t keyword;
1572 cmdline_fixed_string_t all;
1573 cmdline_fixed_string_t name;
1578 cmd_config_threshold_parsed(void *parsed_result,
1579 __attribute__((unused)) struct cmdline *cl,
1580 __attribute__((unused)) void *data)
1582 struct cmd_config_threshold *res = parsed_result;
1584 if (!all_ports_stopped()) {
1585 printf("Please stop all ports first\n");
1589 if (!strcmp(res->name, "txfreet"))
1590 tx_free_thresh = res->value;
1591 else if (!strcmp(res->name, "txrst"))
1592 tx_rs_thresh = res->value;
1593 else if (!strcmp(res->name, "rxfreet"))
1594 rx_free_thresh = res->value;
1596 printf("Unknown parameter\n");
1602 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1605 cmdline_parse_token_string_t cmd_config_threshold_port =
1606 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1607 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1608 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1610 cmdline_parse_token_string_t cmd_config_threshold_all =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1612 cmdline_parse_token_string_t cmd_config_threshold_name =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1614 "txfreet#txrst#rxfreet");
1615 cmdline_parse_token_num_t cmd_config_threshold_value =
1616 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1618 cmdline_parse_inst_t cmd_config_threshold = {
1619 .f = cmd_config_threshold_parsed,
1621 .help_str = "port config all txfreet|txrst|rxfreet value",
1623 (void *)&cmd_config_threshold_port,
1624 (void *)&cmd_config_threshold_keyword,
1625 (void *)&cmd_config_threshold_all,
1626 (void *)&cmd_config_threshold_name,
1627 (void *)&cmd_config_threshold_value,
1633 struct cmd_stop_result {
1634 cmdline_fixed_string_t stop;
1637 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1638 __attribute__((unused)) struct cmdline *cl,
1639 __attribute__((unused)) void *data)
1641 stop_packet_forwarding();
1644 cmdline_parse_token_string_t cmd_stop_stop =
1645 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1647 cmdline_parse_inst_t cmd_stop = {
1648 .f = cmd_stop_parsed,
1650 .help_str = "stop - stop packet forwarding",
1652 (void *)&cmd_stop_stop,
1657 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1660 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1661 unsigned int *parsed_items, int check_unique_values)
1663 unsigned int nb_item;
1671 * First parse all items in the list and store their value.
1676 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1678 if ((c >= '0') && (c <= '9')) {
1679 value = (unsigned int) (value * 10 + (c - '0'));
1684 printf("character %c is not a decimal digit\n", c);
1688 printf("No valid value before comma\n");
1691 if (nb_item < max_items) {
1692 parsed_items[nb_item] = value;
1698 if (nb_item >= max_items) {
1699 printf("Number of %s = %u > %u (maximum items)\n",
1700 item_name, nb_item + 1, max_items);
1703 parsed_items[nb_item++] = value;
1704 if (! check_unique_values)
1708 * Then, check that all values in the list are differents.
1709 * No optimization here...
1711 for (i = 0; i < nb_item; i++) {
1712 for (j = i + 1; j < nb_item; j++) {
1713 if (parsed_items[j] == parsed_items[i]) {
1714 printf("duplicated %s %u at index %u and %u\n",
1715 item_name, parsed_items[i], i, j);
1723 struct cmd_set_list_result {
1724 cmdline_fixed_string_t cmd_keyword;
1725 cmdline_fixed_string_t list_name;
1726 cmdline_fixed_string_t list_of_items;
1729 static void cmd_set_list_parsed(void *parsed_result,
1730 __attribute__((unused)) struct cmdline *cl,
1731 __attribute__((unused)) void *data)
1733 struct cmd_set_list_result *res;
1735 unsigned int lcorelist[RTE_MAX_LCORE];
1736 unsigned int portlist[RTE_MAX_ETHPORTS];
1738 unsigned int nb_item;
1740 res = parsed_result;
1741 if (!strcmp(res->list_name, "corelist")) {
1742 nb_item = parse_item_list(res->list_of_items, "core",
1744 parsed_items.lcorelist, 1);
1746 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1749 if (!strcmp(res->list_name, "portlist")) {
1750 nb_item = parse_item_list(res->list_of_items, "port",
1752 parsed_items.portlist, 1);
1754 set_fwd_ports_list(parsed_items.portlist, nb_item);
1758 cmdline_parse_token_string_t cmd_set_list_keyword =
1759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1761 cmdline_parse_token_string_t cmd_set_list_name =
1762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1763 "corelist#portlist");
1764 cmdline_parse_token_string_t cmd_set_list_of_items =
1765 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1768 cmdline_parse_inst_t cmd_set_fwd_list = {
1769 .f = cmd_set_list_parsed,
1771 .help_str = "set corelist|portlist x[,y]*",
1773 (void *)&cmd_set_list_keyword,
1774 (void *)&cmd_set_list_name,
1775 (void *)&cmd_set_list_of_items,
1780 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1782 struct cmd_setmask_result {
1783 cmdline_fixed_string_t set;
1784 cmdline_fixed_string_t mask;
1788 static void cmd_set_mask_parsed(void *parsed_result,
1789 __attribute__((unused)) struct cmdline *cl,
1790 __attribute__((unused)) void *data)
1792 struct cmd_setmask_result *res = parsed_result;
1794 if (!strcmp(res->mask, "coremask"))
1795 set_fwd_lcores_mask(res->hexavalue);
1796 else if (!strcmp(res->mask, "portmask"))
1797 set_fwd_ports_mask(res->hexavalue);
1800 cmdline_parse_token_string_t cmd_setmask_set =
1801 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1802 cmdline_parse_token_string_t cmd_setmask_mask =
1803 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1804 "coremask#portmask");
1805 cmdline_parse_token_num_t cmd_setmask_value =
1806 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1808 cmdline_parse_inst_t cmd_set_fwd_mask = {
1809 .f = cmd_set_mask_parsed,
1811 .help_str = "set coremask|portmask hexadecimal value",
1813 (void *)&cmd_setmask_set,
1814 (void *)&cmd_setmask_mask,
1815 (void *)&cmd_setmask_value,
1821 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1823 struct cmd_set_result {
1824 cmdline_fixed_string_t set;
1825 cmdline_fixed_string_t what;
1829 static void cmd_set_parsed(void *parsed_result,
1830 __attribute__((unused)) struct cmdline *cl,
1831 __attribute__((unused)) void *data)
1833 struct cmd_set_result *res = parsed_result;
1834 if (!strcmp(res->what, "nbport"))
1835 set_fwd_ports_number(res->value);
1836 else if (!strcmp(res->what, "nbcore"))
1837 set_fwd_lcores_number(res->value);
1838 else if (!strcmp(res->what, "burst"))
1839 set_nb_pkt_per_burst(res->value);
1840 else if (!strcmp(res->what, "verbose"))
1841 set_verbose_level(res->value);
1844 cmdline_parse_token_string_t cmd_set_set =
1845 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1846 cmdline_parse_token_string_t cmd_set_what =
1847 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1848 "nbport#nbcore#burst#verbose");
1849 cmdline_parse_token_num_t cmd_set_value =
1850 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1852 cmdline_parse_inst_t cmd_set_numbers = {
1853 .f = cmd_set_parsed,
1855 .help_str = "set nbport|nbcore|burst|verbose value",
1857 (void *)&cmd_set_set,
1858 (void *)&cmd_set_what,
1859 (void *)&cmd_set_value,
1864 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1866 struct cmd_set_txpkts_result {
1867 cmdline_fixed_string_t cmd_keyword;
1868 cmdline_fixed_string_t txpkts;
1869 cmdline_fixed_string_t seg_lengths;
1873 cmd_set_txpkts_parsed(void *parsed_result,
1874 __attribute__((unused)) struct cmdline *cl,
1875 __attribute__((unused)) void *data)
1877 struct cmd_set_txpkts_result *res;
1878 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1879 unsigned int nb_segs;
1881 res = parsed_result;
1882 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1883 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1885 set_tx_pkt_segments(seg_lengths, nb_segs);
1888 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1889 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1890 cmd_keyword, "set");
1891 cmdline_parse_token_string_t cmd_set_txpkts_name =
1892 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1894 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1898 cmdline_parse_inst_t cmd_set_txpkts = {
1899 .f = cmd_set_txpkts_parsed,
1901 .help_str = "set txpkts x[,y]*",
1903 (void *)&cmd_set_txpkts_keyword,
1904 (void *)&cmd_set_txpkts_name,
1905 (void *)&cmd_set_txpkts_lengths,
1910 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1911 struct cmd_rx_vlan_filter_all_result {
1912 cmdline_fixed_string_t rx_vlan;
1913 cmdline_fixed_string_t what;
1914 cmdline_fixed_string_t all;
1919 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1920 __attribute__((unused)) struct cmdline *cl,
1921 __attribute__((unused)) void *data)
1923 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1925 if (!strcmp(res->what, "add"))
1926 rx_vlan_all_filter_set(res->port_id, 1);
1928 rx_vlan_all_filter_set(res->port_id, 0);
1931 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1932 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1933 rx_vlan, "rx_vlan");
1934 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1935 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1937 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1938 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1940 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1941 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1944 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1945 .f = cmd_rx_vlan_filter_all_parsed,
1947 .help_str = "add/remove all identifiers to/from the set of VLAN "
1948 "Identifiers filtered by a port",
1950 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1951 (void *)&cmd_rx_vlan_filter_all_what,
1952 (void *)&cmd_rx_vlan_filter_all_all,
1953 (void *)&cmd_rx_vlan_filter_all_portid,
1958 /* *** VLAN OFFLOAD SET ON A PORT *** */
1959 struct cmd_vlan_offload_result {
1960 cmdline_fixed_string_t vlan;
1961 cmdline_fixed_string_t set;
1962 cmdline_fixed_string_t what;
1963 cmdline_fixed_string_t on;
1964 cmdline_fixed_string_t port_id;
1968 cmd_vlan_offload_parsed(void *parsed_result,
1969 __attribute__((unused)) struct cmdline *cl,
1970 __attribute__((unused)) void *data)
1973 struct cmd_vlan_offload_result *res = parsed_result;
1976 portid_t port_id = 0;
1980 len = strnlen(str, STR_TOKEN_SIZE);
1982 /* Get port_id first */
1990 tmp = strtoul(str, NULL, 0);
1991 /* If port_id greater that what portid_t can represent, return */
1992 if(tmp >= RTE_MAX_ETHPORTS)
1994 port_id = (portid_t)tmp;
1996 if (!strcmp(res->on, "on"))
2001 if (!strcmp(res->what, "strip"))
2002 rx_vlan_strip_set(port_id, on);
2003 else if(!strcmp(res->what, "stripq")){
2004 uint16_t queue_id = 0;
2006 /* No queue_id, return */
2009 tmp = strtoul(str + i + 1, NULL, 0);
2010 /* If queue_id greater that what 16-bits can represent, return */
2014 queue_id = (uint16_t)tmp;
2015 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2017 else if (!strcmp(res->what, "filter"))
2018 rx_vlan_filter_set(port_id, on);
2020 vlan_extend_set(port_id, on);
2025 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2028 cmdline_parse_token_string_t cmd_vlan_offload_set =
2029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2031 cmdline_parse_token_string_t cmd_vlan_offload_what =
2032 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2033 what, "strip#filter#qinq#stripq");
2034 cmdline_parse_token_string_t cmd_vlan_offload_on =
2035 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2037 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2038 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2041 cmdline_parse_inst_t cmd_vlan_offload = {
2042 .f = cmd_vlan_offload_parsed,
2044 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2045 " qinq(extended) for both rx/tx sides ",
2047 (void *)&cmd_vlan_offload_vlan,
2048 (void *)&cmd_vlan_offload_set,
2049 (void *)&cmd_vlan_offload_what,
2050 (void *)&cmd_vlan_offload_on,
2051 (void *)&cmd_vlan_offload_portid,
2056 /* *** VLAN TPID SET ON A PORT *** */
2057 struct cmd_vlan_tpid_result {
2058 cmdline_fixed_string_t vlan;
2059 cmdline_fixed_string_t set;
2060 cmdline_fixed_string_t what;
2066 cmd_vlan_tpid_parsed(void *parsed_result,
2067 __attribute__((unused)) struct cmdline *cl,
2068 __attribute__((unused)) void *data)
2070 struct cmd_vlan_tpid_result *res = parsed_result;
2071 vlan_tpid_set(res->port_id, res->tp_id);
2075 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2076 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2078 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2079 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2081 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2082 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2084 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2085 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2087 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2088 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2091 cmdline_parse_inst_t cmd_vlan_tpid = {
2092 .f = cmd_vlan_tpid_parsed,
2094 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2096 (void *)&cmd_vlan_tpid_vlan,
2097 (void *)&cmd_vlan_tpid_set,
2098 (void *)&cmd_vlan_tpid_what,
2099 (void *)&cmd_vlan_tpid_tpid,
2100 (void *)&cmd_vlan_tpid_portid,
2105 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2106 struct cmd_rx_vlan_filter_result {
2107 cmdline_fixed_string_t rx_vlan;
2108 cmdline_fixed_string_t what;
2114 cmd_rx_vlan_filter_parsed(void *parsed_result,
2115 __attribute__((unused)) struct cmdline *cl,
2116 __attribute__((unused)) void *data)
2118 struct cmd_rx_vlan_filter_result *res = parsed_result;
2120 if (!strcmp(res->what, "add"))
2121 rx_vft_set(res->port_id, res->vlan_id, 1);
2123 rx_vft_set(res->port_id, res->vlan_id, 0);
2126 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2128 rx_vlan, "rx_vlan");
2129 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2132 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2133 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2135 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2136 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2139 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2140 .f = cmd_rx_vlan_filter_parsed,
2142 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2143 "Identifiers filtered by a port",
2145 (void *)&cmd_rx_vlan_filter_rx_vlan,
2146 (void *)&cmd_rx_vlan_filter_what,
2147 (void *)&cmd_rx_vlan_filter_vlanid,
2148 (void *)&cmd_rx_vlan_filter_portid,
2153 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2154 struct cmd_tx_vlan_set_result {
2155 cmdline_fixed_string_t tx_vlan;
2156 cmdline_fixed_string_t set;
2162 cmd_tx_vlan_set_parsed(void *parsed_result,
2163 __attribute__((unused)) struct cmdline *cl,
2164 __attribute__((unused)) void *data)
2166 struct cmd_tx_vlan_set_result *res = parsed_result;
2167 tx_vlan_set(res->port_id, res->vlan_id);
2170 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2171 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2172 tx_vlan, "tx_vlan");
2173 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2174 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2176 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2177 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2179 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2180 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2183 cmdline_parse_inst_t cmd_tx_vlan_set = {
2184 .f = cmd_tx_vlan_set_parsed,
2186 .help_str = "enable hardware insertion of a VLAN header with a given "
2187 "TAG Identifier in packets sent on a port",
2189 (void *)&cmd_tx_vlan_set_tx_vlan,
2190 (void *)&cmd_tx_vlan_set_set,
2191 (void *)&cmd_tx_vlan_set_vlanid,
2192 (void *)&cmd_tx_vlan_set_portid,
2197 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2198 struct cmd_tx_vlan_reset_result {
2199 cmdline_fixed_string_t tx_vlan;
2200 cmdline_fixed_string_t reset;
2205 cmd_tx_vlan_reset_parsed(void *parsed_result,
2206 __attribute__((unused)) struct cmdline *cl,
2207 __attribute__((unused)) void *data)
2209 struct cmd_tx_vlan_reset_result *res = parsed_result;
2211 tx_vlan_reset(res->port_id);
2214 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2215 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2216 tx_vlan, "tx_vlan");
2217 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2220 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2221 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2224 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2225 .f = cmd_tx_vlan_reset_parsed,
2227 .help_str = "disable hardware insertion of a VLAN header in packets "
2230 (void *)&cmd_tx_vlan_reset_tx_vlan,
2231 (void *)&cmd_tx_vlan_reset_reset,
2232 (void *)&cmd_tx_vlan_reset_portid,
2238 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2239 struct cmd_tx_cksum_set_result {
2240 cmdline_fixed_string_t tx_cksum;
2241 cmdline_fixed_string_t set;
2247 cmd_tx_cksum_set_parsed(void *parsed_result,
2248 __attribute__((unused)) struct cmdline *cl,
2249 __attribute__((unused)) void *data)
2251 struct cmd_tx_cksum_set_result *res = parsed_result;
2253 tx_cksum_set(res->port_id, res->cksum_mask);
2256 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2257 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2258 tx_cksum, "tx_checksum");
2259 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2260 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2262 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2263 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2265 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2266 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2269 cmdline_parse_inst_t cmd_tx_cksum_set = {
2270 .f = cmd_tx_cksum_set_parsed,
2272 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2273 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2274 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2276 (void *)&cmd_tx_cksum_set_tx_cksum,
2277 (void *)&cmd_tx_cksum_set_set,
2278 (void *)&cmd_tx_cksum_set_cksum_mask,
2279 (void *)&cmd_tx_cksum_set_portid,
2284 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2285 struct cmd_set_flush_rx {
2286 cmdline_fixed_string_t set;
2287 cmdline_fixed_string_t flush_rx;
2288 cmdline_fixed_string_t mode;
2292 cmd_set_flush_rx_parsed(void *parsed_result,
2293 __attribute__((unused)) struct cmdline *cl,
2294 __attribute__((unused)) void *data)
2296 struct cmd_set_flush_rx *res = parsed_result;
2297 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2300 cmdline_parse_token_string_t cmd_setflushrx_set =
2301 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2303 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2304 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2305 flush_rx, "flush_rx");
2306 cmdline_parse_token_string_t cmd_setflushrx_mode =
2307 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2311 cmdline_parse_inst_t cmd_set_flush_rx = {
2312 .f = cmd_set_flush_rx_parsed,
2313 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2316 (void *)&cmd_setflushrx_set,
2317 (void *)&cmd_setflushrx_flush_rx,
2318 (void *)&cmd_setflushrx_mode,
2323 #ifdef RTE_NIC_BYPASS
2324 /* *** SET NIC BYPASS MODE *** */
2325 struct cmd_set_bypass_mode_result {
2326 cmdline_fixed_string_t set;
2327 cmdline_fixed_string_t bypass;
2328 cmdline_fixed_string_t mode;
2329 cmdline_fixed_string_t value;
2334 cmd_set_bypass_mode_parsed(void *parsed_result,
2335 __attribute__((unused)) struct cmdline *cl,
2336 __attribute__((unused)) void *data)
2338 struct cmd_set_bypass_mode_result *res = parsed_result;
2339 portid_t port_id = res->port_id;
2340 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2342 if (!bypass_is_supported(port_id))
2345 if (!strcmp(res->value, "bypass"))
2346 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2347 else if (!strcmp(res->value, "isolate"))
2348 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2350 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2352 /* Set the bypass mode for the relevant port. */
2353 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2354 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2358 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2359 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2361 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2362 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2364 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2365 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2367 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2368 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2369 value, "normal#bypass#isolate");
2370 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2371 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2374 cmdline_parse_inst_t cmd_set_bypass_mode = {
2375 .f = cmd_set_bypass_mode_parsed,
2376 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2377 "Set the NIC bypass mode for port_id",
2380 (void *)&cmd_setbypass_mode_set,
2381 (void *)&cmd_setbypass_mode_bypass,
2382 (void *)&cmd_setbypass_mode_mode,
2383 (void *)&cmd_setbypass_mode_value,
2384 (void *)&cmd_setbypass_mode_port,
2389 /* *** SET NIC BYPASS EVENT *** */
2390 struct cmd_set_bypass_event_result {
2391 cmdline_fixed_string_t set;
2392 cmdline_fixed_string_t bypass;
2393 cmdline_fixed_string_t event;
2394 cmdline_fixed_string_t event_value;
2395 cmdline_fixed_string_t mode;
2396 cmdline_fixed_string_t mode_value;
2401 cmd_set_bypass_event_parsed(void *parsed_result,
2402 __attribute__((unused)) struct cmdline *cl,
2403 __attribute__((unused)) void *data)
2406 struct cmd_set_bypass_event_result *res = parsed_result;
2407 portid_t port_id = res->port_id;
2408 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2409 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2411 if (!bypass_is_supported(port_id))
2414 if (!strcmp(res->event_value, "timeout"))
2415 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2416 else if (!strcmp(res->event_value, "os_on"))
2417 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2418 else if (!strcmp(res->event_value, "os_off"))
2419 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2420 else if (!strcmp(res->event_value, "power_on"))
2421 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2422 else if (!strcmp(res->event_value, "power_off"))
2423 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2425 bypass_event = RTE_BYPASS_EVENT_NONE;
2427 if (!strcmp(res->mode_value, "bypass"))
2428 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2429 else if (!strcmp(res->mode_value, "isolate"))
2430 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2432 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2434 /* Set the watchdog timeout. */
2435 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2438 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2439 (rc = rte_eth_dev_wd_timeout_store(port_id,
2440 bypass_timeout)) != 0) {
2441 printf("Failed to set timeout value %u "
2442 "for port %d, errto code: %d.\n",
2443 bypass_timeout, port_id, rc);
2447 /* Set the bypass event to transition to bypass mode. */
2448 if (0 != rte_eth_dev_bypass_event_store(port_id,
2449 bypass_event, bypass_mode)) {
2450 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2455 cmdline_parse_token_string_t cmd_setbypass_event_set =
2456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2458 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2461 cmdline_parse_token_string_t cmd_setbypass_event_event =
2462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2464 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2466 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2467 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2470 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2471 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2472 mode_value, "normal#bypass#isolate");
2473 cmdline_parse_token_num_t cmd_setbypass_event_port =
2474 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2477 cmdline_parse_inst_t cmd_set_bypass_event = {
2478 .f = cmd_set_bypass_event_parsed,
2479 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2480 "mode (normal|bypass|isolate) (port_id): "
2481 "Set the NIC bypass event mode for port_id",
2484 (void *)&cmd_setbypass_event_set,
2485 (void *)&cmd_setbypass_event_bypass,
2486 (void *)&cmd_setbypass_event_event,
2487 (void *)&cmd_setbypass_event_event_value,
2488 (void *)&cmd_setbypass_event_mode,
2489 (void *)&cmd_setbypass_event_mode_value,
2490 (void *)&cmd_setbypass_event_port,
2496 /* *** SET NIC BYPASS TIMEOUT *** */
2497 struct cmd_set_bypass_timeout_result {
2498 cmdline_fixed_string_t set;
2499 cmdline_fixed_string_t bypass;
2500 cmdline_fixed_string_t timeout;
2501 cmdline_fixed_string_t value;
2505 cmd_set_bypass_timeout_parsed(void *parsed_result,
2506 __attribute__((unused)) struct cmdline *cl,
2507 __attribute__((unused)) void *data)
2509 struct cmd_set_bypass_timeout_result *res = parsed_result;
2511 if (!strcmp(res->value, "1.5"))
2512 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2513 else if (!strcmp(res->value, "2"))
2514 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2515 else if (!strcmp(res->value, "3"))
2516 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2517 else if (!strcmp(res->value, "4"))
2518 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2519 else if (!strcmp(res->value, "8"))
2520 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2521 else if (!strcmp(res->value, "16"))
2522 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2523 else if (!strcmp(res->value, "32"))
2524 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2526 bypass_timeout = RTE_BYPASS_TMT_OFF;
2529 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2530 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2532 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2533 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2535 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2536 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2537 timeout, "timeout");
2538 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2539 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2540 value, "0#1.5#2#3#4#8#16#32");
2542 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2543 .f = cmd_set_bypass_timeout_parsed,
2544 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2545 "Set the NIC bypass watchdog timeout",
2548 (void *)&cmd_setbypass_timeout_set,
2549 (void *)&cmd_setbypass_timeout_bypass,
2550 (void *)&cmd_setbypass_timeout_timeout,
2551 (void *)&cmd_setbypass_timeout_value,
2556 /* *** SHOW NIC BYPASS MODE *** */
2557 struct cmd_show_bypass_config_result {
2558 cmdline_fixed_string_t show;
2559 cmdline_fixed_string_t bypass;
2560 cmdline_fixed_string_t config;
2565 cmd_show_bypass_config_parsed(void *parsed_result,
2566 __attribute__((unused)) struct cmdline *cl,
2567 __attribute__((unused)) void *data)
2569 struct cmd_show_bypass_config_result *res = parsed_result;
2570 uint32_t event_mode;
2571 uint32_t bypass_mode;
2572 portid_t port_id = res->port_id;
2573 uint32_t timeout = bypass_timeout;
2576 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2577 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2578 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2579 {"UNKNOWN", "normal", "bypass", "isolate"};
2580 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2587 int num_events = (sizeof events) / (sizeof events[0]);
2589 if (!bypass_is_supported(port_id))
2592 /* Display the bypass mode.*/
2593 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2594 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2598 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2599 bypass_mode = RTE_BYPASS_MODE_NONE;
2601 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2604 /* Display the bypass timeout.*/
2605 if (!RTE_BYPASS_TMT_VALID(timeout))
2606 timeout = RTE_BYPASS_TMT_OFF;
2608 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2610 /* Display the bypass events and associated modes. */
2611 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2613 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2614 printf("\tFailed to get bypass mode for event = %s\n",
2617 if (!RTE_BYPASS_MODE_VALID(event_mode))
2618 event_mode = RTE_BYPASS_MODE_NONE;
2620 printf("\tbypass event: %-16s = %s\n", events[i],
2626 cmdline_parse_token_string_t cmd_showbypass_config_show =
2627 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2629 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2630 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2632 cmdline_parse_token_string_t cmd_showbypass_config_config =
2633 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2635 cmdline_parse_token_num_t cmd_showbypass_config_port =
2636 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2639 cmdline_parse_inst_t cmd_show_bypass_config = {
2640 .f = cmd_show_bypass_config_parsed,
2641 .help_str = "show bypass config (port_id): "
2642 "Show the NIC bypass config for port_id",
2645 (void *)&cmd_showbypass_config_show,
2646 (void *)&cmd_showbypass_config_bypass,
2647 (void *)&cmd_showbypass_config_config,
2648 (void *)&cmd_showbypass_config_port,
2654 /* *** SET FORWARDING MODE *** */
2655 struct cmd_set_fwd_mode_result {
2656 cmdline_fixed_string_t set;
2657 cmdline_fixed_string_t fwd;
2658 cmdline_fixed_string_t mode;
2661 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2662 __attribute__((unused)) struct cmdline *cl,
2663 __attribute__((unused)) void *data)
2665 struct cmd_set_fwd_mode_result *res = parsed_result;
2667 set_pkt_forwarding_mode(res->mode);
2670 cmdline_parse_token_string_t cmd_setfwd_set =
2671 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2672 cmdline_parse_token_string_t cmd_setfwd_fwd =
2673 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2674 cmdline_parse_token_string_t cmd_setfwd_mode =
2675 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2676 #ifdef RTE_LIBRTE_IEEE1588
2677 "io#mac#rxonly#txonly#csum#ieee1588");
2679 "io#mac#rxonly#txonly#csum");
2682 cmdline_parse_inst_t cmd_set_fwd_mode = {
2683 .f = cmd_set_fwd_mode_parsed,
2685 #ifdef RTE_LIBRTE_IEEE1588
2686 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2687 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2689 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2690 " RXONLY, CSUM or TXONLY packet forwarding mode",
2693 (void *)&cmd_setfwd_set,
2694 (void *)&cmd_setfwd_fwd,
2695 (void *)&cmd_setfwd_mode,
2700 /* *** SET PROMISC MODE *** */
2701 struct cmd_set_promisc_mode_result {
2702 cmdline_fixed_string_t set;
2703 cmdline_fixed_string_t promisc;
2704 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2705 uint8_t port_num; /* valid if "allports" argument == 0 */
2706 cmdline_fixed_string_t mode;
2709 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2710 __attribute__((unused)) struct cmdline *cl,
2713 struct cmd_set_promisc_mode_result *res = parsed_result;
2717 if (!strcmp(res->mode, "on"))
2724 for (i = 0; i < nb_ports; i++) {
2726 rte_eth_promiscuous_enable(i);
2728 rte_eth_promiscuous_disable(i);
2733 rte_eth_promiscuous_enable(res->port_num);
2735 rte_eth_promiscuous_disable(res->port_num);
2739 cmdline_parse_token_string_t cmd_setpromisc_set =
2740 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2741 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2742 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2744 cmdline_parse_token_string_t cmd_setpromisc_portall =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2747 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2748 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2750 cmdline_parse_token_string_t cmd_setpromisc_mode =
2751 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2754 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2755 .f = cmd_set_promisc_mode_parsed,
2757 .help_str = "set promisc all on|off: set promisc mode for all ports",
2759 (void *)&cmd_setpromisc_set,
2760 (void *)&cmd_setpromisc_promisc,
2761 (void *)&cmd_setpromisc_portall,
2762 (void *)&cmd_setpromisc_mode,
2767 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2768 .f = cmd_set_promisc_mode_parsed,
2770 .help_str = "set promisc X on|off: set promisc mode on port X",
2772 (void *)&cmd_setpromisc_set,
2773 (void *)&cmd_setpromisc_promisc,
2774 (void *)&cmd_setpromisc_portnum,
2775 (void *)&cmd_setpromisc_mode,
2780 /* *** SET ALLMULTI MODE *** */
2781 struct cmd_set_allmulti_mode_result {
2782 cmdline_fixed_string_t set;
2783 cmdline_fixed_string_t allmulti;
2784 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2785 uint8_t port_num; /* valid if "allports" argument == 0 */
2786 cmdline_fixed_string_t mode;
2789 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2790 __attribute__((unused)) struct cmdline *cl,
2793 struct cmd_set_allmulti_mode_result *res = parsed_result;
2797 if (!strcmp(res->mode, "on"))
2804 for (i = 0; i < nb_ports; i++) {
2806 rte_eth_allmulticast_enable(i);
2808 rte_eth_allmulticast_disable(i);
2813 rte_eth_allmulticast_enable(res->port_num);
2815 rte_eth_allmulticast_disable(res->port_num);
2819 cmdline_parse_token_string_t cmd_setallmulti_set =
2820 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2821 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2822 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2824 cmdline_parse_token_string_t cmd_setallmulti_portall =
2825 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2827 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2828 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2830 cmdline_parse_token_string_t cmd_setallmulti_mode =
2831 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2834 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2835 .f = cmd_set_allmulti_mode_parsed,
2837 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2839 (void *)&cmd_setallmulti_set,
2840 (void *)&cmd_setallmulti_allmulti,
2841 (void *)&cmd_setallmulti_portall,
2842 (void *)&cmd_setallmulti_mode,
2847 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2848 .f = cmd_set_allmulti_mode_parsed,
2850 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2852 (void *)&cmd_setallmulti_set,
2853 (void *)&cmd_setallmulti_allmulti,
2854 (void *)&cmd_setallmulti_portnum,
2855 (void *)&cmd_setallmulti_mode,
2860 /* *** ADD/REMOVE A PKT FILTER *** */
2861 struct cmd_pkt_filter_result {
2862 cmdline_fixed_string_t pkt_filter;
2864 cmdline_fixed_string_t protocol;
2865 cmdline_fixed_string_t src;
2866 cmdline_ipaddr_t ip_src;
2868 cmdline_fixed_string_t dst;
2869 cmdline_ipaddr_t ip_dst;
2871 cmdline_fixed_string_t flexbytes;
2872 uint16_t flexbytes_value;
2873 cmdline_fixed_string_t vlan;
2875 cmdline_fixed_string_t queue;
2877 cmdline_fixed_string_t soft;
2882 cmd_pkt_filter_parsed(void *parsed_result,
2883 __attribute__((unused)) struct cmdline *cl,
2884 __attribute__((unused)) void *data)
2886 struct rte_fdir_filter fdir_filter;
2887 struct cmd_pkt_filter_result *res = parsed_result;
2889 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2891 if (res->ip_src.family == AF_INET)
2892 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2894 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2895 &(res->ip_src.addr.ipv6),
2896 sizeof(struct in6_addr));
2898 if (res->ip_dst.family == AF_INET)
2899 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2901 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2902 &(res->ip_dst.addr.ipv6),
2903 sizeof(struct in6_addr));
2905 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2906 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2908 if (!strcmp(res->protocol, "udp"))
2909 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2910 else if (!strcmp(res->protocol, "tcp"))
2911 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2912 else if (!strcmp(res->protocol, "sctp"))
2913 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2914 else /* default only IP */
2915 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2917 if (res->ip_dst.family == AF_INET6)
2918 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2920 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2922 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2923 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2925 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2926 fdir_add_signature_filter(res->port_id, res->queue_id,
2928 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2929 fdir_update_signature_filter(res->port_id, res->queue_id,
2931 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2932 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2933 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2934 fdir_add_perfect_filter(res->port_id, res->soft_id,
2936 (uint8_t) (res->queue_id < 0),
2938 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2939 fdir_update_perfect_filter(res->port_id, res->soft_id,
2941 (uint8_t) (res->queue_id < 0),
2943 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2944 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2950 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2951 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2953 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2954 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2955 protocol, "ip#tcp#udp#sctp");
2956 cmdline_parse_token_string_t cmd_pkt_filter_src =
2957 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2959 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2960 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2962 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2963 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2965 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2966 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2968 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2969 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2971 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2972 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2974 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2975 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2976 flexbytes, "flexbytes");
2977 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2978 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2979 flexbytes_value, UINT16);
2980 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2981 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2983 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2984 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2986 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2987 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2989 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2990 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2992 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2993 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2995 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2996 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3000 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3001 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3002 pkt_filter, "add_signature_filter");
3003 cmdline_parse_inst_t cmd_add_signature_filter = {
3004 .f = cmd_pkt_filter_parsed,
3006 .help_str = "add a signature filter",
3008 (void *)&cmd_pkt_filter_add_signature_filter,
3009 (void *)&cmd_pkt_filter_port_id,
3010 (void *)&cmd_pkt_filter_protocol,
3011 (void *)&cmd_pkt_filter_src,
3012 (void *)&cmd_pkt_filter_ip_src,
3013 (void *)&cmd_pkt_filter_port_src,
3014 (void *)&cmd_pkt_filter_dst,
3015 (void *)&cmd_pkt_filter_ip_dst,
3016 (void *)&cmd_pkt_filter_port_dst,
3017 (void *)&cmd_pkt_filter_flexbytes,
3018 (void *)&cmd_pkt_filter_flexbytes_value,
3019 (void *)&cmd_pkt_filter_vlan,
3020 (void *)&cmd_pkt_filter_vlan_id,
3021 (void *)&cmd_pkt_filter_queue,
3022 (void *)&cmd_pkt_filter_queue_id,
3028 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3029 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3030 pkt_filter, "upd_signature_filter");
3031 cmdline_parse_inst_t cmd_upd_signature_filter = {
3032 .f = cmd_pkt_filter_parsed,
3034 .help_str = "update a signature filter",
3036 (void *)&cmd_pkt_filter_upd_signature_filter,
3037 (void *)&cmd_pkt_filter_port_id,
3038 (void *)&cmd_pkt_filter_protocol,
3039 (void *)&cmd_pkt_filter_src,
3040 (void *)&cmd_pkt_filter_ip_src,
3041 (void *)&cmd_pkt_filter_port_src,
3042 (void *)&cmd_pkt_filter_dst,
3043 (void *)&cmd_pkt_filter_ip_dst,
3044 (void *)&cmd_pkt_filter_port_dst,
3045 (void *)&cmd_pkt_filter_flexbytes,
3046 (void *)&cmd_pkt_filter_flexbytes_value,
3047 (void *)&cmd_pkt_filter_vlan,
3048 (void *)&cmd_pkt_filter_vlan_id,
3049 (void *)&cmd_pkt_filter_queue,
3050 (void *)&cmd_pkt_filter_queue_id,
3056 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3057 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3058 pkt_filter, "rm_signature_filter");
3059 cmdline_parse_inst_t cmd_rm_signature_filter = {
3060 .f = cmd_pkt_filter_parsed,
3062 .help_str = "remove a signature filter",
3064 (void *)&cmd_pkt_filter_rm_signature_filter,
3065 (void *)&cmd_pkt_filter_port_id,
3066 (void *)&cmd_pkt_filter_protocol,
3067 (void *)&cmd_pkt_filter_src,
3068 (void *)&cmd_pkt_filter_ip_src,
3069 (void *)&cmd_pkt_filter_port_src,
3070 (void *)&cmd_pkt_filter_dst,
3071 (void *)&cmd_pkt_filter_ip_dst,
3072 (void *)&cmd_pkt_filter_port_dst,
3073 (void *)&cmd_pkt_filter_flexbytes,
3074 (void *)&cmd_pkt_filter_flexbytes_value,
3075 (void *)&cmd_pkt_filter_vlan,
3076 (void *)&cmd_pkt_filter_vlan_id,
3082 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3083 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3084 pkt_filter, "add_perfect_filter");
3085 cmdline_parse_inst_t cmd_add_perfect_filter = {
3086 .f = cmd_pkt_filter_parsed,
3088 .help_str = "add a perfect filter",
3090 (void *)&cmd_pkt_filter_add_perfect_filter,
3091 (void *)&cmd_pkt_filter_port_id,
3092 (void *)&cmd_pkt_filter_protocol,
3093 (void *)&cmd_pkt_filter_src,
3094 (void *)&cmd_pkt_filter_ip_src,
3095 (void *)&cmd_pkt_filter_port_src,
3096 (void *)&cmd_pkt_filter_dst,
3097 (void *)&cmd_pkt_filter_ip_dst,
3098 (void *)&cmd_pkt_filter_port_dst,
3099 (void *)&cmd_pkt_filter_flexbytes,
3100 (void *)&cmd_pkt_filter_flexbytes_value,
3101 (void *)&cmd_pkt_filter_vlan,
3102 (void *)&cmd_pkt_filter_vlan_id,
3103 (void *)&cmd_pkt_filter_queue,
3104 (void *)&cmd_pkt_filter_queue_id,
3105 (void *)&cmd_pkt_filter_soft,
3106 (void *)&cmd_pkt_filter_soft_id,
3112 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3113 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3114 pkt_filter, "upd_perfect_filter");
3115 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3116 .f = cmd_pkt_filter_parsed,
3118 .help_str = "update a perfect filter",
3120 (void *)&cmd_pkt_filter_upd_perfect_filter,
3121 (void *)&cmd_pkt_filter_port_id,
3122 (void *)&cmd_pkt_filter_protocol,
3123 (void *)&cmd_pkt_filter_src,
3124 (void *)&cmd_pkt_filter_ip_src,
3125 (void *)&cmd_pkt_filter_port_src,
3126 (void *)&cmd_pkt_filter_dst,
3127 (void *)&cmd_pkt_filter_ip_dst,
3128 (void *)&cmd_pkt_filter_port_dst,
3129 (void *)&cmd_pkt_filter_flexbytes,
3130 (void *)&cmd_pkt_filter_flexbytes_value,
3131 (void *)&cmd_pkt_filter_vlan,
3132 (void *)&cmd_pkt_filter_vlan_id,
3133 (void *)&cmd_pkt_filter_queue,
3134 (void *)&cmd_pkt_filter_queue_id,
3135 (void *)&cmd_pkt_filter_soft,
3136 (void *)&cmd_pkt_filter_soft_id,
3142 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3143 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3144 pkt_filter, "rm_perfect_filter");
3145 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3146 .f = cmd_pkt_filter_parsed,
3148 .help_str = "remove a perfect filter",
3150 (void *)&cmd_pkt_filter_rm_perfect_filter,
3151 (void *)&cmd_pkt_filter_port_id,
3152 (void *)&cmd_pkt_filter_protocol,
3153 (void *)&cmd_pkt_filter_src,
3154 (void *)&cmd_pkt_filter_ip_src,
3155 (void *)&cmd_pkt_filter_port_src,
3156 (void *)&cmd_pkt_filter_dst,
3157 (void *)&cmd_pkt_filter_ip_dst,
3158 (void *)&cmd_pkt_filter_port_dst,
3159 (void *)&cmd_pkt_filter_flexbytes,
3160 (void *)&cmd_pkt_filter_flexbytes_value,
3161 (void *)&cmd_pkt_filter_vlan,
3162 (void *)&cmd_pkt_filter_vlan_id,
3163 (void *)&cmd_pkt_filter_soft,
3164 (void *)&cmd_pkt_filter_soft_id,
3169 /* *** SETUP MASKS FILTER *** */
3170 struct cmd_pkt_filter_masks_result {
3171 cmdline_fixed_string_t filter_mask;
3173 cmdline_fixed_string_t src_mask;
3174 uint32_t ip_src_mask;
3175 uint16_t ipv6_src_mask;
3176 uint16_t port_src_mask;
3177 cmdline_fixed_string_t dst_mask;
3178 uint32_t ip_dst_mask;
3179 uint16_t ipv6_dst_mask;
3180 uint16_t port_dst_mask;
3181 cmdline_fixed_string_t flexbytes;
3182 uint8_t flexbytes_value;
3183 cmdline_fixed_string_t vlan_id;
3184 uint8_t vlan_id_value;
3185 cmdline_fixed_string_t vlan_prio;
3186 uint8_t vlan_prio_value;
3187 cmdline_fixed_string_t only_ip_flow;
3188 uint8_t only_ip_flow_value;
3189 cmdline_fixed_string_t comp_ipv6_dst;
3190 uint8_t comp_ipv6_dst_value;
3194 cmd_pkt_filter_masks_parsed(void *parsed_result,
3195 __attribute__((unused)) struct cmdline *cl,
3196 __attribute__((unused)) void *data)
3198 struct rte_fdir_masks fdir_masks;
3199 struct cmd_pkt_filter_masks_result *res = parsed_result;
3201 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3203 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3204 fdir_masks.vlan_id = res->vlan_id_value;
3205 fdir_masks.vlan_prio = res->vlan_prio_value;
3206 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3207 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3208 fdir_masks.src_port_mask = res->port_src_mask;
3209 fdir_masks.dst_port_mask = res->port_dst_mask;
3210 fdir_masks.flexbytes = res->flexbytes_value;
3212 fdir_set_masks(res->port_id, &fdir_masks);
3215 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3216 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3217 filter_mask, "set_masks_filter");
3218 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3221 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3222 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3223 only_ip_flow, "only_ip_flow");
3224 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3225 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3226 only_ip_flow_value, UINT8);
3227 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3228 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3229 src_mask, "src_mask");
3230 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3231 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3232 ip_src_mask, UINT32);
3233 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3234 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3235 port_src_mask, UINT16);
3236 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3237 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3238 dst_mask, "dst_mask");
3239 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3240 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3241 ip_dst_mask, UINT32);
3242 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3243 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3244 port_dst_mask, UINT16);
3245 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3246 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3247 flexbytes, "flexbytes");
3248 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3249 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3250 flexbytes_value, UINT8);
3251 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3252 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3253 vlan_id, "vlan_id");
3254 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3255 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3256 vlan_id_value, UINT8);
3257 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3258 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3259 vlan_prio, "vlan_prio");
3260 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3261 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3262 vlan_prio_value, UINT8);
3264 cmdline_parse_inst_t cmd_set_masks_filter = {
3265 .f = cmd_pkt_filter_masks_parsed,
3267 .help_str = "setup masks filter",
3269 (void *)&cmd_pkt_filter_masks_filter_mask,
3270 (void *)&cmd_pkt_filter_masks_port_id,
3271 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3272 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3273 (void *)&cmd_pkt_filter_masks_src_mask,
3274 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3275 (void *)&cmd_pkt_filter_masks_port_src_mask,
3276 (void *)&cmd_pkt_filter_masks_dst_mask,
3277 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3278 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3279 (void *)&cmd_pkt_filter_masks_flexbytes,
3280 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3281 (void *)&cmd_pkt_filter_masks_vlan_id,
3282 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3283 (void *)&cmd_pkt_filter_masks_vlan_prio,
3284 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3290 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3291 __attribute__((unused)) struct cmdline *cl,
3292 __attribute__((unused)) void *data)
3294 struct rte_fdir_masks fdir_masks;
3295 struct cmd_pkt_filter_masks_result *res = parsed_result;
3297 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3299 fdir_masks.set_ipv6_mask = 1;
3300 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3301 fdir_masks.vlan_id = res->vlan_id_value;
3302 fdir_masks.vlan_prio = res->vlan_prio_value;
3303 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3304 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3305 fdir_masks.src_port_mask = res->port_src_mask;
3306 fdir_masks.dst_port_mask = res->port_dst_mask;
3307 fdir_masks.flexbytes = res->flexbytes_value;
3308 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3310 fdir_set_masks(res->port_id, &fdir_masks);
3313 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3314 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3315 filter_mask, "set_ipv6_masks_filter");
3316 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3317 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3318 ipv6_src_mask, UINT16);
3319 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3320 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3321 ipv6_dst_mask, UINT16);
3323 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3324 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3325 comp_ipv6_dst, "compare_dst");
3326 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3327 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3328 comp_ipv6_dst_value, UINT8);
3330 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3331 .f = cmd_pkt_filter_masks_ipv6_parsed,
3333 .help_str = "setup ipv6 masks filter",
3335 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3336 (void *)&cmd_pkt_filter_masks_port_id,
3337 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3338 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3339 (void *)&cmd_pkt_filter_masks_src_mask,
3340 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3341 (void *)&cmd_pkt_filter_masks_port_src_mask,
3342 (void *)&cmd_pkt_filter_masks_dst_mask,
3343 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3344 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3345 (void *)&cmd_pkt_filter_masks_flexbytes,
3346 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3347 (void *)&cmd_pkt_filter_masks_vlan_id,
3348 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3349 (void *)&cmd_pkt_filter_masks_vlan_prio,
3350 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3351 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3352 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3357 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3358 struct cmd_link_flow_ctrl_set_result {
3359 cmdline_fixed_string_t set;
3360 cmdline_fixed_string_t flow_ctrl;
3361 cmdline_fixed_string_t rx;
3362 cmdline_fixed_string_t rx_lfc_mode;
3363 cmdline_fixed_string_t tx;
3364 cmdline_fixed_string_t tx_lfc_mode;
3365 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3366 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3367 uint32_t high_water;
3369 uint16_t pause_time;
3375 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3376 __attribute__((unused)) struct cmdline *cl,
3377 __attribute__((unused)) void *data)
3379 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3380 struct rte_eth_fc_conf fc_conf;
3381 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3385 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3386 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3387 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3388 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3390 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3391 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3394 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3395 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3396 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3398 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3399 fc_conf.high_water = res->high_water;
3400 fc_conf.low_water = res->low_water;
3401 fc_conf.pause_time = res->pause_time;
3402 fc_conf.send_xon = res->send_xon;
3403 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3405 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3407 printf("bad flow contrl parameter, return code = %d \n", ret);
3410 cmdline_parse_token_string_t cmd_lfc_set_set =
3411 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3413 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3414 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3415 flow_ctrl, "flow_ctrl");
3416 cmdline_parse_token_string_t cmd_lfc_set_rx =
3417 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3419 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3420 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3421 rx_lfc_mode, "on#off");
3422 cmdline_parse_token_string_t cmd_lfc_set_tx =
3423 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3425 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3426 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3427 tx_lfc_mode, "on#off");
3428 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3429 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3430 high_water, UINT32);
3431 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3432 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3434 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3435 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3436 pause_time, UINT16);
3437 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3438 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3440 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3441 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3442 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3443 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3444 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3445 mac_ctrl_frame_fwd_mode, "on#off");
3446 cmdline_parse_token_num_t cmd_lfc_set_portid =
3447 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3450 cmdline_parse_inst_t cmd_link_flow_control_set = {
3451 .f = cmd_link_flow_ctrl_set_parsed,
3453 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3454 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3457 (void *)&cmd_lfc_set_set,
3458 (void *)&cmd_lfc_set_flow_ctrl,
3459 (void *)&cmd_lfc_set_rx,
3460 (void *)&cmd_lfc_set_rx_mode,
3461 (void *)&cmd_lfc_set_tx,
3462 (void *)&cmd_lfc_set_tx_mode,
3463 (void *)&cmd_lfc_set_high_water,
3464 (void *)&cmd_lfc_set_low_water,
3465 (void *)&cmd_lfc_set_pause_time,
3466 (void *)&cmd_lfc_set_send_xon,
3467 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3468 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3469 (void *)&cmd_lfc_set_portid,
3474 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3475 struct cmd_priority_flow_ctrl_set_result {
3476 cmdline_fixed_string_t set;
3477 cmdline_fixed_string_t pfc_ctrl;
3478 cmdline_fixed_string_t rx;
3479 cmdline_fixed_string_t rx_pfc_mode;
3480 cmdline_fixed_string_t tx;
3481 cmdline_fixed_string_t tx_pfc_mode;
3482 uint32_t high_water;
3484 uint16_t pause_time;
3490 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3491 __attribute__((unused)) struct cmdline *cl,
3492 __attribute__((unused)) void *data)
3494 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3495 struct rte_eth_pfc_conf pfc_conf;
3496 int rx_fc_enable, tx_fc_enable;
3500 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3501 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3502 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3503 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3505 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3506 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3509 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3510 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3511 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3512 pfc_conf.fc.high_water = res->high_water;
3513 pfc_conf.fc.low_water = res->low_water;
3514 pfc_conf.fc.pause_time = res->pause_time;
3515 pfc_conf.priority = res->priority;
3517 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3519 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3522 cmdline_parse_token_string_t cmd_pfc_set_set =
3523 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3525 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3526 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3527 pfc_ctrl, "pfc_ctrl");
3528 cmdline_parse_token_string_t cmd_pfc_set_rx =
3529 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3531 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3532 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3533 rx_pfc_mode, "on#off");
3534 cmdline_parse_token_string_t cmd_pfc_set_tx =
3535 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3537 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3538 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3539 tx_pfc_mode, "on#off");
3540 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3541 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3542 high_water, UINT32);
3543 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3544 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3546 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3547 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3548 pause_time, UINT16);
3549 cmdline_parse_token_num_t cmd_pfc_set_priority =
3550 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3552 cmdline_parse_token_num_t cmd_pfc_set_portid =
3553 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3556 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3557 .f = cmd_priority_flow_ctrl_set_parsed,
3559 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3560 tx on|off high_water low_water pause_time priority port_id",
3562 (void *)&cmd_pfc_set_set,
3563 (void *)&cmd_pfc_set_flow_ctrl,
3564 (void *)&cmd_pfc_set_rx,
3565 (void *)&cmd_pfc_set_rx_mode,
3566 (void *)&cmd_pfc_set_tx,
3567 (void *)&cmd_pfc_set_tx_mode,
3568 (void *)&cmd_pfc_set_high_water,
3569 (void *)&cmd_pfc_set_low_water,
3570 (void *)&cmd_pfc_set_pause_time,
3571 (void *)&cmd_pfc_set_priority,
3572 (void *)&cmd_pfc_set_portid,
3577 /* *** RESET CONFIGURATION *** */
3578 struct cmd_reset_result {
3579 cmdline_fixed_string_t reset;
3580 cmdline_fixed_string_t def;
3583 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3585 __attribute__((unused)) void *data)
3587 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3588 set_def_fwd_config();
3591 cmdline_parse_token_string_t cmd_reset_set =
3592 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3593 cmdline_parse_token_string_t cmd_reset_def =
3594 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3597 cmdline_parse_inst_t cmd_reset = {
3598 .f = cmd_reset_parsed,
3600 .help_str = "set default: reset default forwarding configuration",
3602 (void *)&cmd_reset_set,
3603 (void *)&cmd_reset_def,
3608 /* *** START FORWARDING *** */
3609 struct cmd_start_result {
3610 cmdline_fixed_string_t start;
3613 cmdline_parse_token_string_t cmd_start_start =
3614 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3616 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3617 __attribute__((unused)) struct cmdline *cl,
3618 __attribute__((unused)) void *data)
3620 start_packet_forwarding(0);
3623 cmdline_parse_inst_t cmd_start = {
3624 .f = cmd_start_parsed,
3626 .help_str = "start packet forwarding",
3628 (void *)&cmd_start_start,
3633 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3634 struct cmd_start_tx_first_result {
3635 cmdline_fixed_string_t start;
3636 cmdline_fixed_string_t tx_first;
3640 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3641 __attribute__((unused)) struct cmdline *cl,
3642 __attribute__((unused)) void *data)
3644 start_packet_forwarding(1);
3647 cmdline_parse_token_string_t cmd_start_tx_first_start =
3648 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3650 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3651 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3652 tx_first, "tx_first");
3654 cmdline_parse_inst_t cmd_start_tx_first = {
3655 .f = cmd_start_tx_first_parsed,
3657 .help_str = "start packet forwarding, after sending 1 burst of packets",
3659 (void *)&cmd_start_tx_first_start,
3660 (void *)&cmd_start_tx_first_tx_first,
3665 /* *** SHOW CFG *** */
3666 struct cmd_showcfg_result {
3667 cmdline_fixed_string_t show;
3668 cmdline_fixed_string_t cfg;
3669 cmdline_fixed_string_t what;
3672 static void cmd_showcfg_parsed(void *parsed_result,
3673 __attribute__((unused)) struct cmdline *cl,
3674 __attribute__((unused)) void *data)
3676 struct cmd_showcfg_result *res = parsed_result;
3677 if (!strcmp(res->what, "rxtx"))
3678 rxtx_config_display();
3679 else if (!strcmp(res->what, "cores"))
3680 fwd_lcores_config_display();
3681 else if (!strcmp(res->what, "fwd"))
3682 fwd_config_display();
3685 cmdline_parse_token_string_t cmd_showcfg_show =
3686 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3687 cmdline_parse_token_string_t cmd_showcfg_port =
3688 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3689 cmdline_parse_token_string_t cmd_showcfg_what =
3690 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3693 cmdline_parse_inst_t cmd_showcfg = {
3694 .f = cmd_showcfg_parsed,
3696 .help_str = "show config rxtx|cores|fwd",
3698 (void *)&cmd_showcfg_show,
3699 (void *)&cmd_showcfg_port,
3700 (void *)&cmd_showcfg_what,
3705 /* *** SHOW ALL PORT INFO *** */
3706 struct cmd_showportall_result {
3707 cmdline_fixed_string_t show;
3708 cmdline_fixed_string_t port;
3709 cmdline_fixed_string_t what;
3710 cmdline_fixed_string_t all;
3713 static void cmd_showportall_parsed(void *parsed_result,
3714 __attribute__((unused)) struct cmdline *cl,
3715 __attribute__((unused)) void *data)
3719 struct cmd_showportall_result *res = parsed_result;
3720 if (!strcmp(res->show, "clear")) {
3721 if (!strcmp(res->what, "stats"))
3722 for (i = 0; i < nb_ports; i++)
3724 } else if (!strcmp(res->what, "info"))
3725 for (i = 0; i < nb_ports; i++)
3726 port_infos_display(i);
3727 else if (!strcmp(res->what, "stats"))
3728 for (i = 0; i < nb_ports; i++)
3729 nic_stats_display(i);
3730 else if (!strcmp(res->what, "fdir"))
3731 for (i = 0; i < nb_ports; i++)
3733 else if (!strcmp(res->what, "stat_qmap"))
3734 for (i = 0; i < nb_ports; i++)
3735 nic_stats_mapping_display(i);
3738 cmdline_parse_token_string_t cmd_showportall_show =
3739 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3741 cmdline_parse_token_string_t cmd_showportall_port =
3742 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3743 cmdline_parse_token_string_t cmd_showportall_what =
3744 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3745 "info#stats#fdir#stat_qmap");
3746 cmdline_parse_token_string_t cmd_showportall_all =
3747 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3748 cmdline_parse_inst_t cmd_showportall = {
3749 .f = cmd_showportall_parsed,
3751 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3753 (void *)&cmd_showportall_show,
3754 (void *)&cmd_showportall_port,
3755 (void *)&cmd_showportall_what,
3756 (void *)&cmd_showportall_all,
3761 /* *** SHOW PORT INFO *** */
3762 struct cmd_showport_result {
3763 cmdline_fixed_string_t show;
3764 cmdline_fixed_string_t port;
3765 cmdline_fixed_string_t what;
3769 static void cmd_showport_parsed(void *parsed_result,
3770 __attribute__((unused)) struct cmdline *cl,
3771 __attribute__((unused)) void *data)
3773 struct cmd_showport_result *res = parsed_result;
3774 if (!strcmp(res->show, "clear")) {
3775 if (!strcmp(res->what, "stats"))
3776 nic_stats_clear(res->portnum);
3777 } else if (!strcmp(res->what, "info"))
3778 port_infos_display(res->portnum);
3779 else if (!strcmp(res->what, "stats"))
3780 nic_stats_display(res->portnum);
3781 else if (!strcmp(res->what, "fdir"))
3782 fdir_get_infos(res->portnum);
3783 else if (!strcmp(res->what, "stat_qmap"))
3784 nic_stats_mapping_display(res->portnum);
3787 cmdline_parse_token_string_t cmd_showport_show =
3788 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3790 cmdline_parse_token_string_t cmd_showport_port =
3791 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3792 cmdline_parse_token_string_t cmd_showport_what =
3793 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3794 "info#stats#fdir#stat_qmap");
3795 cmdline_parse_token_num_t cmd_showport_portnum =
3796 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3798 cmdline_parse_inst_t cmd_showport = {
3799 .f = cmd_showport_parsed,
3801 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3803 (void *)&cmd_showport_show,
3804 (void *)&cmd_showport_port,
3805 (void *)&cmd_showport_what,
3806 (void *)&cmd_showport_portnum,
3811 /* *** READ PORT REGISTER *** */
3812 struct cmd_read_reg_result {
3813 cmdline_fixed_string_t read;
3814 cmdline_fixed_string_t reg;
3820 cmd_read_reg_parsed(void *parsed_result,
3821 __attribute__((unused)) struct cmdline *cl,
3822 __attribute__((unused)) void *data)
3824 struct cmd_read_reg_result *res = parsed_result;
3825 port_reg_display(res->port_id, res->reg_off);
3828 cmdline_parse_token_string_t cmd_read_reg_read =
3829 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3830 cmdline_parse_token_string_t cmd_read_reg_reg =
3831 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3832 cmdline_parse_token_num_t cmd_read_reg_port_id =
3833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3834 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3835 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3837 cmdline_parse_inst_t cmd_read_reg = {
3838 .f = cmd_read_reg_parsed,
3840 .help_str = "read reg port_id reg_off",
3842 (void *)&cmd_read_reg_read,
3843 (void *)&cmd_read_reg_reg,
3844 (void *)&cmd_read_reg_port_id,
3845 (void *)&cmd_read_reg_reg_off,
3850 /* *** READ PORT REGISTER BIT FIELD *** */
3851 struct cmd_read_reg_bit_field_result {
3852 cmdline_fixed_string_t read;
3853 cmdline_fixed_string_t regfield;
3861 cmd_read_reg_bit_field_parsed(void *parsed_result,
3862 __attribute__((unused)) struct cmdline *cl,
3863 __attribute__((unused)) void *data)
3865 struct cmd_read_reg_bit_field_result *res = parsed_result;
3866 port_reg_bit_field_display(res->port_id, res->reg_off,
3867 res->bit1_pos, res->bit2_pos);
3870 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3871 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3873 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3874 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3875 regfield, "regfield");
3876 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3877 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3879 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3880 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3882 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3883 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3885 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3889 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3890 .f = cmd_read_reg_bit_field_parsed,
3892 .help_str = "read regfield port_id reg_off bit_x bit_y "
3893 "(read register bit field between bit_x and bit_y included)",
3895 (void *)&cmd_read_reg_bit_field_read,
3896 (void *)&cmd_read_reg_bit_field_regfield,
3897 (void *)&cmd_read_reg_bit_field_port_id,
3898 (void *)&cmd_read_reg_bit_field_reg_off,
3899 (void *)&cmd_read_reg_bit_field_bit1_pos,
3900 (void *)&cmd_read_reg_bit_field_bit2_pos,
3905 /* *** READ PORT REGISTER BIT *** */
3906 struct cmd_read_reg_bit_result {
3907 cmdline_fixed_string_t read;
3908 cmdline_fixed_string_t regbit;
3915 cmd_read_reg_bit_parsed(void *parsed_result,
3916 __attribute__((unused)) struct cmdline *cl,
3917 __attribute__((unused)) void *data)
3919 struct cmd_read_reg_bit_result *res = parsed_result;
3920 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3923 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3924 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3925 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3926 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3928 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3929 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3930 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3931 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3932 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3933 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3935 cmdline_parse_inst_t cmd_read_reg_bit = {
3936 .f = cmd_read_reg_bit_parsed,
3938 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3940 (void *)&cmd_read_reg_bit_read,
3941 (void *)&cmd_read_reg_bit_regbit,
3942 (void *)&cmd_read_reg_bit_port_id,
3943 (void *)&cmd_read_reg_bit_reg_off,
3944 (void *)&cmd_read_reg_bit_bit_pos,
3949 /* *** WRITE PORT REGISTER *** */
3950 struct cmd_write_reg_result {
3951 cmdline_fixed_string_t write;
3952 cmdline_fixed_string_t reg;
3959 cmd_write_reg_parsed(void *parsed_result,
3960 __attribute__((unused)) struct cmdline *cl,
3961 __attribute__((unused)) void *data)
3963 struct cmd_write_reg_result *res = parsed_result;
3964 port_reg_set(res->port_id, res->reg_off, res->value);
3967 cmdline_parse_token_string_t cmd_write_reg_write =
3968 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3969 cmdline_parse_token_string_t cmd_write_reg_reg =
3970 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3971 cmdline_parse_token_num_t cmd_write_reg_port_id =
3972 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3973 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3975 cmdline_parse_token_num_t cmd_write_reg_value =
3976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3978 cmdline_parse_inst_t cmd_write_reg = {
3979 .f = cmd_write_reg_parsed,
3981 .help_str = "write reg port_id reg_off reg_value",
3983 (void *)&cmd_write_reg_write,
3984 (void *)&cmd_write_reg_reg,
3985 (void *)&cmd_write_reg_port_id,
3986 (void *)&cmd_write_reg_reg_off,
3987 (void *)&cmd_write_reg_value,
3992 /* *** WRITE PORT REGISTER BIT FIELD *** */
3993 struct cmd_write_reg_bit_field_result {
3994 cmdline_fixed_string_t write;
3995 cmdline_fixed_string_t regfield;
4004 cmd_write_reg_bit_field_parsed(void *parsed_result,
4005 __attribute__((unused)) struct cmdline *cl,
4006 __attribute__((unused)) void *data)
4008 struct cmd_write_reg_bit_field_result *res = parsed_result;
4009 port_reg_bit_field_set(res->port_id, res->reg_off,
4010 res->bit1_pos, res->bit2_pos, res->value);
4013 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4014 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4016 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4017 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4018 regfield, "regfield");
4019 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4020 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4022 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4023 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4025 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4026 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4028 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4031 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4032 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4035 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4036 .f = cmd_write_reg_bit_field_parsed,
4038 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4039 "(set register bit field between bit_x and bit_y included)",
4041 (void *)&cmd_write_reg_bit_field_write,
4042 (void *)&cmd_write_reg_bit_field_regfield,
4043 (void *)&cmd_write_reg_bit_field_port_id,
4044 (void *)&cmd_write_reg_bit_field_reg_off,
4045 (void *)&cmd_write_reg_bit_field_bit1_pos,
4046 (void *)&cmd_write_reg_bit_field_bit2_pos,
4047 (void *)&cmd_write_reg_bit_field_value,
4052 /* *** WRITE PORT REGISTER BIT *** */
4053 struct cmd_write_reg_bit_result {
4054 cmdline_fixed_string_t write;
4055 cmdline_fixed_string_t regbit;
4063 cmd_write_reg_bit_parsed(void *parsed_result,
4064 __attribute__((unused)) struct cmdline *cl,
4065 __attribute__((unused)) void *data)
4067 struct cmd_write_reg_bit_result *res = parsed_result;
4068 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4071 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4072 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4074 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4075 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4077 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4078 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4079 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4080 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4081 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4082 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4083 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4084 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4086 cmdline_parse_inst_t cmd_write_reg_bit = {
4087 .f = cmd_write_reg_bit_parsed,
4089 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4091 (void *)&cmd_write_reg_bit_write,
4092 (void *)&cmd_write_reg_bit_regbit,
4093 (void *)&cmd_write_reg_bit_port_id,
4094 (void *)&cmd_write_reg_bit_reg_off,
4095 (void *)&cmd_write_reg_bit_bit_pos,
4096 (void *)&cmd_write_reg_bit_value,
4101 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4102 struct cmd_read_rxd_txd_result {
4103 cmdline_fixed_string_t read;
4104 cmdline_fixed_string_t rxd_txd;
4111 cmd_read_rxd_txd_parsed(void *parsed_result,
4112 __attribute__((unused)) struct cmdline *cl,
4113 __attribute__((unused)) void *data)
4115 struct cmd_read_rxd_txd_result *res = parsed_result;
4117 if (!strcmp(res->rxd_txd, "rxd"))
4118 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4119 else if (!strcmp(res->rxd_txd, "txd"))
4120 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4123 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4124 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4125 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4126 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4128 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4129 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4130 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4131 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4132 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4133 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4135 cmdline_parse_inst_t cmd_read_rxd_txd = {
4136 .f = cmd_read_rxd_txd_parsed,
4138 .help_str = "read rxd|txd port_id queue_id rxd_id",
4140 (void *)&cmd_read_rxd_txd_read,
4141 (void *)&cmd_read_rxd_txd_rxd_txd,
4142 (void *)&cmd_read_rxd_txd_port_id,
4143 (void *)&cmd_read_rxd_txd_queue_id,
4144 (void *)&cmd_read_rxd_txd_desc_id,
4150 struct cmd_quit_result {
4151 cmdline_fixed_string_t quit;
4154 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4156 __attribute__((unused)) void *data)
4162 cmdline_parse_token_string_t cmd_quit_quit =
4163 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4165 cmdline_parse_inst_t cmd_quit = {
4166 .f = cmd_quit_parsed,
4168 .help_str = "exit application",
4170 (void *)&cmd_quit_quit,
4175 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4176 struct cmd_mac_addr_result {
4177 cmdline_fixed_string_t mac_addr_cmd;
4178 cmdline_fixed_string_t what;
4180 struct ether_addr address;
4183 static void cmd_mac_addr_parsed(void *parsed_result,
4184 __attribute__((unused)) struct cmdline *cl,
4185 __attribute__((unused)) void *data)
4187 struct cmd_mac_addr_result *res = parsed_result;
4190 if (strcmp(res->what, "add") == 0)
4191 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4193 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4195 /* check the return value and print it if is < 0 */
4197 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4201 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4202 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4204 cmdline_parse_token_string_t cmd_mac_addr_what =
4205 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4207 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4208 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4209 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4210 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4212 cmdline_parse_inst_t cmd_mac_addr = {
4213 .f = cmd_mac_addr_parsed,
4215 .help_str = "mac_addr add|remove X <address>: "
4216 "add/remove MAC address on port X",
4218 (void *)&cmd_mac_addr_cmd,
4219 (void *)&cmd_mac_addr_what,
4220 (void *)&cmd_mac_addr_portnum,
4221 (void *)&cmd_mac_addr_addr,
4227 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4228 struct cmd_set_qmap_result {
4229 cmdline_fixed_string_t set;
4230 cmdline_fixed_string_t qmap;
4231 cmdline_fixed_string_t what;
4238 cmd_set_qmap_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4240 __attribute__((unused)) void *data)
4242 struct cmd_set_qmap_result *res = parsed_result;
4243 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4245 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4248 cmdline_parse_token_string_t cmd_setqmap_set =
4249 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4251 cmdline_parse_token_string_t cmd_setqmap_qmap =
4252 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4254 cmdline_parse_token_string_t cmd_setqmap_what =
4255 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4257 cmdline_parse_token_num_t cmd_setqmap_portid =
4258 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4260 cmdline_parse_token_num_t cmd_setqmap_queueid =
4261 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4263 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4264 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4267 cmdline_parse_inst_t cmd_set_qmap = {
4268 .f = cmd_set_qmap_parsed,
4270 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4272 (void *)&cmd_setqmap_set,
4273 (void *)&cmd_setqmap_qmap,
4274 (void *)&cmd_setqmap_what,
4275 (void *)&cmd_setqmap_portid,
4276 (void *)&cmd_setqmap_queueid,
4277 (void *)&cmd_setqmap_mapvalue,
4282 /* *** CONFIGURE UNICAST HASH TABLE *** */
4283 struct cmd_set_uc_hash_table {
4284 cmdline_fixed_string_t set;
4285 cmdline_fixed_string_t port;
4287 cmdline_fixed_string_t what;
4288 struct ether_addr address;
4289 cmdline_fixed_string_t mode;
4293 cmd_set_uc_hash_parsed(void *parsed_result,
4294 __attribute__((unused)) struct cmdline *cl,
4295 __attribute__((unused)) void *data)
4298 struct cmd_set_uc_hash_table *res = parsed_result;
4300 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4302 if (strcmp(res->what, "uta") == 0)
4303 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4304 &res->address,(uint8_t)is_on);
4306 printf("bad unicast hash table parameter, return code = %d \n", ret);
4310 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4311 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4313 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4314 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4316 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4317 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4319 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4322 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4323 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4325 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4326 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4329 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4330 .f = cmd_set_uc_hash_parsed,
4332 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4334 (void *)&cmd_set_uc_hash_set,
4335 (void *)&cmd_set_uc_hash_port,
4336 (void *)&cmd_set_uc_hash_portid,
4337 (void *)&cmd_set_uc_hash_what,
4338 (void *)&cmd_set_uc_hash_mac,
4339 (void *)&cmd_set_uc_hash_mode,
4344 struct cmd_set_uc_all_hash_table {
4345 cmdline_fixed_string_t set;
4346 cmdline_fixed_string_t port;
4348 cmdline_fixed_string_t what;
4349 cmdline_fixed_string_t value;
4350 cmdline_fixed_string_t mode;
4354 cmd_set_uc_all_hash_parsed(void *parsed_result,
4355 __attribute__((unused)) struct cmdline *cl,
4356 __attribute__((unused)) void *data)
4359 struct cmd_set_uc_all_hash_table *res = parsed_result;
4361 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4363 if ((strcmp(res->what, "uta") == 0) &&
4364 (strcmp(res->value, "all") == 0))
4365 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4367 printf("bad unicast hash table parameter,"
4368 "return code = %d \n", ret);
4371 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4372 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4374 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4375 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4377 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4378 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4380 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4381 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4383 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4384 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4386 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4390 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4391 .f = cmd_set_uc_all_hash_parsed,
4393 .help_str = "set port X uta all on|off (X = port number)",
4395 (void *)&cmd_set_uc_all_hash_set,
4396 (void *)&cmd_set_uc_all_hash_port,
4397 (void *)&cmd_set_uc_all_hash_portid,
4398 (void *)&cmd_set_uc_all_hash_what,
4399 (void *)&cmd_set_uc_all_hash_value,
4400 (void *)&cmd_set_uc_all_hash_mode,
4405 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4406 struct cmd_set_vf_traffic {
4407 cmdline_fixed_string_t set;
4408 cmdline_fixed_string_t port;
4410 cmdline_fixed_string_t vf;
4412 cmdline_fixed_string_t what;
4413 cmdline_fixed_string_t mode;
4417 cmd_set_vf_traffic_parsed(void *parsed_result,
4418 __attribute__((unused)) struct cmdline *cl,
4419 __attribute__((unused)) void *data)
4421 struct cmd_set_vf_traffic *res = parsed_result;
4422 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4423 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4425 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4428 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4431 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4434 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4435 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4437 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4440 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4441 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4443 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4444 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4446 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4447 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4450 cmdline_parse_inst_t cmd_set_vf_traffic = {
4451 .f = cmd_set_vf_traffic_parsed,
4453 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4455 (void *)&cmd_setvf_traffic_set,
4456 (void *)&cmd_setvf_traffic_port,
4457 (void *)&cmd_setvf_traffic_portid,
4458 (void *)&cmd_setvf_traffic_vf,
4459 (void *)&cmd_setvf_traffic_vfid,
4460 (void *)&cmd_setvf_traffic_what,
4461 (void *)&cmd_setvf_traffic_mode,
4466 /* *** CONFIGURE VF RECEIVE MODE *** */
4467 struct cmd_set_vf_rxmode {
4468 cmdline_fixed_string_t set;
4469 cmdline_fixed_string_t port;
4471 cmdline_fixed_string_t vf;
4473 cmdline_fixed_string_t what;
4474 cmdline_fixed_string_t mode;
4475 cmdline_fixed_string_t on;
4479 cmd_set_vf_rxmode_parsed(void *parsed_result,
4480 __attribute__((unused)) struct cmdline *cl,
4481 __attribute__((unused)) void *data)
4484 uint16_t rx_mode = 0;
4485 struct cmd_set_vf_rxmode *res = parsed_result;
4487 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4488 if (!strcmp(res->what,"rxmode")) {
4489 if (!strcmp(res->mode, "AUPE"))
4490 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4491 else if (!strcmp(res->mode, "ROPE"))
4492 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4493 else if (!strcmp(res->mode, "BAM"))
4494 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4495 else if (!strncmp(res->mode, "MPE",3))
4496 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4499 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4501 printf("bad VF receive mode parameter, return code = %d \n",
4505 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4506 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4508 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4511 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4512 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4514 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4515 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4517 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4518 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4520 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4523 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4525 mode, "AUPE#ROPE#BAM#MPE");
4526 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4530 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4531 .f = cmd_set_vf_rxmode_parsed,
4533 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4535 (void *)&cmd_set_vf_rxmode_set,
4536 (void *)&cmd_set_vf_rxmode_port,
4537 (void *)&cmd_set_vf_rxmode_portid,
4538 (void *)&cmd_set_vf_rxmode_vf,
4539 (void *)&cmd_set_vf_rxmode_vfid,
4540 (void *)&cmd_set_vf_rxmode_what,
4541 (void *)&cmd_set_vf_rxmode_mode,
4542 (void *)&cmd_set_vf_rxmode_on,
4547 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4548 struct cmd_vf_mac_addr_result {
4549 cmdline_fixed_string_t mac_addr_cmd;
4550 cmdline_fixed_string_t what;
4551 cmdline_fixed_string_t port;
4553 cmdline_fixed_string_t vf;
4555 struct ether_addr address;
4558 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4559 __attribute__((unused)) struct cmdline *cl,
4560 __attribute__((unused)) void *data)
4562 struct cmd_vf_mac_addr_result *res = parsed_result;
4565 if (strcmp(res->what, "add") == 0)
4566 ret = rte_eth_dev_mac_addr_add(res->port_num,
4567 &res->address, res->vf_num);
4569 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4573 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4574 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4575 mac_addr_cmd,"mac_addr");
4576 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4577 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4579 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4580 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4582 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4583 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4585 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4586 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4588 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4589 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4591 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4592 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4595 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4596 .f = cmd_vf_mac_addr_parsed,
4598 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4599 "Y = VF number)add MAC address filtering for a VF on port X",
4601 (void *)&cmd_vf_mac_addr_cmd,
4602 (void *)&cmd_vf_mac_addr_what,
4603 (void *)&cmd_vf_mac_addr_port,
4604 (void *)&cmd_vf_mac_addr_portnum,
4605 (void *)&cmd_vf_mac_addr_vf,
4606 (void *)&cmd_vf_mac_addr_vfnum,
4607 (void *)&cmd_vf_mac_addr_addr,
4612 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4613 struct cmd_vf_rx_vlan_filter {
4614 cmdline_fixed_string_t rx_vlan;
4615 cmdline_fixed_string_t what;
4617 cmdline_fixed_string_t port;
4619 cmdline_fixed_string_t vf;
4624 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4625 __attribute__((unused)) struct cmdline *cl,
4626 __attribute__((unused)) void *data)
4628 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4630 if (!strcmp(res->what, "add"))
4631 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4633 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4636 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4637 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4638 rx_vlan, "rx_vlan");
4639 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4640 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4642 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4643 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4645 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4646 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4648 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4649 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4651 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4652 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4654 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4655 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4658 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4659 .f = cmd_vf_rx_vlan_filter_parsed,
4661 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4662 "Y = port number,Z = hexadecimal VF mask)",
4664 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4665 (void *)&cmd_vf_rx_vlan_filter_what,
4666 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4667 (void *)&cmd_vf_rx_vlan_filter_port,
4668 (void *)&cmd_vf_rx_vlan_filter_portid,
4669 (void *)&cmd_vf_rx_vlan_filter_vf,
4670 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4675 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4676 struct cmd_set_mirror_mask_result {
4677 cmdline_fixed_string_t set;
4678 cmdline_fixed_string_t port;
4680 cmdline_fixed_string_t mirror;
4682 cmdline_fixed_string_t what;
4683 cmdline_fixed_string_t value;
4684 cmdline_fixed_string_t dstpool;
4686 cmdline_fixed_string_t on;
4689 cmdline_parse_token_string_t cmd_mirror_mask_set =
4690 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4692 cmdline_parse_token_string_t cmd_mirror_mask_port =
4693 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4695 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4696 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4698 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4699 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4700 mirror, "mirror-rule");
4701 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4702 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4704 cmdline_parse_token_string_t cmd_mirror_mask_what =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4706 what, "pool-mirror#vlan-mirror");
4707 cmdline_parse_token_string_t cmd_mirror_mask_value =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4710 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4712 dstpool, "dst-pool");
4713 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4714 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4716 cmdline_parse_token_string_t cmd_mirror_mask_on =
4717 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4721 cmd_set_mirror_mask_parsed(void *parsed_result,
4722 __attribute__((unused)) struct cmdline *cl,
4723 __attribute__((unused)) void *data)
4726 struct cmd_set_mirror_mask_result *res = parsed_result;
4727 struct rte_eth_vmdq_mirror_conf mr_conf;
4729 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4731 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4733 mr_conf.dst_pool = res->dstpool_id;
4735 if (!strcmp(res->what, "pool-mirror")) {
4736 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4737 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4738 } else if(!strcmp(res->what, "vlan-mirror")) {
4739 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4740 nb_item = parse_item_list(res->value, "core",
4741 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4745 for(i=0; i < nb_item; i++) {
4746 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4747 printf("Invalid vlan_id: must be < 4096\n");
4751 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4752 mr_conf.vlan.vlan_mask |= 1ULL << i;
4756 if(!strcmp(res->on, "on"))
4757 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4760 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4763 printf("mirror rule add error: (%s)\n", strerror(-ret));
4766 cmdline_parse_inst_t cmd_set_mirror_mask = {
4767 .f = cmd_set_mirror_mask_parsed,
4769 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4770 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4772 (void *)&cmd_mirror_mask_set,
4773 (void *)&cmd_mirror_mask_port,
4774 (void *)&cmd_mirror_mask_portid,
4775 (void *)&cmd_mirror_mask_mirror,
4776 (void *)&cmd_mirror_mask_ruleid,
4777 (void *)&cmd_mirror_mask_what,
4778 (void *)&cmd_mirror_mask_value,
4779 (void *)&cmd_mirror_mask_dstpool,
4780 (void *)&cmd_mirror_mask_poolid,
4781 (void *)&cmd_mirror_mask_on,
4786 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4787 struct cmd_set_mirror_link_result {
4788 cmdline_fixed_string_t set;
4789 cmdline_fixed_string_t port;
4791 cmdline_fixed_string_t mirror;
4793 cmdline_fixed_string_t what;
4794 cmdline_fixed_string_t dstpool;
4796 cmdline_fixed_string_t on;
4799 cmdline_parse_token_string_t cmd_mirror_link_set =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4802 cmdline_parse_token_string_t cmd_mirror_link_port =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4805 cmdline_parse_token_string_t cmd_mirror_link_portid =
4806 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4808 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4809 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4810 mirror, "mirror-rule");
4811 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4812 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4814 cmdline_parse_token_string_t cmd_mirror_link_what =
4815 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4816 what, "uplink-mirror#downlink-mirror");
4817 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4818 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4819 dstpool, "dst-pool");
4820 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4821 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4823 cmdline_parse_token_string_t cmd_mirror_link_on =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4828 cmd_set_mirror_link_parsed(void *parsed_result,
4829 __attribute__((unused)) struct cmdline *cl,
4830 __attribute__((unused)) void *data)
4833 struct cmd_set_mirror_link_result *res = parsed_result;
4834 struct rte_eth_vmdq_mirror_conf mr_conf;
4836 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4837 if(!strcmp(res->what, "uplink-mirror")) {
4838 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4839 }else if(!strcmp(res->what, "downlink-mirror"))
4840 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4842 mr_conf.dst_pool = res->dstpool_id;
4844 if(!strcmp(res->on, "on"))
4845 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4848 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4851 /* check the return value and print it if is < 0 */
4853 printf("mirror rule add error: (%s)\n", strerror(-ret));
4857 cmdline_parse_inst_t cmd_set_mirror_link = {
4858 .f = cmd_set_mirror_link_parsed,
4860 .help_str = "set port X mirror-rule Y uplink-mirror|"
4861 "downlink-mirror dst-pool Z on|off",
4863 (void *)&cmd_mirror_link_set,
4864 (void *)&cmd_mirror_link_port,
4865 (void *)&cmd_mirror_link_portid,
4866 (void *)&cmd_mirror_link_mirror,
4867 (void *)&cmd_mirror_link_ruleid,
4868 (void *)&cmd_mirror_link_what,
4869 (void *)&cmd_mirror_link_dstpool,
4870 (void *)&cmd_mirror_link_poolid,
4871 (void *)&cmd_mirror_link_on,
4876 /* *** RESET VM MIRROR RULE *** */
4877 struct cmd_rm_mirror_rule_result {
4878 cmdline_fixed_string_t reset;
4879 cmdline_fixed_string_t port;
4881 cmdline_fixed_string_t mirror;
4885 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4886 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4888 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4889 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4891 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4892 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4894 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4895 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4896 mirror, "mirror-rule");
4897 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4898 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4902 cmd_reset_mirror_rule_parsed(void *parsed_result,
4903 __attribute__((unused)) struct cmdline *cl,
4904 __attribute__((unused)) void *data)
4907 struct cmd_set_mirror_link_result *res = parsed_result;
4909 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4911 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4914 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4915 .f = cmd_reset_mirror_rule_parsed,
4917 .help_str = "reset port X mirror-rule Y",
4919 (void *)&cmd_rm_mirror_rule_reset,
4920 (void *)&cmd_rm_mirror_rule_port,
4921 (void *)&cmd_rm_mirror_rule_portid,
4922 (void *)&cmd_rm_mirror_rule_mirror,
4923 (void *)&cmd_rm_mirror_rule_ruleid,
4928 /* ******************************************************************************** */
4930 /* list of instructions */
4931 cmdline_parse_ctx_t main_ctx[] = {
4932 (cmdline_parse_inst_t *)&cmd_help_brief,
4933 (cmdline_parse_inst_t *)&cmd_help_long,
4934 (cmdline_parse_inst_t *)&cmd_quit,
4935 (cmdline_parse_inst_t *)&cmd_showport,
4936 (cmdline_parse_inst_t *)&cmd_showportall,
4937 (cmdline_parse_inst_t *)&cmd_showcfg,
4938 (cmdline_parse_inst_t *)&cmd_start,
4939 (cmdline_parse_inst_t *)&cmd_start_tx_first,
4940 (cmdline_parse_inst_t *)&cmd_reset,
4941 (cmdline_parse_inst_t *)&cmd_set_numbers,
4942 (cmdline_parse_inst_t *)&cmd_set_txpkts,
4943 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4944 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4945 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4946 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4947 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4948 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4949 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4950 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4951 #ifdef RTE_NIC_BYPASS
4952 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
4953 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
4954 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
4955 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
4957 (cmdline_parse_inst_t *)&cmd_vlan_offload,
4958 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4959 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4960 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4961 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4962 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4963 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4964 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4965 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4966 (cmdline_parse_inst_t *)&cmd_config_dcb,
4967 (cmdline_parse_inst_t *)&cmd_read_reg,
4968 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4969 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4970 (cmdline_parse_inst_t *)&cmd_write_reg,
4971 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4972 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4973 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4974 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4975 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4976 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4977 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4978 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4979 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4980 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4981 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4982 (cmdline_parse_inst_t *)&cmd_stop,
4983 (cmdline_parse_inst_t *)&cmd_mac_addr,
4984 (cmdline_parse_inst_t *)&cmd_set_qmap,
4985 (cmdline_parse_inst_t *)&cmd_operate_port,
4986 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4987 (cmdline_parse_inst_t *)&cmd_config_speed_all,
4988 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4989 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4990 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
4991 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
4992 (cmdline_parse_inst_t *)&cmd_config_rss,
4993 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
4994 (cmdline_parse_inst_t *)&cmd_showport_reta,
4995 (cmdline_parse_inst_t *)&cmd_config_burst,
4996 (cmdline_parse_inst_t *)&cmd_config_thresh,
4997 (cmdline_parse_inst_t *)&cmd_config_threshold,
4998 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
4999 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5000 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5001 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5002 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5003 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5004 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5005 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5006 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5010 /* prompt function, called from main on MASTER lcore */
5016 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5020 cmdline_interact(cl);
5021 cmdline_stdin_exit(cl);
5025 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5027 if (id < nb_ports) {
5028 /* check if need_reconfig has been set to 1 */
5029 if (ports[id].need_reconfig == 0)
5030 ports[id].need_reconfig = dev;
5031 /* check if need_reconfig_queues has been set to 1 */
5032 if (ports[id].need_reconfig_queues == 0)
5033 ports[id].need_reconfig_queues = queue;
5037 for (pid = 0; pid < nb_ports; pid++) {
5038 /* check if need_reconfig has been set to 1 */
5039 if (ports[pid].need_reconfig == 0)
5040 ports[pid].need_reconfig = dev;
5041 /* check if need_reconfig_queues has been set to 1 */
5042 if (ports[pid].need_reconfig_queues == 0)
5043 ports[pid].need_reconfig_queues = queue;
5048 #ifdef RTE_NIC_BYPASS
5050 bypass_is_supported(portid_t port_id)
5052 struct rte_port *port;
5053 struct rte_pci_id *pci_id;
5055 if (port_id >= nb_ports) {
5056 printf("\tPort id must be less than %d.\n", nb_ports);
5060 /* Get the device id. */
5061 port = &ports[port_id];
5062 pci_id = &port->dev_info.pci_dev->id;
5064 /* Check if NIC supports bypass. */
5065 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5069 printf("\tBypass not supported for port_id = %d.\n", port_id);