4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <netinet/in.h>
49 #include <sys/queue.h>
51 #include <rte_common.h>
52 #include <rte_byteorder.h>
54 #include <rte_debug.h>
55 #include <rte_cycles.h>
56 #include <rte_memory.h>
57 #include <rte_memzone.h>
58 #include <rte_launch.h>
59 #include <rte_tailq.h>
61 #include <rte_per_lcore.h>
62 #include <rte_lcore.h>
63 #include <rte_atomic.h>
64 #include <rte_branch_prediction.h>
66 #include <rte_mempool.h>
67 #include <rte_interrupts.h>
69 #include <rte_ether.h>
70 #include <rte_ethdev.h>
71 #include <rte_string_fns.h>
73 #include <cmdline_rdline.h>
74 #include <cmdline_parse.h>
75 #include <cmdline_parse_num.h>
76 #include <cmdline_parse_string.h>
77 #include <cmdline_parse_ipaddr.h>
78 #include <cmdline_parse_etheraddr.h>
79 #include <cmdline_socket.h>
84 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
86 /* *** Help command with introduction. *** */
87 struct cmd_help_brief_result {
88 cmdline_fixed_string_t help;
91 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
93 __attribute__((unused)) void *data)
98 "Help is available for the following sections:\n\n"
99 " help control : Start and stop forwarding.\n"
100 " help display : Displaying port, stats and config "
102 " help config : Configuration information.\n"
103 " help ports : Configuring ports.\n"
104 " help flowdir : Flow Director filter help.\n"
105 " help registers : Reading and setting port registers.\n"
106 " help all : All of the above sections.\n\n"
111 cmdline_parse_token_string_t cmd_help_brief_help =
112 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
114 cmdline_parse_inst_t cmd_help_brief = {
115 .f = cmd_help_brief_parsed,
117 .help_str = "show help",
119 (void *)&cmd_help_brief_help,
124 /* *** Help command with help sections. *** */
125 struct cmd_help_long_result {
126 cmdline_fixed_string_t help;
127 cmdline_fixed_string_t section;
130 static void cmd_help_long_parsed(void *parsed_result,
132 __attribute__((unused)) void *data)
135 struct cmd_help_long_result *res = parsed_result;
137 if (!strcmp(res->section, "all"))
140 if (show_all || !strcmp(res->section, "control")) {
145 "Control forwarding:\n"
146 "-------------------\n\n"
149 " Start packet forwarding with current configuration.\n\n"
152 " Start packet forwarding with current config"
153 " after sending one burst of packets.\n\n"
156 " Stop packet forwarding, and display accumulated"
160 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
164 if (show_all || !strcmp(res->section, "display")) {
172 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
173 " Display information for port_id, or all.\n\n"
175 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
176 " Clear information for port_id, or all.\n\n"
178 "show config (rxtx|cores|fwd)\n"
179 " Display the given configuration.\n\n"
181 "read rxd (port_id) (queue_id) (rxd_id)\n"
182 " Display an RX descriptor of a port RX queue.\n\n"
184 "read txd (port_id) (queue_id) (txd_id)\n"
185 " Display a TX descriptor of a port TX queue.\n\n"
189 if (show_all || !strcmp(res->section, "config")) {
195 "Configuration changes only become active when"
196 " forwarding is started/restarted.\n\n"
199 " Reset forwarding to the default configuration.\n\n"
201 "set verbose (level)\n"
202 " Set the debug verbosity level X.\n\n"
205 " Set number of ports.\n\n"
208 " Set number of cores.\n\n"
210 "set coremask (mask)\n"
211 " Set the forwarding cores hexadecimal mask.\n\n"
213 "set portmask (mask)\n"
214 " Set the forwarding ports hexadecimal mask.\n\n"
217 " Set number of packets per burst.\n\n"
219 "set txpkts (x[,y]*)\n"
220 " Set the length of each segment of TXONLY"
223 "set corelist (x[,y]*)\n"
224 " Set the list of forwarding cores.\n\n"
226 "set portlist (x[,y]*)\n"
227 " Set the list of forwarding ports.\n\n"
229 "vlan set strip (on|off) (port_id)\n"
230 " Set the VLAN strip on a port.\n\n"
232 "vlan set filter (on|off) (port_id)\n"
233 " Set the VLAN filter on a port.\n\n"
235 "vlan set qinq (on|off) (port_id)\n"
236 " Set the VLAN QinQ (extended queue in queue)"
239 "vlan set tpid (value) (port_id)\n"
240 " Set the outer VLAN TPID for Packet Filtering on"
243 "rx_vlan add (vlan_id|all) (port_id)\n"
244 " Add a vlan_id, or all identifiers, to the set"
245 " of VLAN identifiers filtered by port_id.\n\n"
247 "rx_vlan rm (vlan_id|all) (port_id)\n"
248 " Remove a vlan_id, or all identifiers, from the set"
249 " of VLAN identifiers filtered by port_id.\n\n"
251 "tx_vlan set vlan_id (port_id)\n"
252 " Set hardware insertion of VLAN ID in packets sent"
255 "tx_vlan reset (port_id)\n"
256 " Disable hardware insertion of a VLAN header in"
257 " packets sent on a port.\n\n"
259 "tx_checksum set mask (port_id)\n"
260 " Enable hardware insertion of checksum offload with"
261 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
262 " bit 0 - insert ip checksum offload if set\n"
263 " bit 1 - insert udp checksum offload if set\n"
264 " bit 2 - insert tcp checksum offload if set\n"
265 " bit 3 - insert sctp checksum offload if set\n"
266 " Please check the NIC datasheet for HW limits.\n\n"
268 #ifdef RTE_LIBRTE_IEEE1588
269 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
270 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
271 " packet forwarding mode.\n\n"
274 "set fwd (io|mac|rxonly|txonly|csum)\n"
275 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
276 " forwarding mode.\n\n"
279 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
280 " Add a MAC address on port_id.\n\n"
282 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
283 " Remove a MAC address from port_id.\n\n"
285 "set promisc (port_id|all) (on|off)\n"
286 " Set the promiscuous mode on port_id, or all.\n\n"
288 "set allmulti (port_id|all) (on|off)\n"
289 " Set the allmulti mode on port_id, or all.\n\n"
291 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
292 " (low_water) (pause_time) (send_xon) (port_id)\n"
293 " Set the link flow control parameter on a port.\n\n"
295 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
296 " (low_water) (pause_time) (priority) (port_id)\n"
297 " Set the priority flow control parameter on a"
300 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
301 " Set statistics mapping (qmapping 0..15) for RX/TX"
303 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
304 " on port 0 to mapping 5.\n\n"
309 if (show_all || !strcmp(res->section, "flowdir")) {
314 "Flow director mode:\n"
315 "-------------------\n\n"
317 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
318 " src (src_ip_address) (src_port)"
319 " dst (dst_ip_address) (dst_port)"
320 " flexbytes (flexbytes_values) vlan (vlan_id)"
321 " queue (queue_id)\n"
322 " Add a signature filter.\n\n"
324 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
325 " src (src_ip_address) (src_port)"
326 " dst (dst_ip_address) (dst_port)"
327 " flexbytes (flexbytes_values) vlan (vlan_id)"
328 " queue (queue_id)\n"
329 " Update a signature filter.\n\n"
331 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
332 " src (src_ip_address) (src_port)"
333 " dst (dst_ip_address) (dst_port)"
334 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
335 " Remove a signature filter.\n\n"
337 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
338 " src (src_ip_address) (src_port)"
339 " dst (dst_ip_address) (dst_port)"
340 " flexbytes (flexbytes_values) vlan (vlan_id)"
341 " queue (queue_id) soft (soft_id)\n"
342 " Add a perfect filter.\n\n"
344 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
345 " src (src_ip_address) (src_port)"
346 " dst (dst_ip_address) (dst_port)"
347 " flexbytes (flexbytes_values) vlan (vlan_id)"
348 " queue (queue_id)\n"
349 " Update a perfect filter.\n\n"
351 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
352 " src (src_ip_address) (src_port)"
353 " dst (dst_ip_address) (dst_port)"
354 " flexbytes (flexbytes_values) vlan (vlan_id)"
356 " Remove a perfect filter.\n\n"
358 "set_masks_filter (port_id) only_ip_flow (0|1)"
359 " src_mask (ip_src_mask) (src_port_mask)"
360 " dst_mask (ip_dst_mask) (dst_port_mask)"
361 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
362 " Set IPv4 filter masks.\n\n"
364 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
365 " src_mask (ip_src_mask) (src_port_mask)"
366 " dst_mask (ip_dst_mask) (dst_port_mask)"
367 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
368 " compare_dst (0|1)\n"
369 " Set IPv6 filter masks.\n\n"
373 if (show_all || !strcmp(res->section, "ports")) {
379 "----------------\n\n"
381 "port start (port_id|all)\n"
382 " Start all ports or port_id.\n\n"
384 "port stop (port_id|all)\n"
385 " Stop all ports or port_id.\n\n"
387 "port close (port_id|all)\n"
388 " Close all ports or port_id.\n\n"
390 "port config (port_id|all) speed (10|100|1000|10000|auto)"
391 " duplex (half|full|auto)\n"
392 " Set speed and duplex for all ports or port_id\n\n"
394 "port config all (rxq|txq|rxd|txd) (value)\n"
395 " Set number for rxq/txq/rxd/txd.\n\n"
397 "port config all max-pkt-len (value)\n"
398 " Set the max packet length.\n\n"
400 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
402 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
405 "port config all rss (ip|udp|none)\n"
406 " Set the RSS mode.\n\n"
408 "port config (port_id) dcb vt (on|off) (traffic_class)"
410 " Set the DCB mode.\n\n"
412 "port config all burst (value)\n"
413 " Set the number of packets per burst.\n\n"
415 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
417 " Set the ring prefetch/host/writeback threshold"
418 " for tx/rx queue.\n\n"
420 "port config all (txfreet|txrst|rxfreet) (value)\n"
421 " Set free threshold for rx/tx, or set"
422 " tx rs bit threshold.\n\n"
426 if (show_all || !strcmp(res->section, "registers")) {
434 "read reg (port_id) (address)\n"
435 " Display value of a port register.\n\n"
437 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
438 " Display a port register bit field.\n\n"
440 "read regbit (port_id) (address) (bit_x)\n"
441 " Display a single port register bit.\n\n"
443 "write reg (port_id) (address) (value)\n"
444 " Set value of a port register.\n\n"
446 "write regfield (port_id) (address) (bit_x) (bit_y)"
448 " Set bit field of a port register.\n\n"
450 "write regbit (port_id) (address) (bit_x) (value)\n"
451 " Set single bit value of a port register.\n\n"
456 cmdline_parse_token_string_t cmd_help_long_help =
457 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
459 cmdline_parse_token_string_t cmd_help_long_section =
460 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
461 "all#control#display#config#flowdir#"
464 cmdline_parse_inst_t cmd_help_long = {
465 .f = cmd_help_long_parsed,
467 .help_str = "show help",
469 (void *)&cmd_help_long_help,
470 (void *)&cmd_help_long_section,
476 /* *** start/stop/close all ports *** */
477 struct cmd_operate_port_result {
478 cmdline_fixed_string_t keyword;
479 cmdline_fixed_string_t name;
480 cmdline_fixed_string_t value;
483 static void cmd_operate_port_parsed(void *parsed_result,
484 __attribute__((unused)) struct cmdline *cl,
485 __attribute__((unused)) void *data)
487 struct cmd_operate_port_result *res = parsed_result;
489 if (!strcmp(res->name, "start"))
490 start_port(RTE_PORT_ALL);
491 else if (!strcmp(res->name, "stop"))
492 stop_port(RTE_PORT_ALL);
493 else if (!strcmp(res->name, "close"))
494 close_port(RTE_PORT_ALL);
496 printf("Unknown parameter\n");
499 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
500 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
502 cmdline_parse_token_string_t cmd_operate_port_all_port =
503 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
505 cmdline_parse_token_string_t cmd_operate_port_all_all =
506 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
508 cmdline_parse_inst_t cmd_operate_port = {
509 .f = cmd_operate_port_parsed,
511 .help_str = "port start|stop|close all: start/stop/close all ports",
513 (void *)&cmd_operate_port_all_cmd,
514 (void *)&cmd_operate_port_all_port,
515 (void *)&cmd_operate_port_all_all,
520 /* *** start/stop/close specific port *** */
521 struct cmd_operate_specific_port_result {
522 cmdline_fixed_string_t keyword;
523 cmdline_fixed_string_t name;
527 static void cmd_operate_specific_port_parsed(void *parsed_result,
528 __attribute__((unused)) struct cmdline *cl,
529 __attribute__((unused)) void *data)
531 struct cmd_operate_specific_port_result *res = parsed_result;
533 if (!strcmp(res->name, "start"))
534 start_port(res->value);
535 else if (!strcmp(res->name, "stop"))
536 stop_port(res->value);
537 else if (!strcmp(res->name, "close"))
538 close_port(res->value);
540 printf("Unknown parameter\n");
543 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
544 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
546 cmdline_parse_token_string_t cmd_operate_specific_port_port =
547 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
548 name, "start#stop#close");
549 cmdline_parse_token_num_t cmd_operate_specific_port_id =
550 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
553 cmdline_parse_inst_t cmd_operate_specific_port = {
554 .f = cmd_operate_specific_port_parsed,
556 .help_str = "port start|stop|close X: start/stop/close port X",
558 (void *)&cmd_operate_specific_port_cmd,
559 (void *)&cmd_operate_specific_port_port,
560 (void *)&cmd_operate_specific_port_id,
565 /* *** configure speed for all ports *** */
566 struct cmd_config_speed_all {
567 cmdline_fixed_string_t port;
568 cmdline_fixed_string_t keyword;
569 cmdline_fixed_string_t all;
570 cmdline_fixed_string_t item1;
571 cmdline_fixed_string_t item2;
572 cmdline_fixed_string_t value1;
573 cmdline_fixed_string_t value2;
577 cmd_config_speed_all_parsed(void *parsed_result,
578 __attribute__((unused)) struct cmdline *cl,
579 __attribute__((unused)) void *data)
581 struct cmd_config_speed_all *res = parsed_result;
582 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
583 uint16_t link_duplex = 0;
586 if (!all_ports_stopped()) {
587 printf("Please stop all ports first\n");
591 if (!strcmp(res->value1, "10"))
592 link_speed = ETH_LINK_SPEED_10;
593 else if (!strcmp(res->value1, "100"))
594 link_speed = ETH_LINK_SPEED_100;
595 else if (!strcmp(res->value1, "1000"))
596 link_speed = ETH_LINK_SPEED_1000;
597 else if (!strcmp(res->value1, "10000"))
598 link_speed = ETH_LINK_SPEED_10000;
599 else if (!strcmp(res->value1, "auto"))
600 link_speed = ETH_LINK_SPEED_AUTONEG;
602 printf("Unknown parameter\n");
606 if (!strcmp(res->value2, "half"))
607 link_duplex = ETH_LINK_HALF_DUPLEX;
608 else if (!strcmp(res->value2, "full"))
609 link_duplex = ETH_LINK_FULL_DUPLEX;
610 else if (!strcmp(res->value2, "auto"))
611 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
613 printf("Unknown parameter\n");
617 for (pid = 0; pid < nb_ports; pid++) {
618 ports[pid].dev_conf.link_speed = link_speed;
619 ports[pid].dev_conf.link_duplex = link_duplex;
622 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
625 cmdline_parse_token_string_t cmd_config_speed_all_port =
626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
627 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
628 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
630 cmdline_parse_token_string_t cmd_config_speed_all_all =
631 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
632 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
633 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
634 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
635 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
636 "10#100#1000#10000#auto");
637 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
638 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
639 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
643 cmdline_parse_inst_t cmd_config_speed_all = {
644 .f = cmd_config_speed_all_parsed,
646 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
649 (void *)&cmd_config_speed_all_port,
650 (void *)&cmd_config_speed_all_keyword,
651 (void *)&cmd_config_speed_all_all,
652 (void *)&cmd_config_speed_all_item1,
653 (void *)&cmd_config_speed_all_value1,
654 (void *)&cmd_config_speed_all_item2,
655 (void *)&cmd_config_speed_all_value2,
660 /* *** configure speed for specific port *** */
661 struct cmd_config_speed_specific {
662 cmdline_fixed_string_t port;
663 cmdline_fixed_string_t keyword;
665 cmdline_fixed_string_t item1;
666 cmdline_fixed_string_t item2;
667 cmdline_fixed_string_t value1;
668 cmdline_fixed_string_t value2;
672 cmd_config_speed_specific_parsed(void *parsed_result,
673 __attribute__((unused)) struct cmdline *cl,
674 __attribute__((unused)) void *data)
676 struct cmd_config_speed_specific *res = parsed_result;
677 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
678 uint16_t link_duplex = 0;
680 if (!all_ports_stopped()) {
681 printf("Please stop all ports first\n");
685 if (res->id >= nb_ports) {
686 printf("Port id %d must be less than %d\n", res->id, nb_ports);
690 if (!strcmp(res->value1, "10"))
691 link_speed = ETH_LINK_SPEED_10;
692 else if (!strcmp(res->value1, "100"))
693 link_speed = ETH_LINK_SPEED_100;
694 else if (!strcmp(res->value1, "1000"))
695 link_speed = ETH_LINK_SPEED_1000;
696 else if (!strcmp(res->value1, "10000"))
697 link_speed = ETH_LINK_SPEED_10000;
698 else if (!strcmp(res->value1, "auto"))
699 link_speed = ETH_LINK_SPEED_AUTONEG;
701 printf("Unknown parameter\n");
705 if (!strcmp(res->value2, "half"))
706 link_duplex = ETH_LINK_HALF_DUPLEX;
707 else if (!strcmp(res->value2, "full"))
708 link_duplex = ETH_LINK_FULL_DUPLEX;
709 else if (!strcmp(res->value2, "auto"))
710 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
712 printf("Unknown parameter\n");
716 ports[res->id].dev_conf.link_speed = link_speed;
717 ports[res->id].dev_conf.link_duplex = link_duplex;
719 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
723 cmdline_parse_token_string_t cmd_config_speed_specific_port =
724 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
726 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
727 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
729 cmdline_parse_token_num_t cmd_config_speed_specific_id =
730 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
731 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
734 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
736 "10#100#1000#10000#auto");
737 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
740 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
744 cmdline_parse_inst_t cmd_config_speed_specific = {
745 .f = cmd_config_speed_specific_parsed,
747 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
750 (void *)&cmd_config_speed_specific_port,
751 (void *)&cmd_config_speed_specific_keyword,
752 (void *)&cmd_config_speed_specific_id,
753 (void *)&cmd_config_speed_specific_item1,
754 (void *)&cmd_config_speed_specific_value1,
755 (void *)&cmd_config_speed_specific_item2,
756 (void *)&cmd_config_speed_specific_value2,
761 /* *** configure txq/rxq, txd/rxd *** */
762 struct cmd_config_rx_tx {
763 cmdline_fixed_string_t port;
764 cmdline_fixed_string_t keyword;
765 cmdline_fixed_string_t all;
766 cmdline_fixed_string_t name;
771 cmd_config_rx_tx_parsed(void *parsed_result,
772 __attribute__((unused)) struct cmdline *cl,
773 __attribute__((unused)) void *data)
775 struct cmd_config_rx_tx *res = parsed_result;
777 if (!all_ports_stopped()) {
778 printf("Please stop all ports first\n");
782 if (!strcmp(res->name, "rxq")) {
783 if (res->value <= 0) {
784 printf("rxq %d invalid - must be > 0\n", res->value);
789 else if (!strcmp(res->name, "txq")) {
790 if (res->value <= 0) {
791 printf("txq %d invalid - must be > 0\n", res->value);
796 else if (!strcmp(res->name, "rxd")) {
797 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
798 printf("rxd %d invalid - must be > 0 && <= %d\n",
799 res->value, RTE_TEST_RX_DESC_MAX);
803 } else if (!strcmp(res->name, "txd")) {
804 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
805 printf("txd %d invalid - must be > 0 && <= %d\n",
806 res->value, RTE_TEST_TX_DESC_MAX);
811 printf("Unknown parameter\n");
817 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
820 cmdline_parse_token_string_t cmd_config_rx_tx_port =
821 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
822 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
823 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
824 cmdline_parse_token_string_t cmd_config_rx_tx_all =
825 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
826 cmdline_parse_token_string_t cmd_config_rx_tx_name =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
829 cmdline_parse_token_num_t cmd_config_rx_tx_value =
830 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
832 cmdline_parse_inst_t cmd_config_rx_tx = {
833 .f = cmd_config_rx_tx_parsed,
835 .help_str = "port config all rxq|txq|rxd|txd value",
837 (void *)&cmd_config_rx_tx_port,
838 (void *)&cmd_config_rx_tx_keyword,
839 (void *)&cmd_config_rx_tx_all,
840 (void *)&cmd_config_rx_tx_name,
841 (void *)&cmd_config_rx_tx_value,
846 /* *** config max packet length *** */
847 struct cmd_config_max_pkt_len_result {
848 cmdline_fixed_string_t port;
849 cmdline_fixed_string_t keyword;
850 cmdline_fixed_string_t all;
851 cmdline_fixed_string_t name;
856 cmd_config_max_pkt_len_parsed(void *parsed_result,
857 __attribute__((unused)) struct cmdline *cl,
858 __attribute__((unused)) void *data)
860 struct cmd_config_max_pkt_len_result *res = parsed_result;
862 if (!all_ports_stopped()) {
863 printf("Please stop all ports first\n");
867 if (!strcmp(res->name, "max-pkt-len")) {
868 if (res->value < ETHER_MIN_LEN) {
869 printf("max-pkt-len can not be less than %d\n",
873 if (res->value == rx_mode.max_rx_pkt_len)
876 rx_mode.max_rx_pkt_len = res->value;
877 if (res->value > ETHER_MAX_LEN)
878 rx_mode.jumbo_frame = 1;
880 rx_mode.jumbo_frame = 0;
882 printf("Unknown parameter\n");
888 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
891 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
892 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
894 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
895 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
897 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
898 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
900 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
901 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
903 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
904 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
907 cmdline_parse_inst_t cmd_config_max_pkt_len = {
908 .f = cmd_config_max_pkt_len_parsed,
910 .help_str = "port config all max-pkt-len value",
912 (void *)&cmd_config_max_pkt_len_port,
913 (void *)&cmd_config_max_pkt_len_keyword,
914 (void *)&cmd_config_max_pkt_len_all,
915 (void *)&cmd_config_max_pkt_len_name,
916 (void *)&cmd_config_max_pkt_len_value,
921 /* *** configure rx mode *** */
922 struct cmd_config_rx_mode_flag {
923 cmdline_fixed_string_t port;
924 cmdline_fixed_string_t keyword;
925 cmdline_fixed_string_t all;
926 cmdline_fixed_string_t name;
927 cmdline_fixed_string_t value;
931 cmd_config_rx_mode_flag_parsed(void *parsed_result,
932 __attribute__((unused)) struct cmdline *cl,
933 __attribute__((unused)) void *data)
935 struct cmd_config_rx_mode_flag *res = parsed_result;
937 if (!all_ports_stopped()) {
938 printf("Please stop all ports first\n");
942 if (!strcmp(res->name, "crc-strip")) {
943 if (!strcmp(res->value, "on"))
944 rx_mode.hw_strip_crc = 1;
945 else if (!strcmp(res->value, "off"))
946 rx_mode.hw_strip_crc = 0;
948 printf("Unknown parameter\n");
951 } else if (!strcmp(res->name, "rx-cksum")) {
952 if (!strcmp(res->value, "on"))
953 rx_mode.hw_ip_checksum = 1;
954 else if (!strcmp(res->value, "off"))
955 rx_mode.hw_ip_checksum = 0;
957 printf("Unknown parameter\n");
960 } else if (!strcmp(res->name, "hw-vlan")) {
961 if (!strcmp(res->value, "on")) {
962 rx_mode.hw_vlan_filter = 1;
963 rx_mode.hw_vlan_strip = 1;
965 else if (!strcmp(res->value, "off")) {
966 rx_mode.hw_vlan_filter = 0;
967 rx_mode.hw_vlan_strip = 0;
970 printf("Unknown parameter\n");
973 } else if (!strcmp(res->name, "drop-en")) {
974 if (!strcmp(res->value, "on"))
976 else if (!strcmp(res->value, "off"))
979 printf("Unknown parameter\n");
983 printf("Unknown parameter\n");
989 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
992 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
994 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
997 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
999 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1001 "crc-strip#rx-cksum#hw-vlan");
1002 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1006 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1007 .f = cmd_config_rx_mode_flag_parsed,
1009 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1011 (void *)&cmd_config_rx_mode_flag_port,
1012 (void *)&cmd_config_rx_mode_flag_keyword,
1013 (void *)&cmd_config_rx_mode_flag_all,
1014 (void *)&cmd_config_rx_mode_flag_name,
1015 (void *)&cmd_config_rx_mode_flag_value,
1020 /* *** configure rss *** */
1021 struct cmd_config_rss {
1022 cmdline_fixed_string_t port;
1023 cmdline_fixed_string_t keyword;
1024 cmdline_fixed_string_t all;
1025 cmdline_fixed_string_t name;
1026 cmdline_fixed_string_t value;
1030 cmd_config_rss_parsed(void *parsed_result,
1031 __attribute__((unused)) struct cmdline *cl,
1032 __attribute__((unused)) void *data)
1034 struct cmd_config_rss *res = parsed_result;
1036 if (!all_ports_stopped()) {
1037 printf("Please stop all ports first\n");
1041 if (!strcmp(res->value, "ip"))
1042 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1043 else if (!strcmp(res->value, "udp"))
1044 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1045 else if (!strcmp(res->value, "none"))
1048 printf("Unknown parameter\n");
1054 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1057 cmdline_parse_token_string_t cmd_config_rss_port =
1058 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1059 cmdline_parse_token_string_t cmd_config_rss_keyword =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1061 cmdline_parse_token_string_t cmd_config_rss_all =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1063 cmdline_parse_token_string_t cmd_config_rss_name =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1065 cmdline_parse_token_string_t cmd_config_rss_value =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1068 cmdline_parse_inst_t cmd_config_rss = {
1069 .f = cmd_config_rss_parsed,
1071 .help_str = "port config all rss ip|udp|none",
1073 (void *)&cmd_config_rss_port,
1074 (void *)&cmd_config_rss_keyword,
1075 (void *)&cmd_config_rss_all,
1076 (void *)&cmd_config_rss_name,
1077 (void *)&cmd_config_rss_value,
1082 /* *** Configure DCB *** */
1083 struct cmd_config_dcb {
1084 cmdline_fixed_string_t port;
1085 cmdline_fixed_string_t config;
1087 cmdline_fixed_string_t dcb;
1088 cmdline_fixed_string_t vt;
1089 cmdline_fixed_string_t vt_en;
1091 cmdline_fixed_string_t pfc;
1092 cmdline_fixed_string_t pfc_en;
1096 cmd_config_dcb_parsed(void *parsed_result,
1097 __attribute__((unused)) struct cmdline *cl,
1098 __attribute__((unused)) void *data)
1100 struct cmd_config_dcb *res = parsed_result;
1101 struct dcb_config dcb_conf;
1102 portid_t port_id = res->port_id;
1103 struct rte_port *port;
1105 port = &ports[port_id];
1106 /** Check if the port is not started **/
1107 if (port->port_status != RTE_PORT_STOPPED) {
1108 printf("Please stop port %d first\n",port_id);
1112 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1113 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1114 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1118 /* DCB in VT mode */
1119 if (!strncmp(res->vt_en, "on",2))
1120 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1122 dcb_conf.dcb_mode = DCB_ENABLED;
1124 if (!strncmp(res->pfc_en, "on",2)) {
1125 dcb_conf.pfc_en = 1;
1128 dcb_conf.pfc_en = 0;
1130 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1131 printf("Cannot initialize network ports\n");
1135 cmd_reconfig_device_queue(port_id, 1, 1);
1138 cmdline_parse_token_string_t cmd_config_dcb_port =
1139 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1140 cmdline_parse_token_string_t cmd_config_dcb_config =
1141 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1142 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1143 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1144 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1145 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1146 cmdline_parse_token_string_t cmd_config_dcb_vt =
1147 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1148 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1149 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1150 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1151 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1152 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1154 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1155 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1157 cmdline_parse_inst_t cmd_config_dcb = {
1158 .f = cmd_config_dcb_parsed,
1160 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1162 (void *)&cmd_config_dcb_port,
1163 (void *)&cmd_config_dcb_config,
1164 (void *)&cmd_config_dcb_port_id,
1165 (void *)&cmd_config_dcb_dcb,
1166 (void *)&cmd_config_dcb_vt,
1167 (void *)&cmd_config_dcb_vt_en,
1168 (void *)&cmd_config_dcb_num_tcs,
1169 (void *)&cmd_config_dcb_pfc,
1170 (void *)&cmd_config_dcb_pfc_en,
1175 /* *** configure number of packets per burst *** */
1176 struct cmd_config_burst {
1177 cmdline_fixed_string_t port;
1178 cmdline_fixed_string_t keyword;
1179 cmdline_fixed_string_t all;
1180 cmdline_fixed_string_t name;
1185 cmd_config_burst_parsed(void *parsed_result,
1186 __attribute__((unused)) struct cmdline *cl,
1187 __attribute__((unused)) void *data)
1189 struct cmd_config_burst *res = parsed_result;
1191 if (!all_ports_stopped()) {
1192 printf("Please stop all ports first\n");
1196 if (!strcmp(res->name, "burst")) {
1197 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1198 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1201 nb_pkt_per_burst = res->value;
1203 printf("Unknown parameter\n");
1209 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1212 cmdline_parse_token_string_t cmd_config_burst_port =
1213 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1214 cmdline_parse_token_string_t cmd_config_burst_keyword =
1215 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1216 cmdline_parse_token_string_t cmd_config_burst_all =
1217 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1218 cmdline_parse_token_string_t cmd_config_burst_name =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1220 cmdline_parse_token_num_t cmd_config_burst_value =
1221 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1223 cmdline_parse_inst_t cmd_config_burst = {
1224 .f = cmd_config_burst_parsed,
1226 .help_str = "port config all burst value",
1228 (void *)&cmd_config_burst_port,
1229 (void *)&cmd_config_burst_keyword,
1230 (void *)&cmd_config_burst_all,
1231 (void *)&cmd_config_burst_name,
1232 (void *)&cmd_config_burst_value,
1237 /* *** configure rx/tx queues *** */
1238 struct cmd_config_thresh {
1239 cmdline_fixed_string_t port;
1240 cmdline_fixed_string_t keyword;
1241 cmdline_fixed_string_t all;
1242 cmdline_fixed_string_t name;
1247 cmd_config_thresh_parsed(void *parsed_result,
1248 __attribute__((unused)) struct cmdline *cl,
1249 __attribute__((unused)) void *data)
1251 struct cmd_config_thresh *res = parsed_result;
1253 if (!all_ports_stopped()) {
1254 printf("Please stop all ports first\n");
1258 if (!strcmp(res->name, "txpt"))
1259 tx_thresh.pthresh = res->value;
1260 else if(!strcmp(res->name, "txht"))
1261 tx_thresh.hthresh = res->value;
1262 else if(!strcmp(res->name, "txwt"))
1263 tx_thresh.wthresh = res->value;
1264 else if(!strcmp(res->name, "rxpt"))
1265 rx_thresh.pthresh = res->value;
1266 else if(!strcmp(res->name, "rxht"))
1267 rx_thresh.hthresh = res->value;
1268 else if(!strcmp(res->name, "rxwt"))
1269 rx_thresh.wthresh = res->value;
1271 printf("Unknown parameter\n");
1277 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1280 cmdline_parse_token_string_t cmd_config_thresh_port =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1282 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1284 cmdline_parse_token_string_t cmd_config_thresh_all =
1285 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1286 cmdline_parse_token_string_t cmd_config_thresh_name =
1287 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1288 "txpt#txht#txwt#rxpt#rxht#rxwt");
1289 cmdline_parse_token_num_t cmd_config_thresh_value =
1290 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1292 cmdline_parse_inst_t cmd_config_thresh = {
1293 .f = cmd_config_thresh_parsed,
1295 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1297 (void *)&cmd_config_thresh_port,
1298 (void *)&cmd_config_thresh_keyword,
1299 (void *)&cmd_config_thresh_all,
1300 (void *)&cmd_config_thresh_name,
1301 (void *)&cmd_config_thresh_value,
1306 /* *** configure free/rs threshold *** */
1307 struct cmd_config_threshold {
1308 cmdline_fixed_string_t port;
1309 cmdline_fixed_string_t keyword;
1310 cmdline_fixed_string_t all;
1311 cmdline_fixed_string_t name;
1316 cmd_config_threshold_parsed(void *parsed_result,
1317 __attribute__((unused)) struct cmdline *cl,
1318 __attribute__((unused)) void *data)
1320 struct cmd_config_threshold *res = parsed_result;
1322 if (!all_ports_stopped()) {
1323 printf("Please stop all ports first\n");
1327 if (!strcmp(res->name, "txfreet"))
1328 tx_free_thresh = res->value;
1329 else if (!strcmp(res->name, "txrst"))
1330 tx_rs_thresh = res->value;
1331 else if (!strcmp(res->name, "rxfreet"))
1332 rx_free_thresh = res->value;
1334 printf("Unknown parameter\n");
1340 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1343 cmdline_parse_token_string_t cmd_config_threshold_port =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1345 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1346 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1348 cmdline_parse_token_string_t cmd_config_threshold_all =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1350 cmdline_parse_token_string_t cmd_config_threshold_name =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1352 "txfreet#txrst#rxfreet");
1353 cmdline_parse_token_num_t cmd_config_threshold_value =
1354 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1356 cmdline_parse_inst_t cmd_config_threshold = {
1357 .f = cmd_config_threshold_parsed,
1359 .help_str = "port config all txfreet|txrst|rxfreet value",
1361 (void *)&cmd_config_threshold_port,
1362 (void *)&cmd_config_threshold_keyword,
1363 (void *)&cmd_config_threshold_all,
1364 (void *)&cmd_config_threshold_name,
1365 (void *)&cmd_config_threshold_value,
1371 struct cmd_stop_result {
1372 cmdline_fixed_string_t stop;
1375 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1376 __attribute__((unused)) struct cmdline *cl,
1377 __attribute__((unused)) void *data)
1379 stop_packet_forwarding();
1382 cmdline_parse_token_string_t cmd_stop_stop =
1383 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1385 cmdline_parse_inst_t cmd_stop = {
1386 .f = cmd_stop_parsed,
1388 .help_str = "stop - stop packet forwarding",
1390 (void *)&cmd_stop_stop,
1395 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1398 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1399 unsigned int *parsed_items, int check_unique_values)
1401 unsigned int nb_item;
1409 * First parse all items in the list and store their value.
1414 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1416 if ((c >= '0') && (c <= '9')) {
1417 value = (unsigned int) (value * 10 + (c - '0'));
1422 printf("character %c is not a decimal digit\n", c);
1426 printf("No valid value before comma\n");
1429 if (nb_item < max_items) {
1430 parsed_items[nb_item] = value;
1436 if (nb_item >= max_items) {
1437 printf("Number of %s = %u > %u (maximum items)\n",
1438 item_name, nb_item + 1, max_items);
1441 parsed_items[nb_item++] = value;
1442 if (! check_unique_values)
1446 * Then, check that all values in the list are differents.
1447 * No optimization here...
1449 for (i = 0; i < nb_item; i++) {
1450 for (j = i + 1; j < nb_item; j++) {
1451 if (parsed_items[j] == parsed_items[i]) {
1452 printf("duplicated %s %u at index %u and %u\n",
1453 item_name, parsed_items[i], i, j);
1461 struct cmd_set_list_result {
1462 cmdline_fixed_string_t cmd_keyword;
1463 cmdline_fixed_string_t list_name;
1464 cmdline_fixed_string_t list_of_items;
1467 static void cmd_set_list_parsed(void *parsed_result,
1468 __attribute__((unused)) struct cmdline *cl,
1469 __attribute__((unused)) void *data)
1471 struct cmd_set_list_result *res;
1473 unsigned int lcorelist[RTE_MAX_LCORE];
1474 unsigned int portlist[RTE_MAX_ETHPORTS];
1476 unsigned int nb_item;
1478 res = parsed_result;
1479 if (!strcmp(res->list_name, "corelist")) {
1480 nb_item = parse_item_list(res->list_of_items, "core",
1482 parsed_items.lcorelist, 1);
1484 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1487 if (!strcmp(res->list_name, "portlist")) {
1488 nb_item = parse_item_list(res->list_of_items, "port",
1490 parsed_items.portlist, 1);
1492 set_fwd_ports_list(parsed_items.portlist, nb_item);
1496 cmdline_parse_token_string_t cmd_set_list_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1499 cmdline_parse_token_string_t cmd_set_list_name =
1500 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1501 "corelist#portlist");
1502 cmdline_parse_token_string_t cmd_set_list_of_items =
1503 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1506 cmdline_parse_inst_t cmd_set_fwd_list = {
1507 .f = cmd_set_list_parsed,
1509 .help_str = "set corelist|portlist x[,y]*",
1511 (void *)&cmd_set_list_keyword,
1512 (void *)&cmd_set_list_name,
1513 (void *)&cmd_set_list_of_items,
1518 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1520 struct cmd_setmask_result {
1521 cmdline_fixed_string_t set;
1522 cmdline_fixed_string_t mask;
1526 static void cmd_set_mask_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_setmask_result *res = parsed_result;
1532 if (!strcmp(res->mask, "coremask"))
1533 set_fwd_lcores_mask(res->hexavalue);
1534 else if (!strcmp(res->mask, "portmask"))
1535 set_fwd_ports_mask(res->hexavalue);
1538 cmdline_parse_token_string_t cmd_setmask_set =
1539 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1540 cmdline_parse_token_string_t cmd_setmask_mask =
1541 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1542 "coremask#portmask");
1543 cmdline_parse_token_num_t cmd_setmask_value =
1544 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1546 cmdline_parse_inst_t cmd_set_fwd_mask = {
1547 .f = cmd_set_mask_parsed,
1549 .help_str = "set coremask|portmask hexadecimal value",
1551 (void *)&cmd_setmask_set,
1552 (void *)&cmd_setmask_mask,
1553 (void *)&cmd_setmask_value,
1559 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1561 struct cmd_set_result {
1562 cmdline_fixed_string_t set;
1563 cmdline_fixed_string_t what;
1567 static void cmd_set_parsed(void *parsed_result,
1568 __attribute__((unused)) struct cmdline *cl,
1569 __attribute__((unused)) void *data)
1571 struct cmd_set_result *res = parsed_result;
1572 if (!strcmp(res->what, "nbport"))
1573 set_fwd_ports_number(res->value);
1574 else if (!strcmp(res->what, "nbcore"))
1575 set_fwd_lcores_number(res->value);
1576 else if (!strcmp(res->what, "burst"))
1577 set_nb_pkt_per_burst(res->value);
1578 else if (!strcmp(res->what, "verbose"))
1579 set_verbose_level(res->value);
1582 cmdline_parse_token_string_t cmd_set_set =
1583 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1584 cmdline_parse_token_string_t cmd_set_what =
1585 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1586 "nbport#nbcore#burst#verbose");
1587 cmdline_parse_token_num_t cmd_set_value =
1588 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1590 cmdline_parse_inst_t cmd_set_numbers = {
1591 .f = cmd_set_parsed,
1593 .help_str = "set nbport|nbcore|burst|verbose value",
1595 (void *)&cmd_set_set,
1596 (void *)&cmd_set_what,
1597 (void *)&cmd_set_value,
1602 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1604 struct cmd_set_txpkts_result {
1605 cmdline_fixed_string_t cmd_keyword;
1606 cmdline_fixed_string_t txpkts;
1607 cmdline_fixed_string_t seg_lengths;
1611 cmd_set_txpkts_parsed(void *parsed_result,
1612 __attribute__((unused)) struct cmdline *cl,
1613 __attribute__((unused)) void *data)
1615 struct cmd_set_txpkts_result *res;
1616 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1617 unsigned int nb_segs;
1619 res = parsed_result;
1620 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1621 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1623 set_tx_pkt_segments(seg_lengths, nb_segs);
1626 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1627 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1628 cmd_keyword, "set");
1629 cmdline_parse_token_string_t cmd_set_txpkts_name =
1630 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1632 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1633 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1636 cmdline_parse_inst_t cmd_set_txpkts = {
1637 .f = cmd_set_txpkts_parsed,
1639 .help_str = "set txpkts x[,y]*",
1641 (void *)&cmd_set_txpkts_keyword,
1642 (void *)&cmd_set_txpkts_name,
1643 (void *)&cmd_set_txpkts_lengths,
1648 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1649 struct cmd_rx_vlan_filter_all_result {
1650 cmdline_fixed_string_t rx_vlan;
1651 cmdline_fixed_string_t what;
1652 cmdline_fixed_string_t all;
1657 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1658 __attribute__((unused)) struct cmdline *cl,
1659 __attribute__((unused)) void *data)
1661 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1663 if (!strcmp(res->what, "add"))
1664 rx_vlan_all_filter_set(res->port_id, 1);
1666 rx_vlan_all_filter_set(res->port_id, 0);
1669 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1670 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1671 rx_vlan, "rx_vlan");
1672 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1673 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1675 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1676 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1678 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1679 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1682 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1683 .f = cmd_rx_vlan_filter_all_parsed,
1685 .help_str = "add/remove all identifiers to/from the set of VLAN "
1686 "Identifiers filtered by a port",
1688 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1689 (void *)&cmd_rx_vlan_filter_all_what,
1690 (void *)&cmd_rx_vlan_filter_all_all,
1691 (void *)&cmd_rx_vlan_filter_all_portid,
1696 /* *** VLAN OFFLOAD SET ON A PORT *** */
1697 struct cmd_vlan_offload_result {
1698 cmdline_fixed_string_t vlan;
1699 cmdline_fixed_string_t set;
1700 cmdline_fixed_string_t what;
1701 cmdline_fixed_string_t on;
1702 cmdline_fixed_string_t port_id;
1706 cmd_vlan_offload_parsed(void *parsed_result,
1707 __attribute__((unused)) struct cmdline *cl,
1708 __attribute__((unused)) void *data)
1711 struct cmd_vlan_offload_result *res = parsed_result;
1714 portid_t port_id = 0;
1718 len = strnlen(str, STR_TOKEN_SIZE);
1720 /* Get port_id first */
1728 tmp = strtoul(str, NULL, 0);
1729 /* If port_id greater that what portid_t can represent, return */
1730 if(tmp >= RTE_MAX_ETHPORTS)
1732 port_id = (portid_t)tmp;
1734 if (!strcmp(res->on, "on"))
1739 if (!strcmp(res->what, "strip"))
1740 rx_vlan_strip_set(port_id, on);
1741 else if(!strcmp(res->what, "stripq")){
1742 uint16_t queue_id = 0;
1744 /* No queue_id, return */
1747 tmp = strtoul(str + i + 1, NULL, 0);
1748 /* If queue_id greater that what 16-bits can represent, return */
1752 queue_id = (uint16_t)tmp;
1753 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1755 else if (!strcmp(res->what, "filter"))
1756 rx_vlan_filter_set(port_id, on);
1758 vlan_extend_set(port_id, on);
1763 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1764 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1766 cmdline_parse_token_string_t cmd_vlan_offload_set =
1767 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1769 cmdline_parse_token_string_t cmd_vlan_offload_what =
1770 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1771 what, "strip#filter#qinq#stripq");
1772 cmdline_parse_token_string_t cmd_vlan_offload_on =
1773 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1775 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1776 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1779 cmdline_parse_inst_t cmd_vlan_offload = {
1780 .f = cmd_vlan_offload_parsed,
1782 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1783 " qinq(extended) for both rx/tx sides ",
1785 (void *)&cmd_vlan_offload_vlan,
1786 (void *)&cmd_vlan_offload_set,
1787 (void *)&cmd_vlan_offload_what,
1788 (void *)&cmd_vlan_offload_on,
1789 (void *)&cmd_vlan_offload_portid,
1794 /* *** VLAN TPID SET ON A PORT *** */
1795 struct cmd_vlan_tpid_result {
1796 cmdline_fixed_string_t vlan;
1797 cmdline_fixed_string_t set;
1798 cmdline_fixed_string_t what;
1804 cmd_vlan_tpid_parsed(void *parsed_result,
1805 __attribute__((unused)) struct cmdline *cl,
1806 __attribute__((unused)) void *data)
1808 struct cmd_vlan_tpid_result *res = parsed_result;
1809 vlan_tpid_set(res->port_id, res->tp_id);
1813 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1814 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1816 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1817 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1819 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1820 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1822 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
1823 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1825 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
1826 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1829 cmdline_parse_inst_t cmd_vlan_tpid = {
1830 .f = cmd_vlan_tpid_parsed,
1832 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
1834 (void *)&cmd_vlan_tpid_vlan,
1835 (void *)&cmd_vlan_tpid_set,
1836 (void *)&cmd_vlan_tpid_what,
1837 (void *)&cmd_vlan_tpid_tpid,
1838 (void *)&cmd_vlan_tpid_portid,
1843 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
1844 struct cmd_rx_vlan_filter_result {
1845 cmdline_fixed_string_t rx_vlan;
1846 cmdline_fixed_string_t what;
1852 cmd_rx_vlan_filter_parsed(void *parsed_result,
1853 __attribute__((unused)) struct cmdline *cl,
1854 __attribute__((unused)) void *data)
1856 struct cmd_rx_vlan_filter_result *res = parsed_result;
1858 if (!strcmp(res->what, "add"))
1859 rx_vft_set(res->port_id, res->vlan_id, 1);
1861 rx_vft_set(res->port_id, res->vlan_id, 0);
1864 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
1865 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1866 rx_vlan, "rx_vlan");
1867 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
1868 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1870 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
1871 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1873 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
1874 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1877 cmdline_parse_inst_t cmd_rx_vlan_filter = {
1878 .f = cmd_rx_vlan_filter_parsed,
1880 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
1881 "Identifiers filtered by a port",
1883 (void *)&cmd_rx_vlan_filter_rx_vlan,
1884 (void *)&cmd_rx_vlan_filter_what,
1885 (void *)&cmd_rx_vlan_filter_vlanid,
1886 (void *)&cmd_rx_vlan_filter_portid,
1891 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1892 struct cmd_tx_vlan_set_result {
1893 cmdline_fixed_string_t tx_vlan;
1894 cmdline_fixed_string_t set;
1900 cmd_tx_vlan_set_parsed(void *parsed_result,
1901 __attribute__((unused)) struct cmdline *cl,
1902 __attribute__((unused)) void *data)
1904 struct cmd_tx_vlan_set_result *res = parsed_result;
1905 tx_vlan_set(res->port_id, res->vlan_id);
1908 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
1909 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1910 tx_vlan, "tx_vlan");
1911 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
1912 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1914 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
1915 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1917 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
1918 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1921 cmdline_parse_inst_t cmd_tx_vlan_set = {
1922 .f = cmd_tx_vlan_set_parsed,
1924 .help_str = "enable hardware insertion of a VLAN header with a given "
1925 "TAG Identifier in packets sent on a port",
1927 (void *)&cmd_tx_vlan_set_tx_vlan,
1928 (void *)&cmd_tx_vlan_set_set,
1929 (void *)&cmd_tx_vlan_set_vlanid,
1930 (void *)&cmd_tx_vlan_set_portid,
1935 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1936 struct cmd_tx_vlan_reset_result {
1937 cmdline_fixed_string_t tx_vlan;
1938 cmdline_fixed_string_t reset;
1943 cmd_tx_vlan_reset_parsed(void *parsed_result,
1944 __attribute__((unused)) struct cmdline *cl,
1945 __attribute__((unused)) void *data)
1947 struct cmd_tx_vlan_reset_result *res = parsed_result;
1949 tx_vlan_reset(res->port_id);
1952 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
1953 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1954 tx_vlan, "tx_vlan");
1955 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
1956 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1958 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
1959 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
1962 cmdline_parse_inst_t cmd_tx_vlan_reset = {
1963 .f = cmd_tx_vlan_reset_parsed,
1965 .help_str = "disable hardware insertion of a VLAN header in packets "
1968 (void *)&cmd_tx_vlan_reset_tx_vlan,
1969 (void *)&cmd_tx_vlan_reset_reset,
1970 (void *)&cmd_tx_vlan_reset_portid,
1976 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
1977 struct cmd_tx_cksum_set_result {
1978 cmdline_fixed_string_t tx_cksum;
1979 cmdline_fixed_string_t set;
1985 cmd_tx_cksum_set_parsed(void *parsed_result,
1986 __attribute__((unused)) struct cmdline *cl,
1987 __attribute__((unused)) void *data)
1989 struct cmd_tx_cksum_set_result *res = parsed_result;
1991 tx_cksum_set(res->port_id, res->cksum_mask);
1994 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
1995 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1996 tx_cksum, "tx_checksum");
1997 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
1998 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2000 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2001 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2003 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2004 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2007 cmdline_parse_inst_t cmd_tx_cksum_set = {
2008 .f = cmd_tx_cksum_set_parsed,
2010 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2011 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2012 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2014 (void *)&cmd_tx_cksum_set_tx_cksum,
2015 (void *)&cmd_tx_cksum_set_set,
2016 (void *)&cmd_tx_cksum_set_cksum_mask,
2017 (void *)&cmd_tx_cksum_set_portid,
2022 /* *** SET FORWARDING MODE *** */
2023 struct cmd_set_fwd_mode_result {
2024 cmdline_fixed_string_t set;
2025 cmdline_fixed_string_t fwd;
2026 cmdline_fixed_string_t mode;
2029 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2030 __attribute__((unused)) struct cmdline *cl,
2031 __attribute__((unused)) void *data)
2033 struct cmd_set_fwd_mode_result *res = parsed_result;
2035 set_pkt_forwarding_mode(res->mode);
2038 cmdline_parse_token_string_t cmd_setfwd_set =
2039 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2040 cmdline_parse_token_string_t cmd_setfwd_fwd =
2041 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2042 cmdline_parse_token_string_t cmd_setfwd_mode =
2043 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2044 #ifdef RTE_LIBRTE_IEEE1588
2045 "io#mac#rxonly#txonly#csum#ieee1588");
2047 "io#mac#rxonly#txonly#csum");
2050 cmdline_parse_inst_t cmd_set_fwd_mode = {
2051 .f = cmd_set_fwd_mode_parsed,
2053 #ifdef RTE_LIBRTE_IEEE1588
2054 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2055 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2057 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2058 " RXONLY, CSUM or TXONLY packet forwarding mode",
2061 (void *)&cmd_setfwd_set,
2062 (void *)&cmd_setfwd_fwd,
2063 (void *)&cmd_setfwd_mode,
2068 /* *** SET PROMISC MODE *** */
2069 struct cmd_set_promisc_mode_result {
2070 cmdline_fixed_string_t set;
2071 cmdline_fixed_string_t promisc;
2072 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2073 uint8_t port_num; /* valid if "allports" argument == 0 */
2074 cmdline_fixed_string_t mode;
2077 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2078 __attribute__((unused)) struct cmdline *cl,
2081 struct cmd_set_promisc_mode_result *res = parsed_result;
2085 if (!strcmp(res->mode, "on"))
2092 for (i = 0; i < nb_ports; i++) {
2094 rte_eth_promiscuous_enable(i);
2096 rte_eth_promiscuous_disable(i);
2101 rte_eth_promiscuous_enable(res->port_num);
2103 rte_eth_promiscuous_disable(res->port_num);
2107 cmdline_parse_token_string_t cmd_setpromisc_set =
2108 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2109 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2110 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2112 cmdline_parse_token_string_t cmd_setpromisc_portall =
2113 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2115 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2116 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2118 cmdline_parse_token_string_t cmd_setpromisc_mode =
2119 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2122 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2123 .f = cmd_set_promisc_mode_parsed,
2125 .help_str = "set promisc all on|off: set promisc mode for all ports",
2127 (void *)&cmd_setpromisc_set,
2128 (void *)&cmd_setpromisc_promisc,
2129 (void *)&cmd_setpromisc_portall,
2130 (void *)&cmd_setpromisc_mode,
2135 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2136 .f = cmd_set_promisc_mode_parsed,
2138 .help_str = "set promisc X on|off: set promisc mode on port X",
2140 (void *)&cmd_setpromisc_set,
2141 (void *)&cmd_setpromisc_promisc,
2142 (void *)&cmd_setpromisc_portnum,
2143 (void *)&cmd_setpromisc_mode,
2148 /* *** SET ALLMULTI MODE *** */
2149 struct cmd_set_allmulti_mode_result {
2150 cmdline_fixed_string_t set;
2151 cmdline_fixed_string_t allmulti;
2152 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2153 uint8_t port_num; /* valid if "allports" argument == 0 */
2154 cmdline_fixed_string_t mode;
2157 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2158 __attribute__((unused)) struct cmdline *cl,
2161 struct cmd_set_allmulti_mode_result *res = parsed_result;
2165 if (!strcmp(res->mode, "on"))
2172 for (i = 0; i < nb_ports; i++) {
2174 rte_eth_allmulticast_enable(i);
2176 rte_eth_allmulticast_disable(i);
2181 rte_eth_allmulticast_enable(res->port_num);
2183 rte_eth_allmulticast_disable(res->port_num);
2187 cmdline_parse_token_string_t cmd_setallmulti_set =
2188 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2189 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2190 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2192 cmdline_parse_token_string_t cmd_setallmulti_portall =
2193 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2195 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2196 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2198 cmdline_parse_token_string_t cmd_setallmulti_mode =
2199 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2202 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2203 .f = cmd_set_allmulti_mode_parsed,
2205 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2207 (void *)&cmd_setallmulti_set,
2208 (void *)&cmd_setallmulti_allmulti,
2209 (void *)&cmd_setallmulti_portall,
2210 (void *)&cmd_setallmulti_mode,
2215 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2216 .f = cmd_set_allmulti_mode_parsed,
2218 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2220 (void *)&cmd_setallmulti_set,
2221 (void *)&cmd_setallmulti_allmulti,
2222 (void *)&cmd_setallmulti_portnum,
2223 (void *)&cmd_setallmulti_mode,
2228 /* *** ADD/REMOVE A PKT FILTER *** */
2229 struct cmd_pkt_filter_result {
2230 cmdline_fixed_string_t pkt_filter;
2232 cmdline_fixed_string_t protocol;
2233 cmdline_fixed_string_t src;
2234 cmdline_ipaddr_t ip_src;
2236 cmdline_fixed_string_t dst;
2237 cmdline_ipaddr_t ip_dst;
2239 cmdline_fixed_string_t flexbytes;
2240 uint16_t flexbytes_value;
2241 cmdline_fixed_string_t vlan;
2243 cmdline_fixed_string_t queue;
2245 cmdline_fixed_string_t soft;
2250 cmd_pkt_filter_parsed(void *parsed_result,
2251 __attribute__((unused)) struct cmdline *cl,
2252 __attribute__((unused)) void *data)
2254 struct rte_fdir_filter fdir_filter;
2255 struct cmd_pkt_filter_result *res = parsed_result;
2257 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2259 if (res->ip_src.family == AF_INET)
2260 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2262 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2263 &(res->ip_src.addr.ipv6),
2264 sizeof(struct in6_addr));
2266 if (res->ip_dst.family == AF_INET)
2267 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2269 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2270 &(res->ip_dst.addr.ipv6),
2271 sizeof(struct in6_addr));
2273 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2274 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2276 if (!strcmp(res->protocol, "udp"))
2277 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2278 else if (!strcmp(res->protocol, "tcp"))
2279 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2280 else if (!strcmp(res->protocol, "sctp"))
2281 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2282 else /* default only IP */
2283 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2285 if (res->ip_dst.family == AF_INET6)
2286 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2288 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2290 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2291 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2293 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2294 fdir_add_signature_filter(res->port_id, res->queue_id,
2296 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2297 fdir_update_signature_filter(res->port_id, res->queue_id,
2299 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2300 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2301 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2302 fdir_add_perfect_filter(res->port_id, res->soft_id,
2304 (uint8_t) (res->queue_id < 0),
2306 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2307 fdir_update_perfect_filter(res->port_id, res->soft_id,
2309 (uint8_t) (res->queue_id < 0),
2311 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2312 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2318 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2319 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2321 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2322 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2323 protocol, "ip#tcp#udp#sctp");
2324 cmdline_parse_token_string_t cmd_pkt_filter_src =
2325 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2327 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2328 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2330 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2331 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2333 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2334 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2336 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2337 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2339 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2340 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2342 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2343 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2344 flexbytes, "flexbytes");
2345 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2346 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2347 flexbytes_value, UINT16);
2348 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2349 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2351 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2352 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2354 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2355 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2357 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2358 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2360 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2361 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2363 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2364 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2368 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2369 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2370 pkt_filter, "add_signature_filter");
2371 cmdline_parse_inst_t cmd_add_signature_filter = {
2372 .f = cmd_pkt_filter_parsed,
2374 .help_str = "add a signature filter",
2376 (void *)&cmd_pkt_filter_add_signature_filter,
2377 (void *)&cmd_pkt_filter_port_id,
2378 (void *)&cmd_pkt_filter_protocol,
2379 (void *)&cmd_pkt_filter_src,
2380 (void *)&cmd_pkt_filter_ip_src,
2381 (void *)&cmd_pkt_filter_port_src,
2382 (void *)&cmd_pkt_filter_dst,
2383 (void *)&cmd_pkt_filter_ip_dst,
2384 (void *)&cmd_pkt_filter_port_dst,
2385 (void *)&cmd_pkt_filter_flexbytes,
2386 (void *)&cmd_pkt_filter_flexbytes_value,
2387 (void *)&cmd_pkt_filter_vlan,
2388 (void *)&cmd_pkt_filter_vlan_id,
2389 (void *)&cmd_pkt_filter_queue,
2390 (void *)&cmd_pkt_filter_queue_id,
2396 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2397 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2398 pkt_filter, "upd_signature_filter");
2399 cmdline_parse_inst_t cmd_upd_signature_filter = {
2400 .f = cmd_pkt_filter_parsed,
2402 .help_str = "update a signature filter",
2404 (void *)&cmd_pkt_filter_upd_signature_filter,
2405 (void *)&cmd_pkt_filter_port_id,
2406 (void *)&cmd_pkt_filter_protocol,
2407 (void *)&cmd_pkt_filter_src,
2408 (void *)&cmd_pkt_filter_ip_src,
2409 (void *)&cmd_pkt_filter_port_src,
2410 (void *)&cmd_pkt_filter_dst,
2411 (void *)&cmd_pkt_filter_ip_dst,
2412 (void *)&cmd_pkt_filter_port_dst,
2413 (void *)&cmd_pkt_filter_flexbytes,
2414 (void *)&cmd_pkt_filter_flexbytes_value,
2415 (void *)&cmd_pkt_filter_vlan,
2416 (void *)&cmd_pkt_filter_vlan_id,
2417 (void *)&cmd_pkt_filter_queue,
2418 (void *)&cmd_pkt_filter_queue_id,
2424 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2425 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2426 pkt_filter, "rm_signature_filter");
2427 cmdline_parse_inst_t cmd_rm_signature_filter = {
2428 .f = cmd_pkt_filter_parsed,
2430 .help_str = "remove a signature filter",
2432 (void *)&cmd_pkt_filter_rm_signature_filter,
2433 (void *)&cmd_pkt_filter_port_id,
2434 (void *)&cmd_pkt_filter_protocol,
2435 (void *)&cmd_pkt_filter_src,
2436 (void *)&cmd_pkt_filter_ip_src,
2437 (void *)&cmd_pkt_filter_port_src,
2438 (void *)&cmd_pkt_filter_dst,
2439 (void *)&cmd_pkt_filter_ip_dst,
2440 (void *)&cmd_pkt_filter_port_dst,
2441 (void *)&cmd_pkt_filter_flexbytes,
2442 (void *)&cmd_pkt_filter_flexbytes_value,
2443 (void *)&cmd_pkt_filter_vlan,
2444 (void *)&cmd_pkt_filter_vlan_id,
2450 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2451 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2452 pkt_filter, "add_perfect_filter");
2453 cmdline_parse_inst_t cmd_add_perfect_filter = {
2454 .f = cmd_pkt_filter_parsed,
2456 .help_str = "add a perfect filter",
2458 (void *)&cmd_pkt_filter_add_perfect_filter,
2459 (void *)&cmd_pkt_filter_port_id,
2460 (void *)&cmd_pkt_filter_protocol,
2461 (void *)&cmd_pkt_filter_src,
2462 (void *)&cmd_pkt_filter_ip_src,
2463 (void *)&cmd_pkt_filter_port_src,
2464 (void *)&cmd_pkt_filter_dst,
2465 (void *)&cmd_pkt_filter_ip_dst,
2466 (void *)&cmd_pkt_filter_port_dst,
2467 (void *)&cmd_pkt_filter_flexbytes,
2468 (void *)&cmd_pkt_filter_flexbytes_value,
2469 (void *)&cmd_pkt_filter_vlan,
2470 (void *)&cmd_pkt_filter_vlan_id,
2471 (void *)&cmd_pkt_filter_queue,
2472 (void *)&cmd_pkt_filter_queue_id,
2473 (void *)&cmd_pkt_filter_soft,
2474 (void *)&cmd_pkt_filter_soft_id,
2480 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2481 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2482 pkt_filter, "upd_perfect_filter");
2483 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2484 .f = cmd_pkt_filter_parsed,
2486 .help_str = "update a perfect filter",
2488 (void *)&cmd_pkt_filter_upd_perfect_filter,
2489 (void *)&cmd_pkt_filter_port_id,
2490 (void *)&cmd_pkt_filter_protocol,
2491 (void *)&cmd_pkt_filter_src,
2492 (void *)&cmd_pkt_filter_ip_src,
2493 (void *)&cmd_pkt_filter_port_src,
2494 (void *)&cmd_pkt_filter_dst,
2495 (void *)&cmd_pkt_filter_ip_dst,
2496 (void *)&cmd_pkt_filter_port_dst,
2497 (void *)&cmd_pkt_filter_flexbytes,
2498 (void *)&cmd_pkt_filter_flexbytes_value,
2499 (void *)&cmd_pkt_filter_vlan,
2500 (void *)&cmd_pkt_filter_vlan_id,
2501 (void *)&cmd_pkt_filter_queue,
2502 (void *)&cmd_pkt_filter_queue_id,
2503 (void *)&cmd_pkt_filter_soft,
2504 (void *)&cmd_pkt_filter_soft_id,
2510 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2511 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2512 pkt_filter, "rm_perfect_filter");
2513 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2514 .f = cmd_pkt_filter_parsed,
2516 .help_str = "remove a perfect filter",
2518 (void *)&cmd_pkt_filter_rm_perfect_filter,
2519 (void *)&cmd_pkt_filter_port_id,
2520 (void *)&cmd_pkt_filter_protocol,
2521 (void *)&cmd_pkt_filter_src,
2522 (void *)&cmd_pkt_filter_ip_src,
2523 (void *)&cmd_pkt_filter_port_src,
2524 (void *)&cmd_pkt_filter_dst,
2525 (void *)&cmd_pkt_filter_ip_dst,
2526 (void *)&cmd_pkt_filter_port_dst,
2527 (void *)&cmd_pkt_filter_flexbytes,
2528 (void *)&cmd_pkt_filter_flexbytes_value,
2529 (void *)&cmd_pkt_filter_vlan,
2530 (void *)&cmd_pkt_filter_vlan_id,
2531 (void *)&cmd_pkt_filter_soft,
2532 (void *)&cmd_pkt_filter_soft_id,
2537 /* *** SETUP MASKS FILTER *** */
2538 struct cmd_pkt_filter_masks_result {
2539 cmdline_fixed_string_t filter_mask;
2541 cmdline_fixed_string_t src_mask;
2542 uint32_t ip_src_mask;
2543 uint16_t ipv6_src_mask;
2544 uint16_t port_src_mask;
2545 cmdline_fixed_string_t dst_mask;
2546 uint32_t ip_dst_mask;
2547 uint16_t ipv6_dst_mask;
2548 uint16_t port_dst_mask;
2549 cmdline_fixed_string_t flexbytes;
2550 uint8_t flexbytes_value;
2551 cmdline_fixed_string_t vlan_id;
2552 uint8_t vlan_id_value;
2553 cmdline_fixed_string_t vlan_prio;
2554 uint8_t vlan_prio_value;
2555 cmdline_fixed_string_t only_ip_flow;
2556 uint8_t only_ip_flow_value;
2557 cmdline_fixed_string_t comp_ipv6_dst;
2558 uint8_t comp_ipv6_dst_value;
2562 cmd_pkt_filter_masks_parsed(void *parsed_result,
2563 __attribute__((unused)) struct cmdline *cl,
2564 __attribute__((unused)) void *data)
2566 struct rte_fdir_masks fdir_masks;
2567 struct cmd_pkt_filter_masks_result *res = parsed_result;
2569 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2571 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2572 fdir_masks.vlan_id = res->vlan_id_value;
2573 fdir_masks.vlan_prio = res->vlan_prio_value;
2574 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2575 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2576 fdir_masks.src_port_mask = res->port_src_mask;
2577 fdir_masks.dst_port_mask = res->port_dst_mask;
2578 fdir_masks.flexbytes = res->flexbytes_value;
2580 fdir_set_masks(res->port_id, &fdir_masks);
2583 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2584 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2585 filter_mask, "set_masks_filter");
2586 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2587 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2589 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2590 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2591 only_ip_flow, "only_ip_flow");
2592 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2593 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2594 only_ip_flow_value, UINT8);
2595 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2596 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2597 src_mask, "src_mask");
2598 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2599 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2600 ip_src_mask, UINT32);
2601 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2602 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2603 port_src_mask, UINT16);
2604 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2605 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2606 dst_mask, "dst_mask");
2607 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2608 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2609 ip_dst_mask, UINT32);
2610 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2611 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2612 port_dst_mask, UINT16);
2613 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2614 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2615 flexbytes, "flexbytes");
2616 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2617 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2618 flexbytes_value, UINT8);
2619 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2620 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2621 vlan_id, "vlan_id");
2622 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2623 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2624 vlan_id_value, UINT8);
2625 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2626 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2627 vlan_prio, "vlan_prio");
2628 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2629 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2630 vlan_prio_value, UINT8);
2632 cmdline_parse_inst_t cmd_set_masks_filter = {
2633 .f = cmd_pkt_filter_masks_parsed,
2635 .help_str = "setup masks filter",
2637 (void *)&cmd_pkt_filter_masks_filter_mask,
2638 (void *)&cmd_pkt_filter_masks_port_id,
2639 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2640 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2641 (void *)&cmd_pkt_filter_masks_src_mask,
2642 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2643 (void *)&cmd_pkt_filter_masks_port_src_mask,
2644 (void *)&cmd_pkt_filter_masks_dst_mask,
2645 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2646 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2647 (void *)&cmd_pkt_filter_masks_flexbytes,
2648 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2649 (void *)&cmd_pkt_filter_masks_vlan_id,
2650 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2651 (void *)&cmd_pkt_filter_masks_vlan_prio,
2652 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2658 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2659 __attribute__((unused)) struct cmdline *cl,
2660 __attribute__((unused)) void *data)
2662 struct rte_fdir_masks fdir_masks;
2663 struct cmd_pkt_filter_masks_result *res = parsed_result;
2665 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2667 fdir_masks.set_ipv6_mask = 1;
2668 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2669 fdir_masks.vlan_id = res->vlan_id_value;
2670 fdir_masks.vlan_prio = res->vlan_prio_value;
2671 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2672 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2673 fdir_masks.src_port_mask = res->port_src_mask;
2674 fdir_masks.dst_port_mask = res->port_dst_mask;
2675 fdir_masks.flexbytes = res->flexbytes_value;
2676 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2678 fdir_set_masks(res->port_id, &fdir_masks);
2681 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2682 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2683 filter_mask, "set_ipv6_masks_filter");
2684 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2685 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2686 ipv6_src_mask, UINT16);
2687 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2688 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2689 ipv6_dst_mask, UINT16);
2691 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2692 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2693 comp_ipv6_dst, "compare_dst");
2694 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2695 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2696 comp_ipv6_dst_value, UINT8);
2698 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2699 .f = cmd_pkt_filter_masks_ipv6_parsed,
2701 .help_str = "setup ipv6 masks filter",
2703 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2704 (void *)&cmd_pkt_filter_masks_port_id,
2705 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2706 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2707 (void *)&cmd_pkt_filter_masks_src_mask,
2708 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2709 (void *)&cmd_pkt_filter_masks_port_src_mask,
2710 (void *)&cmd_pkt_filter_masks_dst_mask,
2711 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2712 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2713 (void *)&cmd_pkt_filter_masks_flexbytes,
2714 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2715 (void *)&cmd_pkt_filter_masks_vlan_id,
2716 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2717 (void *)&cmd_pkt_filter_masks_vlan_prio,
2718 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2719 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2720 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2725 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2726 struct cmd_link_flow_ctrl_set_result {
2727 cmdline_fixed_string_t set;
2728 cmdline_fixed_string_t flow_ctrl;
2729 cmdline_fixed_string_t rx;
2730 cmdline_fixed_string_t rx_lfc_mode;
2731 cmdline_fixed_string_t tx;
2732 cmdline_fixed_string_t tx_lfc_mode;
2733 uint32_t high_water;
2735 uint16_t pause_time;
2741 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2742 __attribute__((unused)) struct cmdline *cl,
2743 __attribute__((unused)) void *data)
2745 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2746 struct rte_eth_fc_conf fc_conf;
2747 int rx_fc_enable, tx_fc_enable;
2751 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2752 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2753 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2754 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2756 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2757 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2760 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2761 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2763 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2764 fc_conf.high_water = res->high_water;
2765 fc_conf.low_water = res->low_water;
2766 fc_conf.pause_time = res->pause_time;
2767 fc_conf.send_xon = res->send_xon;
2769 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2771 printf("bad flow contrl parameter, return code = %d \n", ret);
2774 cmdline_parse_token_string_t cmd_lfc_set_set =
2775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2777 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2779 flow_ctrl, "flow_ctrl");
2780 cmdline_parse_token_string_t cmd_lfc_set_rx =
2781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2783 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2785 rx_lfc_mode, "on#off");
2786 cmdline_parse_token_string_t cmd_lfc_set_tx =
2787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2789 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2790 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2791 tx_lfc_mode, "on#off");
2792 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2793 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2794 high_water, UINT32);
2795 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2798 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2799 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2800 pause_time, UINT16);
2801 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2804 cmdline_parse_token_num_t cmd_lfc_set_portid =
2805 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2808 cmdline_parse_inst_t cmd_link_flow_control_set = {
2809 .f = cmd_link_flow_ctrl_set_parsed,
2811 .help_str = "Configure the Ethernet link flow control...",
2813 (void *)&cmd_lfc_set_set,
2814 (void *)&cmd_lfc_set_flow_ctrl,
2815 (void *)&cmd_lfc_set_rx,
2816 (void *)&cmd_lfc_set_rx_mode,
2817 (void *)&cmd_lfc_set_tx,
2818 (void *)&cmd_lfc_set_tx_mode,
2819 (void *)&cmd_lfc_set_high_water,
2820 (void *)&cmd_lfc_set_low_water,
2821 (void *)&cmd_lfc_set_pause_time,
2822 (void *)&cmd_lfc_set_send_xon,
2823 (void *)&cmd_lfc_set_portid,
2828 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
2829 struct cmd_priority_flow_ctrl_set_result {
2830 cmdline_fixed_string_t set;
2831 cmdline_fixed_string_t pfc_ctrl;
2832 cmdline_fixed_string_t rx;
2833 cmdline_fixed_string_t rx_pfc_mode;
2834 cmdline_fixed_string_t tx;
2835 cmdline_fixed_string_t tx_pfc_mode;
2836 uint32_t high_water;
2838 uint16_t pause_time;
2844 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
2845 __attribute__((unused)) struct cmdline *cl,
2846 __attribute__((unused)) void *data)
2848 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
2849 struct rte_eth_pfc_conf pfc_conf;
2850 int rx_fc_enable, tx_fc_enable;
2854 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2855 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2856 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2857 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2859 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
2860 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2863 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
2864 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
2865 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
2866 pfc_conf.fc.high_water = res->high_water;
2867 pfc_conf.fc.low_water = res->low_water;
2868 pfc_conf.fc.pause_time = res->pause_time;
2869 pfc_conf.priority = res->priority;
2871 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
2873 printf("bad priority flow contrl parameter, return code = %d \n", ret);
2876 cmdline_parse_token_string_t cmd_pfc_set_set =
2877 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2879 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
2880 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2881 pfc_ctrl, "pfc_ctrl");
2882 cmdline_parse_token_string_t cmd_pfc_set_rx =
2883 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2885 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
2886 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2887 rx_pfc_mode, "on#off");
2888 cmdline_parse_token_string_t cmd_pfc_set_tx =
2889 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2891 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
2892 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2893 tx_pfc_mode, "on#off");
2894 cmdline_parse_token_num_t cmd_pfc_set_high_water =
2895 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2896 high_water, UINT32);
2897 cmdline_parse_token_num_t cmd_pfc_set_low_water =
2898 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2900 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
2901 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2902 pause_time, UINT16);
2903 cmdline_parse_token_num_t cmd_pfc_set_priority =
2904 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2906 cmdline_parse_token_num_t cmd_pfc_set_portid =
2907 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
2910 cmdline_parse_inst_t cmd_priority_flow_control_set = {
2911 .f = cmd_priority_flow_ctrl_set_parsed,
2913 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
2914 tx on|off high_water low_water pause_time priority port_id",
2916 (void *)&cmd_pfc_set_set,
2917 (void *)&cmd_pfc_set_flow_ctrl,
2918 (void *)&cmd_pfc_set_rx,
2919 (void *)&cmd_pfc_set_rx_mode,
2920 (void *)&cmd_pfc_set_tx,
2921 (void *)&cmd_pfc_set_tx_mode,
2922 (void *)&cmd_pfc_set_high_water,
2923 (void *)&cmd_pfc_set_low_water,
2924 (void *)&cmd_pfc_set_pause_time,
2925 (void *)&cmd_pfc_set_priority,
2926 (void *)&cmd_pfc_set_portid,
2931 /* *** RESET CONFIGURATION *** */
2932 struct cmd_reset_result {
2933 cmdline_fixed_string_t reset;
2934 cmdline_fixed_string_t def;
2937 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
2939 __attribute__((unused)) void *data)
2941 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
2942 set_def_fwd_config();
2945 cmdline_parse_token_string_t cmd_reset_set =
2946 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
2947 cmdline_parse_token_string_t cmd_reset_def =
2948 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
2951 cmdline_parse_inst_t cmd_reset = {
2952 .f = cmd_reset_parsed,
2954 .help_str = "set default: reset default forwarding configuration",
2956 (void *)&cmd_reset_set,
2957 (void *)&cmd_reset_def,
2962 /* *** START FORWARDING *** */
2963 struct cmd_start_result {
2964 cmdline_fixed_string_t start;
2967 cmdline_parse_token_string_t cmd_start_start =
2968 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
2970 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
2971 __attribute__((unused)) struct cmdline *cl,
2972 __attribute__((unused)) void *data)
2974 start_packet_forwarding(0);
2977 cmdline_parse_inst_t cmd_start = {
2978 .f = cmd_start_parsed,
2980 .help_str = "start packet forwarding",
2982 (void *)&cmd_start_start,
2987 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
2988 struct cmd_start_tx_first_result {
2989 cmdline_fixed_string_t start;
2990 cmdline_fixed_string_t tx_first;
2994 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
2995 __attribute__((unused)) struct cmdline *cl,
2996 __attribute__((unused)) void *data)
2998 start_packet_forwarding(1);
3001 cmdline_parse_token_string_t cmd_start_tx_first_start =
3002 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3004 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3005 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3006 tx_first, "tx_first");
3008 cmdline_parse_inst_t cmd_start_tx_first = {
3009 .f = cmd_start_tx_first_parsed,
3011 .help_str = "start packet forwarding, after sending 1 burst of packets",
3013 (void *)&cmd_start_tx_first_start,
3014 (void *)&cmd_start_tx_first_tx_first,
3019 /* *** SHOW CFG *** */
3020 struct cmd_showcfg_result {
3021 cmdline_fixed_string_t show;
3022 cmdline_fixed_string_t cfg;
3023 cmdline_fixed_string_t what;
3026 static void cmd_showcfg_parsed(void *parsed_result,
3027 __attribute__((unused)) struct cmdline *cl,
3028 __attribute__((unused)) void *data)
3030 struct cmd_showcfg_result *res = parsed_result;
3031 if (!strcmp(res->what, "rxtx"))
3032 rxtx_config_display();
3033 else if (!strcmp(res->what, "cores"))
3034 fwd_lcores_config_display();
3035 else if (!strcmp(res->what, "fwd"))
3036 fwd_config_display();
3039 cmdline_parse_token_string_t cmd_showcfg_show =
3040 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3041 cmdline_parse_token_string_t cmd_showcfg_port =
3042 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3043 cmdline_parse_token_string_t cmd_showcfg_what =
3044 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3047 cmdline_parse_inst_t cmd_showcfg = {
3048 .f = cmd_showcfg_parsed,
3050 .help_str = "show config rxtx|cores|fwd",
3052 (void *)&cmd_showcfg_show,
3053 (void *)&cmd_showcfg_port,
3054 (void *)&cmd_showcfg_what,
3059 /* *** SHOW ALL PORT INFO *** */
3060 struct cmd_showportall_result {
3061 cmdline_fixed_string_t show;
3062 cmdline_fixed_string_t port;
3063 cmdline_fixed_string_t what;
3064 cmdline_fixed_string_t all;
3067 static void cmd_showportall_parsed(void *parsed_result,
3068 __attribute__((unused)) struct cmdline *cl,
3069 __attribute__((unused)) void *data)
3073 struct cmd_showportall_result *res = parsed_result;
3074 if (!strcmp(res->show, "clear")) {
3075 if (!strcmp(res->what, "stats"))
3076 for (i = 0; i < nb_ports; i++)
3078 } else if (!strcmp(res->what, "info"))
3079 for (i = 0; i < nb_ports; i++)
3080 port_infos_display(i);
3081 else if (!strcmp(res->what, "stats"))
3082 for (i = 0; i < nb_ports; i++)
3083 nic_stats_display(i);
3084 else if (!strcmp(res->what, "fdir"))
3085 for (i = 0; i < nb_ports; i++)
3087 else if (!strcmp(res->what, "stat_qmap"))
3088 for (i = 0; i < nb_ports; i++)
3089 nic_stats_mapping_display(i);
3092 cmdline_parse_token_string_t cmd_showportall_show =
3093 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3095 cmdline_parse_token_string_t cmd_showportall_port =
3096 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3097 cmdline_parse_token_string_t cmd_showportall_what =
3098 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3099 "info#stats#fdir#stat_qmap");
3100 cmdline_parse_token_string_t cmd_showportall_all =
3101 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3102 cmdline_parse_inst_t cmd_showportall = {
3103 .f = cmd_showportall_parsed,
3105 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3107 (void *)&cmd_showportall_show,
3108 (void *)&cmd_showportall_port,
3109 (void *)&cmd_showportall_what,
3110 (void *)&cmd_showportall_all,
3115 /* *** SHOW PORT INFO *** */
3116 struct cmd_showport_result {
3117 cmdline_fixed_string_t show;
3118 cmdline_fixed_string_t port;
3119 cmdline_fixed_string_t what;
3123 static void cmd_showport_parsed(void *parsed_result,
3124 __attribute__((unused)) struct cmdline *cl,
3125 __attribute__((unused)) void *data)
3127 struct cmd_showport_result *res = parsed_result;
3128 if (!strcmp(res->show, "clear")) {
3129 if (!strcmp(res->what, "stats"))
3130 nic_stats_clear(res->portnum);
3131 } else if (!strcmp(res->what, "info"))
3132 port_infos_display(res->portnum);
3133 else if (!strcmp(res->what, "stats"))
3134 nic_stats_display(res->portnum);
3135 else if (!strcmp(res->what, "fdir"))
3136 fdir_get_infos(res->portnum);
3137 else if (!strcmp(res->what, "stat_qmap"))
3138 nic_stats_mapping_display(res->portnum);
3141 cmdline_parse_token_string_t cmd_showport_show =
3142 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3144 cmdline_parse_token_string_t cmd_showport_port =
3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3146 cmdline_parse_token_string_t cmd_showport_what =
3147 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3148 "info#stats#fdir#stat_qmap");
3149 cmdline_parse_token_num_t cmd_showport_portnum =
3150 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3152 cmdline_parse_inst_t cmd_showport = {
3153 .f = cmd_showport_parsed,
3155 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3157 (void *)&cmd_showport_show,
3158 (void *)&cmd_showport_port,
3159 (void *)&cmd_showport_what,
3160 (void *)&cmd_showport_portnum,
3165 /* *** READ PORT REGISTER *** */
3166 struct cmd_read_reg_result {
3167 cmdline_fixed_string_t read;
3168 cmdline_fixed_string_t reg;
3174 cmd_read_reg_parsed(void *parsed_result,
3175 __attribute__((unused)) struct cmdline *cl,
3176 __attribute__((unused)) void *data)
3178 struct cmd_read_reg_result *res = parsed_result;
3179 port_reg_display(res->port_id, res->reg_off);
3182 cmdline_parse_token_string_t cmd_read_reg_read =
3183 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3184 cmdline_parse_token_string_t cmd_read_reg_reg =
3185 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3186 cmdline_parse_token_num_t cmd_read_reg_port_id =
3187 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3188 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3189 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3191 cmdline_parse_inst_t cmd_read_reg = {
3192 .f = cmd_read_reg_parsed,
3194 .help_str = "read reg port_id reg_off",
3196 (void *)&cmd_read_reg_read,
3197 (void *)&cmd_read_reg_reg,
3198 (void *)&cmd_read_reg_port_id,
3199 (void *)&cmd_read_reg_reg_off,
3204 /* *** READ PORT REGISTER BIT FIELD *** */
3205 struct cmd_read_reg_bit_field_result {
3206 cmdline_fixed_string_t read;
3207 cmdline_fixed_string_t regfield;
3215 cmd_read_reg_bit_field_parsed(void *parsed_result,
3216 __attribute__((unused)) struct cmdline *cl,
3217 __attribute__((unused)) void *data)
3219 struct cmd_read_reg_bit_field_result *res = parsed_result;
3220 port_reg_bit_field_display(res->port_id, res->reg_off,
3221 res->bit1_pos, res->bit2_pos);
3224 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3225 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3227 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3228 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3229 regfield, "regfield");
3230 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3231 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3233 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3234 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3236 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3237 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3239 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3240 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3243 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3244 .f = cmd_read_reg_bit_field_parsed,
3246 .help_str = "read regfield port_id reg_off bit_x bit_y "
3247 "(read register bit field between bit_x and bit_y included)",
3249 (void *)&cmd_read_reg_bit_field_read,
3250 (void *)&cmd_read_reg_bit_field_regfield,
3251 (void *)&cmd_read_reg_bit_field_port_id,
3252 (void *)&cmd_read_reg_bit_field_reg_off,
3253 (void *)&cmd_read_reg_bit_field_bit1_pos,
3254 (void *)&cmd_read_reg_bit_field_bit2_pos,
3259 /* *** READ PORT REGISTER BIT *** */
3260 struct cmd_read_reg_bit_result {
3261 cmdline_fixed_string_t read;
3262 cmdline_fixed_string_t regbit;
3269 cmd_read_reg_bit_parsed(void *parsed_result,
3270 __attribute__((unused)) struct cmdline *cl,
3271 __attribute__((unused)) void *data)
3273 struct cmd_read_reg_bit_result *res = parsed_result;
3274 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3277 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3278 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3279 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3280 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3282 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3283 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3284 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3285 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3286 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3287 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3289 cmdline_parse_inst_t cmd_read_reg_bit = {
3290 .f = cmd_read_reg_bit_parsed,
3292 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3294 (void *)&cmd_read_reg_bit_read,
3295 (void *)&cmd_read_reg_bit_regbit,
3296 (void *)&cmd_read_reg_bit_port_id,
3297 (void *)&cmd_read_reg_bit_reg_off,
3298 (void *)&cmd_read_reg_bit_bit_pos,
3303 /* *** WRITE PORT REGISTER *** */
3304 struct cmd_write_reg_result {
3305 cmdline_fixed_string_t write;
3306 cmdline_fixed_string_t reg;
3313 cmd_write_reg_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_write_reg_result *res = parsed_result;
3318 port_reg_set(res->port_id, res->reg_off, res->value);
3321 cmdline_parse_token_string_t cmd_write_reg_write =
3322 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3323 cmdline_parse_token_string_t cmd_write_reg_reg =
3324 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3325 cmdline_parse_token_num_t cmd_write_reg_port_id =
3326 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3327 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3328 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3329 cmdline_parse_token_num_t cmd_write_reg_value =
3330 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3332 cmdline_parse_inst_t cmd_write_reg = {
3333 .f = cmd_write_reg_parsed,
3335 .help_str = "write reg port_id reg_off reg_value",
3337 (void *)&cmd_write_reg_write,
3338 (void *)&cmd_write_reg_reg,
3339 (void *)&cmd_write_reg_port_id,
3340 (void *)&cmd_write_reg_reg_off,
3341 (void *)&cmd_write_reg_value,
3346 /* *** WRITE PORT REGISTER BIT FIELD *** */
3347 struct cmd_write_reg_bit_field_result {
3348 cmdline_fixed_string_t write;
3349 cmdline_fixed_string_t regfield;
3358 cmd_write_reg_bit_field_parsed(void *parsed_result,
3359 __attribute__((unused)) struct cmdline *cl,
3360 __attribute__((unused)) void *data)
3362 struct cmd_write_reg_bit_field_result *res = parsed_result;
3363 port_reg_bit_field_set(res->port_id, res->reg_off,
3364 res->bit1_pos, res->bit2_pos, res->value);
3367 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3368 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3370 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3371 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3372 regfield, "regfield");
3373 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3374 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3376 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3377 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3379 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3380 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3382 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3383 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3385 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3386 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3389 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3390 .f = cmd_write_reg_bit_field_parsed,
3392 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3393 "(set register bit field between bit_x and bit_y included)",
3395 (void *)&cmd_write_reg_bit_field_write,
3396 (void *)&cmd_write_reg_bit_field_regfield,
3397 (void *)&cmd_write_reg_bit_field_port_id,
3398 (void *)&cmd_write_reg_bit_field_reg_off,
3399 (void *)&cmd_write_reg_bit_field_bit1_pos,
3400 (void *)&cmd_write_reg_bit_field_bit2_pos,
3401 (void *)&cmd_write_reg_bit_field_value,
3406 /* *** WRITE PORT REGISTER BIT *** */
3407 struct cmd_write_reg_bit_result {
3408 cmdline_fixed_string_t write;
3409 cmdline_fixed_string_t regbit;
3417 cmd_write_reg_bit_parsed(void *parsed_result,
3418 __attribute__((unused)) struct cmdline *cl,
3419 __attribute__((unused)) void *data)
3421 struct cmd_write_reg_bit_result *res = parsed_result;
3422 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3425 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3426 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3428 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3429 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3431 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3432 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3433 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3434 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3435 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3437 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3438 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3440 cmdline_parse_inst_t cmd_write_reg_bit = {
3441 .f = cmd_write_reg_bit_parsed,
3443 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3445 (void *)&cmd_write_reg_bit_write,
3446 (void *)&cmd_write_reg_bit_regbit,
3447 (void *)&cmd_write_reg_bit_port_id,
3448 (void *)&cmd_write_reg_bit_reg_off,
3449 (void *)&cmd_write_reg_bit_bit_pos,
3450 (void *)&cmd_write_reg_bit_value,
3455 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3456 struct cmd_read_rxd_txd_result {
3457 cmdline_fixed_string_t read;
3458 cmdline_fixed_string_t rxd_txd;
3465 cmd_read_rxd_txd_parsed(void *parsed_result,
3466 __attribute__((unused)) struct cmdline *cl,
3467 __attribute__((unused)) void *data)
3469 struct cmd_read_rxd_txd_result *res = parsed_result;
3471 if (!strcmp(res->rxd_txd, "rxd"))
3472 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3473 else if (!strcmp(res->rxd_txd, "txd"))
3474 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3477 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3478 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3479 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3480 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3482 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3483 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3484 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3485 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3486 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3487 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3489 cmdline_parse_inst_t cmd_read_rxd_txd = {
3490 .f = cmd_read_rxd_txd_parsed,
3492 .help_str = "read rxd|txd port_id queue_id rxd_id",
3494 (void *)&cmd_read_rxd_txd_read,
3495 (void *)&cmd_read_rxd_txd_rxd_txd,
3496 (void *)&cmd_read_rxd_txd_port_id,
3497 (void *)&cmd_read_rxd_txd_queue_id,
3498 (void *)&cmd_read_rxd_txd_desc_id,
3504 struct cmd_quit_result {
3505 cmdline_fixed_string_t quit;
3508 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3510 __attribute__((unused)) void *data)
3516 cmdline_parse_token_string_t cmd_quit_quit =
3517 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3519 cmdline_parse_inst_t cmd_quit = {
3520 .f = cmd_quit_parsed,
3522 .help_str = "exit application",
3524 (void *)&cmd_quit_quit,
3529 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3530 struct cmd_mac_addr_result {
3531 cmdline_fixed_string_t mac_addr_cmd;
3532 cmdline_fixed_string_t what;
3534 struct ether_addr address;
3537 static void cmd_mac_addr_parsed(void *parsed_result,
3538 __attribute__((unused)) struct cmdline *cl,
3539 __attribute__((unused)) void *data)
3541 struct cmd_mac_addr_result *res = parsed_result;
3544 if (strcmp(res->what, "add") == 0)
3545 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3547 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3549 /* check the return value and print it if is < 0 */
3551 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3555 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3556 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3558 cmdline_parse_token_string_t cmd_mac_addr_what =
3559 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3561 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3562 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3563 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3566 cmdline_parse_inst_t cmd_mac_addr = {
3567 .f = cmd_mac_addr_parsed,
3569 .help_str = "mac_addr add|remove X <address>: "
3570 "add/remove MAC address on port X",
3572 (void *)&cmd_mac_addr_cmd,
3573 (void *)&cmd_mac_addr_what,
3574 (void *)&cmd_mac_addr_portnum,
3575 (void *)&cmd_mac_addr_addr,
3581 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3582 struct cmd_set_qmap_result {
3583 cmdline_fixed_string_t set;
3584 cmdline_fixed_string_t qmap;
3585 cmdline_fixed_string_t what;
3592 cmd_set_qmap_parsed(void *parsed_result,
3593 __attribute__((unused)) struct cmdline *cl,
3594 __attribute__((unused)) void *data)
3596 struct cmd_set_qmap_result *res = parsed_result;
3597 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3599 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3602 cmdline_parse_token_string_t cmd_setqmap_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3605 cmdline_parse_token_string_t cmd_setqmap_qmap =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3608 cmdline_parse_token_string_t cmd_setqmap_what =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3611 cmdline_parse_token_num_t cmd_setqmap_portid =
3612 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3614 cmdline_parse_token_num_t cmd_setqmap_queueid =
3615 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3617 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3618 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3621 cmdline_parse_inst_t cmd_set_qmap = {
3622 .f = cmd_set_qmap_parsed,
3624 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3626 (void *)&cmd_setqmap_set,
3627 (void *)&cmd_setqmap_qmap,
3628 (void *)&cmd_setqmap_what,
3629 (void *)&cmd_setqmap_portid,
3630 (void *)&cmd_setqmap_queueid,
3631 (void *)&cmd_setqmap_mapvalue,
3636 /* ******************************************************************************** */
3638 /* list of instructions */
3639 cmdline_parse_ctx_t main_ctx[] = {
3640 (cmdline_parse_inst_t *)&cmd_help_brief,
3641 (cmdline_parse_inst_t *)&cmd_help_long,
3642 (cmdline_parse_inst_t *)&cmd_quit,
3643 (cmdline_parse_inst_t *)&cmd_showport,
3644 (cmdline_parse_inst_t *)&cmd_showportall,
3645 (cmdline_parse_inst_t *)&cmd_showcfg,
3646 (cmdline_parse_inst_t *)&cmd_start,
3647 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3648 (cmdline_parse_inst_t *)&cmd_reset,
3649 (cmdline_parse_inst_t *)&cmd_set_numbers,
3650 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3651 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3652 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3653 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3654 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3655 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3656 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3657 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3658 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3659 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3660 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3661 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3662 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3663 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3664 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3666 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
3667 (cmdline_parse_inst_t *)&cmd_config_dcb,
3668 (cmdline_parse_inst_t *)&cmd_read_reg,
3669 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3670 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3671 (cmdline_parse_inst_t *)&cmd_write_reg,
3672 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3673 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3674 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3675 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3676 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3677 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3678 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3679 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3680 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3681 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3682 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3683 (cmdline_parse_inst_t *)&cmd_stop,
3684 (cmdline_parse_inst_t *)&cmd_mac_addr,
3685 (cmdline_parse_inst_t *)&cmd_set_qmap,
3686 (cmdline_parse_inst_t *)&cmd_operate_port,
3687 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3688 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3689 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3690 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3691 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3692 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3693 (cmdline_parse_inst_t *)&cmd_config_rss,
3694 (cmdline_parse_inst_t *)&cmd_config_burst,
3695 (cmdline_parse_inst_t *)&cmd_config_thresh,
3696 (cmdline_parse_inst_t *)&cmd_config_threshold,
3700 /* prompt function, called from main on MASTER lcore */
3706 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3710 cmdline_interact(cl);
3711 cmdline_stdin_exit(cl);
3715 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3717 if (id < nb_ports) {
3718 /* check if need_reconfig has been set to 1 */
3719 if (ports[id].need_reconfig == 0)
3720 ports[id].need_reconfig = dev;
3721 /* check if need_reconfig_queues has been set to 1 */
3722 if (ports[id].need_reconfig_queues == 0)
3723 ports[id].need_reconfig_queues = queue;
3727 for (pid = 0; pid < nb_ports; pid++) {
3728 /* check if need_reconfig has been set to 1 */
3729 if (ports[pid].need_reconfig == 0)
3730 ports[pid].need_reconfig = dev;
3731 /* check if need_reconfig_queues has been set to 1 */
3732 if (ports[pid].need_reconfig_queues == 0)
3733 ports[pid].need_reconfig_queues = queue;