4 * Copyright(c) 2010-2014 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.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_launch.h>
62 #include <rte_tailq.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
76 #include <cmdline_rdline.h>
77 #include <cmdline_parse.h>
78 #include <cmdline_parse_num.h>
79 #include <cmdline_parse_string.h>
80 #include <cmdline_parse_ipaddr.h>
81 #include <cmdline_parse_etheraddr.h>
82 #include <cmdline_socket.h>
84 #include <rte_pci_dev_ids.h>
88 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
91 uint8_t bypass_is_supported(portid_t port_id);
94 /* *** Help command with introduction. *** */
95 struct cmd_help_brief_result {
96 cmdline_fixed_string_t help;
99 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
101 __attribute__((unused)) void *data)
106 "Help is available for the following sections:\n\n"
107 " help control : Start and stop forwarding.\n"
108 " help display : Displaying port, stats and config "
110 " help config : Configuration information.\n"
111 " help ports : Configuring ports.\n"
112 " help flowdir : Flow Director filter help.\n"
113 " help registers : Reading and setting port registers.\n"
114 " help all : All of the above sections.\n\n"
119 cmdline_parse_token_string_t cmd_help_brief_help =
120 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
122 cmdline_parse_inst_t cmd_help_brief = {
123 .f = cmd_help_brief_parsed,
125 .help_str = "show help",
127 (void *)&cmd_help_brief_help,
132 /* *** Help command with help sections. *** */
133 struct cmd_help_long_result {
134 cmdline_fixed_string_t help;
135 cmdline_fixed_string_t section;
138 static void cmd_help_long_parsed(void *parsed_result,
140 __attribute__((unused)) void *data)
143 struct cmd_help_long_result *res = parsed_result;
145 if (!strcmp(res->section, "all"))
148 if (show_all || !strcmp(res->section, "control")) {
153 "Control forwarding:\n"
154 "-------------------\n\n"
157 " Start packet forwarding with current configuration.\n\n"
160 " Start packet forwarding with current config"
161 " after sending one burst of packets.\n\n"
164 " Stop packet forwarding, and display accumulated"
168 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
172 if (show_all || !strcmp(res->section, "display")) {
180 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
181 " Display information for port_id, or all.\n\n"
183 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
184 " Clear information for port_id, or all.\n\n"
186 "show config (rxtx|cores|fwd)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
197 if (show_all || !strcmp(res->section, "config")) {
203 "Configuration changes only become active when"
204 " forwarding is started/restarted.\n\n"
207 " Reset forwarding to the default configuration.\n\n"
209 "set verbose (level)\n"
210 " Set the debug verbosity level X.\n\n"
213 " Set number of ports.\n\n"
216 " Set number of cores.\n\n"
218 "set coremask (mask)\n"
219 " Set the forwarding cores hexadecimal mask.\n\n"
221 "set portmask (mask)\n"
222 " Set the forwarding ports hexadecimal mask.\n\n"
225 " Set number of packets per burst.\n\n"
227 "set burst tx delay (microseconds) retry (num)\n"
228 " Set the transmit delay time and number of retries"
229 " in mac_retry forwarding mode.\n\n"
231 "set txpkts (x[,y]*)\n"
232 " Set the length of each segment of TXONLY"
235 "set corelist (x[,y]*)\n"
236 " Set the list of forwarding cores.\n\n"
238 "set portlist (x[,y]*)\n"
239 " Set the list of forwarding ports.\n\n"
241 "vlan set strip (on|off) (port_id)\n"
242 " Set the VLAN strip on a port.\n\n"
244 "vlan set stripq (on|off) (port_id,queue_id)\n"
245 " Set the VLAN strip for a queue on a port.\n\n"
247 "vlan set filter (on|off) (port_id)\n"
248 " Set the VLAN filter on a port.\n\n"
250 "vlan set qinq (on|off) (port_id)\n"
251 " Set the VLAN QinQ (extended queue in queue)"
254 "vlan set tpid (value) (port_id)\n"
255 " Set the outer VLAN TPID for Packet Filtering on"
258 "rx_vlan add (vlan_id|all) (port_id)\n"
259 " Add a vlan_id, or all identifiers, to the set"
260 " of VLAN identifiers filtered by port_id.\n\n"
262 "rx_vlan rm (vlan_id|all) (port_id)\n"
263 " Remove a vlan_id, or all identifiers, from the set"
264 " of VLAN identifiers filtered by port_id.\n\n"
266 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
267 " Add a vlan_id, to the set of VLAN identifiers"
268 "filtered for VF(s) from port_id.\n\n"
270 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
271 " Remove a vlan_id, to the set of VLAN identifiers"
272 "filtered for VF(s) from port_id.\n\n"
274 "rx_vlan set tpid (value) (port_id)\n"
275 " Set the outer VLAN TPID for Packet Filtering on"
278 "tx_vlan set vlan_id (port_id)\n"
279 " Set hardware insertion of VLAN ID in packets sent"
282 "tx_vlan reset (port_id)\n"
283 " Disable hardware insertion of a VLAN header in"
284 " packets sent on a port.\n\n"
286 "tx_checksum set mask (port_id)\n"
287 " Enable hardware insertion of checksum offload with"
288 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
289 " bit 0 - insert ip checksum offload if set\n"
290 " bit 1 - insert udp checksum offload if set\n"
291 " bit 2 - insert tcp checksum offload if set\n"
292 " bit 3 - insert sctp checksum offload if set\n"
293 " Please check the NIC datasheet for HW limits.\n\n"
295 #ifdef RTE_LIBRTE_IEEE1588
296 "set fwd (io|mac|mac_retry|rxonly|txonly|csum|ieee1588)\n"
297 " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY or ieee1588"
298 " packet forwarding mode.\n\n"
301 "set fwd (io|mac|mac_retry|rxonly|txonly|csum)\n"
302 " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY packet"
303 " forwarding mode.\n\n"
306 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
307 " Add a MAC address on port_id.\n\n"
309 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
310 " Remove a MAC address from port_id.\n\n"
312 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
313 " Add a MAC address for a VF on the port.\n\n"
315 "set port (port_id) uta (mac_address|all) (on|off)\n"
316 " Add/Remove a or all unicast hash filter(s)"
319 "set promisc (port_id|all) (on|off)\n"
320 " Set the promiscuous mode on port_id, or all.\n\n"
322 "set allmulti (port_id|all) (on|off)\n"
323 " Set the allmulti mode on port_id, or all.\n\n"
325 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
326 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
327 " (on|off) (port_id)\n"
328 " Set the link flow control parameter on a port.\n\n"
330 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
331 " (low_water) (pause_time) (priority) (port_id)\n"
332 " Set the priority flow control parameter on a"
335 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
336 " Set statistics mapping (qmapping 0..15) for RX/TX"
338 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
339 " on port 0 to mapping 5.\n\n"
341 "set port (port_id) vf (vf_id) rx|tx on|off \n"
342 " Enable/Disable a VF receive/tranmit from a port\n\n"
344 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
346 " AUPE:accepts untagged VLAN;"
347 "ROPE:accept unicast hash\n\n"
348 " BAM:accepts broadcast packets;"
349 "MPE:accepts all multicast packets\n\n"
350 " Enable/Disable a VF receive mode of a port\n\n"
352 "set port (port_id) mirror-rule (rule_id)"
353 "(pool-mirror|vlan-mirror)\n"
354 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
355 " Set pool or vlan type mirror rule on a port.\n"
356 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
357 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
360 "set port (port_id) mirror-rule (rule_id)"
361 " (uplink-mirror|downlink-mirror) dst-pool"
362 " (pool_id) (on|off)\n"
363 " Set uplink or downlink type mirror rule on a port.\n"
364 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
365 " 0 on' enable mirror income traffic to pool 0.\n\n"
367 "reset port (port_id) mirror-rule (rule_id)\n"
368 " Reset a mirror rule.\n\n"
370 "set flush_rx (on|off)\n"
371 " Flush (default) or don't flush RX streams before"
372 " forwarding. Mainly used with PCAP drivers.\n\n"
374 #ifdef RTE_NIC_BYPASS
375 "set bypass mode (normal|bypass|isolate) (port_id)\n"
376 " Set the bypass mode for the lowest port on bypass enabled"
379 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
380 "mode (normal|bypass|isolate) (port_id)\n"
381 " Set the event required to initiate specified bypass mode for"
382 " the lowest port on a bypass enabled NIC where:\n"
383 " timeout = enable bypass after watchdog timeout.\n"
384 " os_on = enable bypass when OS/board is powered on.\n"
385 " os_off = enable bypass when OS/board is powered off.\n"
386 " power_on = enable bypass when power supply is turned on.\n"
387 " power_off = enable bypass when power supply is turned off."
390 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
391 " Set the bypass watchdog timeout to 'n' seconds"
392 " where 0 = instant.\n\n"
394 "show bypass config (port_id)\n"
395 " Show the bypass configuration for a bypass enabled NIC"
396 " using the lowest port on the NIC.\n\n"
403 if (show_all || !strcmp(res->section, "flowdir")) {
408 "Flow director mode:\n"
409 "-------------------\n\n"
411 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
412 " src (src_ip_address) (src_port)"
413 " dst (dst_ip_address) (dst_port)"
414 " flexbytes (flexbytes_values) vlan (vlan_id)"
415 " queue (queue_id)\n"
416 " Add a signature filter.\n\n"
418 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
419 " src (src_ip_address) (src_port)"
420 " dst (dst_ip_address) (dst_port)"
421 " flexbytes (flexbytes_values) vlan (vlan_id)"
422 " queue (queue_id)\n"
423 " Update a signature filter.\n\n"
425 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
426 " src (src_ip_address) (src_port)"
427 " dst (dst_ip_address) (dst_port)"
428 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
429 " Remove a signature filter.\n\n"
431 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
432 " src (src_ip_address) (src_port)"
433 " dst (dst_ip_address) (dst_port)"
434 " flexbytes (flexbytes_values) vlan (vlan_id)"
435 " queue (queue_id) soft (soft_id)\n"
436 " Add a perfect filter.\n\n"
438 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
439 " src (src_ip_address) (src_port)"
440 " dst (dst_ip_address) (dst_port)"
441 " flexbytes (flexbytes_values) vlan (vlan_id)"
442 " queue (queue_id)\n"
443 " Update a perfect filter.\n\n"
445 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
446 " src (src_ip_address) (src_port)"
447 " dst (dst_ip_address) (dst_port)"
448 " flexbytes (flexbytes_values) vlan (vlan_id)"
450 " Remove a perfect filter.\n\n"
452 "set_masks_filter (port_id) only_ip_flow (0|1)"
453 " src_mask (ip_src_mask) (src_port_mask)"
454 " dst_mask (ip_dst_mask) (dst_port_mask)"
455 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
456 " Set IPv4 filter masks.\n\n"
458 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
459 " src_mask (ip_src_mask) (src_port_mask)"
460 " dst_mask (ip_dst_mask) (dst_port_mask)"
461 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
462 " compare_dst (0|1)\n"
463 " Set IPv6 filter masks.\n\n"
467 if (show_all || !strcmp(res->section, "ports")) {
473 "----------------\n\n"
475 "port start (port_id|all)\n"
476 " Start all ports or port_id.\n\n"
478 "port stop (port_id|all)\n"
479 " Stop all ports or port_id.\n\n"
481 "port close (port_id|all)\n"
482 " Close all ports or port_id.\n\n"
484 "port config (port_id|all) speed (10|100|1000|10000|auto)"
485 " duplex (half|full|auto)\n"
486 " Set speed and duplex for all ports or port_id\n\n"
488 "port config all (rxq|txq|rxd|txd) (value)\n"
489 " Set number for rxq/txq/rxd/txd.\n\n"
491 "port config all max-pkt-len (value)\n"
492 " Set the max packet length.\n\n"
494 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
496 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
499 "port config all rss (ip|udp|none)\n"
500 " Set the RSS mode.\n\n"
502 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
503 " Set the RSS redirection table.\n\n"
505 "port config (port_id) dcb vt (on|off) (traffic_class)"
507 " Set the DCB mode.\n\n"
509 "port config all burst (value)\n"
510 " Set the number of packets per burst.\n\n"
512 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
514 " Set the ring prefetch/host/writeback threshold"
515 " for tx/rx queue.\n\n"
517 "port config all (txfreet|txrst|rxfreet) (value)\n"
518 " Set free threshold for rx/tx, or set"
519 " tx rs bit threshold.\n\n"
523 if (show_all || !strcmp(res->section, "registers")) {
531 "read reg (port_id) (address)\n"
532 " Display value of a port register.\n\n"
534 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
535 " Display a port register bit field.\n\n"
537 "read regbit (port_id) (address) (bit_x)\n"
538 " Display a single port register bit.\n\n"
540 "write reg (port_id) (address) (value)\n"
541 " Set value of a port register.\n\n"
543 "write regfield (port_id) (address) (bit_x) (bit_y)"
545 " Set bit field of a port register.\n\n"
547 "write regbit (port_id) (address) (bit_x) (value)\n"
548 " Set single bit value of a port register.\n\n"
553 cmdline_parse_token_string_t cmd_help_long_help =
554 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
556 cmdline_parse_token_string_t cmd_help_long_section =
557 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
558 "all#control#display#config#flowdir#"
561 cmdline_parse_inst_t cmd_help_long = {
562 .f = cmd_help_long_parsed,
564 .help_str = "show help",
566 (void *)&cmd_help_long_help,
567 (void *)&cmd_help_long_section,
573 /* *** start/stop/close all ports *** */
574 struct cmd_operate_port_result {
575 cmdline_fixed_string_t keyword;
576 cmdline_fixed_string_t name;
577 cmdline_fixed_string_t value;
580 static void cmd_operate_port_parsed(void *parsed_result,
581 __attribute__((unused)) struct cmdline *cl,
582 __attribute__((unused)) void *data)
584 struct cmd_operate_port_result *res = parsed_result;
586 if (!strcmp(res->name, "start"))
587 start_port(RTE_PORT_ALL);
588 else if (!strcmp(res->name, "stop"))
589 stop_port(RTE_PORT_ALL);
590 else if (!strcmp(res->name, "close"))
591 close_port(RTE_PORT_ALL);
593 printf("Unknown parameter\n");
596 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
597 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
599 cmdline_parse_token_string_t cmd_operate_port_all_port =
600 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
602 cmdline_parse_token_string_t cmd_operate_port_all_all =
603 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
605 cmdline_parse_inst_t cmd_operate_port = {
606 .f = cmd_operate_port_parsed,
608 .help_str = "port start|stop|close all: start/stop/close all ports",
610 (void *)&cmd_operate_port_all_cmd,
611 (void *)&cmd_operate_port_all_port,
612 (void *)&cmd_operate_port_all_all,
617 /* *** start/stop/close specific port *** */
618 struct cmd_operate_specific_port_result {
619 cmdline_fixed_string_t keyword;
620 cmdline_fixed_string_t name;
624 static void cmd_operate_specific_port_parsed(void *parsed_result,
625 __attribute__((unused)) struct cmdline *cl,
626 __attribute__((unused)) void *data)
628 struct cmd_operate_specific_port_result *res = parsed_result;
630 if (!strcmp(res->name, "start"))
631 start_port(res->value);
632 else if (!strcmp(res->name, "stop"))
633 stop_port(res->value);
634 else if (!strcmp(res->name, "close"))
635 close_port(res->value);
637 printf("Unknown parameter\n");
640 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
641 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
643 cmdline_parse_token_string_t cmd_operate_specific_port_port =
644 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
645 name, "start#stop#close");
646 cmdline_parse_token_num_t cmd_operate_specific_port_id =
647 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
650 cmdline_parse_inst_t cmd_operate_specific_port = {
651 .f = cmd_operate_specific_port_parsed,
653 .help_str = "port start|stop|close X: start/stop/close port X",
655 (void *)&cmd_operate_specific_port_cmd,
656 (void *)&cmd_operate_specific_port_port,
657 (void *)&cmd_operate_specific_port_id,
662 /* *** configure speed for all ports *** */
663 struct cmd_config_speed_all {
664 cmdline_fixed_string_t port;
665 cmdline_fixed_string_t keyword;
666 cmdline_fixed_string_t all;
667 cmdline_fixed_string_t item1;
668 cmdline_fixed_string_t item2;
669 cmdline_fixed_string_t value1;
670 cmdline_fixed_string_t value2;
674 cmd_config_speed_all_parsed(void *parsed_result,
675 __attribute__((unused)) struct cmdline *cl,
676 __attribute__((unused)) void *data)
678 struct cmd_config_speed_all *res = parsed_result;
679 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
680 uint16_t link_duplex = 0;
683 if (!all_ports_stopped()) {
684 printf("Please stop all ports first\n");
688 if (!strcmp(res->value1, "10"))
689 link_speed = ETH_LINK_SPEED_10;
690 else if (!strcmp(res->value1, "100"))
691 link_speed = ETH_LINK_SPEED_100;
692 else if (!strcmp(res->value1, "1000"))
693 link_speed = ETH_LINK_SPEED_1000;
694 else if (!strcmp(res->value1, "10000"))
695 link_speed = ETH_LINK_SPEED_10000;
696 else if (!strcmp(res->value1, "auto"))
697 link_speed = ETH_LINK_SPEED_AUTONEG;
699 printf("Unknown parameter\n");
703 if (!strcmp(res->value2, "half"))
704 link_duplex = ETH_LINK_HALF_DUPLEX;
705 else if (!strcmp(res->value2, "full"))
706 link_duplex = ETH_LINK_FULL_DUPLEX;
707 else if (!strcmp(res->value2, "auto"))
708 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
710 printf("Unknown parameter\n");
714 for (pid = 0; pid < nb_ports; pid++) {
715 ports[pid].dev_conf.link_speed = link_speed;
716 ports[pid].dev_conf.link_duplex = link_duplex;
719 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
722 cmdline_parse_token_string_t cmd_config_speed_all_port =
723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
724 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
727 cmdline_parse_token_string_t cmd_config_speed_all_all =
728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
729 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
731 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
733 "10#100#1000#10000#auto");
734 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
736 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
740 cmdline_parse_inst_t cmd_config_speed_all = {
741 .f = cmd_config_speed_all_parsed,
743 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
746 (void *)&cmd_config_speed_all_port,
747 (void *)&cmd_config_speed_all_keyword,
748 (void *)&cmd_config_speed_all_all,
749 (void *)&cmd_config_speed_all_item1,
750 (void *)&cmd_config_speed_all_value1,
751 (void *)&cmd_config_speed_all_item2,
752 (void *)&cmd_config_speed_all_value2,
757 /* *** configure speed for specific port *** */
758 struct cmd_config_speed_specific {
759 cmdline_fixed_string_t port;
760 cmdline_fixed_string_t keyword;
762 cmdline_fixed_string_t item1;
763 cmdline_fixed_string_t item2;
764 cmdline_fixed_string_t value1;
765 cmdline_fixed_string_t value2;
769 cmd_config_speed_specific_parsed(void *parsed_result,
770 __attribute__((unused)) struct cmdline *cl,
771 __attribute__((unused)) void *data)
773 struct cmd_config_speed_specific *res = parsed_result;
774 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
775 uint16_t link_duplex = 0;
777 if (!all_ports_stopped()) {
778 printf("Please stop all ports first\n");
782 if (res->id >= nb_ports) {
783 printf("Port id %d must be less than %d\n", res->id, nb_ports);
787 if (!strcmp(res->value1, "10"))
788 link_speed = ETH_LINK_SPEED_10;
789 else if (!strcmp(res->value1, "100"))
790 link_speed = ETH_LINK_SPEED_100;
791 else if (!strcmp(res->value1, "1000"))
792 link_speed = ETH_LINK_SPEED_1000;
793 else if (!strcmp(res->value1, "10000"))
794 link_speed = ETH_LINK_SPEED_10000;
795 else if (!strcmp(res->value1, "auto"))
796 link_speed = ETH_LINK_SPEED_AUTONEG;
798 printf("Unknown parameter\n");
802 if (!strcmp(res->value2, "half"))
803 link_duplex = ETH_LINK_HALF_DUPLEX;
804 else if (!strcmp(res->value2, "full"))
805 link_duplex = ETH_LINK_FULL_DUPLEX;
806 else if (!strcmp(res->value2, "auto"))
807 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
809 printf("Unknown parameter\n");
813 ports[res->id].dev_conf.link_speed = link_speed;
814 ports[res->id].dev_conf.link_duplex = link_duplex;
816 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
820 cmdline_parse_token_string_t cmd_config_speed_specific_port =
821 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
823 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
824 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
826 cmdline_parse_token_num_t cmd_config_speed_specific_id =
827 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
828 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
829 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
831 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
832 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
833 "10#100#1000#10000#auto");
834 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
835 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
837 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
838 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
841 cmdline_parse_inst_t cmd_config_speed_specific = {
842 .f = cmd_config_speed_specific_parsed,
844 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
847 (void *)&cmd_config_speed_specific_port,
848 (void *)&cmd_config_speed_specific_keyword,
849 (void *)&cmd_config_speed_specific_id,
850 (void *)&cmd_config_speed_specific_item1,
851 (void *)&cmd_config_speed_specific_value1,
852 (void *)&cmd_config_speed_specific_item2,
853 (void *)&cmd_config_speed_specific_value2,
858 /* *** configure txq/rxq, txd/rxd *** */
859 struct cmd_config_rx_tx {
860 cmdline_fixed_string_t port;
861 cmdline_fixed_string_t keyword;
862 cmdline_fixed_string_t all;
863 cmdline_fixed_string_t name;
868 cmd_config_rx_tx_parsed(void *parsed_result,
869 __attribute__((unused)) struct cmdline *cl,
870 __attribute__((unused)) void *data)
872 struct cmd_config_rx_tx *res = parsed_result;
874 if (!all_ports_stopped()) {
875 printf("Please stop all ports first\n");
879 if (!strcmp(res->name, "rxq")) {
880 if (res->value <= 0) {
881 printf("rxq %d invalid - must be > 0\n", res->value);
886 else if (!strcmp(res->name, "txq")) {
887 if (res->value <= 0) {
888 printf("txq %d invalid - must be > 0\n", res->value);
893 else if (!strcmp(res->name, "rxd")) {
894 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
895 printf("rxd %d invalid - must be > 0 && <= %d\n",
896 res->value, RTE_TEST_RX_DESC_MAX);
900 } else if (!strcmp(res->name, "txd")) {
901 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
902 printf("txd %d invalid - must be > 0 && <= %d\n",
903 res->value, RTE_TEST_TX_DESC_MAX);
908 printf("Unknown parameter\n");
914 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
917 cmdline_parse_token_string_t cmd_config_rx_tx_port =
918 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
919 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
920 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
921 cmdline_parse_token_string_t cmd_config_rx_tx_all =
922 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
923 cmdline_parse_token_string_t cmd_config_rx_tx_name =
924 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
926 cmdline_parse_token_num_t cmd_config_rx_tx_value =
927 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
929 cmdline_parse_inst_t cmd_config_rx_tx = {
930 .f = cmd_config_rx_tx_parsed,
932 .help_str = "port config all rxq|txq|rxd|txd value",
934 (void *)&cmd_config_rx_tx_port,
935 (void *)&cmd_config_rx_tx_keyword,
936 (void *)&cmd_config_rx_tx_all,
937 (void *)&cmd_config_rx_tx_name,
938 (void *)&cmd_config_rx_tx_value,
943 /* *** config max packet length *** */
944 struct cmd_config_max_pkt_len_result {
945 cmdline_fixed_string_t port;
946 cmdline_fixed_string_t keyword;
947 cmdline_fixed_string_t all;
948 cmdline_fixed_string_t name;
953 cmd_config_max_pkt_len_parsed(void *parsed_result,
954 __attribute__((unused)) struct cmdline *cl,
955 __attribute__((unused)) void *data)
957 struct cmd_config_max_pkt_len_result *res = parsed_result;
959 if (!all_ports_stopped()) {
960 printf("Please stop all ports first\n");
964 if (!strcmp(res->name, "max-pkt-len")) {
965 if (res->value < ETHER_MIN_LEN) {
966 printf("max-pkt-len can not be less than %d\n",
970 if (res->value == rx_mode.max_rx_pkt_len)
973 rx_mode.max_rx_pkt_len = res->value;
974 if (res->value > ETHER_MAX_LEN)
975 rx_mode.jumbo_frame = 1;
977 rx_mode.jumbo_frame = 0;
979 printf("Unknown parameter\n");
985 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
988 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
989 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
991 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
992 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
994 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
997 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
998 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1000 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1001 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1004 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1005 .f = cmd_config_max_pkt_len_parsed,
1007 .help_str = "port config all max-pkt-len value",
1009 (void *)&cmd_config_max_pkt_len_port,
1010 (void *)&cmd_config_max_pkt_len_keyword,
1011 (void *)&cmd_config_max_pkt_len_all,
1012 (void *)&cmd_config_max_pkt_len_name,
1013 (void *)&cmd_config_max_pkt_len_value,
1018 /* *** configure rx mode *** */
1019 struct cmd_config_rx_mode_flag {
1020 cmdline_fixed_string_t port;
1021 cmdline_fixed_string_t keyword;
1022 cmdline_fixed_string_t all;
1023 cmdline_fixed_string_t name;
1024 cmdline_fixed_string_t value;
1028 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1029 __attribute__((unused)) struct cmdline *cl,
1030 __attribute__((unused)) void *data)
1032 struct cmd_config_rx_mode_flag *res = parsed_result;
1034 if (!all_ports_stopped()) {
1035 printf("Please stop all ports first\n");
1039 if (!strcmp(res->name, "crc-strip")) {
1040 if (!strcmp(res->value, "on"))
1041 rx_mode.hw_strip_crc = 1;
1042 else if (!strcmp(res->value, "off"))
1043 rx_mode.hw_strip_crc = 0;
1045 printf("Unknown parameter\n");
1048 } else if (!strcmp(res->name, "rx-cksum")) {
1049 if (!strcmp(res->value, "on"))
1050 rx_mode.hw_ip_checksum = 1;
1051 else if (!strcmp(res->value, "off"))
1052 rx_mode.hw_ip_checksum = 0;
1054 printf("Unknown parameter\n");
1057 } else if (!strcmp(res->name, "hw-vlan")) {
1058 if (!strcmp(res->value, "on")) {
1059 rx_mode.hw_vlan_filter = 1;
1060 rx_mode.hw_vlan_strip = 1;
1062 else if (!strcmp(res->value, "off")) {
1063 rx_mode.hw_vlan_filter = 0;
1064 rx_mode.hw_vlan_strip = 0;
1067 printf("Unknown parameter\n");
1070 } else if (!strcmp(res->name, "drop-en")) {
1071 if (!strcmp(res->value, "on"))
1073 else if (!strcmp(res->value, "off"))
1076 printf("Unknown parameter\n");
1080 printf("Unknown parameter\n");
1086 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1089 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1090 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1091 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1092 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1094 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1095 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1096 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1097 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1098 "crc-strip#rx-cksum#hw-vlan");
1099 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1100 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1103 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1104 .f = cmd_config_rx_mode_flag_parsed,
1106 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1108 (void *)&cmd_config_rx_mode_flag_port,
1109 (void *)&cmd_config_rx_mode_flag_keyword,
1110 (void *)&cmd_config_rx_mode_flag_all,
1111 (void *)&cmd_config_rx_mode_flag_name,
1112 (void *)&cmd_config_rx_mode_flag_value,
1117 /* *** configure rss *** */
1118 struct cmd_config_rss {
1119 cmdline_fixed_string_t port;
1120 cmdline_fixed_string_t keyword;
1121 cmdline_fixed_string_t all;
1122 cmdline_fixed_string_t name;
1123 cmdline_fixed_string_t value;
1127 cmd_config_rss_parsed(void *parsed_result,
1128 __attribute__((unused)) struct cmdline *cl,
1129 __attribute__((unused)) void *data)
1131 struct cmd_config_rss *res = parsed_result;
1133 if (!all_ports_stopped()) {
1134 printf("Please stop all ports first\n");
1138 if (!strcmp(res->value, "ip"))
1139 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1140 else if (!strcmp(res->value, "udp"))
1141 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1142 else if (!strcmp(res->value, "none"))
1145 printf("Unknown parameter\n");
1151 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1154 cmdline_parse_token_string_t cmd_config_rss_port =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1156 cmdline_parse_token_string_t cmd_config_rss_keyword =
1157 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1158 cmdline_parse_token_string_t cmd_config_rss_all =
1159 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1160 cmdline_parse_token_string_t cmd_config_rss_name =
1161 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1162 cmdline_parse_token_string_t cmd_config_rss_value =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1165 cmdline_parse_inst_t cmd_config_rss = {
1166 .f = cmd_config_rss_parsed,
1168 .help_str = "port config all rss ip|udp|none",
1170 (void *)&cmd_config_rss_port,
1171 (void *)&cmd_config_rss_keyword,
1172 (void *)&cmd_config_rss_all,
1173 (void *)&cmd_config_rss_name,
1174 (void *)&cmd_config_rss_value,
1179 /* *** Configure RSS RETA *** */
1180 struct cmd_config_rss_reta {
1181 cmdline_fixed_string_t port;
1182 cmdline_fixed_string_t keyword;
1184 cmdline_fixed_string_t name;
1185 cmdline_fixed_string_t list_name;
1186 cmdline_fixed_string_t list_of_items;
1190 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1197 const char *p, *p0 = str;
1204 unsigned long int_fld[_NUM_FLD];
1205 char *str_fld[_NUM_FLD];
1207 while ((p = strchr(p0,'(')) != NULL) {
1209 if((p0 = strchr(p,')')) == NULL)
1213 if(size >= sizeof(s))
1216 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1217 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1219 for (i = 0; i < _NUM_FLD; i++) {
1221 int_fld[i] = strtoul(str_fld[i], &end, 0);
1222 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1226 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1227 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1229 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1230 printf("Invalid RETA hash index=%d",hash_index);
1234 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1235 reta_conf->mask_lo |= (1ULL << hash_index);
1237 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1239 reta_conf->reta[hash_index] = nb_queue;
1246 cmd_set_rss_reta_parsed(void *parsed_result,
1247 __attribute__((unused)) struct cmdline *cl,
1248 __attribute__((unused)) void *data)
1251 struct rte_eth_rss_reta reta_conf;
1252 struct cmd_config_rss_reta *res = parsed_result;
1254 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1255 if (!strcmp(res->list_name, "reta")) {
1256 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1257 printf("Invalid RSS Redirection Table config entered\n");
1260 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1262 printf("Bad redirection table parameter, return code = %d \n",ret);
1266 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1268 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1270 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1271 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1272 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1274 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1276 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1279 cmdline_parse_inst_t cmd_config_rss_reta = {
1280 .f = cmd_set_rss_reta_parsed,
1282 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1284 (void *)&cmd_config_rss_reta_port,
1285 (void *)&cmd_config_rss_reta_keyword,
1286 (void *)&cmd_config_rss_reta_port_id,
1287 (void *)&cmd_config_rss_reta_name,
1288 (void *)&cmd_config_rss_reta_list_name,
1289 (void *)&cmd_config_rss_reta_list_of_items,
1294 /* *** SHOW PORT RETA INFO *** */
1295 struct cmd_showport_reta {
1296 cmdline_fixed_string_t show;
1297 cmdline_fixed_string_t port;
1299 cmdline_fixed_string_t rss;
1300 cmdline_fixed_string_t reta;
1305 static void cmd_showport_reta_parsed(void *parsed_result,
1306 __attribute__((unused)) struct cmdline *cl,
1307 __attribute__((unused)) void *data)
1309 struct cmd_showport_reta *res = parsed_result;
1310 struct rte_eth_rss_reta reta_conf;
1312 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1313 printf("Invalid RSS Redirection Table config entered\n");
1317 reta_conf.mask_lo = res->mask_lo;
1318 reta_conf.mask_hi = res->mask_hi;
1320 port_rss_reta_info(res->port_id,&reta_conf);
1323 cmdline_parse_token_string_t cmd_showport_reta_show =
1324 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1325 cmdline_parse_token_string_t cmd_showport_reta_port =
1326 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1327 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1328 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1329 cmdline_parse_token_string_t cmd_showport_reta_rss =
1330 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1331 cmdline_parse_token_string_t cmd_showport_reta_reta =
1332 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1333 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1334 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1335 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1336 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1338 cmdline_parse_inst_t cmd_showport_reta = {
1339 .f = cmd_showport_reta_parsed,
1341 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1342 (mask_lo and mask_hi is UINT64)",
1344 (void *)&cmd_showport_reta_show,
1345 (void *)&cmd_showport_reta_port,
1346 (void *)&cmd_showport_reta_port_id,
1347 (void *)&cmd_showport_reta_rss,
1348 (void *)&cmd_showport_reta_reta,
1349 (void *)&cmd_showport_reta_mask_lo,
1350 (void *)&cmd_showport_reta_mask_hi,
1355 /* *** Configure DCB *** */
1356 struct cmd_config_dcb {
1357 cmdline_fixed_string_t port;
1358 cmdline_fixed_string_t config;
1360 cmdline_fixed_string_t dcb;
1361 cmdline_fixed_string_t vt;
1362 cmdline_fixed_string_t vt_en;
1364 cmdline_fixed_string_t pfc;
1365 cmdline_fixed_string_t pfc_en;
1369 cmd_config_dcb_parsed(void *parsed_result,
1370 __attribute__((unused)) struct cmdline *cl,
1371 __attribute__((unused)) void *data)
1373 struct cmd_config_dcb *res = parsed_result;
1374 struct dcb_config dcb_conf;
1375 portid_t port_id = res->port_id;
1376 struct rte_port *port;
1378 port = &ports[port_id];
1379 /** Check if the port is not started **/
1380 if (port->port_status != RTE_PORT_STOPPED) {
1381 printf("Please stop port %d first\n",port_id);
1385 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1386 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1387 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1391 /* DCB in VT mode */
1392 if (!strncmp(res->vt_en, "on",2))
1393 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1395 dcb_conf.dcb_mode = DCB_ENABLED;
1397 if (!strncmp(res->pfc_en, "on",2)) {
1398 dcb_conf.pfc_en = 1;
1401 dcb_conf.pfc_en = 0;
1403 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1404 printf("Cannot initialize network ports\n");
1408 cmd_reconfig_device_queue(port_id, 1, 1);
1411 cmdline_parse_token_string_t cmd_config_dcb_port =
1412 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1413 cmdline_parse_token_string_t cmd_config_dcb_config =
1414 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1415 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1416 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1417 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1419 cmdline_parse_token_string_t cmd_config_dcb_vt =
1420 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1421 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1423 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1424 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1425 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1427 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1430 cmdline_parse_inst_t cmd_config_dcb = {
1431 .f = cmd_config_dcb_parsed,
1433 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1435 (void *)&cmd_config_dcb_port,
1436 (void *)&cmd_config_dcb_config,
1437 (void *)&cmd_config_dcb_port_id,
1438 (void *)&cmd_config_dcb_dcb,
1439 (void *)&cmd_config_dcb_vt,
1440 (void *)&cmd_config_dcb_vt_en,
1441 (void *)&cmd_config_dcb_num_tcs,
1442 (void *)&cmd_config_dcb_pfc,
1443 (void *)&cmd_config_dcb_pfc_en,
1448 /* *** configure number of packets per burst *** */
1449 struct cmd_config_burst {
1450 cmdline_fixed_string_t port;
1451 cmdline_fixed_string_t keyword;
1452 cmdline_fixed_string_t all;
1453 cmdline_fixed_string_t name;
1458 cmd_config_burst_parsed(void *parsed_result,
1459 __attribute__((unused)) struct cmdline *cl,
1460 __attribute__((unused)) void *data)
1462 struct cmd_config_burst *res = parsed_result;
1464 if (!all_ports_stopped()) {
1465 printf("Please stop all ports first\n");
1469 if (!strcmp(res->name, "burst")) {
1470 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1471 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1474 nb_pkt_per_burst = res->value;
1476 printf("Unknown parameter\n");
1482 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1485 cmdline_parse_token_string_t cmd_config_burst_port =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1487 cmdline_parse_token_string_t cmd_config_burst_keyword =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1489 cmdline_parse_token_string_t cmd_config_burst_all =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1491 cmdline_parse_token_string_t cmd_config_burst_name =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1493 cmdline_parse_token_num_t cmd_config_burst_value =
1494 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1496 cmdline_parse_inst_t cmd_config_burst = {
1497 .f = cmd_config_burst_parsed,
1499 .help_str = "port config all burst value",
1501 (void *)&cmd_config_burst_port,
1502 (void *)&cmd_config_burst_keyword,
1503 (void *)&cmd_config_burst_all,
1504 (void *)&cmd_config_burst_name,
1505 (void *)&cmd_config_burst_value,
1510 /* *** configure rx/tx queues *** */
1511 struct cmd_config_thresh {
1512 cmdline_fixed_string_t port;
1513 cmdline_fixed_string_t keyword;
1514 cmdline_fixed_string_t all;
1515 cmdline_fixed_string_t name;
1520 cmd_config_thresh_parsed(void *parsed_result,
1521 __attribute__((unused)) struct cmdline *cl,
1522 __attribute__((unused)) void *data)
1524 struct cmd_config_thresh *res = parsed_result;
1526 if (!all_ports_stopped()) {
1527 printf("Please stop all ports first\n");
1531 if (!strcmp(res->name, "txpt"))
1532 tx_thresh.pthresh = res->value;
1533 else if(!strcmp(res->name, "txht"))
1534 tx_thresh.hthresh = res->value;
1535 else if(!strcmp(res->name, "txwt"))
1536 tx_thresh.wthresh = res->value;
1537 else if(!strcmp(res->name, "rxpt"))
1538 rx_thresh.pthresh = res->value;
1539 else if(!strcmp(res->name, "rxht"))
1540 rx_thresh.hthresh = res->value;
1541 else if(!strcmp(res->name, "rxwt"))
1542 rx_thresh.wthresh = res->value;
1544 printf("Unknown parameter\n");
1550 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1553 cmdline_parse_token_string_t cmd_config_thresh_port =
1554 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1555 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1557 cmdline_parse_token_string_t cmd_config_thresh_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1559 cmdline_parse_token_string_t cmd_config_thresh_name =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1561 "txpt#txht#txwt#rxpt#rxht#rxwt");
1562 cmdline_parse_token_num_t cmd_config_thresh_value =
1563 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1565 cmdline_parse_inst_t cmd_config_thresh = {
1566 .f = cmd_config_thresh_parsed,
1568 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1570 (void *)&cmd_config_thresh_port,
1571 (void *)&cmd_config_thresh_keyword,
1572 (void *)&cmd_config_thresh_all,
1573 (void *)&cmd_config_thresh_name,
1574 (void *)&cmd_config_thresh_value,
1579 /* *** configure free/rs threshold *** */
1580 struct cmd_config_threshold {
1581 cmdline_fixed_string_t port;
1582 cmdline_fixed_string_t keyword;
1583 cmdline_fixed_string_t all;
1584 cmdline_fixed_string_t name;
1589 cmd_config_threshold_parsed(void *parsed_result,
1590 __attribute__((unused)) struct cmdline *cl,
1591 __attribute__((unused)) void *data)
1593 struct cmd_config_threshold *res = parsed_result;
1595 if (!all_ports_stopped()) {
1596 printf("Please stop all ports first\n");
1600 if (!strcmp(res->name, "txfreet"))
1601 tx_free_thresh = res->value;
1602 else if (!strcmp(res->name, "txrst"))
1603 tx_rs_thresh = res->value;
1604 else if (!strcmp(res->name, "rxfreet"))
1605 rx_free_thresh = res->value;
1607 printf("Unknown parameter\n");
1613 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1616 cmdline_parse_token_string_t cmd_config_threshold_port =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1618 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1621 cmdline_parse_token_string_t cmd_config_threshold_all =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1623 cmdline_parse_token_string_t cmd_config_threshold_name =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1625 "txfreet#txrst#rxfreet");
1626 cmdline_parse_token_num_t cmd_config_threshold_value =
1627 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1629 cmdline_parse_inst_t cmd_config_threshold = {
1630 .f = cmd_config_threshold_parsed,
1632 .help_str = "port config all txfreet|txrst|rxfreet value",
1634 (void *)&cmd_config_threshold_port,
1635 (void *)&cmd_config_threshold_keyword,
1636 (void *)&cmd_config_threshold_all,
1637 (void *)&cmd_config_threshold_name,
1638 (void *)&cmd_config_threshold_value,
1644 struct cmd_stop_result {
1645 cmdline_fixed_string_t stop;
1648 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1649 __attribute__((unused)) struct cmdline *cl,
1650 __attribute__((unused)) void *data)
1652 stop_packet_forwarding();
1655 cmdline_parse_token_string_t cmd_stop_stop =
1656 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1658 cmdline_parse_inst_t cmd_stop = {
1659 .f = cmd_stop_parsed,
1661 .help_str = "stop - stop packet forwarding",
1663 (void *)&cmd_stop_stop,
1668 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1671 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1672 unsigned int *parsed_items, int check_unique_values)
1674 unsigned int nb_item;
1682 * First parse all items in the list and store their value.
1687 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1689 if ((c >= '0') && (c <= '9')) {
1690 value = (unsigned int) (value * 10 + (c - '0'));
1695 printf("character %c is not a decimal digit\n", c);
1699 printf("No valid value before comma\n");
1702 if (nb_item < max_items) {
1703 parsed_items[nb_item] = value;
1709 if (nb_item >= max_items) {
1710 printf("Number of %s = %u > %u (maximum items)\n",
1711 item_name, nb_item + 1, max_items);
1714 parsed_items[nb_item++] = value;
1715 if (! check_unique_values)
1719 * Then, check that all values in the list are differents.
1720 * No optimization here...
1722 for (i = 0; i < nb_item; i++) {
1723 for (j = i + 1; j < nb_item; j++) {
1724 if (parsed_items[j] == parsed_items[i]) {
1725 printf("duplicated %s %u at index %u and %u\n",
1726 item_name, parsed_items[i], i, j);
1734 struct cmd_set_list_result {
1735 cmdline_fixed_string_t cmd_keyword;
1736 cmdline_fixed_string_t list_name;
1737 cmdline_fixed_string_t list_of_items;
1740 static void cmd_set_list_parsed(void *parsed_result,
1741 __attribute__((unused)) struct cmdline *cl,
1742 __attribute__((unused)) void *data)
1744 struct cmd_set_list_result *res;
1746 unsigned int lcorelist[RTE_MAX_LCORE];
1747 unsigned int portlist[RTE_MAX_ETHPORTS];
1749 unsigned int nb_item;
1751 res = parsed_result;
1752 if (!strcmp(res->list_name, "corelist")) {
1753 nb_item = parse_item_list(res->list_of_items, "core",
1755 parsed_items.lcorelist, 1);
1757 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1760 if (!strcmp(res->list_name, "portlist")) {
1761 nb_item = parse_item_list(res->list_of_items, "port",
1763 parsed_items.portlist, 1);
1765 set_fwd_ports_list(parsed_items.portlist, nb_item);
1769 cmdline_parse_token_string_t cmd_set_list_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1772 cmdline_parse_token_string_t cmd_set_list_name =
1773 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1774 "corelist#portlist");
1775 cmdline_parse_token_string_t cmd_set_list_of_items =
1776 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1779 cmdline_parse_inst_t cmd_set_fwd_list = {
1780 .f = cmd_set_list_parsed,
1782 .help_str = "set corelist|portlist x[,y]*",
1784 (void *)&cmd_set_list_keyword,
1785 (void *)&cmd_set_list_name,
1786 (void *)&cmd_set_list_of_items,
1791 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1793 struct cmd_setmask_result {
1794 cmdline_fixed_string_t set;
1795 cmdline_fixed_string_t mask;
1799 static void cmd_set_mask_parsed(void *parsed_result,
1800 __attribute__((unused)) struct cmdline *cl,
1801 __attribute__((unused)) void *data)
1803 struct cmd_setmask_result *res = parsed_result;
1805 if (!strcmp(res->mask, "coremask"))
1806 set_fwd_lcores_mask(res->hexavalue);
1807 else if (!strcmp(res->mask, "portmask"))
1808 set_fwd_ports_mask(res->hexavalue);
1811 cmdline_parse_token_string_t cmd_setmask_set =
1812 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1813 cmdline_parse_token_string_t cmd_setmask_mask =
1814 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1815 "coremask#portmask");
1816 cmdline_parse_token_num_t cmd_setmask_value =
1817 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1819 cmdline_parse_inst_t cmd_set_fwd_mask = {
1820 .f = cmd_set_mask_parsed,
1822 .help_str = "set coremask|portmask hexadecimal value",
1824 (void *)&cmd_setmask_set,
1825 (void *)&cmd_setmask_mask,
1826 (void *)&cmd_setmask_value,
1832 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1834 struct cmd_set_result {
1835 cmdline_fixed_string_t set;
1836 cmdline_fixed_string_t what;
1840 static void cmd_set_parsed(void *parsed_result,
1841 __attribute__((unused)) struct cmdline *cl,
1842 __attribute__((unused)) void *data)
1844 struct cmd_set_result *res = parsed_result;
1845 if (!strcmp(res->what, "nbport"))
1846 set_fwd_ports_number(res->value);
1847 else if (!strcmp(res->what, "nbcore"))
1848 set_fwd_lcores_number(res->value);
1849 else if (!strcmp(res->what, "burst"))
1850 set_nb_pkt_per_burst(res->value);
1851 else if (!strcmp(res->what, "verbose"))
1852 set_verbose_level(res->value);
1855 cmdline_parse_token_string_t cmd_set_set =
1856 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1857 cmdline_parse_token_string_t cmd_set_what =
1858 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1859 "nbport#nbcore#burst#verbose");
1860 cmdline_parse_token_num_t cmd_set_value =
1861 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1863 cmdline_parse_inst_t cmd_set_numbers = {
1864 .f = cmd_set_parsed,
1866 .help_str = "set nbport|nbcore|burst|verbose value",
1868 (void *)&cmd_set_set,
1869 (void *)&cmd_set_what,
1870 (void *)&cmd_set_value,
1875 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1877 struct cmd_set_txpkts_result {
1878 cmdline_fixed_string_t cmd_keyword;
1879 cmdline_fixed_string_t txpkts;
1880 cmdline_fixed_string_t seg_lengths;
1884 cmd_set_txpkts_parsed(void *parsed_result,
1885 __attribute__((unused)) struct cmdline *cl,
1886 __attribute__((unused)) void *data)
1888 struct cmd_set_txpkts_result *res;
1889 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1890 unsigned int nb_segs;
1892 res = parsed_result;
1893 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1894 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1896 set_tx_pkt_segments(seg_lengths, nb_segs);
1899 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1900 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1901 cmd_keyword, "set");
1902 cmdline_parse_token_string_t cmd_set_txpkts_name =
1903 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1905 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1906 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1909 cmdline_parse_inst_t cmd_set_txpkts = {
1910 .f = cmd_set_txpkts_parsed,
1912 .help_str = "set txpkts x[,y]*",
1914 (void *)&cmd_set_txpkts_keyword,
1915 (void *)&cmd_set_txpkts_name,
1916 (void *)&cmd_set_txpkts_lengths,
1921 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1922 struct cmd_rx_vlan_filter_all_result {
1923 cmdline_fixed_string_t rx_vlan;
1924 cmdline_fixed_string_t what;
1925 cmdline_fixed_string_t all;
1930 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1931 __attribute__((unused)) struct cmdline *cl,
1932 __attribute__((unused)) void *data)
1934 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1936 if (!strcmp(res->what, "add"))
1937 rx_vlan_all_filter_set(res->port_id, 1);
1939 rx_vlan_all_filter_set(res->port_id, 0);
1942 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1943 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1944 rx_vlan, "rx_vlan");
1945 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1946 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1948 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1949 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1951 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1952 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1955 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1956 .f = cmd_rx_vlan_filter_all_parsed,
1958 .help_str = "add/remove all identifiers to/from the set of VLAN "
1959 "Identifiers filtered by a port",
1961 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1962 (void *)&cmd_rx_vlan_filter_all_what,
1963 (void *)&cmd_rx_vlan_filter_all_all,
1964 (void *)&cmd_rx_vlan_filter_all_portid,
1969 /* *** VLAN OFFLOAD SET ON A PORT *** */
1970 struct cmd_vlan_offload_result {
1971 cmdline_fixed_string_t vlan;
1972 cmdline_fixed_string_t set;
1973 cmdline_fixed_string_t what;
1974 cmdline_fixed_string_t on;
1975 cmdline_fixed_string_t port_id;
1979 cmd_vlan_offload_parsed(void *parsed_result,
1980 __attribute__((unused)) struct cmdline *cl,
1981 __attribute__((unused)) void *data)
1984 struct cmd_vlan_offload_result *res = parsed_result;
1987 portid_t port_id = 0;
1991 len = strnlen(str, STR_TOKEN_SIZE);
1993 /* Get port_id first */
2001 tmp = strtoul(str, NULL, 0);
2002 /* If port_id greater that what portid_t can represent, return */
2003 if(tmp >= RTE_MAX_ETHPORTS)
2005 port_id = (portid_t)tmp;
2007 if (!strcmp(res->on, "on"))
2012 if (!strcmp(res->what, "strip"))
2013 rx_vlan_strip_set(port_id, on);
2014 else if(!strcmp(res->what, "stripq")){
2015 uint16_t queue_id = 0;
2017 /* No queue_id, return */
2019 printf("must specify (port,queue_id)\n");
2022 tmp = strtoul(str + i + 1, NULL, 0);
2023 /* If queue_id greater that what 16-bits can represent, return */
2027 queue_id = (uint16_t)tmp;
2028 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2030 else if (!strcmp(res->what, "filter"))
2031 rx_vlan_filter_set(port_id, on);
2033 vlan_extend_set(port_id, on);
2038 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2039 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2041 cmdline_parse_token_string_t cmd_vlan_offload_set =
2042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2044 cmdline_parse_token_string_t cmd_vlan_offload_what =
2045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2046 what, "strip#filter#qinq#stripq");
2047 cmdline_parse_token_string_t cmd_vlan_offload_on =
2048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2050 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2051 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2054 cmdline_parse_inst_t cmd_vlan_offload = {
2055 .f = cmd_vlan_offload_parsed,
2057 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2058 " qinq(extended) for both rx/tx sides ",
2060 (void *)&cmd_vlan_offload_vlan,
2061 (void *)&cmd_vlan_offload_set,
2062 (void *)&cmd_vlan_offload_what,
2063 (void *)&cmd_vlan_offload_on,
2064 (void *)&cmd_vlan_offload_portid,
2069 /* *** VLAN TPID SET ON A PORT *** */
2070 struct cmd_vlan_tpid_result {
2071 cmdline_fixed_string_t vlan;
2072 cmdline_fixed_string_t set;
2073 cmdline_fixed_string_t what;
2079 cmd_vlan_tpid_parsed(void *parsed_result,
2080 __attribute__((unused)) struct cmdline *cl,
2081 __attribute__((unused)) void *data)
2083 struct cmd_vlan_tpid_result *res = parsed_result;
2084 vlan_tpid_set(res->port_id, res->tp_id);
2088 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2089 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2091 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2092 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2094 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2095 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2097 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2098 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2100 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2101 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2104 cmdline_parse_inst_t cmd_vlan_tpid = {
2105 .f = cmd_vlan_tpid_parsed,
2107 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2109 (void *)&cmd_vlan_tpid_vlan,
2110 (void *)&cmd_vlan_tpid_set,
2111 (void *)&cmd_vlan_tpid_what,
2112 (void *)&cmd_vlan_tpid_tpid,
2113 (void *)&cmd_vlan_tpid_portid,
2118 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2119 struct cmd_rx_vlan_filter_result {
2120 cmdline_fixed_string_t rx_vlan;
2121 cmdline_fixed_string_t what;
2127 cmd_rx_vlan_filter_parsed(void *parsed_result,
2128 __attribute__((unused)) struct cmdline *cl,
2129 __attribute__((unused)) void *data)
2131 struct cmd_rx_vlan_filter_result *res = parsed_result;
2133 if (!strcmp(res->what, "add"))
2134 rx_vft_set(res->port_id, res->vlan_id, 1);
2136 rx_vft_set(res->port_id, res->vlan_id, 0);
2139 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2141 rx_vlan, "rx_vlan");
2142 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2145 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2146 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2148 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2149 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2152 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2153 .f = cmd_rx_vlan_filter_parsed,
2155 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2156 "Identifiers filtered by a port",
2158 (void *)&cmd_rx_vlan_filter_rx_vlan,
2159 (void *)&cmd_rx_vlan_filter_what,
2160 (void *)&cmd_rx_vlan_filter_vlanid,
2161 (void *)&cmd_rx_vlan_filter_portid,
2166 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2167 struct cmd_tx_vlan_set_result {
2168 cmdline_fixed_string_t tx_vlan;
2169 cmdline_fixed_string_t set;
2175 cmd_tx_vlan_set_parsed(void *parsed_result,
2176 __attribute__((unused)) struct cmdline *cl,
2177 __attribute__((unused)) void *data)
2179 struct cmd_tx_vlan_set_result *res = parsed_result;
2180 tx_vlan_set(res->port_id, res->vlan_id);
2183 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2184 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2185 tx_vlan, "tx_vlan");
2186 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2187 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2189 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2190 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2192 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2193 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2196 cmdline_parse_inst_t cmd_tx_vlan_set = {
2197 .f = cmd_tx_vlan_set_parsed,
2199 .help_str = "enable hardware insertion of a VLAN header with a given "
2200 "TAG Identifier in packets sent on a port",
2202 (void *)&cmd_tx_vlan_set_tx_vlan,
2203 (void *)&cmd_tx_vlan_set_set,
2204 (void *)&cmd_tx_vlan_set_vlanid,
2205 (void *)&cmd_tx_vlan_set_portid,
2210 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2211 struct cmd_tx_vlan_reset_result {
2212 cmdline_fixed_string_t tx_vlan;
2213 cmdline_fixed_string_t reset;
2218 cmd_tx_vlan_reset_parsed(void *parsed_result,
2219 __attribute__((unused)) struct cmdline *cl,
2220 __attribute__((unused)) void *data)
2222 struct cmd_tx_vlan_reset_result *res = parsed_result;
2224 tx_vlan_reset(res->port_id);
2227 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2228 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2229 tx_vlan, "tx_vlan");
2230 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2231 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2233 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2234 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2237 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2238 .f = cmd_tx_vlan_reset_parsed,
2240 .help_str = "disable hardware insertion of a VLAN header in packets "
2243 (void *)&cmd_tx_vlan_reset_tx_vlan,
2244 (void *)&cmd_tx_vlan_reset_reset,
2245 (void *)&cmd_tx_vlan_reset_portid,
2251 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2252 struct cmd_tx_cksum_set_result {
2253 cmdline_fixed_string_t tx_cksum;
2254 cmdline_fixed_string_t set;
2260 cmd_tx_cksum_set_parsed(void *parsed_result,
2261 __attribute__((unused)) struct cmdline *cl,
2262 __attribute__((unused)) void *data)
2264 struct cmd_tx_cksum_set_result *res = parsed_result;
2266 tx_cksum_set(res->port_id, res->cksum_mask);
2269 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2270 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2271 tx_cksum, "tx_checksum");
2272 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2273 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2275 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2276 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2278 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2279 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2282 cmdline_parse_inst_t cmd_tx_cksum_set = {
2283 .f = cmd_tx_cksum_set_parsed,
2285 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2286 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2287 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2289 (void *)&cmd_tx_cksum_set_tx_cksum,
2290 (void *)&cmd_tx_cksum_set_set,
2291 (void *)&cmd_tx_cksum_set_cksum_mask,
2292 (void *)&cmd_tx_cksum_set_portid,
2297 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2298 struct cmd_set_flush_rx {
2299 cmdline_fixed_string_t set;
2300 cmdline_fixed_string_t flush_rx;
2301 cmdline_fixed_string_t mode;
2305 cmd_set_flush_rx_parsed(void *parsed_result,
2306 __attribute__((unused)) struct cmdline *cl,
2307 __attribute__((unused)) void *data)
2309 struct cmd_set_flush_rx *res = parsed_result;
2310 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2313 cmdline_parse_token_string_t cmd_setflushrx_set =
2314 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2316 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2317 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2318 flush_rx, "flush_rx");
2319 cmdline_parse_token_string_t cmd_setflushrx_mode =
2320 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2324 cmdline_parse_inst_t cmd_set_flush_rx = {
2325 .f = cmd_set_flush_rx_parsed,
2326 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2329 (void *)&cmd_setflushrx_set,
2330 (void *)&cmd_setflushrx_flush_rx,
2331 (void *)&cmd_setflushrx_mode,
2336 #ifdef RTE_NIC_BYPASS
2337 /* *** SET NIC BYPASS MODE *** */
2338 struct cmd_set_bypass_mode_result {
2339 cmdline_fixed_string_t set;
2340 cmdline_fixed_string_t bypass;
2341 cmdline_fixed_string_t mode;
2342 cmdline_fixed_string_t value;
2347 cmd_set_bypass_mode_parsed(void *parsed_result,
2348 __attribute__((unused)) struct cmdline *cl,
2349 __attribute__((unused)) void *data)
2351 struct cmd_set_bypass_mode_result *res = parsed_result;
2352 portid_t port_id = res->port_id;
2353 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2355 if (!bypass_is_supported(port_id))
2358 if (!strcmp(res->value, "bypass"))
2359 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2360 else if (!strcmp(res->value, "isolate"))
2361 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2363 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2365 /* Set the bypass mode for the relevant port. */
2366 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2367 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2371 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2372 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2374 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2375 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2377 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2378 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2380 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2381 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2382 value, "normal#bypass#isolate");
2383 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2384 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2387 cmdline_parse_inst_t cmd_set_bypass_mode = {
2388 .f = cmd_set_bypass_mode_parsed,
2389 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2390 "Set the NIC bypass mode for port_id",
2393 (void *)&cmd_setbypass_mode_set,
2394 (void *)&cmd_setbypass_mode_bypass,
2395 (void *)&cmd_setbypass_mode_mode,
2396 (void *)&cmd_setbypass_mode_value,
2397 (void *)&cmd_setbypass_mode_port,
2402 /* *** SET NIC BYPASS EVENT *** */
2403 struct cmd_set_bypass_event_result {
2404 cmdline_fixed_string_t set;
2405 cmdline_fixed_string_t bypass;
2406 cmdline_fixed_string_t event;
2407 cmdline_fixed_string_t event_value;
2408 cmdline_fixed_string_t mode;
2409 cmdline_fixed_string_t mode_value;
2414 cmd_set_bypass_event_parsed(void *parsed_result,
2415 __attribute__((unused)) struct cmdline *cl,
2416 __attribute__((unused)) void *data)
2419 struct cmd_set_bypass_event_result *res = parsed_result;
2420 portid_t port_id = res->port_id;
2421 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2422 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2424 if (!bypass_is_supported(port_id))
2427 if (!strcmp(res->event_value, "timeout"))
2428 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2429 else if (!strcmp(res->event_value, "os_on"))
2430 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2431 else if (!strcmp(res->event_value, "os_off"))
2432 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2433 else if (!strcmp(res->event_value, "power_on"))
2434 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2435 else if (!strcmp(res->event_value, "power_off"))
2436 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2438 bypass_event = RTE_BYPASS_EVENT_NONE;
2440 if (!strcmp(res->mode_value, "bypass"))
2441 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2442 else if (!strcmp(res->mode_value, "isolate"))
2443 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2445 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2447 /* Set the watchdog timeout. */
2448 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2451 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2452 (rc = rte_eth_dev_wd_timeout_store(port_id,
2453 bypass_timeout)) != 0) {
2454 printf("Failed to set timeout value %u "
2455 "for port %d, errto code: %d.\n",
2456 bypass_timeout, port_id, rc);
2460 /* Set the bypass event to transition to bypass mode. */
2461 if (0 != rte_eth_dev_bypass_event_store(port_id,
2462 bypass_event, bypass_mode)) {
2463 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2468 cmdline_parse_token_string_t cmd_setbypass_event_set =
2469 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2471 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2472 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2474 cmdline_parse_token_string_t cmd_setbypass_event_event =
2475 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2477 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2478 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2479 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2480 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2481 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2483 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2484 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2485 mode_value, "normal#bypass#isolate");
2486 cmdline_parse_token_num_t cmd_setbypass_event_port =
2487 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2490 cmdline_parse_inst_t cmd_set_bypass_event = {
2491 .f = cmd_set_bypass_event_parsed,
2492 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2493 "mode (normal|bypass|isolate) (port_id): "
2494 "Set the NIC bypass event mode for port_id",
2497 (void *)&cmd_setbypass_event_set,
2498 (void *)&cmd_setbypass_event_bypass,
2499 (void *)&cmd_setbypass_event_event,
2500 (void *)&cmd_setbypass_event_event_value,
2501 (void *)&cmd_setbypass_event_mode,
2502 (void *)&cmd_setbypass_event_mode_value,
2503 (void *)&cmd_setbypass_event_port,
2509 /* *** SET NIC BYPASS TIMEOUT *** */
2510 struct cmd_set_bypass_timeout_result {
2511 cmdline_fixed_string_t set;
2512 cmdline_fixed_string_t bypass;
2513 cmdline_fixed_string_t timeout;
2514 cmdline_fixed_string_t value;
2518 cmd_set_bypass_timeout_parsed(void *parsed_result,
2519 __attribute__((unused)) struct cmdline *cl,
2520 __attribute__((unused)) void *data)
2522 struct cmd_set_bypass_timeout_result *res = parsed_result;
2524 if (!strcmp(res->value, "1.5"))
2525 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2526 else if (!strcmp(res->value, "2"))
2527 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2528 else if (!strcmp(res->value, "3"))
2529 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2530 else if (!strcmp(res->value, "4"))
2531 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2532 else if (!strcmp(res->value, "8"))
2533 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2534 else if (!strcmp(res->value, "16"))
2535 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2536 else if (!strcmp(res->value, "32"))
2537 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2539 bypass_timeout = RTE_BYPASS_TMT_OFF;
2542 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2545 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2548 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2550 timeout, "timeout");
2551 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2553 value, "0#1.5#2#3#4#8#16#32");
2555 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2556 .f = cmd_set_bypass_timeout_parsed,
2557 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2558 "Set the NIC bypass watchdog timeout",
2561 (void *)&cmd_setbypass_timeout_set,
2562 (void *)&cmd_setbypass_timeout_bypass,
2563 (void *)&cmd_setbypass_timeout_timeout,
2564 (void *)&cmd_setbypass_timeout_value,
2569 /* *** SHOW NIC BYPASS MODE *** */
2570 struct cmd_show_bypass_config_result {
2571 cmdline_fixed_string_t show;
2572 cmdline_fixed_string_t bypass;
2573 cmdline_fixed_string_t config;
2578 cmd_show_bypass_config_parsed(void *parsed_result,
2579 __attribute__((unused)) struct cmdline *cl,
2580 __attribute__((unused)) void *data)
2582 struct cmd_show_bypass_config_result *res = parsed_result;
2583 uint32_t event_mode;
2584 uint32_t bypass_mode;
2585 portid_t port_id = res->port_id;
2586 uint32_t timeout = bypass_timeout;
2589 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2590 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2591 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2592 {"UNKNOWN", "normal", "bypass", "isolate"};
2593 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2600 int num_events = (sizeof events) / (sizeof events[0]);
2602 if (!bypass_is_supported(port_id))
2605 /* Display the bypass mode.*/
2606 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2607 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2611 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2612 bypass_mode = RTE_BYPASS_MODE_NONE;
2614 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2617 /* Display the bypass timeout.*/
2618 if (!RTE_BYPASS_TMT_VALID(timeout))
2619 timeout = RTE_BYPASS_TMT_OFF;
2621 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2623 /* Display the bypass events and associated modes. */
2624 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2626 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2627 printf("\tFailed to get bypass mode for event = %s\n",
2630 if (!RTE_BYPASS_MODE_VALID(event_mode))
2631 event_mode = RTE_BYPASS_MODE_NONE;
2633 printf("\tbypass event: %-16s = %s\n", events[i],
2639 cmdline_parse_token_string_t cmd_showbypass_config_show =
2640 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2642 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2643 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2645 cmdline_parse_token_string_t cmd_showbypass_config_config =
2646 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2648 cmdline_parse_token_num_t cmd_showbypass_config_port =
2649 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2652 cmdline_parse_inst_t cmd_show_bypass_config = {
2653 .f = cmd_show_bypass_config_parsed,
2654 .help_str = "show bypass config (port_id): "
2655 "Show the NIC bypass config for port_id",
2658 (void *)&cmd_showbypass_config_show,
2659 (void *)&cmd_showbypass_config_bypass,
2660 (void *)&cmd_showbypass_config_config,
2661 (void *)&cmd_showbypass_config_port,
2667 /* *** SET FORWARDING MODE *** */
2668 struct cmd_set_fwd_mode_result {
2669 cmdline_fixed_string_t set;
2670 cmdline_fixed_string_t fwd;
2671 cmdline_fixed_string_t mode;
2674 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2675 __attribute__((unused)) struct cmdline *cl,
2676 __attribute__((unused)) void *data)
2678 struct cmd_set_fwd_mode_result *res = parsed_result;
2680 set_pkt_forwarding_mode(res->mode);
2683 cmdline_parse_token_string_t cmd_setfwd_set =
2684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2685 cmdline_parse_token_string_t cmd_setfwd_fwd =
2686 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2687 cmdline_parse_token_string_t cmd_setfwd_mode =
2688 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2689 #ifdef RTE_LIBRTE_IEEE1588
2690 "io#mac#mac_retry#rxonly#txonly#csum#ieee1588");
2692 "io#mac#mac_retry#rxonly#txonly#csum");
2695 cmdline_parse_inst_t cmd_set_fwd_mode = {
2696 .f = cmd_set_fwd_mode_parsed,
2698 #ifdef RTE_LIBRTE_IEEE1588
2699 .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2700 " MAC_RETRY, RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2702 .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum - set IO, MAC,"
2703 " MAC_RETRY, RXONLY, CSUM or TXONLY packet forwarding mode",
2706 (void *)&cmd_setfwd_set,
2707 (void *)&cmd_setfwd_fwd,
2708 (void *)&cmd_setfwd_mode,
2713 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2714 struct cmd_set_burst_tx_retry_result {
2715 cmdline_fixed_string_t set;
2716 cmdline_fixed_string_t burst;
2717 cmdline_fixed_string_t tx;
2718 cmdline_fixed_string_t delay;
2720 cmdline_fixed_string_t retry;
2724 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2725 __attribute__((unused)) struct cmdline *cl,
2726 __attribute__((unused)) void *data)
2728 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2730 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2731 && !strcmp(res->tx, "tx")) {
2732 if (!strcmp(res->delay, "delay"))
2733 burst_tx_delay_time = res->time;
2734 if (!strcmp(res->retry, "retry"))
2735 burst_tx_retry_num = res->retry_num;
2740 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
2741 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
2742 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
2743 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
2745 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
2746 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
2747 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
2749 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
2750 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
2751 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
2752 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
2753 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
2754 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
2756 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
2757 .f = cmd_set_burst_tx_retry_parsed,
2758 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
2760 (void *)&cmd_set_burst_tx_retry_set,
2761 (void *)&cmd_set_burst_tx_retry_burst,
2762 (void *)&cmd_set_burst_tx_retry_tx,
2763 (void *)&cmd_set_burst_tx_retry_delay,
2764 (void *)&cmd_set_burst_tx_retry_time,
2765 (void *)&cmd_set_burst_tx_retry_retry,
2766 (void *)&cmd_set_burst_tx_retry_retry_num,
2771 /* *** SET PROMISC MODE *** */
2772 struct cmd_set_promisc_mode_result {
2773 cmdline_fixed_string_t set;
2774 cmdline_fixed_string_t promisc;
2775 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2776 uint8_t port_num; /* valid if "allports" argument == 0 */
2777 cmdline_fixed_string_t mode;
2780 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2784 struct cmd_set_promisc_mode_result *res = parsed_result;
2788 if (!strcmp(res->mode, "on"))
2795 for (i = 0; i < nb_ports; i++) {
2797 rte_eth_promiscuous_enable(i);
2799 rte_eth_promiscuous_disable(i);
2804 rte_eth_promiscuous_enable(res->port_num);
2806 rte_eth_promiscuous_disable(res->port_num);
2810 cmdline_parse_token_string_t cmd_setpromisc_set =
2811 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2812 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2813 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2815 cmdline_parse_token_string_t cmd_setpromisc_portall =
2816 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2818 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2819 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2821 cmdline_parse_token_string_t cmd_setpromisc_mode =
2822 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2825 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2826 .f = cmd_set_promisc_mode_parsed,
2828 .help_str = "set promisc all on|off: set promisc mode for all ports",
2830 (void *)&cmd_setpromisc_set,
2831 (void *)&cmd_setpromisc_promisc,
2832 (void *)&cmd_setpromisc_portall,
2833 (void *)&cmd_setpromisc_mode,
2838 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2839 .f = cmd_set_promisc_mode_parsed,
2841 .help_str = "set promisc X on|off: set promisc mode on port X",
2843 (void *)&cmd_setpromisc_set,
2844 (void *)&cmd_setpromisc_promisc,
2845 (void *)&cmd_setpromisc_portnum,
2846 (void *)&cmd_setpromisc_mode,
2851 /* *** SET ALLMULTI MODE *** */
2852 struct cmd_set_allmulti_mode_result {
2853 cmdline_fixed_string_t set;
2854 cmdline_fixed_string_t allmulti;
2855 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2856 uint8_t port_num; /* valid if "allports" argument == 0 */
2857 cmdline_fixed_string_t mode;
2860 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2861 __attribute__((unused)) struct cmdline *cl,
2864 struct cmd_set_allmulti_mode_result *res = parsed_result;
2868 if (!strcmp(res->mode, "on"))
2875 for (i = 0; i < nb_ports; i++) {
2877 rte_eth_allmulticast_enable(i);
2879 rte_eth_allmulticast_disable(i);
2884 rte_eth_allmulticast_enable(res->port_num);
2886 rte_eth_allmulticast_disable(res->port_num);
2890 cmdline_parse_token_string_t cmd_setallmulti_set =
2891 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2892 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2893 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2895 cmdline_parse_token_string_t cmd_setallmulti_portall =
2896 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2898 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2899 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2901 cmdline_parse_token_string_t cmd_setallmulti_mode =
2902 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2905 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2906 .f = cmd_set_allmulti_mode_parsed,
2908 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2910 (void *)&cmd_setallmulti_set,
2911 (void *)&cmd_setallmulti_allmulti,
2912 (void *)&cmd_setallmulti_portall,
2913 (void *)&cmd_setallmulti_mode,
2918 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2919 .f = cmd_set_allmulti_mode_parsed,
2921 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2923 (void *)&cmd_setallmulti_set,
2924 (void *)&cmd_setallmulti_allmulti,
2925 (void *)&cmd_setallmulti_portnum,
2926 (void *)&cmd_setallmulti_mode,
2931 /* *** ADD/REMOVE A PKT FILTER *** */
2932 struct cmd_pkt_filter_result {
2933 cmdline_fixed_string_t pkt_filter;
2935 cmdline_fixed_string_t protocol;
2936 cmdline_fixed_string_t src;
2937 cmdline_ipaddr_t ip_src;
2939 cmdline_fixed_string_t dst;
2940 cmdline_ipaddr_t ip_dst;
2942 cmdline_fixed_string_t flexbytes;
2943 uint16_t flexbytes_value;
2944 cmdline_fixed_string_t vlan;
2946 cmdline_fixed_string_t queue;
2948 cmdline_fixed_string_t soft;
2953 cmd_pkt_filter_parsed(void *parsed_result,
2954 __attribute__((unused)) struct cmdline *cl,
2955 __attribute__((unused)) void *data)
2957 struct rte_fdir_filter fdir_filter;
2958 struct cmd_pkt_filter_result *res = parsed_result;
2960 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2962 if (res->ip_src.family == AF_INET)
2963 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2965 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2966 &(res->ip_src.addr.ipv6),
2967 sizeof(struct in6_addr));
2969 if (res->ip_dst.family == AF_INET)
2970 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2972 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2973 &(res->ip_dst.addr.ipv6),
2974 sizeof(struct in6_addr));
2976 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2977 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2979 if (!strcmp(res->protocol, "udp"))
2980 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2981 else if (!strcmp(res->protocol, "tcp"))
2982 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2983 else if (!strcmp(res->protocol, "sctp"))
2984 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2985 else /* default only IP */
2986 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2988 if (res->ip_dst.family == AF_INET6)
2989 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2991 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2993 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2994 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2996 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2997 fdir_add_signature_filter(res->port_id, res->queue_id,
2999 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3000 fdir_update_signature_filter(res->port_id, res->queue_id,
3002 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3003 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3004 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3005 fdir_add_perfect_filter(res->port_id, res->soft_id,
3007 (uint8_t) (res->queue_id < 0),
3009 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3010 fdir_update_perfect_filter(res->port_id, res->soft_id,
3012 (uint8_t) (res->queue_id < 0),
3014 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3015 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3021 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3022 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3024 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3025 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3026 protocol, "ip#tcp#udp#sctp");
3027 cmdline_parse_token_string_t cmd_pkt_filter_src =
3028 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3030 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3031 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3033 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3034 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3036 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3037 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3039 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3040 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3042 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3043 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3045 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3046 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3047 flexbytes, "flexbytes");
3048 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3049 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3050 flexbytes_value, UINT16);
3051 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3052 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3054 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3055 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3057 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3058 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3060 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3061 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3063 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3064 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3066 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3067 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3071 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3072 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3073 pkt_filter, "add_signature_filter");
3074 cmdline_parse_inst_t cmd_add_signature_filter = {
3075 .f = cmd_pkt_filter_parsed,
3077 .help_str = "add a signature filter",
3079 (void *)&cmd_pkt_filter_add_signature_filter,
3080 (void *)&cmd_pkt_filter_port_id,
3081 (void *)&cmd_pkt_filter_protocol,
3082 (void *)&cmd_pkt_filter_src,
3083 (void *)&cmd_pkt_filter_ip_src,
3084 (void *)&cmd_pkt_filter_port_src,
3085 (void *)&cmd_pkt_filter_dst,
3086 (void *)&cmd_pkt_filter_ip_dst,
3087 (void *)&cmd_pkt_filter_port_dst,
3088 (void *)&cmd_pkt_filter_flexbytes,
3089 (void *)&cmd_pkt_filter_flexbytes_value,
3090 (void *)&cmd_pkt_filter_vlan,
3091 (void *)&cmd_pkt_filter_vlan_id,
3092 (void *)&cmd_pkt_filter_queue,
3093 (void *)&cmd_pkt_filter_queue_id,
3099 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3100 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3101 pkt_filter, "upd_signature_filter");
3102 cmdline_parse_inst_t cmd_upd_signature_filter = {
3103 .f = cmd_pkt_filter_parsed,
3105 .help_str = "update a signature filter",
3107 (void *)&cmd_pkt_filter_upd_signature_filter,
3108 (void *)&cmd_pkt_filter_port_id,
3109 (void *)&cmd_pkt_filter_protocol,
3110 (void *)&cmd_pkt_filter_src,
3111 (void *)&cmd_pkt_filter_ip_src,
3112 (void *)&cmd_pkt_filter_port_src,
3113 (void *)&cmd_pkt_filter_dst,
3114 (void *)&cmd_pkt_filter_ip_dst,
3115 (void *)&cmd_pkt_filter_port_dst,
3116 (void *)&cmd_pkt_filter_flexbytes,
3117 (void *)&cmd_pkt_filter_flexbytes_value,
3118 (void *)&cmd_pkt_filter_vlan,
3119 (void *)&cmd_pkt_filter_vlan_id,
3120 (void *)&cmd_pkt_filter_queue,
3121 (void *)&cmd_pkt_filter_queue_id,
3127 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3128 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3129 pkt_filter, "rm_signature_filter");
3130 cmdline_parse_inst_t cmd_rm_signature_filter = {
3131 .f = cmd_pkt_filter_parsed,
3133 .help_str = "remove a signature filter",
3135 (void *)&cmd_pkt_filter_rm_signature_filter,
3136 (void *)&cmd_pkt_filter_port_id,
3137 (void *)&cmd_pkt_filter_protocol,
3138 (void *)&cmd_pkt_filter_src,
3139 (void *)&cmd_pkt_filter_ip_src,
3140 (void *)&cmd_pkt_filter_port_src,
3141 (void *)&cmd_pkt_filter_dst,
3142 (void *)&cmd_pkt_filter_ip_dst,
3143 (void *)&cmd_pkt_filter_port_dst,
3144 (void *)&cmd_pkt_filter_flexbytes,
3145 (void *)&cmd_pkt_filter_flexbytes_value,
3146 (void *)&cmd_pkt_filter_vlan,
3147 (void *)&cmd_pkt_filter_vlan_id,
3153 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3154 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3155 pkt_filter, "add_perfect_filter");
3156 cmdline_parse_inst_t cmd_add_perfect_filter = {
3157 .f = cmd_pkt_filter_parsed,
3159 .help_str = "add a perfect filter",
3161 (void *)&cmd_pkt_filter_add_perfect_filter,
3162 (void *)&cmd_pkt_filter_port_id,
3163 (void *)&cmd_pkt_filter_protocol,
3164 (void *)&cmd_pkt_filter_src,
3165 (void *)&cmd_pkt_filter_ip_src,
3166 (void *)&cmd_pkt_filter_port_src,
3167 (void *)&cmd_pkt_filter_dst,
3168 (void *)&cmd_pkt_filter_ip_dst,
3169 (void *)&cmd_pkt_filter_port_dst,
3170 (void *)&cmd_pkt_filter_flexbytes,
3171 (void *)&cmd_pkt_filter_flexbytes_value,
3172 (void *)&cmd_pkt_filter_vlan,
3173 (void *)&cmd_pkt_filter_vlan_id,
3174 (void *)&cmd_pkt_filter_queue,
3175 (void *)&cmd_pkt_filter_queue_id,
3176 (void *)&cmd_pkt_filter_soft,
3177 (void *)&cmd_pkt_filter_soft_id,
3183 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3184 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3185 pkt_filter, "upd_perfect_filter");
3186 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3187 .f = cmd_pkt_filter_parsed,
3189 .help_str = "update a perfect filter",
3191 (void *)&cmd_pkt_filter_upd_perfect_filter,
3192 (void *)&cmd_pkt_filter_port_id,
3193 (void *)&cmd_pkt_filter_protocol,
3194 (void *)&cmd_pkt_filter_src,
3195 (void *)&cmd_pkt_filter_ip_src,
3196 (void *)&cmd_pkt_filter_port_src,
3197 (void *)&cmd_pkt_filter_dst,
3198 (void *)&cmd_pkt_filter_ip_dst,
3199 (void *)&cmd_pkt_filter_port_dst,
3200 (void *)&cmd_pkt_filter_flexbytes,
3201 (void *)&cmd_pkt_filter_flexbytes_value,
3202 (void *)&cmd_pkt_filter_vlan,
3203 (void *)&cmd_pkt_filter_vlan_id,
3204 (void *)&cmd_pkt_filter_queue,
3205 (void *)&cmd_pkt_filter_queue_id,
3206 (void *)&cmd_pkt_filter_soft,
3207 (void *)&cmd_pkt_filter_soft_id,
3213 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3214 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3215 pkt_filter, "rm_perfect_filter");
3216 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3217 .f = cmd_pkt_filter_parsed,
3219 .help_str = "remove a perfect filter",
3221 (void *)&cmd_pkt_filter_rm_perfect_filter,
3222 (void *)&cmd_pkt_filter_port_id,
3223 (void *)&cmd_pkt_filter_protocol,
3224 (void *)&cmd_pkt_filter_src,
3225 (void *)&cmd_pkt_filter_ip_src,
3226 (void *)&cmd_pkt_filter_port_src,
3227 (void *)&cmd_pkt_filter_dst,
3228 (void *)&cmd_pkt_filter_ip_dst,
3229 (void *)&cmd_pkt_filter_port_dst,
3230 (void *)&cmd_pkt_filter_flexbytes,
3231 (void *)&cmd_pkt_filter_flexbytes_value,
3232 (void *)&cmd_pkt_filter_vlan,
3233 (void *)&cmd_pkt_filter_vlan_id,
3234 (void *)&cmd_pkt_filter_soft,
3235 (void *)&cmd_pkt_filter_soft_id,
3240 /* *** SETUP MASKS FILTER *** */
3241 struct cmd_pkt_filter_masks_result {
3242 cmdline_fixed_string_t filter_mask;
3244 cmdline_fixed_string_t src_mask;
3245 uint32_t ip_src_mask;
3246 uint16_t ipv6_src_mask;
3247 uint16_t port_src_mask;
3248 cmdline_fixed_string_t dst_mask;
3249 uint32_t ip_dst_mask;
3250 uint16_t ipv6_dst_mask;
3251 uint16_t port_dst_mask;
3252 cmdline_fixed_string_t flexbytes;
3253 uint8_t flexbytes_value;
3254 cmdline_fixed_string_t vlan_id;
3255 uint8_t vlan_id_value;
3256 cmdline_fixed_string_t vlan_prio;
3257 uint8_t vlan_prio_value;
3258 cmdline_fixed_string_t only_ip_flow;
3259 uint8_t only_ip_flow_value;
3260 cmdline_fixed_string_t comp_ipv6_dst;
3261 uint8_t comp_ipv6_dst_value;
3265 cmd_pkt_filter_masks_parsed(void *parsed_result,
3266 __attribute__((unused)) struct cmdline *cl,
3267 __attribute__((unused)) void *data)
3269 struct rte_fdir_masks fdir_masks;
3270 struct cmd_pkt_filter_masks_result *res = parsed_result;
3272 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3274 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3275 fdir_masks.vlan_id = res->vlan_id_value;
3276 fdir_masks.vlan_prio = res->vlan_prio_value;
3277 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3278 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3279 fdir_masks.src_port_mask = res->port_src_mask;
3280 fdir_masks.dst_port_mask = res->port_dst_mask;
3281 fdir_masks.flexbytes = res->flexbytes_value;
3283 fdir_set_masks(res->port_id, &fdir_masks);
3286 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3287 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3288 filter_mask, "set_masks_filter");
3289 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3290 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3292 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3293 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3294 only_ip_flow, "only_ip_flow");
3295 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3296 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3297 only_ip_flow_value, UINT8);
3298 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3299 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3300 src_mask, "src_mask");
3301 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3302 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3303 ip_src_mask, UINT32);
3304 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3305 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3306 port_src_mask, UINT16);
3307 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3308 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3309 dst_mask, "dst_mask");
3310 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3311 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3312 ip_dst_mask, UINT32);
3313 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3314 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3315 port_dst_mask, UINT16);
3316 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3317 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3318 flexbytes, "flexbytes");
3319 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3320 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3321 flexbytes_value, UINT8);
3322 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3323 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3324 vlan_id, "vlan_id");
3325 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3326 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3327 vlan_id_value, UINT8);
3328 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3329 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3330 vlan_prio, "vlan_prio");
3331 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3332 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3333 vlan_prio_value, UINT8);
3335 cmdline_parse_inst_t cmd_set_masks_filter = {
3336 .f = cmd_pkt_filter_masks_parsed,
3338 .help_str = "setup masks filter",
3340 (void *)&cmd_pkt_filter_masks_filter_mask,
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_ip_src_mask,
3346 (void *)&cmd_pkt_filter_masks_port_src_mask,
3347 (void *)&cmd_pkt_filter_masks_dst_mask,
3348 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
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,
3361 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3362 __attribute__((unused)) struct cmdline *cl,
3363 __attribute__((unused)) void *data)
3365 struct rte_fdir_masks fdir_masks;
3366 struct cmd_pkt_filter_masks_result *res = parsed_result;
3368 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3370 fdir_masks.set_ipv6_mask = 1;
3371 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3372 fdir_masks.vlan_id = res->vlan_id_value;
3373 fdir_masks.vlan_prio = res->vlan_prio_value;
3374 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3375 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3376 fdir_masks.src_port_mask = res->port_src_mask;
3377 fdir_masks.dst_port_mask = res->port_dst_mask;
3378 fdir_masks.flexbytes = res->flexbytes_value;
3379 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3381 fdir_set_masks(res->port_id, &fdir_masks);
3384 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3385 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3386 filter_mask, "set_ipv6_masks_filter");
3387 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3388 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3389 ipv6_src_mask, UINT16);
3390 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3391 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3392 ipv6_dst_mask, UINT16);
3394 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3395 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3396 comp_ipv6_dst, "compare_dst");
3397 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3398 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3399 comp_ipv6_dst_value, UINT8);
3401 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3402 .f = cmd_pkt_filter_masks_ipv6_parsed,
3404 .help_str = "setup ipv6 masks filter",
3406 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3407 (void *)&cmd_pkt_filter_masks_port_id,
3408 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3409 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3410 (void *)&cmd_pkt_filter_masks_src_mask,
3411 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3412 (void *)&cmd_pkt_filter_masks_port_src_mask,
3413 (void *)&cmd_pkt_filter_masks_dst_mask,
3414 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3415 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3416 (void *)&cmd_pkt_filter_masks_flexbytes,
3417 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3418 (void *)&cmd_pkt_filter_masks_vlan_id,
3419 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3420 (void *)&cmd_pkt_filter_masks_vlan_prio,
3421 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3422 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3423 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3428 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3429 struct cmd_link_flow_ctrl_set_result {
3430 cmdline_fixed_string_t set;
3431 cmdline_fixed_string_t flow_ctrl;
3432 cmdline_fixed_string_t rx;
3433 cmdline_fixed_string_t rx_lfc_mode;
3434 cmdline_fixed_string_t tx;
3435 cmdline_fixed_string_t tx_lfc_mode;
3436 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3437 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3438 uint32_t high_water;
3440 uint16_t pause_time;
3446 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3447 __attribute__((unused)) struct cmdline *cl,
3448 __attribute__((unused)) void *data)
3450 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3451 struct rte_eth_fc_conf fc_conf;
3452 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3456 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3457 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3458 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3459 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3461 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3462 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3465 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3466 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3467 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3469 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3470 fc_conf.high_water = res->high_water;
3471 fc_conf.low_water = res->low_water;
3472 fc_conf.pause_time = res->pause_time;
3473 fc_conf.send_xon = res->send_xon;
3474 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3476 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3478 printf("bad flow contrl parameter, return code = %d \n", ret);
3481 cmdline_parse_token_string_t cmd_lfc_set_set =
3482 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3484 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3485 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3486 flow_ctrl, "flow_ctrl");
3487 cmdline_parse_token_string_t cmd_lfc_set_rx =
3488 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3490 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3491 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3492 rx_lfc_mode, "on#off");
3493 cmdline_parse_token_string_t cmd_lfc_set_tx =
3494 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3496 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3497 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3498 tx_lfc_mode, "on#off");
3499 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3500 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3501 high_water, UINT32);
3502 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3503 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3505 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3506 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3507 pause_time, UINT16);
3508 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3509 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3511 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3512 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3513 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3514 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3515 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3516 mac_ctrl_frame_fwd_mode, "on#off");
3517 cmdline_parse_token_num_t cmd_lfc_set_portid =
3518 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3521 cmdline_parse_inst_t cmd_link_flow_control_set = {
3522 .f = cmd_link_flow_ctrl_set_parsed,
3524 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3525 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3528 (void *)&cmd_lfc_set_set,
3529 (void *)&cmd_lfc_set_flow_ctrl,
3530 (void *)&cmd_lfc_set_rx,
3531 (void *)&cmd_lfc_set_rx_mode,
3532 (void *)&cmd_lfc_set_tx,
3533 (void *)&cmd_lfc_set_tx_mode,
3534 (void *)&cmd_lfc_set_high_water,
3535 (void *)&cmd_lfc_set_low_water,
3536 (void *)&cmd_lfc_set_pause_time,
3537 (void *)&cmd_lfc_set_send_xon,
3538 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3539 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3540 (void *)&cmd_lfc_set_portid,
3545 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3546 struct cmd_priority_flow_ctrl_set_result {
3547 cmdline_fixed_string_t set;
3548 cmdline_fixed_string_t pfc_ctrl;
3549 cmdline_fixed_string_t rx;
3550 cmdline_fixed_string_t rx_pfc_mode;
3551 cmdline_fixed_string_t tx;
3552 cmdline_fixed_string_t tx_pfc_mode;
3553 uint32_t high_water;
3555 uint16_t pause_time;
3561 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3562 __attribute__((unused)) struct cmdline *cl,
3563 __attribute__((unused)) void *data)
3565 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3566 struct rte_eth_pfc_conf pfc_conf;
3567 int rx_fc_enable, tx_fc_enable;
3571 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3572 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3573 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3574 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3576 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3577 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3580 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3581 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3582 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3583 pfc_conf.fc.high_water = res->high_water;
3584 pfc_conf.fc.low_water = res->low_water;
3585 pfc_conf.fc.pause_time = res->pause_time;
3586 pfc_conf.priority = res->priority;
3588 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3590 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3593 cmdline_parse_token_string_t cmd_pfc_set_set =
3594 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3596 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3597 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3598 pfc_ctrl, "pfc_ctrl");
3599 cmdline_parse_token_string_t cmd_pfc_set_rx =
3600 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3602 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3603 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3604 rx_pfc_mode, "on#off");
3605 cmdline_parse_token_string_t cmd_pfc_set_tx =
3606 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3608 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3609 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3610 tx_pfc_mode, "on#off");
3611 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3612 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3613 high_water, UINT32);
3614 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3615 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3617 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3618 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3619 pause_time, UINT16);
3620 cmdline_parse_token_num_t cmd_pfc_set_priority =
3621 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3623 cmdline_parse_token_num_t cmd_pfc_set_portid =
3624 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3627 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3628 .f = cmd_priority_flow_ctrl_set_parsed,
3630 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3631 tx on|off high_water low_water pause_time priority port_id",
3633 (void *)&cmd_pfc_set_set,
3634 (void *)&cmd_pfc_set_flow_ctrl,
3635 (void *)&cmd_pfc_set_rx,
3636 (void *)&cmd_pfc_set_rx_mode,
3637 (void *)&cmd_pfc_set_tx,
3638 (void *)&cmd_pfc_set_tx_mode,
3639 (void *)&cmd_pfc_set_high_water,
3640 (void *)&cmd_pfc_set_low_water,
3641 (void *)&cmd_pfc_set_pause_time,
3642 (void *)&cmd_pfc_set_priority,
3643 (void *)&cmd_pfc_set_portid,
3648 /* *** RESET CONFIGURATION *** */
3649 struct cmd_reset_result {
3650 cmdline_fixed_string_t reset;
3651 cmdline_fixed_string_t def;
3654 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3656 __attribute__((unused)) void *data)
3658 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3659 set_def_fwd_config();
3662 cmdline_parse_token_string_t cmd_reset_set =
3663 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3664 cmdline_parse_token_string_t cmd_reset_def =
3665 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3668 cmdline_parse_inst_t cmd_reset = {
3669 .f = cmd_reset_parsed,
3671 .help_str = "set default: reset default forwarding configuration",
3673 (void *)&cmd_reset_set,
3674 (void *)&cmd_reset_def,
3679 /* *** START FORWARDING *** */
3680 struct cmd_start_result {
3681 cmdline_fixed_string_t start;
3684 cmdline_parse_token_string_t cmd_start_start =
3685 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3687 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3688 __attribute__((unused)) struct cmdline *cl,
3689 __attribute__((unused)) void *data)
3691 start_packet_forwarding(0);
3694 cmdline_parse_inst_t cmd_start = {
3695 .f = cmd_start_parsed,
3697 .help_str = "start packet forwarding",
3699 (void *)&cmd_start_start,
3704 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3705 struct cmd_start_tx_first_result {
3706 cmdline_fixed_string_t start;
3707 cmdline_fixed_string_t tx_first;
3711 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3712 __attribute__((unused)) struct cmdline *cl,
3713 __attribute__((unused)) void *data)
3715 start_packet_forwarding(1);
3718 cmdline_parse_token_string_t cmd_start_tx_first_start =
3719 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3721 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3722 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3723 tx_first, "tx_first");
3725 cmdline_parse_inst_t cmd_start_tx_first = {
3726 .f = cmd_start_tx_first_parsed,
3728 .help_str = "start packet forwarding, after sending 1 burst of packets",
3730 (void *)&cmd_start_tx_first_start,
3731 (void *)&cmd_start_tx_first_tx_first,
3736 /* *** SHOW CFG *** */
3737 struct cmd_showcfg_result {
3738 cmdline_fixed_string_t show;
3739 cmdline_fixed_string_t cfg;
3740 cmdline_fixed_string_t what;
3743 static void cmd_showcfg_parsed(void *parsed_result,
3744 __attribute__((unused)) struct cmdline *cl,
3745 __attribute__((unused)) void *data)
3747 struct cmd_showcfg_result *res = parsed_result;
3748 if (!strcmp(res->what, "rxtx"))
3749 rxtx_config_display();
3750 else if (!strcmp(res->what, "cores"))
3751 fwd_lcores_config_display();
3752 else if (!strcmp(res->what, "fwd"))
3753 fwd_config_display();
3756 cmdline_parse_token_string_t cmd_showcfg_show =
3757 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3758 cmdline_parse_token_string_t cmd_showcfg_port =
3759 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3760 cmdline_parse_token_string_t cmd_showcfg_what =
3761 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3764 cmdline_parse_inst_t cmd_showcfg = {
3765 .f = cmd_showcfg_parsed,
3767 .help_str = "show config rxtx|cores|fwd",
3769 (void *)&cmd_showcfg_show,
3770 (void *)&cmd_showcfg_port,
3771 (void *)&cmd_showcfg_what,
3776 /* *** SHOW ALL PORT INFO *** */
3777 struct cmd_showportall_result {
3778 cmdline_fixed_string_t show;
3779 cmdline_fixed_string_t port;
3780 cmdline_fixed_string_t what;
3781 cmdline_fixed_string_t all;
3784 static void cmd_showportall_parsed(void *parsed_result,
3785 __attribute__((unused)) struct cmdline *cl,
3786 __attribute__((unused)) void *data)
3790 struct cmd_showportall_result *res = parsed_result;
3791 if (!strcmp(res->show, "clear")) {
3792 if (!strcmp(res->what, "stats"))
3793 for (i = 0; i < nb_ports; i++)
3795 } else if (!strcmp(res->what, "info"))
3796 for (i = 0; i < nb_ports; i++)
3797 port_infos_display(i);
3798 else if (!strcmp(res->what, "stats"))
3799 for (i = 0; i < nb_ports; i++)
3800 nic_stats_display(i);
3801 else if (!strcmp(res->what, "fdir"))
3802 for (i = 0; i < nb_ports; i++)
3804 else if (!strcmp(res->what, "stat_qmap"))
3805 for (i = 0; i < nb_ports; i++)
3806 nic_stats_mapping_display(i);
3809 cmdline_parse_token_string_t cmd_showportall_show =
3810 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3812 cmdline_parse_token_string_t cmd_showportall_port =
3813 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3814 cmdline_parse_token_string_t cmd_showportall_what =
3815 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3816 "info#stats#fdir#stat_qmap");
3817 cmdline_parse_token_string_t cmd_showportall_all =
3818 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3819 cmdline_parse_inst_t cmd_showportall = {
3820 .f = cmd_showportall_parsed,
3822 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3824 (void *)&cmd_showportall_show,
3825 (void *)&cmd_showportall_port,
3826 (void *)&cmd_showportall_what,
3827 (void *)&cmd_showportall_all,
3832 /* *** SHOW PORT INFO *** */
3833 struct cmd_showport_result {
3834 cmdline_fixed_string_t show;
3835 cmdline_fixed_string_t port;
3836 cmdline_fixed_string_t what;
3840 static void cmd_showport_parsed(void *parsed_result,
3841 __attribute__((unused)) struct cmdline *cl,
3842 __attribute__((unused)) void *data)
3844 struct cmd_showport_result *res = parsed_result;
3845 if (!strcmp(res->show, "clear")) {
3846 if (!strcmp(res->what, "stats"))
3847 nic_stats_clear(res->portnum);
3848 } else if (!strcmp(res->what, "info"))
3849 port_infos_display(res->portnum);
3850 else if (!strcmp(res->what, "stats"))
3851 nic_stats_display(res->portnum);
3852 else if (!strcmp(res->what, "fdir"))
3853 fdir_get_infos(res->portnum);
3854 else if (!strcmp(res->what, "stat_qmap"))
3855 nic_stats_mapping_display(res->portnum);
3858 cmdline_parse_token_string_t cmd_showport_show =
3859 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3861 cmdline_parse_token_string_t cmd_showport_port =
3862 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3863 cmdline_parse_token_string_t cmd_showport_what =
3864 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3865 "info#stats#fdir#stat_qmap");
3866 cmdline_parse_token_num_t cmd_showport_portnum =
3867 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3869 cmdline_parse_inst_t cmd_showport = {
3870 .f = cmd_showport_parsed,
3872 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3874 (void *)&cmd_showport_show,
3875 (void *)&cmd_showport_port,
3876 (void *)&cmd_showport_what,
3877 (void *)&cmd_showport_portnum,
3882 /* *** READ PORT REGISTER *** */
3883 struct cmd_read_reg_result {
3884 cmdline_fixed_string_t read;
3885 cmdline_fixed_string_t reg;
3891 cmd_read_reg_parsed(void *parsed_result,
3892 __attribute__((unused)) struct cmdline *cl,
3893 __attribute__((unused)) void *data)
3895 struct cmd_read_reg_result *res = parsed_result;
3896 port_reg_display(res->port_id, res->reg_off);
3899 cmdline_parse_token_string_t cmd_read_reg_read =
3900 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3901 cmdline_parse_token_string_t cmd_read_reg_reg =
3902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3903 cmdline_parse_token_num_t cmd_read_reg_port_id =
3904 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3905 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3908 cmdline_parse_inst_t cmd_read_reg = {
3909 .f = cmd_read_reg_parsed,
3911 .help_str = "read reg port_id reg_off",
3913 (void *)&cmd_read_reg_read,
3914 (void *)&cmd_read_reg_reg,
3915 (void *)&cmd_read_reg_port_id,
3916 (void *)&cmd_read_reg_reg_off,
3921 /* *** READ PORT REGISTER BIT FIELD *** */
3922 struct cmd_read_reg_bit_field_result {
3923 cmdline_fixed_string_t read;
3924 cmdline_fixed_string_t regfield;
3932 cmd_read_reg_bit_field_parsed(void *parsed_result,
3933 __attribute__((unused)) struct cmdline *cl,
3934 __attribute__((unused)) void *data)
3936 struct cmd_read_reg_bit_field_result *res = parsed_result;
3937 port_reg_bit_field_display(res->port_id, res->reg_off,
3938 res->bit1_pos, res->bit2_pos);
3941 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3942 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3944 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3945 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3946 regfield, "regfield");
3947 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3948 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3950 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3951 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3953 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3954 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3956 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3957 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3960 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3961 .f = cmd_read_reg_bit_field_parsed,
3963 .help_str = "read regfield port_id reg_off bit_x bit_y "
3964 "(read register bit field between bit_x and bit_y included)",
3966 (void *)&cmd_read_reg_bit_field_read,
3967 (void *)&cmd_read_reg_bit_field_regfield,
3968 (void *)&cmd_read_reg_bit_field_port_id,
3969 (void *)&cmd_read_reg_bit_field_reg_off,
3970 (void *)&cmd_read_reg_bit_field_bit1_pos,
3971 (void *)&cmd_read_reg_bit_field_bit2_pos,
3976 /* *** READ PORT REGISTER BIT *** */
3977 struct cmd_read_reg_bit_result {
3978 cmdline_fixed_string_t read;
3979 cmdline_fixed_string_t regbit;
3986 cmd_read_reg_bit_parsed(void *parsed_result,
3987 __attribute__((unused)) struct cmdline *cl,
3988 __attribute__((unused)) void *data)
3990 struct cmd_read_reg_bit_result *res = parsed_result;
3991 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3994 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3995 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3996 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3997 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3999 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4000 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4001 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4003 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4006 cmdline_parse_inst_t cmd_read_reg_bit = {
4007 .f = cmd_read_reg_bit_parsed,
4009 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4011 (void *)&cmd_read_reg_bit_read,
4012 (void *)&cmd_read_reg_bit_regbit,
4013 (void *)&cmd_read_reg_bit_port_id,
4014 (void *)&cmd_read_reg_bit_reg_off,
4015 (void *)&cmd_read_reg_bit_bit_pos,
4020 /* *** WRITE PORT REGISTER *** */
4021 struct cmd_write_reg_result {
4022 cmdline_fixed_string_t write;
4023 cmdline_fixed_string_t reg;
4030 cmd_write_reg_parsed(void *parsed_result,
4031 __attribute__((unused)) struct cmdline *cl,
4032 __attribute__((unused)) void *data)
4034 struct cmd_write_reg_result *res = parsed_result;
4035 port_reg_set(res->port_id, res->reg_off, res->value);
4038 cmdline_parse_token_string_t cmd_write_reg_write =
4039 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4040 cmdline_parse_token_string_t cmd_write_reg_reg =
4041 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4042 cmdline_parse_token_num_t cmd_write_reg_port_id =
4043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4044 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4046 cmdline_parse_token_num_t cmd_write_reg_value =
4047 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4049 cmdline_parse_inst_t cmd_write_reg = {
4050 .f = cmd_write_reg_parsed,
4052 .help_str = "write reg port_id reg_off reg_value",
4054 (void *)&cmd_write_reg_write,
4055 (void *)&cmd_write_reg_reg,
4056 (void *)&cmd_write_reg_port_id,
4057 (void *)&cmd_write_reg_reg_off,
4058 (void *)&cmd_write_reg_value,
4063 /* *** WRITE PORT REGISTER BIT FIELD *** */
4064 struct cmd_write_reg_bit_field_result {
4065 cmdline_fixed_string_t write;
4066 cmdline_fixed_string_t regfield;
4075 cmd_write_reg_bit_field_parsed(void *parsed_result,
4076 __attribute__((unused)) struct cmdline *cl,
4077 __attribute__((unused)) void *data)
4079 struct cmd_write_reg_bit_field_result *res = parsed_result;
4080 port_reg_bit_field_set(res->port_id, res->reg_off,
4081 res->bit1_pos, res->bit2_pos, res->value);
4084 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4085 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4087 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4088 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4089 regfield, "regfield");
4090 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4091 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4093 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4094 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4096 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4097 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4099 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4100 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4102 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4103 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4106 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4107 .f = cmd_write_reg_bit_field_parsed,
4109 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4110 "(set register bit field between bit_x and bit_y included)",
4112 (void *)&cmd_write_reg_bit_field_write,
4113 (void *)&cmd_write_reg_bit_field_regfield,
4114 (void *)&cmd_write_reg_bit_field_port_id,
4115 (void *)&cmd_write_reg_bit_field_reg_off,
4116 (void *)&cmd_write_reg_bit_field_bit1_pos,
4117 (void *)&cmd_write_reg_bit_field_bit2_pos,
4118 (void *)&cmd_write_reg_bit_field_value,
4123 /* *** WRITE PORT REGISTER BIT *** */
4124 struct cmd_write_reg_bit_result {
4125 cmdline_fixed_string_t write;
4126 cmdline_fixed_string_t regbit;
4134 cmd_write_reg_bit_parsed(void *parsed_result,
4135 __attribute__((unused)) struct cmdline *cl,
4136 __attribute__((unused)) void *data)
4138 struct cmd_write_reg_bit_result *res = parsed_result;
4139 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4142 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4143 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4145 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4146 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4148 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4149 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4150 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4151 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4152 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4153 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4154 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4157 cmdline_parse_inst_t cmd_write_reg_bit = {
4158 .f = cmd_write_reg_bit_parsed,
4160 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4162 (void *)&cmd_write_reg_bit_write,
4163 (void *)&cmd_write_reg_bit_regbit,
4164 (void *)&cmd_write_reg_bit_port_id,
4165 (void *)&cmd_write_reg_bit_reg_off,
4166 (void *)&cmd_write_reg_bit_bit_pos,
4167 (void *)&cmd_write_reg_bit_value,
4172 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4173 struct cmd_read_rxd_txd_result {
4174 cmdline_fixed_string_t read;
4175 cmdline_fixed_string_t rxd_txd;
4182 cmd_read_rxd_txd_parsed(void *parsed_result,
4183 __attribute__((unused)) struct cmdline *cl,
4184 __attribute__((unused)) void *data)
4186 struct cmd_read_rxd_txd_result *res = parsed_result;
4188 if (!strcmp(res->rxd_txd, "rxd"))
4189 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4190 else if (!strcmp(res->rxd_txd, "txd"))
4191 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4194 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4195 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4196 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4197 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4199 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4200 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4201 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4202 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4203 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4204 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4206 cmdline_parse_inst_t cmd_read_rxd_txd = {
4207 .f = cmd_read_rxd_txd_parsed,
4209 .help_str = "read rxd|txd port_id queue_id rxd_id",
4211 (void *)&cmd_read_rxd_txd_read,
4212 (void *)&cmd_read_rxd_txd_rxd_txd,
4213 (void *)&cmd_read_rxd_txd_port_id,
4214 (void *)&cmd_read_rxd_txd_queue_id,
4215 (void *)&cmd_read_rxd_txd_desc_id,
4221 struct cmd_quit_result {
4222 cmdline_fixed_string_t quit;
4225 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4227 __attribute__((unused)) void *data)
4233 cmdline_parse_token_string_t cmd_quit_quit =
4234 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4236 cmdline_parse_inst_t cmd_quit = {
4237 .f = cmd_quit_parsed,
4239 .help_str = "exit application",
4241 (void *)&cmd_quit_quit,
4246 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4247 struct cmd_mac_addr_result {
4248 cmdline_fixed_string_t mac_addr_cmd;
4249 cmdline_fixed_string_t what;
4251 struct ether_addr address;
4254 static void cmd_mac_addr_parsed(void *parsed_result,
4255 __attribute__((unused)) struct cmdline *cl,
4256 __attribute__((unused)) void *data)
4258 struct cmd_mac_addr_result *res = parsed_result;
4261 if (strcmp(res->what, "add") == 0)
4262 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4264 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4266 /* check the return value and print it if is < 0 */
4268 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4272 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4273 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4275 cmdline_parse_token_string_t cmd_mac_addr_what =
4276 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4278 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4279 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4280 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4281 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4283 cmdline_parse_inst_t cmd_mac_addr = {
4284 .f = cmd_mac_addr_parsed,
4286 .help_str = "mac_addr add|remove X <address>: "
4287 "add/remove MAC address on port X",
4289 (void *)&cmd_mac_addr_cmd,
4290 (void *)&cmd_mac_addr_what,
4291 (void *)&cmd_mac_addr_portnum,
4292 (void *)&cmd_mac_addr_addr,
4298 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4299 struct cmd_set_qmap_result {
4300 cmdline_fixed_string_t set;
4301 cmdline_fixed_string_t qmap;
4302 cmdline_fixed_string_t what;
4309 cmd_set_qmap_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4311 __attribute__((unused)) void *data)
4313 struct cmd_set_qmap_result *res = parsed_result;
4314 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4316 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4319 cmdline_parse_token_string_t cmd_setqmap_set =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4322 cmdline_parse_token_string_t cmd_setqmap_qmap =
4323 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4325 cmdline_parse_token_string_t cmd_setqmap_what =
4326 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4328 cmdline_parse_token_num_t cmd_setqmap_portid =
4329 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4331 cmdline_parse_token_num_t cmd_setqmap_queueid =
4332 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4334 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4335 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4338 cmdline_parse_inst_t cmd_set_qmap = {
4339 .f = cmd_set_qmap_parsed,
4341 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4343 (void *)&cmd_setqmap_set,
4344 (void *)&cmd_setqmap_qmap,
4345 (void *)&cmd_setqmap_what,
4346 (void *)&cmd_setqmap_portid,
4347 (void *)&cmd_setqmap_queueid,
4348 (void *)&cmd_setqmap_mapvalue,
4353 /* *** CONFIGURE UNICAST HASH TABLE *** */
4354 struct cmd_set_uc_hash_table {
4355 cmdline_fixed_string_t set;
4356 cmdline_fixed_string_t port;
4358 cmdline_fixed_string_t what;
4359 struct ether_addr address;
4360 cmdline_fixed_string_t mode;
4364 cmd_set_uc_hash_parsed(void *parsed_result,
4365 __attribute__((unused)) struct cmdline *cl,
4366 __attribute__((unused)) void *data)
4369 struct cmd_set_uc_hash_table *res = parsed_result;
4371 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4373 if (strcmp(res->what, "uta") == 0)
4374 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4375 &res->address,(uint8_t)is_on);
4377 printf("bad unicast hash table parameter, return code = %d \n", ret);
4381 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4382 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4384 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4385 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4387 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4388 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4390 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4391 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4393 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4396 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4400 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4401 .f = cmd_set_uc_hash_parsed,
4403 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4405 (void *)&cmd_set_uc_hash_set,
4406 (void *)&cmd_set_uc_hash_port,
4407 (void *)&cmd_set_uc_hash_portid,
4408 (void *)&cmd_set_uc_hash_what,
4409 (void *)&cmd_set_uc_hash_mac,
4410 (void *)&cmd_set_uc_hash_mode,
4415 struct cmd_set_uc_all_hash_table {
4416 cmdline_fixed_string_t set;
4417 cmdline_fixed_string_t port;
4419 cmdline_fixed_string_t what;
4420 cmdline_fixed_string_t value;
4421 cmdline_fixed_string_t mode;
4425 cmd_set_uc_all_hash_parsed(void *parsed_result,
4426 __attribute__((unused)) struct cmdline *cl,
4427 __attribute__((unused)) void *data)
4430 struct cmd_set_uc_all_hash_table *res = parsed_result;
4432 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4434 if ((strcmp(res->what, "uta") == 0) &&
4435 (strcmp(res->value, "all") == 0))
4436 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4438 printf("bad unicast hash table parameter,"
4439 "return code = %d \n", ret);
4442 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4443 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4445 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4446 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4448 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4449 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4451 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4454 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4457 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4458 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4461 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4462 .f = cmd_set_uc_all_hash_parsed,
4464 .help_str = "set port X uta all on|off (X = port number)",
4466 (void *)&cmd_set_uc_all_hash_set,
4467 (void *)&cmd_set_uc_all_hash_port,
4468 (void *)&cmd_set_uc_all_hash_portid,
4469 (void *)&cmd_set_uc_all_hash_what,
4470 (void *)&cmd_set_uc_all_hash_value,
4471 (void *)&cmd_set_uc_all_hash_mode,
4476 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4477 struct cmd_set_vf_traffic {
4478 cmdline_fixed_string_t set;
4479 cmdline_fixed_string_t port;
4481 cmdline_fixed_string_t vf;
4483 cmdline_fixed_string_t what;
4484 cmdline_fixed_string_t mode;
4488 cmd_set_vf_traffic_parsed(void *parsed_result,
4489 __attribute__((unused)) struct cmdline *cl,
4490 __attribute__((unused)) void *data)
4492 struct cmd_set_vf_traffic *res = parsed_result;
4493 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4494 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4496 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4499 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4500 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4502 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4503 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4505 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4506 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4508 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4511 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4512 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4514 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4515 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4517 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4521 cmdline_parse_inst_t cmd_set_vf_traffic = {
4522 .f = cmd_set_vf_traffic_parsed,
4524 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4526 (void *)&cmd_setvf_traffic_set,
4527 (void *)&cmd_setvf_traffic_port,
4528 (void *)&cmd_setvf_traffic_portid,
4529 (void *)&cmd_setvf_traffic_vf,
4530 (void *)&cmd_setvf_traffic_vfid,
4531 (void *)&cmd_setvf_traffic_what,
4532 (void *)&cmd_setvf_traffic_mode,
4537 /* *** CONFIGURE VF RECEIVE MODE *** */
4538 struct cmd_set_vf_rxmode {
4539 cmdline_fixed_string_t set;
4540 cmdline_fixed_string_t port;
4542 cmdline_fixed_string_t vf;
4544 cmdline_fixed_string_t what;
4545 cmdline_fixed_string_t mode;
4546 cmdline_fixed_string_t on;
4550 cmd_set_vf_rxmode_parsed(void *parsed_result,
4551 __attribute__((unused)) struct cmdline *cl,
4552 __attribute__((unused)) void *data)
4555 uint16_t rx_mode = 0;
4556 struct cmd_set_vf_rxmode *res = parsed_result;
4558 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4559 if (!strcmp(res->what,"rxmode")) {
4560 if (!strcmp(res->mode, "AUPE"))
4561 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4562 else if (!strcmp(res->mode, "ROPE"))
4563 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4564 else if (!strcmp(res->mode, "BAM"))
4565 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4566 else if (!strncmp(res->mode, "MPE",3))
4567 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4570 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4572 printf("bad VF receive mode parameter, return code = %d \n",
4576 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4577 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4579 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4582 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4583 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4585 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4588 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4589 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4591 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4594 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4596 mode, "AUPE#ROPE#BAM#MPE");
4597 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4601 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4602 .f = cmd_set_vf_rxmode_parsed,
4604 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4606 (void *)&cmd_set_vf_rxmode_set,
4607 (void *)&cmd_set_vf_rxmode_port,
4608 (void *)&cmd_set_vf_rxmode_portid,
4609 (void *)&cmd_set_vf_rxmode_vf,
4610 (void *)&cmd_set_vf_rxmode_vfid,
4611 (void *)&cmd_set_vf_rxmode_what,
4612 (void *)&cmd_set_vf_rxmode_mode,
4613 (void *)&cmd_set_vf_rxmode_on,
4618 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4619 struct cmd_vf_mac_addr_result {
4620 cmdline_fixed_string_t mac_addr_cmd;
4621 cmdline_fixed_string_t what;
4622 cmdline_fixed_string_t port;
4624 cmdline_fixed_string_t vf;
4626 struct ether_addr address;
4629 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4630 __attribute__((unused)) struct cmdline *cl,
4631 __attribute__((unused)) void *data)
4633 struct cmd_vf_mac_addr_result *res = parsed_result;
4636 if (strcmp(res->what, "add") == 0)
4637 ret = rte_eth_dev_mac_addr_add(res->port_num,
4638 &res->address, res->vf_num);
4640 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4644 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4645 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4646 mac_addr_cmd,"mac_addr");
4647 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4648 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4650 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4651 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4653 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4654 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4656 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4657 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4659 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4660 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4662 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4666 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4667 .f = cmd_vf_mac_addr_parsed,
4669 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4670 "Y = VF number)add MAC address filtering for a VF on port X",
4672 (void *)&cmd_vf_mac_addr_cmd,
4673 (void *)&cmd_vf_mac_addr_what,
4674 (void *)&cmd_vf_mac_addr_port,
4675 (void *)&cmd_vf_mac_addr_portnum,
4676 (void *)&cmd_vf_mac_addr_vf,
4677 (void *)&cmd_vf_mac_addr_vfnum,
4678 (void *)&cmd_vf_mac_addr_addr,
4683 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4684 struct cmd_vf_rx_vlan_filter {
4685 cmdline_fixed_string_t rx_vlan;
4686 cmdline_fixed_string_t what;
4688 cmdline_fixed_string_t port;
4690 cmdline_fixed_string_t vf;
4695 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4696 __attribute__((unused)) struct cmdline *cl,
4697 __attribute__((unused)) void *data)
4699 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4701 if (!strcmp(res->what, "add"))
4702 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4704 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4707 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4708 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4709 rx_vlan, "rx_vlan");
4710 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4711 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4713 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4714 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4716 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4717 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4719 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4720 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4722 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4723 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4725 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4726 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4729 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4730 .f = cmd_vf_rx_vlan_filter_parsed,
4732 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4733 "Y = port number,Z = hexadecimal VF mask)",
4735 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4736 (void *)&cmd_vf_rx_vlan_filter_what,
4737 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4738 (void *)&cmd_vf_rx_vlan_filter_port,
4739 (void *)&cmd_vf_rx_vlan_filter_portid,
4740 (void *)&cmd_vf_rx_vlan_filter_vf,
4741 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4746 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4747 struct cmd_set_mirror_mask_result {
4748 cmdline_fixed_string_t set;
4749 cmdline_fixed_string_t port;
4751 cmdline_fixed_string_t mirror;
4753 cmdline_fixed_string_t what;
4754 cmdline_fixed_string_t value;
4755 cmdline_fixed_string_t dstpool;
4757 cmdline_fixed_string_t on;
4760 cmdline_parse_token_string_t cmd_mirror_mask_set =
4761 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4763 cmdline_parse_token_string_t cmd_mirror_mask_port =
4764 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4766 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4767 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4769 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4771 mirror, "mirror-rule");
4772 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4773 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4775 cmdline_parse_token_string_t cmd_mirror_mask_what =
4776 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4777 what, "pool-mirror#vlan-mirror");
4778 cmdline_parse_token_string_t cmd_mirror_mask_value =
4779 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4781 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4782 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4783 dstpool, "dst-pool");
4784 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4785 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4787 cmdline_parse_token_string_t cmd_mirror_mask_on =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4792 cmd_set_mirror_mask_parsed(void *parsed_result,
4793 __attribute__((unused)) struct cmdline *cl,
4794 __attribute__((unused)) void *data)
4797 struct cmd_set_mirror_mask_result *res = parsed_result;
4798 struct rte_eth_vmdq_mirror_conf mr_conf;
4800 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4802 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4804 mr_conf.dst_pool = res->dstpool_id;
4806 if (!strcmp(res->what, "pool-mirror")) {
4807 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4808 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4809 } else if(!strcmp(res->what, "vlan-mirror")) {
4810 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4811 nb_item = parse_item_list(res->value, "core",
4812 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4816 for(i=0; i < nb_item; i++) {
4817 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4818 printf("Invalid vlan_id: must be < 4096\n");
4822 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4823 mr_conf.vlan.vlan_mask |= 1ULL << i;
4827 if(!strcmp(res->on, "on"))
4828 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4831 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4834 printf("mirror rule add error: (%s)\n", strerror(-ret));
4837 cmdline_parse_inst_t cmd_set_mirror_mask = {
4838 .f = cmd_set_mirror_mask_parsed,
4840 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4841 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4843 (void *)&cmd_mirror_mask_set,
4844 (void *)&cmd_mirror_mask_port,
4845 (void *)&cmd_mirror_mask_portid,
4846 (void *)&cmd_mirror_mask_mirror,
4847 (void *)&cmd_mirror_mask_ruleid,
4848 (void *)&cmd_mirror_mask_what,
4849 (void *)&cmd_mirror_mask_value,
4850 (void *)&cmd_mirror_mask_dstpool,
4851 (void *)&cmd_mirror_mask_poolid,
4852 (void *)&cmd_mirror_mask_on,
4857 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4858 struct cmd_set_mirror_link_result {
4859 cmdline_fixed_string_t set;
4860 cmdline_fixed_string_t port;
4862 cmdline_fixed_string_t mirror;
4864 cmdline_fixed_string_t what;
4865 cmdline_fixed_string_t dstpool;
4867 cmdline_fixed_string_t on;
4870 cmdline_parse_token_string_t cmd_mirror_link_set =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4873 cmdline_parse_token_string_t cmd_mirror_link_port =
4874 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4876 cmdline_parse_token_string_t cmd_mirror_link_portid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4879 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4881 mirror, "mirror-rule");
4882 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4883 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4885 cmdline_parse_token_string_t cmd_mirror_link_what =
4886 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4887 what, "uplink-mirror#downlink-mirror");
4888 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4889 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4890 dstpool, "dst-pool");
4891 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4892 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4894 cmdline_parse_token_string_t cmd_mirror_link_on =
4895 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4899 cmd_set_mirror_link_parsed(void *parsed_result,
4900 __attribute__((unused)) struct cmdline *cl,
4901 __attribute__((unused)) void *data)
4904 struct cmd_set_mirror_link_result *res = parsed_result;
4905 struct rte_eth_vmdq_mirror_conf mr_conf;
4907 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4908 if(!strcmp(res->what, "uplink-mirror")) {
4909 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4910 }else if(!strcmp(res->what, "downlink-mirror"))
4911 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4913 mr_conf.dst_pool = res->dstpool_id;
4915 if(!strcmp(res->on, "on"))
4916 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4919 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4922 /* check the return value and print it if is < 0 */
4924 printf("mirror rule add error: (%s)\n", strerror(-ret));
4928 cmdline_parse_inst_t cmd_set_mirror_link = {
4929 .f = cmd_set_mirror_link_parsed,
4931 .help_str = "set port X mirror-rule Y uplink-mirror|"
4932 "downlink-mirror dst-pool Z on|off",
4934 (void *)&cmd_mirror_link_set,
4935 (void *)&cmd_mirror_link_port,
4936 (void *)&cmd_mirror_link_portid,
4937 (void *)&cmd_mirror_link_mirror,
4938 (void *)&cmd_mirror_link_ruleid,
4939 (void *)&cmd_mirror_link_what,
4940 (void *)&cmd_mirror_link_dstpool,
4941 (void *)&cmd_mirror_link_poolid,
4942 (void *)&cmd_mirror_link_on,
4947 /* *** RESET VM MIRROR RULE *** */
4948 struct cmd_rm_mirror_rule_result {
4949 cmdline_fixed_string_t reset;
4950 cmdline_fixed_string_t port;
4952 cmdline_fixed_string_t mirror;
4956 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4957 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4959 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4960 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4962 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4963 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4965 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4966 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4967 mirror, "mirror-rule");
4968 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4969 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4973 cmd_reset_mirror_rule_parsed(void *parsed_result,
4974 __attribute__((unused)) struct cmdline *cl,
4975 __attribute__((unused)) void *data)
4978 struct cmd_set_mirror_link_result *res = parsed_result;
4980 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4982 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4985 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4986 .f = cmd_reset_mirror_rule_parsed,
4988 .help_str = "reset port X mirror-rule Y",
4990 (void *)&cmd_rm_mirror_rule_reset,
4991 (void *)&cmd_rm_mirror_rule_port,
4992 (void *)&cmd_rm_mirror_rule_portid,
4993 (void *)&cmd_rm_mirror_rule_mirror,
4994 (void *)&cmd_rm_mirror_rule_ruleid,
4999 /* ******************************************************************************** */
5001 /* list of instructions */
5002 cmdline_parse_ctx_t main_ctx[] = {
5003 (cmdline_parse_inst_t *)&cmd_help_brief,
5004 (cmdline_parse_inst_t *)&cmd_help_long,
5005 (cmdline_parse_inst_t *)&cmd_quit,
5006 (cmdline_parse_inst_t *)&cmd_showport,
5007 (cmdline_parse_inst_t *)&cmd_showportall,
5008 (cmdline_parse_inst_t *)&cmd_showcfg,
5009 (cmdline_parse_inst_t *)&cmd_start,
5010 (cmdline_parse_inst_t *)&cmd_start_tx_first,
5011 (cmdline_parse_inst_t *)&cmd_reset,
5012 (cmdline_parse_inst_t *)&cmd_set_numbers,
5013 (cmdline_parse_inst_t *)&cmd_set_txpkts,
5014 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
5015 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
5016 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
5017 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
5018 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
5019 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
5020 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
5021 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
5022 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
5023 #ifdef RTE_NIC_BYPASS
5024 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
5025 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
5026 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
5027 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
5029 (cmdline_parse_inst_t *)&cmd_vlan_offload,
5030 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
5031 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
5032 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
5033 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
5034 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
5035 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
5036 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
5037 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
5038 (cmdline_parse_inst_t *)&cmd_config_dcb,
5039 (cmdline_parse_inst_t *)&cmd_read_reg,
5040 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
5041 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
5042 (cmdline_parse_inst_t *)&cmd_write_reg,
5043 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
5044 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
5045 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
5046 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
5047 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
5048 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
5049 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
5050 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
5051 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
5052 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
5053 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
5054 (cmdline_parse_inst_t *)&cmd_stop,
5055 (cmdline_parse_inst_t *)&cmd_mac_addr,
5056 (cmdline_parse_inst_t *)&cmd_set_qmap,
5057 (cmdline_parse_inst_t *)&cmd_operate_port,
5058 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
5059 (cmdline_parse_inst_t *)&cmd_config_speed_all,
5060 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
5061 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
5062 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
5063 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
5064 (cmdline_parse_inst_t *)&cmd_config_rss,
5065 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
5066 (cmdline_parse_inst_t *)&cmd_showport_reta,
5067 (cmdline_parse_inst_t *)&cmd_config_burst,
5068 (cmdline_parse_inst_t *)&cmd_config_thresh,
5069 (cmdline_parse_inst_t *)&cmd_config_threshold,
5070 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
5071 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
5072 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
5073 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
5074 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
5075 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
5076 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
5077 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
5078 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
5082 /* prompt function, called from main on MASTER lcore */
5088 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
5092 cmdline_interact(cl);
5093 cmdline_stdin_exit(cl);
5097 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
5099 if (id < nb_ports) {
5100 /* check if need_reconfig has been set to 1 */
5101 if (ports[id].need_reconfig == 0)
5102 ports[id].need_reconfig = dev;
5103 /* check if need_reconfig_queues has been set to 1 */
5104 if (ports[id].need_reconfig_queues == 0)
5105 ports[id].need_reconfig_queues = queue;
5109 for (pid = 0; pid < nb_ports; pid++) {
5110 /* check if need_reconfig has been set to 1 */
5111 if (ports[pid].need_reconfig == 0)
5112 ports[pid].need_reconfig = dev;
5113 /* check if need_reconfig_queues has been set to 1 */
5114 if (ports[pid].need_reconfig_queues == 0)
5115 ports[pid].need_reconfig_queues = queue;
5120 #ifdef RTE_NIC_BYPASS
5122 bypass_is_supported(portid_t port_id)
5124 struct rte_port *port;
5125 struct rte_pci_id *pci_id;
5127 if (port_id >= nb_ports) {
5128 printf("\tPort id must be less than %d.\n", nb_ports);
5132 /* Get the device id. */
5133 port = &ports[port_id];
5134 pci_id = &port->dev_info.pci_dev->id;
5136 /* Check if NIC supports bypass. */
5137 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
5141 printf("\tBypass not supported for port_id = %d.\n", port_id);