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 stripq (on|off) (port_id,queue_id)\n"
237 " Set the VLAN strip for a queue on a port.\n\n"
239 "vlan set filter (on|off) (port_id)\n"
240 " Set the VLAN filter on a port.\n\n"
242 "vlan set qinq (on|off) (port_id)\n"
243 " Set the VLAN QinQ (extended queue in queue)"
246 "vlan set tpid (value) (port_id)\n"
247 " Set the outer VLAN TPID for Packet Filtering on"
250 "rx_vlan add (vlan_id|all) (port_id)\n"
251 " Add a vlan_id, or all identifiers, to the set"
252 " of VLAN identifiers filtered by port_id.\n\n"
254 "rx_vlan rm (vlan_id|all) (port_id)\n"
255 " Remove a vlan_id, or all identifiers, from the set"
256 " of VLAN identifiers filtered by port_id.\n\n"
258 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
259 " Add a vlan_id, to the set of VLAN identifiers"
260 "filtered for VF(s) from port_id.\n\n"
262 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
263 " Remove a vlan_id, to the set of VLAN identifiers"
264 "filtered for VF(s) from port_id.\n\n"
266 "rx_vlan set tpid (value) (port_id)\n"
267 " Set the outer VLAN TPID for Packet Filtering on"
270 "tx_vlan set vlan_id (port_id)\n"
271 " Set hardware insertion of VLAN ID in packets sent"
274 "tx_vlan reset (port_id)\n"
275 " Disable hardware insertion of a VLAN header in"
276 " packets sent on a port.\n\n"
278 "tx_checksum set mask (port_id)\n"
279 " Enable hardware insertion of checksum offload with"
280 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
281 " bit 0 - insert ip checksum offload if set\n"
282 " bit 1 - insert udp checksum offload if set\n"
283 " bit 2 - insert tcp checksum offload if set\n"
284 " bit 3 - insert sctp checksum offload if set\n"
285 " Please check the NIC datasheet for HW limits.\n\n"
287 #ifdef RTE_LIBRTE_IEEE1588
288 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
289 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
290 " packet forwarding mode.\n\n"
293 "set fwd (io|mac|rxonly|txonly|csum)\n"
294 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
295 " forwarding mode.\n\n"
298 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
299 " Add a MAC address on port_id.\n\n"
301 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
302 " Remove a MAC address from port_id.\n\n"
304 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
305 " Add a MAC address for a VF on the port.\n\n"
307 "set port (port_id) uta (mac_address|all) (on|off)\n"
308 " Add/Remove a or all unicast hash filter(s)"
311 "set promisc (port_id|all) (on|off)\n"
312 " Set the promiscuous mode on port_id, or all.\n\n"
314 "set allmulti (port_id|all) (on|off)\n"
315 " Set the allmulti mode on port_id, or all.\n\n"
317 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
318 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
319 " (on|off) (port_id)\n"
320 " Set the link flow control parameter on a port.\n\n"
322 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
323 " (low_water) (pause_time) (priority) (port_id)\n"
324 " Set the priority flow control parameter on a"
327 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
328 " Set statistics mapping (qmapping 0..15) for RX/TX"
330 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
331 " on port 0 to mapping 5.\n\n"
333 "set port (port_id) vf (vf_id) rx|tx on|off \n"
334 " Enable/Disable a VF receive/tranmit from a port\n\n"
336 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
338 " AUPE:accepts untagged VLAN;"
339 "ROPE:accept unicast hash\n\n"
340 " BAM:accepts broadcast packets;"
341 "MPE:accepts all multicast packets\n\n"
342 " Enable/Disable a VF receive mode of a port\n\n"
344 "set port (port_id) mirror-rule (rule_id)"
345 "(pool-mirror|vlan-mirror)\n"
346 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
347 " Set pool or vlan type mirror rule on a port.\n"
348 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
349 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
352 "set port (port_id) mirror-rule (rule_id)"
353 " (uplink-mirror|downlink-mirror) dst-pool"
354 " (pool_id) (on|off)\n"
355 " Set uplink or downlink type mirror rule on a port.\n"
356 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
357 " 0 on' enable mirror income traffic to pool 0.\n\n"
359 "reset port (port_id) mirror-rule (rule_id)\n"
360 " Reset a mirror rule.\n\n"
362 "set flush_rx (on|off)\n"
363 " Flush (default) or don't flush RX streams before"
364 " forwarding. Mainly used with PCAP drivers.\n\n"
366 #ifdef RTE_NIC_BYPASS
367 "set bypass mode (normal|bypass|isolate) (port_id)\n"
368 " Set the bypass mode for the lowest port on bypass enabled"
371 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
372 "mode (normal|bypass|isolate) (port_id)\n"
373 " Set the event required to initiate specified bypass mode for"
374 " the lowest port on a bypass enabled NIC where:\n"
375 " timeout = enable bypass after watchdog timeout.\n"
376 " os_on = enable bypass when OS/board is powered on.\n"
377 " os_off = enable bypass when OS/board is powered off.\n"
378 " power_on = enable bypass when power supply is turned on.\n"
379 " power_off = enable bypass when power supply is turned off."
382 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
383 " Set the bypass watchdog timeout to 'n' seconds"
384 " where 0 = instant.\n\n"
386 "show bypass config (port_id)\n"
387 " Show the bypass configuration for a bypass enabled NIC"
388 " using the lowest port on the NIC.\n\n"
395 if (show_all || !strcmp(res->section, "flowdir")) {
400 "Flow director mode:\n"
401 "-------------------\n\n"
403 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
404 " src (src_ip_address) (src_port)"
405 " dst (dst_ip_address) (dst_port)"
406 " flexbytes (flexbytes_values) vlan (vlan_id)"
407 " queue (queue_id)\n"
408 " Add a signature filter.\n\n"
410 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
411 " src (src_ip_address) (src_port)"
412 " dst (dst_ip_address) (dst_port)"
413 " flexbytes (flexbytes_values) vlan (vlan_id)"
414 " queue (queue_id)\n"
415 " Update a signature filter.\n\n"
417 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
418 " src (src_ip_address) (src_port)"
419 " dst (dst_ip_address) (dst_port)"
420 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
421 " Remove a signature filter.\n\n"
423 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
424 " src (src_ip_address) (src_port)"
425 " dst (dst_ip_address) (dst_port)"
426 " flexbytes (flexbytes_values) vlan (vlan_id)"
427 " queue (queue_id) soft (soft_id)\n"
428 " Add a perfect filter.\n\n"
430 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
431 " src (src_ip_address) (src_port)"
432 " dst (dst_ip_address) (dst_port)"
433 " flexbytes (flexbytes_values) vlan (vlan_id)"
434 " queue (queue_id)\n"
435 " Update a perfect filter.\n\n"
437 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
438 " src (src_ip_address) (src_port)"
439 " dst (dst_ip_address) (dst_port)"
440 " flexbytes (flexbytes_values) vlan (vlan_id)"
442 " Remove a perfect filter.\n\n"
444 "set_masks_filter (port_id) only_ip_flow (0|1)"
445 " src_mask (ip_src_mask) (src_port_mask)"
446 " dst_mask (ip_dst_mask) (dst_port_mask)"
447 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
448 " Set IPv4 filter masks.\n\n"
450 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
451 " src_mask (ip_src_mask) (src_port_mask)"
452 " dst_mask (ip_dst_mask) (dst_port_mask)"
453 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
454 " compare_dst (0|1)\n"
455 " Set IPv6 filter masks.\n\n"
459 if (show_all || !strcmp(res->section, "ports")) {
465 "----------------\n\n"
467 "port start (port_id|all)\n"
468 " Start all ports or port_id.\n\n"
470 "port stop (port_id|all)\n"
471 " Stop all ports or port_id.\n\n"
473 "port close (port_id|all)\n"
474 " Close all ports or port_id.\n\n"
476 "port config (port_id|all) speed (10|100|1000|10000|auto)"
477 " duplex (half|full|auto)\n"
478 " Set speed and duplex for all ports or port_id\n\n"
480 "port config all (rxq|txq|rxd|txd) (value)\n"
481 " Set number for rxq/txq/rxd/txd.\n\n"
483 "port config all max-pkt-len (value)\n"
484 " Set the max packet length.\n\n"
486 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
488 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
491 "port config all rss (ip|udp|none)\n"
492 " Set the RSS mode.\n\n"
494 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
495 " Set the RSS redirection table.\n\n"
497 "port config (port_id) dcb vt (on|off) (traffic_class)"
499 " Set the DCB mode.\n\n"
501 "port config all burst (value)\n"
502 " Set the number of packets per burst.\n\n"
504 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
506 " Set the ring prefetch/host/writeback threshold"
507 " for tx/rx queue.\n\n"
509 "port config all (txfreet|txrst|rxfreet) (value)\n"
510 " Set free threshold for rx/tx, or set"
511 " tx rs bit threshold.\n\n"
515 if (show_all || !strcmp(res->section, "registers")) {
523 "read reg (port_id) (address)\n"
524 " Display value of a port register.\n\n"
526 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
527 " Display a port register bit field.\n\n"
529 "read regbit (port_id) (address) (bit_x)\n"
530 " Display a single port register bit.\n\n"
532 "write reg (port_id) (address) (value)\n"
533 " Set value of a port register.\n\n"
535 "write regfield (port_id) (address) (bit_x) (bit_y)"
537 " Set bit field of a port register.\n\n"
539 "write regbit (port_id) (address) (bit_x) (value)\n"
540 " Set single bit value of a port register.\n\n"
545 cmdline_parse_token_string_t cmd_help_long_help =
546 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
548 cmdline_parse_token_string_t cmd_help_long_section =
549 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
550 "all#control#display#config#flowdir#"
553 cmdline_parse_inst_t cmd_help_long = {
554 .f = cmd_help_long_parsed,
556 .help_str = "show help",
558 (void *)&cmd_help_long_help,
559 (void *)&cmd_help_long_section,
565 /* *** start/stop/close all ports *** */
566 struct cmd_operate_port_result {
567 cmdline_fixed_string_t keyword;
568 cmdline_fixed_string_t name;
569 cmdline_fixed_string_t value;
572 static void cmd_operate_port_parsed(void *parsed_result,
573 __attribute__((unused)) struct cmdline *cl,
574 __attribute__((unused)) void *data)
576 struct cmd_operate_port_result *res = parsed_result;
578 if (!strcmp(res->name, "start"))
579 start_port(RTE_PORT_ALL);
580 else if (!strcmp(res->name, "stop"))
581 stop_port(RTE_PORT_ALL);
582 else if (!strcmp(res->name, "close"))
583 close_port(RTE_PORT_ALL);
585 printf("Unknown parameter\n");
588 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
589 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
591 cmdline_parse_token_string_t cmd_operate_port_all_port =
592 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
594 cmdline_parse_token_string_t cmd_operate_port_all_all =
595 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
597 cmdline_parse_inst_t cmd_operate_port = {
598 .f = cmd_operate_port_parsed,
600 .help_str = "port start|stop|close all: start/stop/close all ports",
602 (void *)&cmd_operate_port_all_cmd,
603 (void *)&cmd_operate_port_all_port,
604 (void *)&cmd_operate_port_all_all,
609 /* *** start/stop/close specific port *** */
610 struct cmd_operate_specific_port_result {
611 cmdline_fixed_string_t keyword;
612 cmdline_fixed_string_t name;
616 static void cmd_operate_specific_port_parsed(void *parsed_result,
617 __attribute__((unused)) struct cmdline *cl,
618 __attribute__((unused)) void *data)
620 struct cmd_operate_specific_port_result *res = parsed_result;
622 if (!strcmp(res->name, "start"))
623 start_port(res->value);
624 else if (!strcmp(res->name, "stop"))
625 stop_port(res->value);
626 else if (!strcmp(res->name, "close"))
627 close_port(res->value);
629 printf("Unknown parameter\n");
632 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
633 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
635 cmdline_parse_token_string_t cmd_operate_specific_port_port =
636 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
637 name, "start#stop#close");
638 cmdline_parse_token_num_t cmd_operate_specific_port_id =
639 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
642 cmdline_parse_inst_t cmd_operate_specific_port = {
643 .f = cmd_operate_specific_port_parsed,
645 .help_str = "port start|stop|close X: start/stop/close port X",
647 (void *)&cmd_operate_specific_port_cmd,
648 (void *)&cmd_operate_specific_port_port,
649 (void *)&cmd_operate_specific_port_id,
654 /* *** configure speed for all ports *** */
655 struct cmd_config_speed_all {
656 cmdline_fixed_string_t port;
657 cmdline_fixed_string_t keyword;
658 cmdline_fixed_string_t all;
659 cmdline_fixed_string_t item1;
660 cmdline_fixed_string_t item2;
661 cmdline_fixed_string_t value1;
662 cmdline_fixed_string_t value2;
666 cmd_config_speed_all_parsed(void *parsed_result,
667 __attribute__((unused)) struct cmdline *cl,
668 __attribute__((unused)) void *data)
670 struct cmd_config_speed_all *res = parsed_result;
671 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
672 uint16_t link_duplex = 0;
675 if (!all_ports_stopped()) {
676 printf("Please stop all ports first\n");
680 if (!strcmp(res->value1, "10"))
681 link_speed = ETH_LINK_SPEED_10;
682 else if (!strcmp(res->value1, "100"))
683 link_speed = ETH_LINK_SPEED_100;
684 else if (!strcmp(res->value1, "1000"))
685 link_speed = ETH_LINK_SPEED_1000;
686 else if (!strcmp(res->value1, "10000"))
687 link_speed = ETH_LINK_SPEED_10000;
688 else if (!strcmp(res->value1, "auto"))
689 link_speed = ETH_LINK_SPEED_AUTONEG;
691 printf("Unknown parameter\n");
695 if (!strcmp(res->value2, "half"))
696 link_duplex = ETH_LINK_HALF_DUPLEX;
697 else if (!strcmp(res->value2, "full"))
698 link_duplex = ETH_LINK_FULL_DUPLEX;
699 else if (!strcmp(res->value2, "auto"))
700 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
702 printf("Unknown parameter\n");
706 for (pid = 0; pid < nb_ports; pid++) {
707 ports[pid].dev_conf.link_speed = link_speed;
708 ports[pid].dev_conf.link_duplex = link_duplex;
711 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
714 cmdline_parse_token_string_t cmd_config_speed_all_port =
715 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
716 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
719 cmdline_parse_token_string_t cmd_config_speed_all_all =
720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
721 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
722 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
723 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
725 "10#100#1000#10000#auto");
726 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
728 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
732 cmdline_parse_inst_t cmd_config_speed_all = {
733 .f = cmd_config_speed_all_parsed,
735 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
738 (void *)&cmd_config_speed_all_port,
739 (void *)&cmd_config_speed_all_keyword,
740 (void *)&cmd_config_speed_all_all,
741 (void *)&cmd_config_speed_all_item1,
742 (void *)&cmd_config_speed_all_value1,
743 (void *)&cmd_config_speed_all_item2,
744 (void *)&cmd_config_speed_all_value2,
749 /* *** configure speed for specific port *** */
750 struct cmd_config_speed_specific {
751 cmdline_fixed_string_t port;
752 cmdline_fixed_string_t keyword;
754 cmdline_fixed_string_t item1;
755 cmdline_fixed_string_t item2;
756 cmdline_fixed_string_t value1;
757 cmdline_fixed_string_t value2;
761 cmd_config_speed_specific_parsed(void *parsed_result,
762 __attribute__((unused)) struct cmdline *cl,
763 __attribute__((unused)) void *data)
765 struct cmd_config_speed_specific *res = parsed_result;
766 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
767 uint16_t link_duplex = 0;
769 if (!all_ports_stopped()) {
770 printf("Please stop all ports first\n");
774 if (res->id >= nb_ports) {
775 printf("Port id %d must be less than %d\n", res->id, nb_ports);
779 if (!strcmp(res->value1, "10"))
780 link_speed = ETH_LINK_SPEED_10;
781 else if (!strcmp(res->value1, "100"))
782 link_speed = ETH_LINK_SPEED_100;
783 else if (!strcmp(res->value1, "1000"))
784 link_speed = ETH_LINK_SPEED_1000;
785 else if (!strcmp(res->value1, "10000"))
786 link_speed = ETH_LINK_SPEED_10000;
787 else if (!strcmp(res->value1, "auto"))
788 link_speed = ETH_LINK_SPEED_AUTONEG;
790 printf("Unknown parameter\n");
794 if (!strcmp(res->value2, "half"))
795 link_duplex = ETH_LINK_HALF_DUPLEX;
796 else if (!strcmp(res->value2, "full"))
797 link_duplex = ETH_LINK_FULL_DUPLEX;
798 else if (!strcmp(res->value2, "auto"))
799 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
801 printf("Unknown parameter\n");
805 ports[res->id].dev_conf.link_speed = link_speed;
806 ports[res->id].dev_conf.link_duplex = link_duplex;
808 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
812 cmdline_parse_token_string_t cmd_config_speed_specific_port =
813 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
815 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
816 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
818 cmdline_parse_token_num_t cmd_config_speed_specific_id =
819 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
820 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
821 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
823 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
824 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
825 "10#100#1000#10000#auto");
826 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
829 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
830 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
833 cmdline_parse_inst_t cmd_config_speed_specific = {
834 .f = cmd_config_speed_specific_parsed,
836 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
839 (void *)&cmd_config_speed_specific_port,
840 (void *)&cmd_config_speed_specific_keyword,
841 (void *)&cmd_config_speed_specific_id,
842 (void *)&cmd_config_speed_specific_item1,
843 (void *)&cmd_config_speed_specific_value1,
844 (void *)&cmd_config_speed_specific_item2,
845 (void *)&cmd_config_speed_specific_value2,
850 /* *** configure txq/rxq, txd/rxd *** */
851 struct cmd_config_rx_tx {
852 cmdline_fixed_string_t port;
853 cmdline_fixed_string_t keyword;
854 cmdline_fixed_string_t all;
855 cmdline_fixed_string_t name;
860 cmd_config_rx_tx_parsed(void *parsed_result,
861 __attribute__((unused)) struct cmdline *cl,
862 __attribute__((unused)) void *data)
864 struct cmd_config_rx_tx *res = parsed_result;
866 if (!all_ports_stopped()) {
867 printf("Please stop all ports first\n");
871 if (!strcmp(res->name, "rxq")) {
872 if (res->value <= 0) {
873 printf("rxq %d invalid - must be > 0\n", res->value);
878 else if (!strcmp(res->name, "txq")) {
879 if (res->value <= 0) {
880 printf("txq %d invalid - must be > 0\n", res->value);
885 else if (!strcmp(res->name, "rxd")) {
886 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
887 printf("rxd %d invalid - must be > 0 && <= %d\n",
888 res->value, RTE_TEST_RX_DESC_MAX);
892 } else if (!strcmp(res->name, "txd")) {
893 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
894 printf("txd %d invalid - must be > 0 && <= %d\n",
895 res->value, RTE_TEST_TX_DESC_MAX);
900 printf("Unknown parameter\n");
906 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
909 cmdline_parse_token_string_t cmd_config_rx_tx_port =
910 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
911 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
912 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
913 cmdline_parse_token_string_t cmd_config_rx_tx_all =
914 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
915 cmdline_parse_token_string_t cmd_config_rx_tx_name =
916 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
918 cmdline_parse_token_num_t cmd_config_rx_tx_value =
919 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
921 cmdline_parse_inst_t cmd_config_rx_tx = {
922 .f = cmd_config_rx_tx_parsed,
924 .help_str = "port config all rxq|txq|rxd|txd value",
926 (void *)&cmd_config_rx_tx_port,
927 (void *)&cmd_config_rx_tx_keyword,
928 (void *)&cmd_config_rx_tx_all,
929 (void *)&cmd_config_rx_tx_name,
930 (void *)&cmd_config_rx_tx_value,
935 /* *** config max packet length *** */
936 struct cmd_config_max_pkt_len_result {
937 cmdline_fixed_string_t port;
938 cmdline_fixed_string_t keyword;
939 cmdline_fixed_string_t all;
940 cmdline_fixed_string_t name;
945 cmd_config_max_pkt_len_parsed(void *parsed_result,
946 __attribute__((unused)) struct cmdline *cl,
947 __attribute__((unused)) void *data)
949 struct cmd_config_max_pkt_len_result *res = parsed_result;
951 if (!all_ports_stopped()) {
952 printf("Please stop all ports first\n");
956 if (!strcmp(res->name, "max-pkt-len")) {
957 if (res->value < ETHER_MIN_LEN) {
958 printf("max-pkt-len can not be less than %d\n",
962 if (res->value == rx_mode.max_rx_pkt_len)
965 rx_mode.max_rx_pkt_len = res->value;
966 if (res->value > ETHER_MAX_LEN)
967 rx_mode.jumbo_frame = 1;
969 rx_mode.jumbo_frame = 0;
971 printf("Unknown parameter\n");
977 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
980 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
981 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
983 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
984 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
986 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
987 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
989 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
992 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
993 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
996 cmdline_parse_inst_t cmd_config_max_pkt_len = {
997 .f = cmd_config_max_pkt_len_parsed,
999 .help_str = "port config all max-pkt-len value",
1001 (void *)&cmd_config_max_pkt_len_port,
1002 (void *)&cmd_config_max_pkt_len_keyword,
1003 (void *)&cmd_config_max_pkt_len_all,
1004 (void *)&cmd_config_max_pkt_len_name,
1005 (void *)&cmd_config_max_pkt_len_value,
1010 /* *** configure rx mode *** */
1011 struct cmd_config_rx_mode_flag {
1012 cmdline_fixed_string_t port;
1013 cmdline_fixed_string_t keyword;
1014 cmdline_fixed_string_t all;
1015 cmdline_fixed_string_t name;
1016 cmdline_fixed_string_t value;
1020 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1021 __attribute__((unused)) struct cmdline *cl,
1022 __attribute__((unused)) void *data)
1024 struct cmd_config_rx_mode_flag *res = parsed_result;
1026 if (!all_ports_stopped()) {
1027 printf("Please stop all ports first\n");
1031 if (!strcmp(res->name, "crc-strip")) {
1032 if (!strcmp(res->value, "on"))
1033 rx_mode.hw_strip_crc = 1;
1034 else if (!strcmp(res->value, "off"))
1035 rx_mode.hw_strip_crc = 0;
1037 printf("Unknown parameter\n");
1040 } else if (!strcmp(res->name, "rx-cksum")) {
1041 if (!strcmp(res->value, "on"))
1042 rx_mode.hw_ip_checksum = 1;
1043 else if (!strcmp(res->value, "off"))
1044 rx_mode.hw_ip_checksum = 0;
1046 printf("Unknown parameter\n");
1049 } else if (!strcmp(res->name, "hw-vlan")) {
1050 if (!strcmp(res->value, "on")) {
1051 rx_mode.hw_vlan_filter = 1;
1052 rx_mode.hw_vlan_strip = 1;
1054 else if (!strcmp(res->value, "off")) {
1055 rx_mode.hw_vlan_filter = 0;
1056 rx_mode.hw_vlan_strip = 0;
1059 printf("Unknown parameter\n");
1062 } else if (!strcmp(res->name, "drop-en")) {
1063 if (!strcmp(res->value, "on"))
1065 else if (!strcmp(res->value, "off"))
1068 printf("Unknown parameter\n");
1072 printf("Unknown parameter\n");
1078 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1081 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1082 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1083 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1084 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1086 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1087 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1088 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1089 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1090 "crc-strip#rx-cksum#hw-vlan");
1091 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1092 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1095 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1096 .f = cmd_config_rx_mode_flag_parsed,
1098 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1100 (void *)&cmd_config_rx_mode_flag_port,
1101 (void *)&cmd_config_rx_mode_flag_keyword,
1102 (void *)&cmd_config_rx_mode_flag_all,
1103 (void *)&cmd_config_rx_mode_flag_name,
1104 (void *)&cmd_config_rx_mode_flag_value,
1109 /* *** configure rss *** */
1110 struct cmd_config_rss {
1111 cmdline_fixed_string_t port;
1112 cmdline_fixed_string_t keyword;
1113 cmdline_fixed_string_t all;
1114 cmdline_fixed_string_t name;
1115 cmdline_fixed_string_t value;
1119 cmd_config_rss_parsed(void *parsed_result,
1120 __attribute__((unused)) struct cmdline *cl,
1121 __attribute__((unused)) void *data)
1123 struct cmd_config_rss *res = parsed_result;
1125 if (!all_ports_stopped()) {
1126 printf("Please stop all ports first\n");
1130 if (!strcmp(res->value, "ip"))
1131 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1132 else if (!strcmp(res->value, "udp"))
1133 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1134 else if (!strcmp(res->value, "none"))
1137 printf("Unknown parameter\n");
1143 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1146 cmdline_parse_token_string_t cmd_config_rss_port =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1148 cmdline_parse_token_string_t cmd_config_rss_keyword =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1150 cmdline_parse_token_string_t cmd_config_rss_all =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1152 cmdline_parse_token_string_t cmd_config_rss_name =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1154 cmdline_parse_token_string_t cmd_config_rss_value =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1157 cmdline_parse_inst_t cmd_config_rss = {
1158 .f = cmd_config_rss_parsed,
1160 .help_str = "port config all rss ip|udp|none",
1162 (void *)&cmd_config_rss_port,
1163 (void *)&cmd_config_rss_keyword,
1164 (void *)&cmd_config_rss_all,
1165 (void *)&cmd_config_rss_name,
1166 (void *)&cmd_config_rss_value,
1171 /* *** Configure RSS RETA *** */
1172 struct cmd_config_rss_reta {
1173 cmdline_fixed_string_t port;
1174 cmdline_fixed_string_t keyword;
1176 cmdline_fixed_string_t name;
1177 cmdline_fixed_string_t list_name;
1178 cmdline_fixed_string_t list_of_items;
1182 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1189 const char *p, *p0 = str;
1196 unsigned long int_fld[_NUM_FLD];
1197 char *str_fld[_NUM_FLD];
1199 while ((p = strchr(p0,'(')) != NULL) {
1201 if((p0 = strchr(p,')')) == NULL)
1205 if(size >= sizeof(s))
1208 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1209 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1211 for (i = 0; i < _NUM_FLD; i++) {
1213 int_fld[i] = strtoul(str_fld[i], &end, 0);
1214 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1218 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1219 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1221 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1222 printf("Invalid RETA hash index=%d",hash_index);
1226 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1227 reta_conf->mask_lo |= (1ULL << hash_index);
1229 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1231 reta_conf->reta[hash_index] = nb_queue;
1238 cmd_set_rss_reta_parsed(void *parsed_result,
1239 __attribute__((unused)) struct cmdline *cl,
1240 __attribute__((unused)) void *data)
1243 struct rte_eth_rss_reta reta_conf;
1244 struct cmd_config_rss_reta *res = parsed_result;
1246 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1247 if (!strcmp(res->list_name, "reta")) {
1248 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1249 printf("Invalid RSS Redirection Table config entered\n");
1252 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1254 printf("Bad redirection table parameter, return code = %d \n",ret);
1258 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1259 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1260 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1261 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1262 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1263 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1264 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1265 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1266 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1268 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1271 cmdline_parse_inst_t cmd_config_rss_reta = {
1272 .f = cmd_set_rss_reta_parsed,
1274 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1276 (void *)&cmd_config_rss_reta_port,
1277 (void *)&cmd_config_rss_reta_keyword,
1278 (void *)&cmd_config_rss_reta_port_id,
1279 (void *)&cmd_config_rss_reta_name,
1280 (void *)&cmd_config_rss_reta_list_name,
1281 (void *)&cmd_config_rss_reta_list_of_items,
1286 /* *** SHOW PORT RETA INFO *** */
1287 struct cmd_showport_reta {
1288 cmdline_fixed_string_t show;
1289 cmdline_fixed_string_t port;
1291 cmdline_fixed_string_t rss;
1292 cmdline_fixed_string_t reta;
1297 static void cmd_showport_reta_parsed(void *parsed_result,
1298 __attribute__((unused)) struct cmdline *cl,
1299 __attribute__((unused)) void *data)
1301 struct cmd_showport_reta *res = parsed_result;
1302 struct rte_eth_rss_reta reta_conf;
1304 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1305 printf("Invalid RSS Redirection Table config entered\n");
1309 reta_conf.mask_lo = res->mask_lo;
1310 reta_conf.mask_hi = res->mask_hi;
1312 port_rss_reta_info(res->port_id,&reta_conf);
1315 cmdline_parse_token_string_t cmd_showport_reta_show =
1316 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1317 cmdline_parse_token_string_t cmd_showport_reta_port =
1318 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1319 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1320 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1321 cmdline_parse_token_string_t cmd_showport_reta_rss =
1322 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1323 cmdline_parse_token_string_t cmd_showport_reta_reta =
1324 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1325 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1326 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1327 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1328 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1330 cmdline_parse_inst_t cmd_showport_reta = {
1331 .f = cmd_showport_reta_parsed,
1333 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1334 (mask_lo and mask_hi is UINT64)",
1336 (void *)&cmd_showport_reta_show,
1337 (void *)&cmd_showport_reta_port,
1338 (void *)&cmd_showport_reta_port_id,
1339 (void *)&cmd_showport_reta_rss,
1340 (void *)&cmd_showport_reta_reta,
1341 (void *)&cmd_showport_reta_mask_lo,
1342 (void *)&cmd_showport_reta_mask_hi,
1347 /* *** Configure DCB *** */
1348 struct cmd_config_dcb {
1349 cmdline_fixed_string_t port;
1350 cmdline_fixed_string_t config;
1352 cmdline_fixed_string_t dcb;
1353 cmdline_fixed_string_t vt;
1354 cmdline_fixed_string_t vt_en;
1356 cmdline_fixed_string_t pfc;
1357 cmdline_fixed_string_t pfc_en;
1361 cmd_config_dcb_parsed(void *parsed_result,
1362 __attribute__((unused)) struct cmdline *cl,
1363 __attribute__((unused)) void *data)
1365 struct cmd_config_dcb *res = parsed_result;
1366 struct dcb_config dcb_conf;
1367 portid_t port_id = res->port_id;
1368 struct rte_port *port;
1370 port = &ports[port_id];
1371 /** Check if the port is not started **/
1372 if (port->port_status != RTE_PORT_STOPPED) {
1373 printf("Please stop port %d first\n",port_id);
1377 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1378 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1379 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1383 /* DCB in VT mode */
1384 if (!strncmp(res->vt_en, "on",2))
1385 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1387 dcb_conf.dcb_mode = DCB_ENABLED;
1389 if (!strncmp(res->pfc_en, "on",2)) {
1390 dcb_conf.pfc_en = 1;
1393 dcb_conf.pfc_en = 0;
1395 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1396 printf("Cannot initialize network ports\n");
1400 cmd_reconfig_device_queue(port_id, 1, 1);
1403 cmdline_parse_token_string_t cmd_config_dcb_port =
1404 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1405 cmdline_parse_token_string_t cmd_config_dcb_config =
1406 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1407 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1408 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1409 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1410 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1411 cmdline_parse_token_string_t cmd_config_dcb_vt =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1413 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1415 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1416 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1417 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1419 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1422 cmdline_parse_inst_t cmd_config_dcb = {
1423 .f = cmd_config_dcb_parsed,
1425 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1427 (void *)&cmd_config_dcb_port,
1428 (void *)&cmd_config_dcb_config,
1429 (void *)&cmd_config_dcb_port_id,
1430 (void *)&cmd_config_dcb_dcb,
1431 (void *)&cmd_config_dcb_vt,
1432 (void *)&cmd_config_dcb_vt_en,
1433 (void *)&cmd_config_dcb_num_tcs,
1434 (void *)&cmd_config_dcb_pfc,
1435 (void *)&cmd_config_dcb_pfc_en,
1440 /* *** configure number of packets per burst *** */
1441 struct cmd_config_burst {
1442 cmdline_fixed_string_t port;
1443 cmdline_fixed_string_t keyword;
1444 cmdline_fixed_string_t all;
1445 cmdline_fixed_string_t name;
1450 cmd_config_burst_parsed(void *parsed_result,
1451 __attribute__((unused)) struct cmdline *cl,
1452 __attribute__((unused)) void *data)
1454 struct cmd_config_burst *res = parsed_result;
1456 if (!all_ports_stopped()) {
1457 printf("Please stop all ports first\n");
1461 if (!strcmp(res->name, "burst")) {
1462 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1463 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1466 nb_pkt_per_burst = res->value;
1468 printf("Unknown parameter\n");
1474 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1477 cmdline_parse_token_string_t cmd_config_burst_port =
1478 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1479 cmdline_parse_token_string_t cmd_config_burst_keyword =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1481 cmdline_parse_token_string_t cmd_config_burst_all =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1483 cmdline_parse_token_string_t cmd_config_burst_name =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1485 cmdline_parse_token_num_t cmd_config_burst_value =
1486 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1488 cmdline_parse_inst_t cmd_config_burst = {
1489 .f = cmd_config_burst_parsed,
1491 .help_str = "port config all burst value",
1493 (void *)&cmd_config_burst_port,
1494 (void *)&cmd_config_burst_keyword,
1495 (void *)&cmd_config_burst_all,
1496 (void *)&cmd_config_burst_name,
1497 (void *)&cmd_config_burst_value,
1502 /* *** configure rx/tx queues *** */
1503 struct cmd_config_thresh {
1504 cmdline_fixed_string_t port;
1505 cmdline_fixed_string_t keyword;
1506 cmdline_fixed_string_t all;
1507 cmdline_fixed_string_t name;
1512 cmd_config_thresh_parsed(void *parsed_result,
1513 __attribute__((unused)) struct cmdline *cl,
1514 __attribute__((unused)) void *data)
1516 struct cmd_config_thresh *res = parsed_result;
1518 if (!all_ports_stopped()) {
1519 printf("Please stop all ports first\n");
1523 if (!strcmp(res->name, "txpt"))
1524 tx_thresh.pthresh = res->value;
1525 else if(!strcmp(res->name, "txht"))
1526 tx_thresh.hthresh = res->value;
1527 else if(!strcmp(res->name, "txwt"))
1528 tx_thresh.wthresh = res->value;
1529 else if(!strcmp(res->name, "rxpt"))
1530 rx_thresh.pthresh = res->value;
1531 else if(!strcmp(res->name, "rxht"))
1532 rx_thresh.hthresh = res->value;
1533 else if(!strcmp(res->name, "rxwt"))
1534 rx_thresh.wthresh = res->value;
1536 printf("Unknown parameter\n");
1542 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1545 cmdline_parse_token_string_t cmd_config_thresh_port =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1547 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1549 cmdline_parse_token_string_t cmd_config_thresh_all =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1551 cmdline_parse_token_string_t cmd_config_thresh_name =
1552 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1553 "txpt#txht#txwt#rxpt#rxht#rxwt");
1554 cmdline_parse_token_num_t cmd_config_thresh_value =
1555 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1557 cmdline_parse_inst_t cmd_config_thresh = {
1558 .f = cmd_config_thresh_parsed,
1560 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1562 (void *)&cmd_config_thresh_port,
1563 (void *)&cmd_config_thresh_keyword,
1564 (void *)&cmd_config_thresh_all,
1565 (void *)&cmd_config_thresh_name,
1566 (void *)&cmd_config_thresh_value,
1571 /* *** configure free/rs threshold *** */
1572 struct cmd_config_threshold {
1573 cmdline_fixed_string_t port;
1574 cmdline_fixed_string_t keyword;
1575 cmdline_fixed_string_t all;
1576 cmdline_fixed_string_t name;
1581 cmd_config_threshold_parsed(void *parsed_result,
1582 __attribute__((unused)) struct cmdline *cl,
1583 __attribute__((unused)) void *data)
1585 struct cmd_config_threshold *res = parsed_result;
1587 if (!all_ports_stopped()) {
1588 printf("Please stop all ports first\n");
1592 if (!strcmp(res->name, "txfreet"))
1593 tx_free_thresh = res->value;
1594 else if (!strcmp(res->name, "txrst"))
1595 tx_rs_thresh = res->value;
1596 else if (!strcmp(res->name, "rxfreet"))
1597 rx_free_thresh = res->value;
1599 printf("Unknown parameter\n");
1605 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1608 cmdline_parse_token_string_t cmd_config_threshold_port =
1609 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1610 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1613 cmdline_parse_token_string_t cmd_config_threshold_all =
1614 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1615 cmdline_parse_token_string_t cmd_config_threshold_name =
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1617 "txfreet#txrst#rxfreet");
1618 cmdline_parse_token_num_t cmd_config_threshold_value =
1619 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1621 cmdline_parse_inst_t cmd_config_threshold = {
1622 .f = cmd_config_threshold_parsed,
1624 .help_str = "port config all txfreet|txrst|rxfreet value",
1626 (void *)&cmd_config_threshold_port,
1627 (void *)&cmd_config_threshold_keyword,
1628 (void *)&cmd_config_threshold_all,
1629 (void *)&cmd_config_threshold_name,
1630 (void *)&cmd_config_threshold_value,
1636 struct cmd_stop_result {
1637 cmdline_fixed_string_t stop;
1640 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1641 __attribute__((unused)) struct cmdline *cl,
1642 __attribute__((unused)) void *data)
1644 stop_packet_forwarding();
1647 cmdline_parse_token_string_t cmd_stop_stop =
1648 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1650 cmdline_parse_inst_t cmd_stop = {
1651 .f = cmd_stop_parsed,
1653 .help_str = "stop - stop packet forwarding",
1655 (void *)&cmd_stop_stop,
1660 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1663 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1664 unsigned int *parsed_items, int check_unique_values)
1666 unsigned int nb_item;
1674 * First parse all items in the list and store their value.
1679 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1681 if ((c >= '0') && (c <= '9')) {
1682 value = (unsigned int) (value * 10 + (c - '0'));
1687 printf("character %c is not a decimal digit\n", c);
1691 printf("No valid value before comma\n");
1694 if (nb_item < max_items) {
1695 parsed_items[nb_item] = value;
1701 if (nb_item >= max_items) {
1702 printf("Number of %s = %u > %u (maximum items)\n",
1703 item_name, nb_item + 1, max_items);
1706 parsed_items[nb_item++] = value;
1707 if (! check_unique_values)
1711 * Then, check that all values in the list are differents.
1712 * No optimization here...
1714 for (i = 0; i < nb_item; i++) {
1715 for (j = i + 1; j < nb_item; j++) {
1716 if (parsed_items[j] == parsed_items[i]) {
1717 printf("duplicated %s %u at index %u and %u\n",
1718 item_name, parsed_items[i], i, j);
1726 struct cmd_set_list_result {
1727 cmdline_fixed_string_t cmd_keyword;
1728 cmdline_fixed_string_t list_name;
1729 cmdline_fixed_string_t list_of_items;
1732 static void cmd_set_list_parsed(void *parsed_result,
1733 __attribute__((unused)) struct cmdline *cl,
1734 __attribute__((unused)) void *data)
1736 struct cmd_set_list_result *res;
1738 unsigned int lcorelist[RTE_MAX_LCORE];
1739 unsigned int portlist[RTE_MAX_ETHPORTS];
1741 unsigned int nb_item;
1743 res = parsed_result;
1744 if (!strcmp(res->list_name, "corelist")) {
1745 nb_item = parse_item_list(res->list_of_items, "core",
1747 parsed_items.lcorelist, 1);
1749 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1752 if (!strcmp(res->list_name, "portlist")) {
1753 nb_item = parse_item_list(res->list_of_items, "port",
1755 parsed_items.portlist, 1);
1757 set_fwd_ports_list(parsed_items.portlist, nb_item);
1761 cmdline_parse_token_string_t cmd_set_list_keyword =
1762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1764 cmdline_parse_token_string_t cmd_set_list_name =
1765 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1766 "corelist#portlist");
1767 cmdline_parse_token_string_t cmd_set_list_of_items =
1768 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1771 cmdline_parse_inst_t cmd_set_fwd_list = {
1772 .f = cmd_set_list_parsed,
1774 .help_str = "set corelist|portlist x[,y]*",
1776 (void *)&cmd_set_list_keyword,
1777 (void *)&cmd_set_list_name,
1778 (void *)&cmd_set_list_of_items,
1783 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1785 struct cmd_setmask_result {
1786 cmdline_fixed_string_t set;
1787 cmdline_fixed_string_t mask;
1791 static void cmd_set_mask_parsed(void *parsed_result,
1792 __attribute__((unused)) struct cmdline *cl,
1793 __attribute__((unused)) void *data)
1795 struct cmd_setmask_result *res = parsed_result;
1797 if (!strcmp(res->mask, "coremask"))
1798 set_fwd_lcores_mask(res->hexavalue);
1799 else if (!strcmp(res->mask, "portmask"))
1800 set_fwd_ports_mask(res->hexavalue);
1803 cmdline_parse_token_string_t cmd_setmask_set =
1804 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1805 cmdline_parse_token_string_t cmd_setmask_mask =
1806 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1807 "coremask#portmask");
1808 cmdline_parse_token_num_t cmd_setmask_value =
1809 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1811 cmdline_parse_inst_t cmd_set_fwd_mask = {
1812 .f = cmd_set_mask_parsed,
1814 .help_str = "set coremask|portmask hexadecimal value",
1816 (void *)&cmd_setmask_set,
1817 (void *)&cmd_setmask_mask,
1818 (void *)&cmd_setmask_value,
1824 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1826 struct cmd_set_result {
1827 cmdline_fixed_string_t set;
1828 cmdline_fixed_string_t what;
1832 static void cmd_set_parsed(void *parsed_result,
1833 __attribute__((unused)) struct cmdline *cl,
1834 __attribute__((unused)) void *data)
1836 struct cmd_set_result *res = parsed_result;
1837 if (!strcmp(res->what, "nbport"))
1838 set_fwd_ports_number(res->value);
1839 else if (!strcmp(res->what, "nbcore"))
1840 set_fwd_lcores_number(res->value);
1841 else if (!strcmp(res->what, "burst"))
1842 set_nb_pkt_per_burst(res->value);
1843 else if (!strcmp(res->what, "verbose"))
1844 set_verbose_level(res->value);
1847 cmdline_parse_token_string_t cmd_set_set =
1848 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1849 cmdline_parse_token_string_t cmd_set_what =
1850 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1851 "nbport#nbcore#burst#verbose");
1852 cmdline_parse_token_num_t cmd_set_value =
1853 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1855 cmdline_parse_inst_t cmd_set_numbers = {
1856 .f = cmd_set_parsed,
1858 .help_str = "set nbport|nbcore|burst|verbose value",
1860 (void *)&cmd_set_set,
1861 (void *)&cmd_set_what,
1862 (void *)&cmd_set_value,
1867 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1869 struct cmd_set_txpkts_result {
1870 cmdline_fixed_string_t cmd_keyword;
1871 cmdline_fixed_string_t txpkts;
1872 cmdline_fixed_string_t seg_lengths;
1876 cmd_set_txpkts_parsed(void *parsed_result,
1877 __attribute__((unused)) struct cmdline *cl,
1878 __attribute__((unused)) void *data)
1880 struct cmd_set_txpkts_result *res;
1881 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1882 unsigned int nb_segs;
1884 res = parsed_result;
1885 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1886 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1888 set_tx_pkt_segments(seg_lengths, nb_segs);
1891 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1892 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1893 cmd_keyword, "set");
1894 cmdline_parse_token_string_t cmd_set_txpkts_name =
1895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1897 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1901 cmdline_parse_inst_t cmd_set_txpkts = {
1902 .f = cmd_set_txpkts_parsed,
1904 .help_str = "set txpkts x[,y]*",
1906 (void *)&cmd_set_txpkts_keyword,
1907 (void *)&cmd_set_txpkts_name,
1908 (void *)&cmd_set_txpkts_lengths,
1913 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1914 struct cmd_rx_vlan_filter_all_result {
1915 cmdline_fixed_string_t rx_vlan;
1916 cmdline_fixed_string_t what;
1917 cmdline_fixed_string_t all;
1922 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1923 __attribute__((unused)) struct cmdline *cl,
1924 __attribute__((unused)) void *data)
1926 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1928 if (!strcmp(res->what, "add"))
1929 rx_vlan_all_filter_set(res->port_id, 1);
1931 rx_vlan_all_filter_set(res->port_id, 0);
1934 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1935 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1936 rx_vlan, "rx_vlan");
1937 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1938 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1940 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1941 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1943 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1944 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1947 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1948 .f = cmd_rx_vlan_filter_all_parsed,
1950 .help_str = "add/remove all identifiers to/from the set of VLAN "
1951 "Identifiers filtered by a port",
1953 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1954 (void *)&cmd_rx_vlan_filter_all_what,
1955 (void *)&cmd_rx_vlan_filter_all_all,
1956 (void *)&cmd_rx_vlan_filter_all_portid,
1961 /* *** VLAN OFFLOAD SET ON A PORT *** */
1962 struct cmd_vlan_offload_result {
1963 cmdline_fixed_string_t vlan;
1964 cmdline_fixed_string_t set;
1965 cmdline_fixed_string_t what;
1966 cmdline_fixed_string_t on;
1967 cmdline_fixed_string_t port_id;
1971 cmd_vlan_offload_parsed(void *parsed_result,
1972 __attribute__((unused)) struct cmdline *cl,
1973 __attribute__((unused)) void *data)
1976 struct cmd_vlan_offload_result *res = parsed_result;
1979 portid_t port_id = 0;
1983 len = strnlen(str, STR_TOKEN_SIZE);
1985 /* Get port_id first */
1993 tmp = strtoul(str, NULL, 0);
1994 /* If port_id greater that what portid_t can represent, return */
1995 if(tmp >= RTE_MAX_ETHPORTS)
1997 port_id = (portid_t)tmp;
1999 if (!strcmp(res->on, "on"))
2004 if (!strcmp(res->what, "strip"))
2005 rx_vlan_strip_set(port_id, on);
2006 else if(!strcmp(res->what, "stripq")){
2007 uint16_t queue_id = 0;
2009 /* No queue_id, return */
2011 printf("must specify (port,queue_id)\n");
2014 tmp = strtoul(str + i + 1, NULL, 0);
2015 /* If queue_id greater that what 16-bits can represent, return */
2019 queue_id = (uint16_t)tmp;
2020 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2022 else if (!strcmp(res->what, "filter"))
2023 rx_vlan_filter_set(port_id, on);
2025 vlan_extend_set(port_id, on);
2030 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2031 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2033 cmdline_parse_token_string_t cmd_vlan_offload_set =
2034 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2036 cmdline_parse_token_string_t cmd_vlan_offload_what =
2037 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2038 what, "strip#filter#qinq#stripq");
2039 cmdline_parse_token_string_t cmd_vlan_offload_on =
2040 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2042 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2043 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2046 cmdline_parse_inst_t cmd_vlan_offload = {
2047 .f = cmd_vlan_offload_parsed,
2049 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2050 " qinq(extended) for both rx/tx sides ",
2052 (void *)&cmd_vlan_offload_vlan,
2053 (void *)&cmd_vlan_offload_set,
2054 (void *)&cmd_vlan_offload_what,
2055 (void *)&cmd_vlan_offload_on,
2056 (void *)&cmd_vlan_offload_portid,
2061 /* *** VLAN TPID SET ON A PORT *** */
2062 struct cmd_vlan_tpid_result {
2063 cmdline_fixed_string_t vlan;
2064 cmdline_fixed_string_t set;
2065 cmdline_fixed_string_t what;
2071 cmd_vlan_tpid_parsed(void *parsed_result,
2072 __attribute__((unused)) struct cmdline *cl,
2073 __attribute__((unused)) void *data)
2075 struct cmd_vlan_tpid_result *res = parsed_result;
2076 vlan_tpid_set(res->port_id, res->tp_id);
2080 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2083 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2086 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2089 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2090 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2092 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2096 cmdline_parse_inst_t cmd_vlan_tpid = {
2097 .f = cmd_vlan_tpid_parsed,
2099 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2101 (void *)&cmd_vlan_tpid_vlan,
2102 (void *)&cmd_vlan_tpid_set,
2103 (void *)&cmd_vlan_tpid_what,
2104 (void *)&cmd_vlan_tpid_tpid,
2105 (void *)&cmd_vlan_tpid_portid,
2110 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2111 struct cmd_rx_vlan_filter_result {
2112 cmdline_fixed_string_t rx_vlan;
2113 cmdline_fixed_string_t what;
2119 cmd_rx_vlan_filter_parsed(void *parsed_result,
2120 __attribute__((unused)) struct cmdline *cl,
2121 __attribute__((unused)) void *data)
2123 struct cmd_rx_vlan_filter_result *res = parsed_result;
2125 if (!strcmp(res->what, "add"))
2126 rx_vft_set(res->port_id, res->vlan_id, 1);
2128 rx_vft_set(res->port_id, res->vlan_id, 0);
2131 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2132 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2133 rx_vlan, "rx_vlan");
2134 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2135 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2137 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2140 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2141 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2144 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2145 .f = cmd_rx_vlan_filter_parsed,
2147 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2148 "Identifiers filtered by a port",
2150 (void *)&cmd_rx_vlan_filter_rx_vlan,
2151 (void *)&cmd_rx_vlan_filter_what,
2152 (void *)&cmd_rx_vlan_filter_vlanid,
2153 (void *)&cmd_rx_vlan_filter_portid,
2158 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2159 struct cmd_tx_vlan_set_result {
2160 cmdline_fixed_string_t tx_vlan;
2161 cmdline_fixed_string_t set;
2167 cmd_tx_vlan_set_parsed(void *parsed_result,
2168 __attribute__((unused)) struct cmdline *cl,
2169 __attribute__((unused)) void *data)
2171 struct cmd_tx_vlan_set_result *res = parsed_result;
2172 tx_vlan_set(res->port_id, res->vlan_id);
2175 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2176 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2177 tx_vlan, "tx_vlan");
2178 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2179 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2181 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2182 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2184 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2185 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2188 cmdline_parse_inst_t cmd_tx_vlan_set = {
2189 .f = cmd_tx_vlan_set_parsed,
2191 .help_str = "enable hardware insertion of a VLAN header with a given "
2192 "TAG Identifier in packets sent on a port",
2194 (void *)&cmd_tx_vlan_set_tx_vlan,
2195 (void *)&cmd_tx_vlan_set_set,
2196 (void *)&cmd_tx_vlan_set_vlanid,
2197 (void *)&cmd_tx_vlan_set_portid,
2202 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2203 struct cmd_tx_vlan_reset_result {
2204 cmdline_fixed_string_t tx_vlan;
2205 cmdline_fixed_string_t reset;
2210 cmd_tx_vlan_reset_parsed(void *parsed_result,
2211 __attribute__((unused)) struct cmdline *cl,
2212 __attribute__((unused)) void *data)
2214 struct cmd_tx_vlan_reset_result *res = parsed_result;
2216 tx_vlan_reset(res->port_id);
2219 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2221 tx_vlan, "tx_vlan");
2222 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2225 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2226 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2229 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2230 .f = cmd_tx_vlan_reset_parsed,
2232 .help_str = "disable hardware insertion of a VLAN header in packets "
2235 (void *)&cmd_tx_vlan_reset_tx_vlan,
2236 (void *)&cmd_tx_vlan_reset_reset,
2237 (void *)&cmd_tx_vlan_reset_portid,
2243 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2244 struct cmd_tx_cksum_set_result {
2245 cmdline_fixed_string_t tx_cksum;
2246 cmdline_fixed_string_t set;
2252 cmd_tx_cksum_set_parsed(void *parsed_result,
2253 __attribute__((unused)) struct cmdline *cl,
2254 __attribute__((unused)) void *data)
2256 struct cmd_tx_cksum_set_result *res = parsed_result;
2258 tx_cksum_set(res->port_id, res->cksum_mask);
2261 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2262 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2263 tx_cksum, "tx_checksum");
2264 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2265 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2267 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2268 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2270 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2271 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2274 cmdline_parse_inst_t cmd_tx_cksum_set = {
2275 .f = cmd_tx_cksum_set_parsed,
2277 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2278 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2279 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2281 (void *)&cmd_tx_cksum_set_tx_cksum,
2282 (void *)&cmd_tx_cksum_set_set,
2283 (void *)&cmd_tx_cksum_set_cksum_mask,
2284 (void *)&cmd_tx_cksum_set_portid,
2289 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2290 struct cmd_set_flush_rx {
2291 cmdline_fixed_string_t set;
2292 cmdline_fixed_string_t flush_rx;
2293 cmdline_fixed_string_t mode;
2297 cmd_set_flush_rx_parsed(void *parsed_result,
2298 __attribute__((unused)) struct cmdline *cl,
2299 __attribute__((unused)) void *data)
2301 struct cmd_set_flush_rx *res = parsed_result;
2302 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2305 cmdline_parse_token_string_t cmd_setflushrx_set =
2306 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2308 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2309 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2310 flush_rx, "flush_rx");
2311 cmdline_parse_token_string_t cmd_setflushrx_mode =
2312 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2316 cmdline_parse_inst_t cmd_set_flush_rx = {
2317 .f = cmd_set_flush_rx_parsed,
2318 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2321 (void *)&cmd_setflushrx_set,
2322 (void *)&cmd_setflushrx_flush_rx,
2323 (void *)&cmd_setflushrx_mode,
2328 #ifdef RTE_NIC_BYPASS
2329 /* *** SET NIC BYPASS MODE *** */
2330 struct cmd_set_bypass_mode_result {
2331 cmdline_fixed_string_t set;
2332 cmdline_fixed_string_t bypass;
2333 cmdline_fixed_string_t mode;
2334 cmdline_fixed_string_t value;
2339 cmd_set_bypass_mode_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_set_bypass_mode_result *res = parsed_result;
2344 portid_t port_id = res->port_id;
2345 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2347 if (!bypass_is_supported(port_id))
2350 if (!strcmp(res->value, "bypass"))
2351 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2352 else if (!strcmp(res->value, "isolate"))
2353 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2355 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2357 /* Set the bypass mode for the relevant port. */
2358 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2359 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2363 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2366 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2369 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2372 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2374 value, "normal#bypass#isolate");
2375 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2376 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2379 cmdline_parse_inst_t cmd_set_bypass_mode = {
2380 .f = cmd_set_bypass_mode_parsed,
2381 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2382 "Set the NIC bypass mode for port_id",
2385 (void *)&cmd_setbypass_mode_set,
2386 (void *)&cmd_setbypass_mode_bypass,
2387 (void *)&cmd_setbypass_mode_mode,
2388 (void *)&cmd_setbypass_mode_value,
2389 (void *)&cmd_setbypass_mode_port,
2394 /* *** SET NIC BYPASS EVENT *** */
2395 struct cmd_set_bypass_event_result {
2396 cmdline_fixed_string_t set;
2397 cmdline_fixed_string_t bypass;
2398 cmdline_fixed_string_t event;
2399 cmdline_fixed_string_t event_value;
2400 cmdline_fixed_string_t mode;
2401 cmdline_fixed_string_t mode_value;
2406 cmd_set_bypass_event_parsed(void *parsed_result,
2407 __attribute__((unused)) struct cmdline *cl,
2408 __attribute__((unused)) void *data)
2411 struct cmd_set_bypass_event_result *res = parsed_result;
2412 portid_t port_id = res->port_id;
2413 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2414 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2416 if (!bypass_is_supported(port_id))
2419 if (!strcmp(res->event_value, "timeout"))
2420 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2421 else if (!strcmp(res->event_value, "os_on"))
2422 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2423 else if (!strcmp(res->event_value, "os_off"))
2424 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2425 else if (!strcmp(res->event_value, "power_on"))
2426 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2427 else if (!strcmp(res->event_value, "power_off"))
2428 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2430 bypass_event = RTE_BYPASS_EVENT_NONE;
2432 if (!strcmp(res->mode_value, "bypass"))
2433 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2434 else if (!strcmp(res->mode_value, "isolate"))
2435 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2437 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2439 /* Set the watchdog timeout. */
2440 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2443 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2444 (rc = rte_eth_dev_wd_timeout_store(port_id,
2445 bypass_timeout)) != 0) {
2446 printf("Failed to set timeout value %u "
2447 "for port %d, errto code: %d.\n",
2448 bypass_timeout, port_id, rc);
2452 /* Set the bypass event to transition to bypass mode. */
2453 if (0 != rte_eth_dev_bypass_event_store(port_id,
2454 bypass_event, bypass_mode)) {
2455 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2460 cmdline_parse_token_string_t cmd_setbypass_event_set =
2461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2463 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2464 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2466 cmdline_parse_token_string_t cmd_setbypass_event_event =
2467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2469 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2471 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2472 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2475 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2476 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2477 mode_value, "normal#bypass#isolate");
2478 cmdline_parse_token_num_t cmd_setbypass_event_port =
2479 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2482 cmdline_parse_inst_t cmd_set_bypass_event = {
2483 .f = cmd_set_bypass_event_parsed,
2484 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2485 "mode (normal|bypass|isolate) (port_id): "
2486 "Set the NIC bypass event mode for port_id",
2489 (void *)&cmd_setbypass_event_set,
2490 (void *)&cmd_setbypass_event_bypass,
2491 (void *)&cmd_setbypass_event_event,
2492 (void *)&cmd_setbypass_event_event_value,
2493 (void *)&cmd_setbypass_event_mode,
2494 (void *)&cmd_setbypass_event_mode_value,
2495 (void *)&cmd_setbypass_event_port,
2501 /* *** SET NIC BYPASS TIMEOUT *** */
2502 struct cmd_set_bypass_timeout_result {
2503 cmdline_fixed_string_t set;
2504 cmdline_fixed_string_t bypass;
2505 cmdline_fixed_string_t timeout;
2506 cmdline_fixed_string_t value;
2510 cmd_set_bypass_timeout_parsed(void *parsed_result,
2511 __attribute__((unused)) struct cmdline *cl,
2512 __attribute__((unused)) void *data)
2514 struct cmd_set_bypass_timeout_result *res = parsed_result;
2516 if (!strcmp(res->value, "1.5"))
2517 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2518 else if (!strcmp(res->value, "2"))
2519 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2520 else if (!strcmp(res->value, "3"))
2521 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2522 else if (!strcmp(res->value, "4"))
2523 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2524 else if (!strcmp(res->value, "8"))
2525 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2526 else if (!strcmp(res->value, "16"))
2527 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2528 else if (!strcmp(res->value, "32"))
2529 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2531 bypass_timeout = RTE_BYPASS_TMT_OFF;
2534 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2537 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2540 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2542 timeout, "timeout");
2543 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2545 value, "0#1.5#2#3#4#8#16#32");
2547 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2548 .f = cmd_set_bypass_timeout_parsed,
2549 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2550 "Set the NIC bypass watchdog timeout",
2553 (void *)&cmd_setbypass_timeout_set,
2554 (void *)&cmd_setbypass_timeout_bypass,
2555 (void *)&cmd_setbypass_timeout_timeout,
2556 (void *)&cmd_setbypass_timeout_value,
2561 /* *** SHOW NIC BYPASS MODE *** */
2562 struct cmd_show_bypass_config_result {
2563 cmdline_fixed_string_t show;
2564 cmdline_fixed_string_t bypass;
2565 cmdline_fixed_string_t config;
2570 cmd_show_bypass_config_parsed(void *parsed_result,
2571 __attribute__((unused)) struct cmdline *cl,
2572 __attribute__((unused)) void *data)
2574 struct cmd_show_bypass_config_result *res = parsed_result;
2575 uint32_t event_mode;
2576 uint32_t bypass_mode;
2577 portid_t port_id = res->port_id;
2578 uint32_t timeout = bypass_timeout;
2581 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2582 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2583 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2584 {"UNKNOWN", "normal", "bypass", "isolate"};
2585 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2592 int num_events = (sizeof events) / (sizeof events[0]);
2594 if (!bypass_is_supported(port_id))
2597 /* Display the bypass mode.*/
2598 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2599 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2603 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2604 bypass_mode = RTE_BYPASS_MODE_NONE;
2606 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2609 /* Display the bypass timeout.*/
2610 if (!RTE_BYPASS_TMT_VALID(timeout))
2611 timeout = RTE_BYPASS_TMT_OFF;
2613 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2615 /* Display the bypass events and associated modes. */
2616 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2618 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2619 printf("\tFailed to get bypass mode for event = %s\n",
2622 if (!RTE_BYPASS_MODE_VALID(event_mode))
2623 event_mode = RTE_BYPASS_MODE_NONE;
2625 printf("\tbypass event: %-16s = %s\n", events[i],
2631 cmdline_parse_token_string_t cmd_showbypass_config_show =
2632 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2634 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2635 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2637 cmdline_parse_token_string_t cmd_showbypass_config_config =
2638 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2640 cmdline_parse_token_num_t cmd_showbypass_config_port =
2641 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2644 cmdline_parse_inst_t cmd_show_bypass_config = {
2645 .f = cmd_show_bypass_config_parsed,
2646 .help_str = "show bypass config (port_id): "
2647 "Show the NIC bypass config for port_id",
2650 (void *)&cmd_showbypass_config_show,
2651 (void *)&cmd_showbypass_config_bypass,
2652 (void *)&cmd_showbypass_config_config,
2653 (void *)&cmd_showbypass_config_port,
2659 /* *** SET FORWARDING MODE *** */
2660 struct cmd_set_fwd_mode_result {
2661 cmdline_fixed_string_t set;
2662 cmdline_fixed_string_t fwd;
2663 cmdline_fixed_string_t mode;
2666 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2667 __attribute__((unused)) struct cmdline *cl,
2668 __attribute__((unused)) void *data)
2670 struct cmd_set_fwd_mode_result *res = parsed_result;
2672 set_pkt_forwarding_mode(res->mode);
2675 cmdline_parse_token_string_t cmd_setfwd_set =
2676 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2677 cmdline_parse_token_string_t cmd_setfwd_fwd =
2678 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2679 cmdline_parse_token_string_t cmd_setfwd_mode =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2681 #ifdef RTE_LIBRTE_IEEE1588
2682 "io#mac#rxonly#txonly#csum#ieee1588");
2684 "io#mac#rxonly#txonly#csum");
2687 cmdline_parse_inst_t cmd_set_fwd_mode = {
2688 .f = cmd_set_fwd_mode_parsed,
2690 #ifdef RTE_LIBRTE_IEEE1588
2691 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2692 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2694 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2695 " RXONLY, CSUM or TXONLY packet forwarding mode",
2698 (void *)&cmd_setfwd_set,
2699 (void *)&cmd_setfwd_fwd,
2700 (void *)&cmd_setfwd_mode,
2705 /* *** SET PROMISC MODE *** */
2706 struct cmd_set_promisc_mode_result {
2707 cmdline_fixed_string_t set;
2708 cmdline_fixed_string_t promisc;
2709 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2710 uint8_t port_num; /* valid if "allports" argument == 0 */
2711 cmdline_fixed_string_t mode;
2714 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2715 __attribute__((unused)) struct cmdline *cl,
2718 struct cmd_set_promisc_mode_result *res = parsed_result;
2722 if (!strcmp(res->mode, "on"))
2729 for (i = 0; i < nb_ports; i++) {
2731 rte_eth_promiscuous_enable(i);
2733 rte_eth_promiscuous_disable(i);
2738 rte_eth_promiscuous_enable(res->port_num);
2740 rte_eth_promiscuous_disable(res->port_num);
2744 cmdline_parse_token_string_t cmd_setpromisc_set =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2746 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2747 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2749 cmdline_parse_token_string_t cmd_setpromisc_portall =
2750 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2752 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2753 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2755 cmdline_parse_token_string_t cmd_setpromisc_mode =
2756 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2759 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2760 .f = cmd_set_promisc_mode_parsed,
2762 .help_str = "set promisc all on|off: set promisc mode for all ports",
2764 (void *)&cmd_setpromisc_set,
2765 (void *)&cmd_setpromisc_promisc,
2766 (void *)&cmd_setpromisc_portall,
2767 (void *)&cmd_setpromisc_mode,
2772 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2773 .f = cmd_set_promisc_mode_parsed,
2775 .help_str = "set promisc X on|off: set promisc mode on port X",
2777 (void *)&cmd_setpromisc_set,
2778 (void *)&cmd_setpromisc_promisc,
2779 (void *)&cmd_setpromisc_portnum,
2780 (void *)&cmd_setpromisc_mode,
2785 /* *** SET ALLMULTI MODE *** */
2786 struct cmd_set_allmulti_mode_result {
2787 cmdline_fixed_string_t set;
2788 cmdline_fixed_string_t allmulti;
2789 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2790 uint8_t port_num; /* valid if "allports" argument == 0 */
2791 cmdline_fixed_string_t mode;
2794 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2795 __attribute__((unused)) struct cmdline *cl,
2798 struct cmd_set_allmulti_mode_result *res = parsed_result;
2802 if (!strcmp(res->mode, "on"))
2809 for (i = 0; i < nb_ports; i++) {
2811 rte_eth_allmulticast_enable(i);
2813 rte_eth_allmulticast_disable(i);
2818 rte_eth_allmulticast_enable(res->port_num);
2820 rte_eth_allmulticast_disable(res->port_num);
2824 cmdline_parse_token_string_t cmd_setallmulti_set =
2825 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2826 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2827 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2829 cmdline_parse_token_string_t cmd_setallmulti_portall =
2830 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2832 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2833 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2835 cmdline_parse_token_string_t cmd_setallmulti_mode =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2839 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2840 .f = cmd_set_allmulti_mode_parsed,
2842 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2844 (void *)&cmd_setallmulti_set,
2845 (void *)&cmd_setallmulti_allmulti,
2846 (void *)&cmd_setallmulti_portall,
2847 (void *)&cmd_setallmulti_mode,
2852 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2853 .f = cmd_set_allmulti_mode_parsed,
2855 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2857 (void *)&cmd_setallmulti_set,
2858 (void *)&cmd_setallmulti_allmulti,
2859 (void *)&cmd_setallmulti_portnum,
2860 (void *)&cmd_setallmulti_mode,
2865 /* *** ADD/REMOVE A PKT FILTER *** */
2866 struct cmd_pkt_filter_result {
2867 cmdline_fixed_string_t pkt_filter;
2869 cmdline_fixed_string_t protocol;
2870 cmdline_fixed_string_t src;
2871 cmdline_ipaddr_t ip_src;
2873 cmdline_fixed_string_t dst;
2874 cmdline_ipaddr_t ip_dst;
2876 cmdline_fixed_string_t flexbytes;
2877 uint16_t flexbytes_value;
2878 cmdline_fixed_string_t vlan;
2880 cmdline_fixed_string_t queue;
2882 cmdline_fixed_string_t soft;
2887 cmd_pkt_filter_parsed(void *parsed_result,
2888 __attribute__((unused)) struct cmdline *cl,
2889 __attribute__((unused)) void *data)
2891 struct rte_fdir_filter fdir_filter;
2892 struct cmd_pkt_filter_result *res = parsed_result;
2894 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2896 if (res->ip_src.family == AF_INET)
2897 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2899 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2900 &(res->ip_src.addr.ipv6),
2901 sizeof(struct in6_addr));
2903 if (res->ip_dst.family == AF_INET)
2904 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2906 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2907 &(res->ip_dst.addr.ipv6),
2908 sizeof(struct in6_addr));
2910 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2911 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2913 if (!strcmp(res->protocol, "udp"))
2914 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2915 else if (!strcmp(res->protocol, "tcp"))
2916 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2917 else if (!strcmp(res->protocol, "sctp"))
2918 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2919 else /* default only IP */
2920 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2922 if (res->ip_dst.family == AF_INET6)
2923 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2925 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2927 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2928 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2930 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2931 fdir_add_signature_filter(res->port_id, res->queue_id,
2933 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2934 fdir_update_signature_filter(res->port_id, res->queue_id,
2936 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2937 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2938 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2939 fdir_add_perfect_filter(res->port_id, res->soft_id,
2941 (uint8_t) (res->queue_id < 0),
2943 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2944 fdir_update_perfect_filter(res->port_id, res->soft_id,
2946 (uint8_t) (res->queue_id < 0),
2948 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2949 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2955 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2956 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2958 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2959 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2960 protocol, "ip#tcp#udp#sctp");
2961 cmdline_parse_token_string_t cmd_pkt_filter_src =
2962 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2964 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2965 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2967 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2968 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2970 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2971 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2973 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2974 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2976 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2977 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2979 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2980 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2981 flexbytes, "flexbytes");
2982 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2983 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2984 flexbytes_value, UINT16);
2985 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2986 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2988 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2989 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2991 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2992 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2994 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2995 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2997 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2998 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3000 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3001 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3005 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3006 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3007 pkt_filter, "add_signature_filter");
3008 cmdline_parse_inst_t cmd_add_signature_filter = {
3009 .f = cmd_pkt_filter_parsed,
3011 .help_str = "add a signature filter",
3013 (void *)&cmd_pkt_filter_add_signature_filter,
3014 (void *)&cmd_pkt_filter_port_id,
3015 (void *)&cmd_pkt_filter_protocol,
3016 (void *)&cmd_pkt_filter_src,
3017 (void *)&cmd_pkt_filter_ip_src,
3018 (void *)&cmd_pkt_filter_port_src,
3019 (void *)&cmd_pkt_filter_dst,
3020 (void *)&cmd_pkt_filter_ip_dst,
3021 (void *)&cmd_pkt_filter_port_dst,
3022 (void *)&cmd_pkt_filter_flexbytes,
3023 (void *)&cmd_pkt_filter_flexbytes_value,
3024 (void *)&cmd_pkt_filter_vlan,
3025 (void *)&cmd_pkt_filter_vlan_id,
3026 (void *)&cmd_pkt_filter_queue,
3027 (void *)&cmd_pkt_filter_queue_id,
3033 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3034 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3035 pkt_filter, "upd_signature_filter");
3036 cmdline_parse_inst_t cmd_upd_signature_filter = {
3037 .f = cmd_pkt_filter_parsed,
3039 .help_str = "update a signature filter",
3041 (void *)&cmd_pkt_filter_upd_signature_filter,
3042 (void *)&cmd_pkt_filter_port_id,
3043 (void *)&cmd_pkt_filter_protocol,
3044 (void *)&cmd_pkt_filter_src,
3045 (void *)&cmd_pkt_filter_ip_src,
3046 (void *)&cmd_pkt_filter_port_src,
3047 (void *)&cmd_pkt_filter_dst,
3048 (void *)&cmd_pkt_filter_ip_dst,
3049 (void *)&cmd_pkt_filter_port_dst,
3050 (void *)&cmd_pkt_filter_flexbytes,
3051 (void *)&cmd_pkt_filter_flexbytes_value,
3052 (void *)&cmd_pkt_filter_vlan,
3053 (void *)&cmd_pkt_filter_vlan_id,
3054 (void *)&cmd_pkt_filter_queue,
3055 (void *)&cmd_pkt_filter_queue_id,
3061 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3062 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3063 pkt_filter, "rm_signature_filter");
3064 cmdline_parse_inst_t cmd_rm_signature_filter = {
3065 .f = cmd_pkt_filter_parsed,
3067 .help_str = "remove a signature filter",
3069 (void *)&cmd_pkt_filter_rm_signature_filter,
3070 (void *)&cmd_pkt_filter_port_id,
3071 (void *)&cmd_pkt_filter_protocol,
3072 (void *)&cmd_pkt_filter_src,
3073 (void *)&cmd_pkt_filter_ip_src,
3074 (void *)&cmd_pkt_filter_port_src,
3075 (void *)&cmd_pkt_filter_dst,
3076 (void *)&cmd_pkt_filter_ip_dst,
3077 (void *)&cmd_pkt_filter_port_dst,
3078 (void *)&cmd_pkt_filter_flexbytes,
3079 (void *)&cmd_pkt_filter_flexbytes_value,
3080 (void *)&cmd_pkt_filter_vlan,
3081 (void *)&cmd_pkt_filter_vlan_id,
3087 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3088 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3089 pkt_filter, "add_perfect_filter");
3090 cmdline_parse_inst_t cmd_add_perfect_filter = {
3091 .f = cmd_pkt_filter_parsed,
3093 .help_str = "add a perfect filter",
3095 (void *)&cmd_pkt_filter_add_perfect_filter,
3096 (void *)&cmd_pkt_filter_port_id,
3097 (void *)&cmd_pkt_filter_protocol,
3098 (void *)&cmd_pkt_filter_src,
3099 (void *)&cmd_pkt_filter_ip_src,
3100 (void *)&cmd_pkt_filter_port_src,
3101 (void *)&cmd_pkt_filter_dst,
3102 (void *)&cmd_pkt_filter_ip_dst,
3103 (void *)&cmd_pkt_filter_port_dst,
3104 (void *)&cmd_pkt_filter_flexbytes,
3105 (void *)&cmd_pkt_filter_flexbytes_value,
3106 (void *)&cmd_pkt_filter_vlan,
3107 (void *)&cmd_pkt_filter_vlan_id,
3108 (void *)&cmd_pkt_filter_queue,
3109 (void *)&cmd_pkt_filter_queue_id,
3110 (void *)&cmd_pkt_filter_soft,
3111 (void *)&cmd_pkt_filter_soft_id,
3117 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3118 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3119 pkt_filter, "upd_perfect_filter");
3120 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3121 .f = cmd_pkt_filter_parsed,
3123 .help_str = "update a perfect filter",
3125 (void *)&cmd_pkt_filter_upd_perfect_filter,
3126 (void *)&cmd_pkt_filter_port_id,
3127 (void *)&cmd_pkt_filter_protocol,
3128 (void *)&cmd_pkt_filter_src,
3129 (void *)&cmd_pkt_filter_ip_src,
3130 (void *)&cmd_pkt_filter_port_src,
3131 (void *)&cmd_pkt_filter_dst,
3132 (void *)&cmd_pkt_filter_ip_dst,
3133 (void *)&cmd_pkt_filter_port_dst,
3134 (void *)&cmd_pkt_filter_flexbytes,
3135 (void *)&cmd_pkt_filter_flexbytes_value,
3136 (void *)&cmd_pkt_filter_vlan,
3137 (void *)&cmd_pkt_filter_vlan_id,
3138 (void *)&cmd_pkt_filter_queue,
3139 (void *)&cmd_pkt_filter_queue_id,
3140 (void *)&cmd_pkt_filter_soft,
3141 (void *)&cmd_pkt_filter_soft_id,
3147 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3148 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3149 pkt_filter, "rm_perfect_filter");
3150 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3151 .f = cmd_pkt_filter_parsed,
3153 .help_str = "remove a perfect filter",
3155 (void *)&cmd_pkt_filter_rm_perfect_filter,
3156 (void *)&cmd_pkt_filter_port_id,
3157 (void *)&cmd_pkt_filter_protocol,
3158 (void *)&cmd_pkt_filter_src,
3159 (void *)&cmd_pkt_filter_ip_src,
3160 (void *)&cmd_pkt_filter_port_src,
3161 (void *)&cmd_pkt_filter_dst,
3162 (void *)&cmd_pkt_filter_ip_dst,
3163 (void *)&cmd_pkt_filter_port_dst,
3164 (void *)&cmd_pkt_filter_flexbytes,
3165 (void *)&cmd_pkt_filter_flexbytes_value,
3166 (void *)&cmd_pkt_filter_vlan,
3167 (void *)&cmd_pkt_filter_vlan_id,
3168 (void *)&cmd_pkt_filter_soft,
3169 (void *)&cmd_pkt_filter_soft_id,
3174 /* *** SETUP MASKS FILTER *** */
3175 struct cmd_pkt_filter_masks_result {
3176 cmdline_fixed_string_t filter_mask;
3178 cmdline_fixed_string_t src_mask;
3179 uint32_t ip_src_mask;
3180 uint16_t ipv6_src_mask;
3181 uint16_t port_src_mask;
3182 cmdline_fixed_string_t dst_mask;
3183 uint32_t ip_dst_mask;
3184 uint16_t ipv6_dst_mask;
3185 uint16_t port_dst_mask;
3186 cmdline_fixed_string_t flexbytes;
3187 uint8_t flexbytes_value;
3188 cmdline_fixed_string_t vlan_id;
3189 uint8_t vlan_id_value;
3190 cmdline_fixed_string_t vlan_prio;
3191 uint8_t vlan_prio_value;
3192 cmdline_fixed_string_t only_ip_flow;
3193 uint8_t only_ip_flow_value;
3194 cmdline_fixed_string_t comp_ipv6_dst;
3195 uint8_t comp_ipv6_dst_value;
3199 cmd_pkt_filter_masks_parsed(void *parsed_result,
3200 __attribute__((unused)) struct cmdline *cl,
3201 __attribute__((unused)) void *data)
3203 struct rte_fdir_masks fdir_masks;
3204 struct cmd_pkt_filter_masks_result *res = parsed_result;
3206 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3208 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3209 fdir_masks.vlan_id = res->vlan_id_value;
3210 fdir_masks.vlan_prio = res->vlan_prio_value;
3211 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3212 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3213 fdir_masks.src_port_mask = res->port_src_mask;
3214 fdir_masks.dst_port_mask = res->port_dst_mask;
3215 fdir_masks.flexbytes = res->flexbytes_value;
3217 fdir_set_masks(res->port_id, &fdir_masks);
3220 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3221 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3222 filter_mask, "set_masks_filter");
3223 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3224 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3226 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3227 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3228 only_ip_flow, "only_ip_flow");
3229 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3230 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3231 only_ip_flow_value, UINT8);
3232 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3233 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3234 src_mask, "src_mask");
3235 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3236 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3237 ip_src_mask, UINT32);
3238 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3239 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3240 port_src_mask, UINT16);
3241 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3242 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3243 dst_mask, "dst_mask");
3244 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3245 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3246 ip_dst_mask, UINT32);
3247 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3248 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3249 port_dst_mask, UINT16);
3250 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3251 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3252 flexbytes, "flexbytes");
3253 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3254 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3255 flexbytes_value, UINT8);
3256 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3257 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3258 vlan_id, "vlan_id");
3259 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3260 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3261 vlan_id_value, UINT8);
3262 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3263 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3264 vlan_prio, "vlan_prio");
3265 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3266 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3267 vlan_prio_value, UINT8);
3269 cmdline_parse_inst_t cmd_set_masks_filter = {
3270 .f = cmd_pkt_filter_masks_parsed,
3272 .help_str = "setup masks filter",
3274 (void *)&cmd_pkt_filter_masks_filter_mask,
3275 (void *)&cmd_pkt_filter_masks_port_id,
3276 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3277 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3278 (void *)&cmd_pkt_filter_masks_src_mask,
3279 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3280 (void *)&cmd_pkt_filter_masks_port_src_mask,
3281 (void *)&cmd_pkt_filter_masks_dst_mask,
3282 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3283 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3284 (void *)&cmd_pkt_filter_masks_flexbytes,
3285 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3286 (void *)&cmd_pkt_filter_masks_vlan_id,
3287 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3288 (void *)&cmd_pkt_filter_masks_vlan_prio,
3289 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3295 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3299 struct rte_fdir_masks fdir_masks;
3300 struct cmd_pkt_filter_masks_result *res = parsed_result;
3302 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3304 fdir_masks.set_ipv6_mask = 1;
3305 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3306 fdir_masks.vlan_id = res->vlan_id_value;
3307 fdir_masks.vlan_prio = res->vlan_prio_value;
3308 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3309 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3310 fdir_masks.src_port_mask = res->port_src_mask;
3311 fdir_masks.dst_port_mask = res->port_dst_mask;
3312 fdir_masks.flexbytes = res->flexbytes_value;
3313 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3315 fdir_set_masks(res->port_id, &fdir_masks);
3318 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3319 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3320 filter_mask, "set_ipv6_masks_filter");
3321 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3322 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3323 ipv6_src_mask, UINT16);
3324 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3325 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3326 ipv6_dst_mask, UINT16);
3328 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3329 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3330 comp_ipv6_dst, "compare_dst");
3331 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3332 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3333 comp_ipv6_dst_value, UINT8);
3335 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3336 .f = cmd_pkt_filter_masks_ipv6_parsed,
3338 .help_str = "setup ipv6 masks filter",
3340 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3341 (void *)&cmd_pkt_filter_masks_port_id,
3342 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3343 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3344 (void *)&cmd_pkt_filter_masks_src_mask,
3345 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3346 (void *)&cmd_pkt_filter_masks_port_src_mask,
3347 (void *)&cmd_pkt_filter_masks_dst_mask,
3348 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3349 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3350 (void *)&cmd_pkt_filter_masks_flexbytes,
3351 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3352 (void *)&cmd_pkt_filter_masks_vlan_id,
3353 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3354 (void *)&cmd_pkt_filter_masks_vlan_prio,
3355 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3356 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3357 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3362 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3363 struct cmd_link_flow_ctrl_set_result {
3364 cmdline_fixed_string_t set;
3365 cmdline_fixed_string_t flow_ctrl;
3366 cmdline_fixed_string_t rx;
3367 cmdline_fixed_string_t rx_lfc_mode;
3368 cmdline_fixed_string_t tx;
3369 cmdline_fixed_string_t tx_lfc_mode;
3370 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3371 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3372 uint32_t high_water;
3374 uint16_t pause_time;
3380 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3381 __attribute__((unused)) struct cmdline *cl,
3382 __attribute__((unused)) void *data)
3384 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3385 struct rte_eth_fc_conf fc_conf;
3386 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3390 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3391 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3392 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3393 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3395 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3396 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3399 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3400 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3401 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3403 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3404 fc_conf.high_water = res->high_water;
3405 fc_conf.low_water = res->low_water;
3406 fc_conf.pause_time = res->pause_time;
3407 fc_conf.send_xon = res->send_xon;
3408 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3410 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3412 printf("bad flow contrl parameter, return code = %d \n", ret);
3415 cmdline_parse_token_string_t cmd_lfc_set_set =
3416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3418 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3419 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3420 flow_ctrl, "flow_ctrl");
3421 cmdline_parse_token_string_t cmd_lfc_set_rx =
3422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3424 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3426 rx_lfc_mode, "on#off");
3427 cmdline_parse_token_string_t cmd_lfc_set_tx =
3428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3430 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3432 tx_lfc_mode, "on#off");
3433 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3435 high_water, UINT32);
3436 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3437 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3439 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3440 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3441 pause_time, UINT16);
3442 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3443 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3445 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3446 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3447 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3448 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3449 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3450 mac_ctrl_frame_fwd_mode, "on#off");
3451 cmdline_parse_token_num_t cmd_lfc_set_portid =
3452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3455 cmdline_parse_inst_t cmd_link_flow_control_set = {
3456 .f = cmd_link_flow_ctrl_set_parsed,
3458 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3459 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3462 (void *)&cmd_lfc_set_set,
3463 (void *)&cmd_lfc_set_flow_ctrl,
3464 (void *)&cmd_lfc_set_rx,
3465 (void *)&cmd_lfc_set_rx_mode,
3466 (void *)&cmd_lfc_set_tx,
3467 (void *)&cmd_lfc_set_tx_mode,
3468 (void *)&cmd_lfc_set_high_water,
3469 (void *)&cmd_lfc_set_low_water,
3470 (void *)&cmd_lfc_set_pause_time,
3471 (void *)&cmd_lfc_set_send_xon,
3472 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3473 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3474 (void *)&cmd_lfc_set_portid,
3479 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3480 struct cmd_priority_flow_ctrl_set_result {
3481 cmdline_fixed_string_t set;
3482 cmdline_fixed_string_t pfc_ctrl;
3483 cmdline_fixed_string_t rx;
3484 cmdline_fixed_string_t rx_pfc_mode;
3485 cmdline_fixed_string_t tx;
3486 cmdline_fixed_string_t tx_pfc_mode;
3487 uint32_t high_water;
3489 uint16_t pause_time;
3495 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3496 __attribute__((unused)) struct cmdline *cl,
3497 __attribute__((unused)) void *data)
3499 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3500 struct rte_eth_pfc_conf pfc_conf;
3501 int rx_fc_enable, tx_fc_enable;
3505 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3506 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3507 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3508 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3510 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3511 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3514 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3515 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3516 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3517 pfc_conf.fc.high_water = res->high_water;
3518 pfc_conf.fc.low_water = res->low_water;
3519 pfc_conf.fc.pause_time = res->pause_time;
3520 pfc_conf.priority = res->priority;
3522 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3524 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3527 cmdline_parse_token_string_t cmd_pfc_set_set =
3528 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3530 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3531 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3532 pfc_ctrl, "pfc_ctrl");
3533 cmdline_parse_token_string_t cmd_pfc_set_rx =
3534 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3536 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3537 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3538 rx_pfc_mode, "on#off");
3539 cmdline_parse_token_string_t cmd_pfc_set_tx =
3540 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3542 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3543 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3544 tx_pfc_mode, "on#off");
3545 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3546 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3547 high_water, UINT32);
3548 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3549 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3551 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3552 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3553 pause_time, UINT16);
3554 cmdline_parse_token_num_t cmd_pfc_set_priority =
3555 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3557 cmdline_parse_token_num_t cmd_pfc_set_portid =
3558 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3561 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3562 .f = cmd_priority_flow_ctrl_set_parsed,
3564 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3565 tx on|off high_water low_water pause_time priority port_id",
3567 (void *)&cmd_pfc_set_set,
3568 (void *)&cmd_pfc_set_flow_ctrl,
3569 (void *)&cmd_pfc_set_rx,
3570 (void *)&cmd_pfc_set_rx_mode,
3571 (void *)&cmd_pfc_set_tx,
3572 (void *)&cmd_pfc_set_tx_mode,
3573 (void *)&cmd_pfc_set_high_water,
3574 (void *)&cmd_pfc_set_low_water,
3575 (void *)&cmd_pfc_set_pause_time,
3576 (void *)&cmd_pfc_set_priority,
3577 (void *)&cmd_pfc_set_portid,
3582 /* *** RESET CONFIGURATION *** */
3583 struct cmd_reset_result {
3584 cmdline_fixed_string_t reset;
3585 cmdline_fixed_string_t def;
3588 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3590 __attribute__((unused)) void *data)
3592 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3593 set_def_fwd_config();
3596 cmdline_parse_token_string_t cmd_reset_set =
3597 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3598 cmdline_parse_token_string_t cmd_reset_def =
3599 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3602 cmdline_parse_inst_t cmd_reset = {
3603 .f = cmd_reset_parsed,
3605 .help_str = "set default: reset default forwarding configuration",
3607 (void *)&cmd_reset_set,
3608 (void *)&cmd_reset_def,
3613 /* *** START FORWARDING *** */
3614 struct cmd_start_result {
3615 cmdline_fixed_string_t start;
3618 cmdline_parse_token_string_t cmd_start_start =
3619 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3621 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3622 __attribute__((unused)) struct cmdline *cl,
3623 __attribute__((unused)) void *data)
3625 start_packet_forwarding(0);
3628 cmdline_parse_inst_t cmd_start = {
3629 .f = cmd_start_parsed,
3631 .help_str = "start packet forwarding",
3633 (void *)&cmd_start_start,
3638 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3639 struct cmd_start_tx_first_result {
3640 cmdline_fixed_string_t start;
3641 cmdline_fixed_string_t tx_first;
3645 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3646 __attribute__((unused)) struct cmdline *cl,
3647 __attribute__((unused)) void *data)
3649 start_packet_forwarding(1);
3652 cmdline_parse_token_string_t cmd_start_tx_first_start =
3653 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3655 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3656 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3657 tx_first, "tx_first");
3659 cmdline_parse_inst_t cmd_start_tx_first = {
3660 .f = cmd_start_tx_first_parsed,
3662 .help_str = "start packet forwarding, after sending 1 burst of packets",
3664 (void *)&cmd_start_tx_first_start,
3665 (void *)&cmd_start_tx_first_tx_first,
3670 /* *** SHOW CFG *** */
3671 struct cmd_showcfg_result {
3672 cmdline_fixed_string_t show;
3673 cmdline_fixed_string_t cfg;
3674 cmdline_fixed_string_t what;
3677 static void cmd_showcfg_parsed(void *parsed_result,
3678 __attribute__((unused)) struct cmdline *cl,
3679 __attribute__((unused)) void *data)
3681 struct cmd_showcfg_result *res = parsed_result;
3682 if (!strcmp(res->what, "rxtx"))
3683 rxtx_config_display();
3684 else if (!strcmp(res->what, "cores"))
3685 fwd_lcores_config_display();
3686 else if (!strcmp(res->what, "fwd"))
3687 fwd_config_display();
3690 cmdline_parse_token_string_t cmd_showcfg_show =
3691 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3692 cmdline_parse_token_string_t cmd_showcfg_port =
3693 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3694 cmdline_parse_token_string_t cmd_showcfg_what =
3695 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3698 cmdline_parse_inst_t cmd_showcfg = {
3699 .f = cmd_showcfg_parsed,
3701 .help_str = "show config rxtx|cores|fwd",
3703 (void *)&cmd_showcfg_show,
3704 (void *)&cmd_showcfg_port,
3705 (void *)&cmd_showcfg_what,
3710 /* *** SHOW ALL PORT INFO *** */
3711 struct cmd_showportall_result {
3712 cmdline_fixed_string_t show;
3713 cmdline_fixed_string_t port;
3714 cmdline_fixed_string_t what;
3715 cmdline_fixed_string_t all;
3718 static void cmd_showportall_parsed(void *parsed_result,
3719 __attribute__((unused)) struct cmdline *cl,
3720 __attribute__((unused)) void *data)
3724 struct cmd_showportall_result *res = parsed_result;
3725 if (!strcmp(res->show, "clear")) {
3726 if (!strcmp(res->what, "stats"))
3727 for (i = 0; i < nb_ports; i++)
3729 } else if (!strcmp(res->what, "info"))
3730 for (i = 0; i < nb_ports; i++)
3731 port_infos_display(i);
3732 else if (!strcmp(res->what, "stats"))
3733 for (i = 0; i < nb_ports; i++)
3734 nic_stats_display(i);
3735 else if (!strcmp(res->what, "fdir"))
3736 for (i = 0; i < nb_ports; i++)
3738 else if (!strcmp(res->what, "stat_qmap"))
3739 for (i = 0; i < nb_ports; i++)
3740 nic_stats_mapping_display(i);
3743 cmdline_parse_token_string_t cmd_showportall_show =
3744 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3746 cmdline_parse_token_string_t cmd_showportall_port =
3747 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3748 cmdline_parse_token_string_t cmd_showportall_what =
3749 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3750 "info#stats#fdir#stat_qmap");
3751 cmdline_parse_token_string_t cmd_showportall_all =
3752 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3753 cmdline_parse_inst_t cmd_showportall = {
3754 .f = cmd_showportall_parsed,
3756 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3758 (void *)&cmd_showportall_show,
3759 (void *)&cmd_showportall_port,
3760 (void *)&cmd_showportall_what,
3761 (void *)&cmd_showportall_all,
3766 /* *** SHOW PORT INFO *** */
3767 struct cmd_showport_result {
3768 cmdline_fixed_string_t show;
3769 cmdline_fixed_string_t port;
3770 cmdline_fixed_string_t what;
3774 static void cmd_showport_parsed(void *parsed_result,
3775 __attribute__((unused)) struct cmdline *cl,
3776 __attribute__((unused)) void *data)
3778 struct cmd_showport_result *res = parsed_result;
3779 if (!strcmp(res->show, "clear")) {
3780 if (!strcmp(res->what, "stats"))
3781 nic_stats_clear(res->portnum);
3782 } else if (!strcmp(res->what, "info"))
3783 port_infos_display(res->portnum);
3784 else if (!strcmp(res->what, "stats"))
3785 nic_stats_display(res->portnum);
3786 else if (!strcmp(res->what, "fdir"))
3787 fdir_get_infos(res->portnum);
3788 else if (!strcmp(res->what, "stat_qmap"))
3789 nic_stats_mapping_display(res->portnum);
3792 cmdline_parse_token_string_t cmd_showport_show =
3793 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3795 cmdline_parse_token_string_t cmd_showport_port =
3796 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3797 cmdline_parse_token_string_t cmd_showport_what =
3798 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3799 "info#stats#fdir#stat_qmap");
3800 cmdline_parse_token_num_t cmd_showport_portnum =
3801 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3803 cmdline_parse_inst_t cmd_showport = {
3804 .f = cmd_showport_parsed,
3806 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3808 (void *)&cmd_showport_show,
3809 (void *)&cmd_showport_port,
3810 (void *)&cmd_showport_what,
3811 (void *)&cmd_showport_portnum,
3816 /* *** READ PORT REGISTER *** */
3817 struct cmd_read_reg_result {
3818 cmdline_fixed_string_t read;
3819 cmdline_fixed_string_t reg;
3825 cmd_read_reg_parsed(void *parsed_result,
3826 __attribute__((unused)) struct cmdline *cl,
3827 __attribute__((unused)) void *data)
3829 struct cmd_read_reg_result *res = parsed_result;
3830 port_reg_display(res->port_id, res->reg_off);
3833 cmdline_parse_token_string_t cmd_read_reg_read =
3834 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3835 cmdline_parse_token_string_t cmd_read_reg_reg =
3836 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3837 cmdline_parse_token_num_t cmd_read_reg_port_id =
3838 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3839 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3840 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3842 cmdline_parse_inst_t cmd_read_reg = {
3843 .f = cmd_read_reg_parsed,
3845 .help_str = "read reg port_id reg_off",
3847 (void *)&cmd_read_reg_read,
3848 (void *)&cmd_read_reg_reg,
3849 (void *)&cmd_read_reg_port_id,
3850 (void *)&cmd_read_reg_reg_off,
3855 /* *** READ PORT REGISTER BIT FIELD *** */
3856 struct cmd_read_reg_bit_field_result {
3857 cmdline_fixed_string_t read;
3858 cmdline_fixed_string_t regfield;
3866 cmd_read_reg_bit_field_parsed(void *parsed_result,
3867 __attribute__((unused)) struct cmdline *cl,
3868 __attribute__((unused)) void *data)
3870 struct cmd_read_reg_bit_field_result *res = parsed_result;
3871 port_reg_bit_field_display(res->port_id, res->reg_off,
3872 res->bit1_pos, res->bit2_pos);
3875 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3876 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3878 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3879 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3880 regfield, "regfield");
3881 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3882 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3884 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3885 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3887 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3888 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3890 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3891 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3894 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3895 .f = cmd_read_reg_bit_field_parsed,
3897 .help_str = "read regfield port_id reg_off bit_x bit_y "
3898 "(read register bit field between bit_x and bit_y included)",
3900 (void *)&cmd_read_reg_bit_field_read,
3901 (void *)&cmd_read_reg_bit_field_regfield,
3902 (void *)&cmd_read_reg_bit_field_port_id,
3903 (void *)&cmd_read_reg_bit_field_reg_off,
3904 (void *)&cmd_read_reg_bit_field_bit1_pos,
3905 (void *)&cmd_read_reg_bit_field_bit2_pos,
3910 /* *** READ PORT REGISTER BIT *** */
3911 struct cmd_read_reg_bit_result {
3912 cmdline_fixed_string_t read;
3913 cmdline_fixed_string_t regbit;
3920 cmd_read_reg_bit_parsed(void *parsed_result,
3921 __attribute__((unused)) struct cmdline *cl,
3922 __attribute__((unused)) void *data)
3924 struct cmd_read_reg_bit_result *res = parsed_result;
3925 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3928 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3929 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3930 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3931 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3933 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3934 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3935 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3936 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3937 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3938 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3940 cmdline_parse_inst_t cmd_read_reg_bit = {
3941 .f = cmd_read_reg_bit_parsed,
3943 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3945 (void *)&cmd_read_reg_bit_read,
3946 (void *)&cmd_read_reg_bit_regbit,
3947 (void *)&cmd_read_reg_bit_port_id,
3948 (void *)&cmd_read_reg_bit_reg_off,
3949 (void *)&cmd_read_reg_bit_bit_pos,
3954 /* *** WRITE PORT REGISTER *** */
3955 struct cmd_write_reg_result {
3956 cmdline_fixed_string_t write;
3957 cmdline_fixed_string_t reg;
3964 cmd_write_reg_parsed(void *parsed_result,
3965 __attribute__((unused)) struct cmdline *cl,
3966 __attribute__((unused)) void *data)
3968 struct cmd_write_reg_result *res = parsed_result;
3969 port_reg_set(res->port_id, res->reg_off, res->value);
3972 cmdline_parse_token_string_t cmd_write_reg_write =
3973 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3974 cmdline_parse_token_string_t cmd_write_reg_reg =
3975 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3976 cmdline_parse_token_num_t cmd_write_reg_port_id =
3977 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3978 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3979 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3980 cmdline_parse_token_num_t cmd_write_reg_value =
3981 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3983 cmdline_parse_inst_t cmd_write_reg = {
3984 .f = cmd_write_reg_parsed,
3986 .help_str = "write reg port_id reg_off reg_value",
3988 (void *)&cmd_write_reg_write,
3989 (void *)&cmd_write_reg_reg,
3990 (void *)&cmd_write_reg_port_id,
3991 (void *)&cmd_write_reg_reg_off,
3992 (void *)&cmd_write_reg_value,
3997 /* *** WRITE PORT REGISTER BIT FIELD *** */
3998 struct cmd_write_reg_bit_field_result {
3999 cmdline_fixed_string_t write;
4000 cmdline_fixed_string_t regfield;
4009 cmd_write_reg_bit_field_parsed(void *parsed_result,
4010 __attribute__((unused)) struct cmdline *cl,
4011 __attribute__((unused)) void *data)
4013 struct cmd_write_reg_bit_field_result *res = parsed_result;
4014 port_reg_bit_field_set(res->port_id, res->reg_off,
4015 res->bit1_pos, res->bit2_pos, res->value);
4018 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4019 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4021 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4022 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4023 regfield, "regfield");
4024 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4025 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4027 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4028 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4030 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4031 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4033 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4034 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4036 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4037 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4040 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4041 .f = cmd_write_reg_bit_field_parsed,
4043 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4044 "(set register bit field between bit_x and bit_y included)",
4046 (void *)&cmd_write_reg_bit_field_write,
4047 (void *)&cmd_write_reg_bit_field_regfield,
4048 (void *)&cmd_write_reg_bit_field_port_id,
4049 (void *)&cmd_write_reg_bit_field_reg_off,
4050 (void *)&cmd_write_reg_bit_field_bit1_pos,
4051 (void *)&cmd_write_reg_bit_field_bit2_pos,
4052 (void *)&cmd_write_reg_bit_field_value,
4057 /* *** WRITE PORT REGISTER BIT *** */
4058 struct cmd_write_reg_bit_result {
4059 cmdline_fixed_string_t write;
4060 cmdline_fixed_string_t regbit;
4068 cmd_write_reg_bit_parsed(void *parsed_result,
4069 __attribute__((unused)) struct cmdline *cl,
4070 __attribute__((unused)) void *data)
4072 struct cmd_write_reg_bit_result *res = parsed_result;
4073 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4076 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4077 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4079 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4080 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4082 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4083 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4084 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4086 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4087 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4088 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4089 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4091 cmdline_parse_inst_t cmd_write_reg_bit = {
4092 .f = cmd_write_reg_bit_parsed,
4094 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4096 (void *)&cmd_write_reg_bit_write,
4097 (void *)&cmd_write_reg_bit_regbit,
4098 (void *)&cmd_write_reg_bit_port_id,
4099 (void *)&cmd_write_reg_bit_reg_off,
4100 (void *)&cmd_write_reg_bit_bit_pos,
4101 (void *)&cmd_write_reg_bit_value,
4106 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4107 struct cmd_read_rxd_txd_result {
4108 cmdline_fixed_string_t read;
4109 cmdline_fixed_string_t rxd_txd;
4116 cmd_read_rxd_txd_parsed(void *parsed_result,
4117 __attribute__((unused)) struct cmdline *cl,
4118 __attribute__((unused)) void *data)
4120 struct cmd_read_rxd_txd_result *res = parsed_result;
4122 if (!strcmp(res->rxd_txd, "rxd"))
4123 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4124 else if (!strcmp(res->rxd_txd, "txd"))
4125 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4128 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4129 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4130 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4131 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4133 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4134 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4135 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4136 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4137 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4138 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4140 cmdline_parse_inst_t cmd_read_rxd_txd = {
4141 .f = cmd_read_rxd_txd_parsed,
4143 .help_str = "read rxd|txd port_id queue_id rxd_id",
4145 (void *)&cmd_read_rxd_txd_read,
4146 (void *)&cmd_read_rxd_txd_rxd_txd,
4147 (void *)&cmd_read_rxd_txd_port_id,
4148 (void *)&cmd_read_rxd_txd_queue_id,
4149 (void *)&cmd_read_rxd_txd_desc_id,
4155 struct cmd_quit_result {
4156 cmdline_fixed_string_t quit;
4159 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4161 __attribute__((unused)) void *data)
4167 cmdline_parse_token_string_t cmd_quit_quit =
4168 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4170 cmdline_parse_inst_t cmd_quit = {
4171 .f = cmd_quit_parsed,
4173 .help_str = "exit application",
4175 (void *)&cmd_quit_quit,
4180 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4181 struct cmd_mac_addr_result {
4182 cmdline_fixed_string_t mac_addr_cmd;
4183 cmdline_fixed_string_t what;
4185 struct ether_addr address;
4188 static void cmd_mac_addr_parsed(void *parsed_result,
4189 __attribute__((unused)) struct cmdline *cl,
4190 __attribute__((unused)) void *data)
4192 struct cmd_mac_addr_result *res = parsed_result;
4195 if (strcmp(res->what, "add") == 0)
4196 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4198 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4200 /* check the return value and print it if is < 0 */
4202 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4206 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4207 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4209 cmdline_parse_token_string_t cmd_mac_addr_what =
4210 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4212 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4213 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4214 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4215 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4217 cmdline_parse_inst_t cmd_mac_addr = {
4218 .f = cmd_mac_addr_parsed,
4220 .help_str = "mac_addr add|remove X <address>: "
4221 "add/remove MAC address on port X",
4223 (void *)&cmd_mac_addr_cmd,
4224 (void *)&cmd_mac_addr_what,
4225 (void *)&cmd_mac_addr_portnum,
4226 (void *)&cmd_mac_addr_addr,
4232 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4233 struct cmd_set_qmap_result {
4234 cmdline_fixed_string_t set;
4235 cmdline_fixed_string_t qmap;
4236 cmdline_fixed_string_t what;
4243 cmd_set_qmap_parsed(void *parsed_result,
4244 __attribute__((unused)) struct cmdline *cl,
4245 __attribute__((unused)) void *data)
4247 struct cmd_set_qmap_result *res = parsed_result;
4248 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4250 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4253 cmdline_parse_token_string_t cmd_setqmap_set =
4254 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4256 cmdline_parse_token_string_t cmd_setqmap_qmap =
4257 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4259 cmdline_parse_token_string_t cmd_setqmap_what =
4260 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4262 cmdline_parse_token_num_t cmd_setqmap_portid =
4263 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4265 cmdline_parse_token_num_t cmd_setqmap_queueid =
4266 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4268 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4269 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4272 cmdline_parse_inst_t cmd_set_qmap = {
4273 .f = cmd_set_qmap_parsed,
4275 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4277 (void *)&cmd_setqmap_set,
4278 (void *)&cmd_setqmap_qmap,
4279 (void *)&cmd_setqmap_what,
4280 (void *)&cmd_setqmap_portid,
4281 (void *)&cmd_setqmap_queueid,
4282 (void *)&cmd_setqmap_mapvalue,
4287 /* *** CONFIGURE UNICAST HASH TABLE *** */
4288 struct cmd_set_uc_hash_table {
4289 cmdline_fixed_string_t set;
4290 cmdline_fixed_string_t port;
4292 cmdline_fixed_string_t what;
4293 struct ether_addr address;
4294 cmdline_fixed_string_t mode;
4298 cmd_set_uc_hash_parsed(void *parsed_result,
4299 __attribute__((unused)) struct cmdline *cl,
4300 __attribute__((unused)) void *data)
4303 struct cmd_set_uc_hash_table *res = parsed_result;
4305 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4307 if (strcmp(res->what, "uta") == 0)
4308 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4309 &res->address,(uint8_t)is_on);
4311 printf("bad unicast hash table parameter, return code = %d \n", ret);
4315 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4316 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4318 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4321 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4322 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4324 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4325 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4327 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4330 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4331 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4334 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4335 .f = cmd_set_uc_hash_parsed,
4337 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4339 (void *)&cmd_set_uc_hash_set,
4340 (void *)&cmd_set_uc_hash_port,
4341 (void *)&cmd_set_uc_hash_portid,
4342 (void *)&cmd_set_uc_hash_what,
4343 (void *)&cmd_set_uc_hash_mac,
4344 (void *)&cmd_set_uc_hash_mode,
4349 struct cmd_set_uc_all_hash_table {
4350 cmdline_fixed_string_t set;
4351 cmdline_fixed_string_t port;
4353 cmdline_fixed_string_t what;
4354 cmdline_fixed_string_t value;
4355 cmdline_fixed_string_t mode;
4359 cmd_set_uc_all_hash_parsed(void *parsed_result,
4360 __attribute__((unused)) struct cmdline *cl,
4361 __attribute__((unused)) void *data)
4364 struct cmd_set_uc_all_hash_table *res = parsed_result;
4366 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4368 if ((strcmp(res->what, "uta") == 0) &&
4369 (strcmp(res->value, "all") == 0))
4370 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4372 printf("bad unicast hash table parameter,"
4373 "return code = %d \n", ret);
4376 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4379 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4382 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4383 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4385 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4386 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4388 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4391 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4392 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4395 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4396 .f = cmd_set_uc_all_hash_parsed,
4398 .help_str = "set port X uta all on|off (X = port number)",
4400 (void *)&cmd_set_uc_all_hash_set,
4401 (void *)&cmd_set_uc_all_hash_port,
4402 (void *)&cmd_set_uc_all_hash_portid,
4403 (void *)&cmd_set_uc_all_hash_what,
4404 (void *)&cmd_set_uc_all_hash_value,
4405 (void *)&cmd_set_uc_all_hash_mode,
4410 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4411 struct cmd_set_vf_traffic {
4412 cmdline_fixed_string_t set;
4413 cmdline_fixed_string_t port;
4415 cmdline_fixed_string_t vf;
4417 cmdline_fixed_string_t what;
4418 cmdline_fixed_string_t mode;
4422 cmd_set_vf_traffic_parsed(void *parsed_result,
4423 __attribute__((unused)) struct cmdline *cl,
4424 __attribute__((unused)) void *data)
4426 struct cmd_set_vf_traffic *res = parsed_result;
4427 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4428 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4430 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4433 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4434 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4436 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4437 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4439 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4440 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4442 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4443 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4445 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4446 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4448 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4449 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4451 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4455 cmdline_parse_inst_t cmd_set_vf_traffic = {
4456 .f = cmd_set_vf_traffic_parsed,
4458 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4460 (void *)&cmd_setvf_traffic_set,
4461 (void *)&cmd_setvf_traffic_port,
4462 (void *)&cmd_setvf_traffic_portid,
4463 (void *)&cmd_setvf_traffic_vf,
4464 (void *)&cmd_setvf_traffic_vfid,
4465 (void *)&cmd_setvf_traffic_what,
4466 (void *)&cmd_setvf_traffic_mode,
4471 /* *** CONFIGURE VF RECEIVE MODE *** */
4472 struct cmd_set_vf_rxmode {
4473 cmdline_fixed_string_t set;
4474 cmdline_fixed_string_t port;
4476 cmdline_fixed_string_t vf;
4478 cmdline_fixed_string_t what;
4479 cmdline_fixed_string_t mode;
4480 cmdline_fixed_string_t on;
4484 cmd_set_vf_rxmode_parsed(void *parsed_result,
4485 __attribute__((unused)) struct cmdline *cl,
4486 __attribute__((unused)) void *data)
4489 uint16_t rx_mode = 0;
4490 struct cmd_set_vf_rxmode *res = parsed_result;
4492 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4493 if (!strcmp(res->what,"rxmode")) {
4494 if (!strcmp(res->mode, "AUPE"))
4495 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4496 else if (!strcmp(res->mode, "ROPE"))
4497 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4498 else if (!strcmp(res->mode, "BAM"))
4499 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4500 else if (!strncmp(res->mode, "MPE",3))
4501 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4504 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4506 printf("bad VF receive mode parameter, return code = %d \n",
4510 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4513 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4514 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4516 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4517 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4519 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4522 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4523 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4525 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4526 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4528 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4530 mode, "AUPE#ROPE#BAM#MPE");
4531 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4532 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4535 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4536 .f = cmd_set_vf_rxmode_parsed,
4538 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4540 (void *)&cmd_set_vf_rxmode_set,
4541 (void *)&cmd_set_vf_rxmode_port,
4542 (void *)&cmd_set_vf_rxmode_portid,
4543 (void *)&cmd_set_vf_rxmode_vf,
4544 (void *)&cmd_set_vf_rxmode_vfid,
4545 (void *)&cmd_set_vf_rxmode_what,
4546 (void *)&cmd_set_vf_rxmode_mode,
4547 (void *)&cmd_set_vf_rxmode_on,
4552 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4553 struct cmd_vf_mac_addr_result {
4554 cmdline_fixed_string_t mac_addr_cmd;
4555 cmdline_fixed_string_t what;
4556 cmdline_fixed_string_t port;
4558 cmdline_fixed_string_t vf;
4560 struct ether_addr address;
4563 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4564 __attribute__((unused)) struct cmdline *cl,
4565 __attribute__((unused)) void *data)
4567 struct cmd_vf_mac_addr_result *res = parsed_result;
4570 if (strcmp(res->what, "add") == 0)
4571 ret = rte_eth_dev_mac_addr_add(res->port_num,
4572 &res->address, res->vf_num);
4574 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4578 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4579 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4580 mac_addr_cmd,"mac_addr");
4581 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4582 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4584 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4585 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4587 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4588 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4590 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4591 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4593 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4594 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4596 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4597 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4600 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4601 .f = cmd_vf_mac_addr_parsed,
4603 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4604 "Y = VF number)add MAC address filtering for a VF on port X",
4606 (void *)&cmd_vf_mac_addr_cmd,
4607 (void *)&cmd_vf_mac_addr_what,
4608 (void *)&cmd_vf_mac_addr_port,
4609 (void *)&cmd_vf_mac_addr_portnum,
4610 (void *)&cmd_vf_mac_addr_vf,
4611 (void *)&cmd_vf_mac_addr_vfnum,
4612 (void *)&cmd_vf_mac_addr_addr,
4617 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4618 struct cmd_vf_rx_vlan_filter {
4619 cmdline_fixed_string_t rx_vlan;
4620 cmdline_fixed_string_t what;
4622 cmdline_fixed_string_t port;
4624 cmdline_fixed_string_t vf;
4629 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4630 __attribute__((unused)) struct cmdline *cl,
4631 __attribute__((unused)) void *data)
4633 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4635 if (!strcmp(res->what, "add"))
4636 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4638 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4641 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4642 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4643 rx_vlan, "rx_vlan");
4644 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4645 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4647 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4648 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4650 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4651 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4653 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4654 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4656 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4657 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4659 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4660 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4663 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4664 .f = cmd_vf_rx_vlan_filter_parsed,
4666 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4667 "Y = port number,Z = hexadecimal VF mask)",
4669 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4670 (void *)&cmd_vf_rx_vlan_filter_what,
4671 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4672 (void *)&cmd_vf_rx_vlan_filter_port,
4673 (void *)&cmd_vf_rx_vlan_filter_portid,
4674 (void *)&cmd_vf_rx_vlan_filter_vf,
4675 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4680 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4681 struct cmd_set_mirror_mask_result {
4682 cmdline_fixed_string_t set;
4683 cmdline_fixed_string_t port;
4685 cmdline_fixed_string_t mirror;
4687 cmdline_fixed_string_t what;
4688 cmdline_fixed_string_t value;
4689 cmdline_fixed_string_t dstpool;
4691 cmdline_fixed_string_t on;
4694 cmdline_parse_token_string_t cmd_mirror_mask_set =
4695 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4697 cmdline_parse_token_string_t cmd_mirror_mask_port =
4698 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4700 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4701 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4703 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4704 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4705 mirror, "mirror-rule");
4706 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4707 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4709 cmdline_parse_token_string_t cmd_mirror_mask_what =
4710 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4711 what, "pool-mirror#vlan-mirror");
4712 cmdline_parse_token_string_t cmd_mirror_mask_value =
4713 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4715 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4716 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4717 dstpool, "dst-pool");
4718 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4719 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4721 cmdline_parse_token_string_t cmd_mirror_mask_on =
4722 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4726 cmd_set_mirror_mask_parsed(void *parsed_result,
4727 __attribute__((unused)) struct cmdline *cl,
4728 __attribute__((unused)) void *data)
4731 struct cmd_set_mirror_mask_result *res = parsed_result;
4732 struct rte_eth_vmdq_mirror_conf mr_conf;
4734 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4736 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4738 mr_conf.dst_pool = res->dstpool_id;
4740 if (!strcmp(res->what, "pool-mirror")) {
4741 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4742 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4743 } else if(!strcmp(res->what, "vlan-mirror")) {
4744 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4745 nb_item = parse_item_list(res->value, "core",
4746 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4750 for(i=0; i < nb_item; i++) {
4751 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4752 printf("Invalid vlan_id: must be < 4096\n");
4756 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4757 mr_conf.vlan.vlan_mask |= 1ULL << i;
4761 if(!strcmp(res->on, "on"))
4762 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4765 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4768 printf("mirror rule add error: (%s)\n", strerror(-ret));
4771 cmdline_parse_inst_t cmd_set_mirror_mask = {
4772 .f = cmd_set_mirror_mask_parsed,
4774 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4775 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4777 (void *)&cmd_mirror_mask_set,
4778 (void *)&cmd_mirror_mask_port,
4779 (void *)&cmd_mirror_mask_portid,
4780 (void *)&cmd_mirror_mask_mirror,
4781 (void *)&cmd_mirror_mask_ruleid,
4782 (void *)&cmd_mirror_mask_what,
4783 (void *)&cmd_mirror_mask_value,
4784 (void *)&cmd_mirror_mask_dstpool,
4785 (void *)&cmd_mirror_mask_poolid,
4786 (void *)&cmd_mirror_mask_on,
4791 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4792 struct cmd_set_mirror_link_result {
4793 cmdline_fixed_string_t set;
4794 cmdline_fixed_string_t port;
4796 cmdline_fixed_string_t mirror;
4798 cmdline_fixed_string_t what;
4799 cmdline_fixed_string_t dstpool;
4801 cmdline_fixed_string_t on;
4804 cmdline_parse_token_string_t cmd_mirror_link_set =
4805 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4807 cmdline_parse_token_string_t cmd_mirror_link_port =
4808 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4810 cmdline_parse_token_string_t cmd_mirror_link_portid =
4811 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4813 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4814 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4815 mirror, "mirror-rule");
4816 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4817 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4819 cmdline_parse_token_string_t cmd_mirror_link_what =
4820 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4821 what, "uplink-mirror#downlink-mirror");
4822 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4823 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4824 dstpool, "dst-pool");
4825 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4826 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4828 cmdline_parse_token_string_t cmd_mirror_link_on =
4829 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4833 cmd_set_mirror_link_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4838 struct cmd_set_mirror_link_result *res = parsed_result;
4839 struct rte_eth_vmdq_mirror_conf mr_conf;
4841 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4842 if(!strcmp(res->what, "uplink-mirror")) {
4843 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4844 }else if(!strcmp(res->what, "downlink-mirror"))
4845 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4847 mr_conf.dst_pool = res->dstpool_id;
4849 if(!strcmp(res->on, "on"))
4850 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4853 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4856 /* check the return value and print it if is < 0 */
4858 printf("mirror rule add error: (%s)\n", strerror(-ret));
4862 cmdline_parse_inst_t cmd_set_mirror_link = {
4863 .f = cmd_set_mirror_link_parsed,
4865 .help_str = "set port X mirror-rule Y uplink-mirror|"
4866 "downlink-mirror dst-pool Z on|off",
4868 (void *)&cmd_mirror_link_set,
4869 (void *)&cmd_mirror_link_port,
4870 (void *)&cmd_mirror_link_portid,
4871 (void *)&cmd_mirror_link_mirror,
4872 (void *)&cmd_mirror_link_ruleid,
4873 (void *)&cmd_mirror_link_what,
4874 (void *)&cmd_mirror_link_dstpool,
4875 (void *)&cmd_mirror_link_poolid,
4876 (void *)&cmd_mirror_link_on,
4881 /* *** RESET VM MIRROR RULE *** */
4882 struct cmd_rm_mirror_rule_result {
4883 cmdline_fixed_string_t reset;
4884 cmdline_fixed_string_t port;
4886 cmdline_fixed_string_t mirror;
4890 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4891 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4893 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4894 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4896 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4897 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4899 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4900 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4901 mirror, "mirror-rule");
4902 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4903 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4907 cmd_reset_mirror_rule_parsed(void *parsed_result,
4908 __attribute__((unused)) struct cmdline *cl,
4909 __attribute__((unused)) void *data)
4912 struct cmd_set_mirror_link_result *res = parsed_result;
4914 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4916 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4919 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4920 .f = cmd_reset_mirror_rule_parsed,
4922 .help_str = "reset port X mirror-rule Y",
4924 (void *)&cmd_rm_mirror_rule_reset,
4925 (void *)&cmd_rm_mirror_rule_port,
4926 (void *)&cmd_rm_mirror_rule_portid,
4927 (void *)&cmd_rm_mirror_rule_mirror,
4928 (void *)&cmd_rm_mirror_rule_ruleid,
4933 /* ******************************************************************************** */
4935 /* list of instructions */
4936 cmdline_parse_ctx_t main_ctx[] = {
4937 (cmdline_parse_inst_t *)&cmd_help_brief,
4938 (cmdline_parse_inst_t *)&cmd_help_long,
4939 (cmdline_parse_inst_t *)&cmd_quit,
4940 (cmdline_parse_inst_t *)&cmd_showport,
4941 (cmdline_parse_inst_t *)&cmd_showportall,
4942 (cmdline_parse_inst_t *)&cmd_showcfg,
4943 (cmdline_parse_inst_t *)&cmd_start,
4944 (cmdline_parse_inst_t *)&cmd_start_tx_first,
4945 (cmdline_parse_inst_t *)&cmd_reset,
4946 (cmdline_parse_inst_t *)&cmd_set_numbers,
4947 (cmdline_parse_inst_t *)&cmd_set_txpkts,
4948 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4949 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4950 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4951 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4952 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4953 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4954 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4955 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4956 #ifdef RTE_NIC_BYPASS
4957 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
4958 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
4959 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
4960 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
4962 (cmdline_parse_inst_t *)&cmd_vlan_offload,
4963 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4964 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4965 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4966 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4967 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4968 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4969 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4970 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4971 (cmdline_parse_inst_t *)&cmd_config_dcb,
4972 (cmdline_parse_inst_t *)&cmd_read_reg,
4973 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4974 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4975 (cmdline_parse_inst_t *)&cmd_write_reg,
4976 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4977 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4978 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4979 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4980 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4981 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4982 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4983 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4984 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4985 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4986 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4987 (cmdline_parse_inst_t *)&cmd_stop,
4988 (cmdline_parse_inst_t *)&cmd_mac_addr,
4989 (cmdline_parse_inst_t *)&cmd_set_qmap,
4990 (cmdline_parse_inst_t *)&cmd_operate_port,
4991 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4992 (cmdline_parse_inst_t *)&cmd_config_speed_all,
4993 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4994 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4995 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
4996 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
4997 (cmdline_parse_inst_t *)&cmd_config_rss,
4998 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
4999 (cmdline_parse_inst_t *)&cmd_showport_reta,
5000 (cmdline_parse_inst_t *)&cmd_config_burst,
5001 (cmdline_parse_inst_t *)&cmd_config_thresh,
5002 (cmdline_parse_inst_t *)&cmd_config_threshold,
5003 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5004 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5005 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5006 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5007 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5008 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5009 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5010 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5011 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5015 /* prompt function, called from main on MASTER lcore */
5021 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5025 cmdline_interact(cl);
5026 cmdline_stdin_exit(cl);
5030 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5032 if (id < nb_ports) {
5033 /* check if need_reconfig has been set to 1 */
5034 if (ports[id].need_reconfig == 0)
5035 ports[id].need_reconfig = dev;
5036 /* check if need_reconfig_queues has been set to 1 */
5037 if (ports[id].need_reconfig_queues == 0)
5038 ports[id].need_reconfig_queues = queue;
5042 for (pid = 0; pid < nb_ports; pid++) {
5043 /* check if need_reconfig has been set to 1 */
5044 if (ports[pid].need_reconfig == 0)
5045 ports[pid].need_reconfig = dev;
5046 /* check if need_reconfig_queues has been set to 1 */
5047 if (ports[pid].need_reconfig_queues == 0)
5048 ports[pid].need_reconfig_queues = queue;
5053 #ifdef RTE_NIC_BYPASS
5055 bypass_is_supported(portid_t port_id)
5057 struct rte_port *port;
5058 struct rte_pci_id *pci_id;
5060 if (port_id >= nb_ports) {
5061 printf("\tPort id must be less than %d.\n", nb_ports);
5065 /* Get the device id. */
5066 port = &ports[port_id];
5067 pci_id = &port->dev_info.pci_dev->id;
5069 /* Check if NIC supports bypass. */
5070 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5074 printf("\tBypass not supported for port_id = %d.\n", port_id);