4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <net/socket.h>
46 #include <netinet/in.h>
48 #include <sys/queue.h>
50 #include <rte_common.h>
51 #include <rte_byteorder.h>
53 #include <rte_debug.h>
54 #include <rte_cycles.h>
55 #include <rte_memory.h>
56 #include <rte_memzone.h>
57 #include <rte_launch.h>
58 #include <rte_tailq.h>
60 #include <rte_per_lcore.h>
61 #include <rte_lcore.h>
62 #include <rte_atomic.h>
63 #include <rte_branch_prediction.h>
65 #include <rte_mempool.h>
66 #include <rte_interrupts.h>
68 #include <rte_ether.h>
69 #include <rte_ethdev.h>
70 #include <rte_string_fns.h>
72 #include <cmdline_rdline.h>
73 #include <cmdline_parse.h>
74 #include <cmdline_parse_num.h>
75 #include <cmdline_parse_string.h>
76 #include <cmdline_parse_ipaddr.h>
77 #include <cmdline_parse_etheraddr.h>
78 #include <cmdline_socket.h>
83 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
85 /* *** Help command with introduction. *** */
86 struct cmd_help_brief_result {
87 cmdline_fixed_string_t help;
90 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
92 __attribute__((unused)) void *data)
97 "Help is available for the following sections:\n\n"
98 " help control : Start and stop forwarding.\n"
99 " help display : Displaying port, stats and config "
101 " help config : Configuration information.\n"
102 " help ports : Configuring ports.\n"
103 " help flowdir : Flow Director filter help.\n"
104 " help registers : Reading and setting port registers.\n"
105 " help all : All of the above sections.\n\n"
110 cmdline_parse_token_string_t cmd_help_brief_help =
111 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
113 cmdline_parse_inst_t cmd_help_brief = {
114 .f = cmd_help_brief_parsed,
116 .help_str = "show help",
118 (void *)&cmd_help_brief_help,
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125 cmdline_fixed_string_t help;
126 cmdline_fixed_string_t section;
129 static void cmd_help_long_parsed(void *parsed_result,
131 __attribute__((unused)) void *data)
134 struct cmd_help_long_result *res = parsed_result;
136 if (!strcmp(res->section, "all"))
139 if (show_all || !strcmp(res->section, "control")) {
144 "Control forwarding:\n"
145 "-------------------\n\n"
148 " Start packet forwarding with current configuration.\n\n"
151 " Start packet forwarding with current config"
152 " after sending one burst of packets.\n\n"
155 " Stop packet forwarding, and display accumulated"
159 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
163 if (show_all || !strcmp(res->section, "display")) {
171 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
172 " Display information for port_id, or all.\n\n"
174 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
175 " Clear information for port_id, or all.\n\n"
177 "show config (rxtx|cores|fwd)\n"
178 " Display the given configuration.\n\n"
180 "read rxd (port_id) (queue_id) (rxd_id)\n"
181 " Display an RX descriptor of a port RX queue.\n\n"
183 "read txd (port_id) (queue_id) (txd_id)\n"
184 " Display a TX descriptor of a port TX queue.\n\n"
188 if (show_all || !strcmp(res->section, "config")) {
194 "Configuration changes only become active when"
195 " forwarding is started/restarted.\n\n"
198 " Reset forwarding to the default configuration.\n\n"
200 "set verbose (level)\n"
201 " Set the debug verbosity level X.\n\n"
204 " Set number of ports.\n\n"
207 " Set number of cores.\n\n"
209 "set coremask (mask)\n"
210 " Set the forwarding cores hexadecimal mask.\n\n"
212 "set portmask (mask)\n"
213 " Set the forwarding ports hexadecimal mask.\n\n"
216 " Set number of packets per burst.\n\n"
218 "set txpkts (x[,y]*)\n"
219 " Set the length of each segment of TXONLY"
222 "set corelist (x[,y]*)\n"
223 " Set the list of forwarding cores.\n\n"
225 "set portlist (x[,y]*)\n"
226 " Set the list of forwarding ports.\n\n"
228 "vlan set strip (on|off) (port_id)\n"
229 " Set the VLAN strip on a port.\n\n"
231 "vlan set filter (on|off) (port_id)\n"
232 " Set the VLAN filter on a port.\n\n"
234 "vlan set qinq (on|off) (port_id)\n"
235 " Set the VLAN QinQ (extended queue in queue)"
238 "vlan set tpid (value) (port_id)\n"
239 " Set the outer VLAN TPID for Packet Filtering on"
242 "rx_vlan add (vlan_id|all) (port_id)\n"
243 " Add a vlan_id, or all identifiers, to the set"
244 " of VLAN identifiers filtered by port_id.\n\n"
246 "rx_vlan rm (vlan_id|all) (port_id)\n"
247 " Remove a vlan_id, or all identifiers, from the set"
248 " of VLAN identifiers filtered by port_id.\n\n"
250 "tx_vlan set vlan_id (port_id)\n"
251 " Set hardware insertion of VLAN ID in packets sent"
254 "tx_vlan reset (port_id)\n"
255 " Disable hardware insertion of a VLAN header in"
256 " packets sent on a port.\n\n"
258 "tx_checksum set mask (port_id)\n"
259 " Enable hardware insertion of checksum offload with"
260 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
261 " bit 0 - insert ip checksum offload if set\n"
262 " bit 1 - insert udp checksum offload if set\n"
263 " bit 2 - insert tcp checksum offload if set\n"
264 " bit 3 - insert sctp checksum offload if set\n"
265 " Please check the NIC datasheet for HW limits.\n\n"
267 #ifdef RTE_LIBRTE_IEEE1588
268 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
269 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
270 " packet forwarding mode.\n\n"
273 "set fwd (io|mac|rxonly|txonly|csum)\n"
274 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
275 " forwarding mode.\n\n"
278 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
279 " Add a MAC address on port_id.\n\n"
281 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
282 " Remove a MAC address from port_id.\n\n"
284 "set promisc (port_id|all) (on|off)\n"
285 " Set the promiscuous mode on port_id, or all.\n\n"
287 "set allmulti (port_id|all) (on|off)\n"
288 " Set the allmulti mode on port_id, or all.\n\n"
290 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
291 " (low_water) (pause_time) (send_xon) (port_id)\n"
292 " Set the link flow control parameter on a port.\n\n"
294 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
295 " (low_water) (pause_time) (priority) (port_id)\n"
296 " Set the priority flow control parameter on a"
299 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
300 " Set statistics mapping (qmapping 0..15) for RX/TX"
302 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
303 " on port 0 to mapping 5.\n\n"
308 if (show_all || !strcmp(res->section, "flowdir")) {
313 "Flow director mode:\n"
314 "-------------------\n\n"
316 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
317 " src (src_ip_address) (src_port)"
318 " dst (dst_ip_address) (dst_port)"
319 " flexbytes (flexbytes_values) vlan (vlan_id)"
320 " queue (queue_id)\n"
321 " Add a signature filter.\n\n"
323 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
324 " src (src_ip_address) (src_port)"
325 " dst (dst_ip_address) (dst_port)"
326 " flexbytes (flexbytes_values) vlan (vlan_id)"
327 " queue (queue_id)\n"
328 " Update a signature filter.\n\n"
330 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
331 " src (src_ip_address) (src_port)"
332 " dst (dst_ip_address) (dst_port)"
333 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
334 " Remove a signature filter.\n\n"
336 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
337 " src (src_ip_address) (src_port)"
338 " dst (dst_ip_address) (dst_port)"
339 " flexbytes (flexbytes_values) vlan (vlan_id)"
340 " queue (queue_id) soft (soft_id)\n"
341 " Add a perfect filter.\n\n"
343 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
344 " src (src_ip_address) (src_port)"
345 " dst (dst_ip_address) (dst_port)"
346 " flexbytes (flexbytes_values) vlan (vlan_id)"
347 " queue (queue_id)\n"
348 " Update a perfect filter.\n\n"
350 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
351 " src (src_ip_address) (src_port)"
352 " dst (dst_ip_address) (dst_port)"
353 " flexbytes (flexbytes_values) vlan (vlan_id)"
355 " Remove a perfect filter.\n\n"
357 "set_masks_filter (port_id) only_ip_flow (0|1)"
358 " src_mask (ip_src_mask) (src_port_mask)"
359 " dst_mask (ip_dst_mask) (dst_port_mask)"
360 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
361 " Set IPv4 filter masks.\n\n"
363 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
364 " src_mask (ip_src_mask) (src_port_mask)"
365 " dst_mask (ip_dst_mask) (dst_port_mask)"
366 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
367 " compare_dst (0|1)\n"
368 " Set IPv6 filter masks.\n\n"
372 if (show_all || !strcmp(res->section, "ports")) {
378 "----------------\n\n"
380 "port start (port_id|all)\n"
381 " Start all ports or port_id.\n\n"
383 "port stop (port_id|all)\n"
384 " Stop all ports or port_id.\n\n"
386 "port close (port_id|all)\n"
387 " Close all ports or port_id.\n\n"
389 "port config (port_id|all) speed (10|100|1000|10000|auto)"
390 " duplex (half|full|auto)\n"
391 " Set speed and duplex for all ports or port_id\n\n"
393 "port config all (rxq|txq|rxd|txd) (value)\n"
394 " Set number for rxq/txq/rxd/txd.\n\n"
396 "port config all max-pkt-len (value)\n"
397 " Set the max packet length.\n\n"
399 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
401 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
404 "port config all rss (ip|udp|none)\n"
405 " Set the RSS mode.\n\n"
407 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
408 " Set the RSS redirection table.\n\n"
410 "port config (port_id) dcb vt (on|off) (traffic_class)"
412 " Set the DCB mode.\n\n"
414 "port config all burst (value)\n"
415 " Set the number of packets per burst.\n\n"
417 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
419 " Set the ring prefetch/host/writeback threshold"
420 " for tx/rx queue.\n\n"
422 "port config all (txfreet|txrst|rxfreet) (value)\n"
423 " Set free threshold for rx/tx, or set"
424 " tx rs bit threshold.\n\n"
428 if (show_all || !strcmp(res->section, "registers")) {
436 "read reg (port_id) (address)\n"
437 " Display value of a port register.\n\n"
439 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
440 " Display a port register bit field.\n\n"
442 "read regbit (port_id) (address) (bit_x)\n"
443 " Display a single port register bit.\n\n"
445 "write reg (port_id) (address) (value)\n"
446 " Set value of a port register.\n\n"
448 "write regfield (port_id) (address) (bit_x) (bit_y)"
450 " Set bit field of a port register.\n\n"
452 "write regbit (port_id) (address) (bit_x) (value)\n"
453 " Set single bit value of a port register.\n\n"
458 cmdline_parse_token_string_t cmd_help_long_help =
459 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
461 cmdline_parse_token_string_t cmd_help_long_section =
462 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
463 "all#control#display#config#flowdir#"
466 cmdline_parse_inst_t cmd_help_long = {
467 .f = cmd_help_long_parsed,
469 .help_str = "show help",
471 (void *)&cmd_help_long_help,
472 (void *)&cmd_help_long_section,
478 /* *** start/stop/close all ports *** */
479 struct cmd_operate_port_result {
480 cmdline_fixed_string_t keyword;
481 cmdline_fixed_string_t name;
482 cmdline_fixed_string_t value;
485 static void cmd_operate_port_parsed(void *parsed_result,
486 __attribute__((unused)) struct cmdline *cl,
487 __attribute__((unused)) void *data)
489 struct cmd_operate_port_result *res = parsed_result;
491 if (!strcmp(res->name, "start"))
492 start_port(RTE_PORT_ALL);
493 else if (!strcmp(res->name, "stop"))
494 stop_port(RTE_PORT_ALL);
495 else if (!strcmp(res->name, "close"))
496 close_port(RTE_PORT_ALL);
498 printf("Unknown parameter\n");
501 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
502 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
504 cmdline_parse_token_string_t cmd_operate_port_all_port =
505 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
507 cmdline_parse_token_string_t cmd_operate_port_all_all =
508 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
510 cmdline_parse_inst_t cmd_operate_port = {
511 .f = cmd_operate_port_parsed,
513 .help_str = "port start|stop|close all: start/stop/close all ports",
515 (void *)&cmd_operate_port_all_cmd,
516 (void *)&cmd_operate_port_all_port,
517 (void *)&cmd_operate_port_all_all,
522 /* *** start/stop/close specific port *** */
523 struct cmd_operate_specific_port_result {
524 cmdline_fixed_string_t keyword;
525 cmdline_fixed_string_t name;
529 static void cmd_operate_specific_port_parsed(void *parsed_result,
530 __attribute__((unused)) struct cmdline *cl,
531 __attribute__((unused)) void *data)
533 struct cmd_operate_specific_port_result *res = parsed_result;
535 if (!strcmp(res->name, "start"))
536 start_port(res->value);
537 else if (!strcmp(res->name, "stop"))
538 stop_port(res->value);
539 else if (!strcmp(res->name, "close"))
540 close_port(res->value);
542 printf("Unknown parameter\n");
545 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
546 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
548 cmdline_parse_token_string_t cmd_operate_specific_port_port =
549 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
550 name, "start#stop#close");
551 cmdline_parse_token_num_t cmd_operate_specific_port_id =
552 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
555 cmdline_parse_inst_t cmd_operate_specific_port = {
556 .f = cmd_operate_specific_port_parsed,
558 .help_str = "port start|stop|close X: start/stop/close port X",
560 (void *)&cmd_operate_specific_port_cmd,
561 (void *)&cmd_operate_specific_port_port,
562 (void *)&cmd_operate_specific_port_id,
567 /* *** configure speed for all ports *** */
568 struct cmd_config_speed_all {
569 cmdline_fixed_string_t port;
570 cmdline_fixed_string_t keyword;
571 cmdline_fixed_string_t all;
572 cmdline_fixed_string_t item1;
573 cmdline_fixed_string_t item2;
574 cmdline_fixed_string_t value1;
575 cmdline_fixed_string_t value2;
579 cmd_config_speed_all_parsed(void *parsed_result,
580 __attribute__((unused)) struct cmdline *cl,
581 __attribute__((unused)) void *data)
583 struct cmd_config_speed_all *res = parsed_result;
584 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
585 uint16_t link_duplex = 0;
588 if (!all_ports_stopped()) {
589 printf("Please stop all ports first\n");
593 if (!strcmp(res->value1, "10"))
594 link_speed = ETH_LINK_SPEED_10;
595 else if (!strcmp(res->value1, "100"))
596 link_speed = ETH_LINK_SPEED_100;
597 else if (!strcmp(res->value1, "1000"))
598 link_speed = ETH_LINK_SPEED_1000;
599 else if (!strcmp(res->value1, "10000"))
600 link_speed = ETH_LINK_SPEED_10000;
601 else if (!strcmp(res->value1, "auto"))
602 link_speed = ETH_LINK_SPEED_AUTONEG;
604 printf("Unknown parameter\n");
608 if (!strcmp(res->value2, "half"))
609 link_duplex = ETH_LINK_HALF_DUPLEX;
610 else if (!strcmp(res->value2, "full"))
611 link_duplex = ETH_LINK_FULL_DUPLEX;
612 else if (!strcmp(res->value2, "auto"))
613 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
615 printf("Unknown parameter\n");
619 for (pid = 0; pid < nb_ports; pid++) {
620 ports[pid].dev_conf.link_speed = link_speed;
621 ports[pid].dev_conf.link_duplex = link_duplex;
624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
627 cmdline_parse_token_string_t cmd_config_speed_all_port =
628 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
629 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
630 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
632 cmdline_parse_token_string_t cmd_config_speed_all_all =
633 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
634 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
635 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
636 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
638 "10#100#1000#10000#auto");
639 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
641 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
645 cmdline_parse_inst_t cmd_config_speed_all = {
646 .f = cmd_config_speed_all_parsed,
648 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
651 (void *)&cmd_config_speed_all_port,
652 (void *)&cmd_config_speed_all_keyword,
653 (void *)&cmd_config_speed_all_all,
654 (void *)&cmd_config_speed_all_item1,
655 (void *)&cmd_config_speed_all_value1,
656 (void *)&cmd_config_speed_all_item2,
657 (void *)&cmd_config_speed_all_value2,
662 /* *** configure speed for specific port *** */
663 struct cmd_config_speed_specific {
664 cmdline_fixed_string_t port;
665 cmdline_fixed_string_t keyword;
667 cmdline_fixed_string_t item1;
668 cmdline_fixed_string_t item2;
669 cmdline_fixed_string_t value1;
670 cmdline_fixed_string_t value2;
674 cmd_config_speed_specific_parsed(void *parsed_result,
675 __attribute__((unused)) struct cmdline *cl,
676 __attribute__((unused)) void *data)
678 struct cmd_config_speed_specific *res = parsed_result;
679 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
680 uint16_t link_duplex = 0;
682 if (!all_ports_stopped()) {
683 printf("Please stop all ports first\n");
687 if (res->id >= nb_ports) {
688 printf("Port id %d must be less than %d\n", res->id, nb_ports);
692 if (!strcmp(res->value1, "10"))
693 link_speed = ETH_LINK_SPEED_10;
694 else if (!strcmp(res->value1, "100"))
695 link_speed = ETH_LINK_SPEED_100;
696 else if (!strcmp(res->value1, "1000"))
697 link_speed = ETH_LINK_SPEED_1000;
698 else if (!strcmp(res->value1, "10000"))
699 link_speed = ETH_LINK_SPEED_10000;
700 else if (!strcmp(res->value1, "auto"))
701 link_speed = ETH_LINK_SPEED_AUTONEG;
703 printf("Unknown parameter\n");
707 if (!strcmp(res->value2, "half"))
708 link_duplex = ETH_LINK_HALF_DUPLEX;
709 else if (!strcmp(res->value2, "full"))
710 link_duplex = ETH_LINK_FULL_DUPLEX;
711 else if (!strcmp(res->value2, "auto"))
712 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
714 printf("Unknown parameter\n");
718 ports[res->id].dev_conf.link_speed = link_speed;
719 ports[res->id].dev_conf.link_duplex = link_duplex;
721 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
725 cmdline_parse_token_string_t cmd_config_speed_specific_port =
726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
728 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
731 cmdline_parse_token_num_t cmd_config_speed_specific_id =
732 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
733 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
736 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
738 "10#100#1000#10000#auto");
739 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
742 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
743 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
746 cmdline_parse_inst_t cmd_config_speed_specific = {
747 .f = cmd_config_speed_specific_parsed,
749 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
752 (void *)&cmd_config_speed_specific_port,
753 (void *)&cmd_config_speed_specific_keyword,
754 (void *)&cmd_config_speed_specific_id,
755 (void *)&cmd_config_speed_specific_item1,
756 (void *)&cmd_config_speed_specific_value1,
757 (void *)&cmd_config_speed_specific_item2,
758 (void *)&cmd_config_speed_specific_value2,
763 /* *** configure txq/rxq, txd/rxd *** */
764 struct cmd_config_rx_tx {
765 cmdline_fixed_string_t port;
766 cmdline_fixed_string_t keyword;
767 cmdline_fixed_string_t all;
768 cmdline_fixed_string_t name;
773 cmd_config_rx_tx_parsed(void *parsed_result,
774 __attribute__((unused)) struct cmdline *cl,
775 __attribute__((unused)) void *data)
777 struct cmd_config_rx_tx *res = parsed_result;
779 if (!all_ports_stopped()) {
780 printf("Please stop all ports first\n");
784 if (!strcmp(res->name, "rxq")) {
785 if (res->value <= 0) {
786 printf("rxq %d invalid - must be > 0\n", res->value);
791 else if (!strcmp(res->name, "txq")) {
792 if (res->value <= 0) {
793 printf("txq %d invalid - must be > 0\n", res->value);
798 else if (!strcmp(res->name, "rxd")) {
799 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
800 printf("rxd %d invalid - must be > 0 && <= %d\n",
801 res->value, RTE_TEST_RX_DESC_MAX);
805 } else if (!strcmp(res->name, "txd")) {
806 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
807 printf("txd %d invalid - must be > 0 && <= %d\n",
808 res->value, RTE_TEST_TX_DESC_MAX);
813 printf("Unknown parameter\n");
819 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
822 cmdline_parse_token_string_t cmd_config_rx_tx_port =
823 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
824 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
825 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
826 cmdline_parse_token_string_t cmd_config_rx_tx_all =
827 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
828 cmdline_parse_token_string_t cmd_config_rx_tx_name =
829 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
831 cmdline_parse_token_num_t cmd_config_rx_tx_value =
832 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
834 cmdline_parse_inst_t cmd_config_rx_tx = {
835 .f = cmd_config_rx_tx_parsed,
837 .help_str = "port config all rxq|txq|rxd|txd value",
839 (void *)&cmd_config_rx_tx_port,
840 (void *)&cmd_config_rx_tx_keyword,
841 (void *)&cmd_config_rx_tx_all,
842 (void *)&cmd_config_rx_tx_name,
843 (void *)&cmd_config_rx_tx_value,
848 /* *** config max packet length *** */
849 struct cmd_config_max_pkt_len_result {
850 cmdline_fixed_string_t port;
851 cmdline_fixed_string_t keyword;
852 cmdline_fixed_string_t all;
853 cmdline_fixed_string_t name;
858 cmd_config_max_pkt_len_parsed(void *parsed_result,
859 __attribute__((unused)) struct cmdline *cl,
860 __attribute__((unused)) void *data)
862 struct cmd_config_max_pkt_len_result *res = parsed_result;
864 if (!all_ports_stopped()) {
865 printf("Please stop all ports first\n");
869 if (!strcmp(res->name, "max-pkt-len")) {
870 if (res->value < ETHER_MIN_LEN) {
871 printf("max-pkt-len can not be less than %d\n",
875 if (res->value == rx_mode.max_rx_pkt_len)
878 rx_mode.max_rx_pkt_len = res->value;
879 if (res->value > ETHER_MAX_LEN)
880 rx_mode.jumbo_frame = 1;
882 rx_mode.jumbo_frame = 0;
884 printf("Unknown parameter\n");
890 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
893 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
894 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
896 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
897 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
899 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
900 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
902 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
903 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
905 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
906 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
909 cmdline_parse_inst_t cmd_config_max_pkt_len = {
910 .f = cmd_config_max_pkt_len_parsed,
912 .help_str = "port config all max-pkt-len value",
914 (void *)&cmd_config_max_pkt_len_port,
915 (void *)&cmd_config_max_pkt_len_keyword,
916 (void *)&cmd_config_max_pkt_len_all,
917 (void *)&cmd_config_max_pkt_len_name,
918 (void *)&cmd_config_max_pkt_len_value,
923 /* *** configure rx mode *** */
924 struct cmd_config_rx_mode_flag {
925 cmdline_fixed_string_t port;
926 cmdline_fixed_string_t keyword;
927 cmdline_fixed_string_t all;
928 cmdline_fixed_string_t name;
929 cmdline_fixed_string_t value;
933 cmd_config_rx_mode_flag_parsed(void *parsed_result,
934 __attribute__((unused)) struct cmdline *cl,
935 __attribute__((unused)) void *data)
937 struct cmd_config_rx_mode_flag *res = parsed_result;
939 if (!all_ports_stopped()) {
940 printf("Please stop all ports first\n");
944 if (!strcmp(res->name, "crc-strip")) {
945 if (!strcmp(res->value, "on"))
946 rx_mode.hw_strip_crc = 1;
947 else if (!strcmp(res->value, "off"))
948 rx_mode.hw_strip_crc = 0;
950 printf("Unknown parameter\n");
953 } else if (!strcmp(res->name, "rx-cksum")) {
954 if (!strcmp(res->value, "on"))
955 rx_mode.hw_ip_checksum = 1;
956 else if (!strcmp(res->value, "off"))
957 rx_mode.hw_ip_checksum = 0;
959 printf("Unknown parameter\n");
962 } else if (!strcmp(res->name, "hw-vlan")) {
963 if (!strcmp(res->value, "on")) {
964 rx_mode.hw_vlan_filter = 1;
965 rx_mode.hw_vlan_strip = 1;
967 else if (!strcmp(res->value, "off")) {
968 rx_mode.hw_vlan_filter = 0;
969 rx_mode.hw_vlan_strip = 0;
972 printf("Unknown parameter\n");
975 } else if (!strcmp(res->name, "drop-en")) {
976 if (!strcmp(res->value, "on"))
978 else if (!strcmp(res->value, "off"))
981 printf("Unknown parameter\n");
985 printf("Unknown parameter\n");
991 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
994 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
996 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
997 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
999 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1001 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1003 "crc-strip#rx-cksum#hw-vlan");
1004 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1005 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1008 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1009 .f = cmd_config_rx_mode_flag_parsed,
1011 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1013 (void *)&cmd_config_rx_mode_flag_port,
1014 (void *)&cmd_config_rx_mode_flag_keyword,
1015 (void *)&cmd_config_rx_mode_flag_all,
1016 (void *)&cmd_config_rx_mode_flag_name,
1017 (void *)&cmd_config_rx_mode_flag_value,
1022 /* *** configure rss *** */
1023 struct cmd_config_rss {
1024 cmdline_fixed_string_t port;
1025 cmdline_fixed_string_t keyword;
1026 cmdline_fixed_string_t all;
1027 cmdline_fixed_string_t name;
1028 cmdline_fixed_string_t value;
1032 cmd_config_rss_parsed(void *parsed_result,
1033 __attribute__((unused)) struct cmdline *cl,
1034 __attribute__((unused)) void *data)
1036 struct cmd_config_rss *res = parsed_result;
1038 if (!all_ports_stopped()) {
1039 printf("Please stop all ports first\n");
1043 if (!strcmp(res->value, "ip"))
1044 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1045 else if (!strcmp(res->value, "udp"))
1046 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1047 else if (!strcmp(res->value, "none"))
1050 printf("Unknown parameter\n");
1056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1059 cmdline_parse_token_string_t cmd_config_rss_port =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1061 cmdline_parse_token_string_t cmd_config_rss_keyword =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1063 cmdline_parse_token_string_t cmd_config_rss_all =
1064 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1065 cmdline_parse_token_string_t cmd_config_rss_name =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1067 cmdline_parse_token_string_t cmd_config_rss_value =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1070 cmdline_parse_inst_t cmd_config_rss = {
1071 .f = cmd_config_rss_parsed,
1073 .help_str = "port config all rss ip|udp|none",
1075 (void *)&cmd_config_rss_port,
1076 (void *)&cmd_config_rss_keyword,
1077 (void *)&cmd_config_rss_all,
1078 (void *)&cmd_config_rss_name,
1079 (void *)&cmd_config_rss_value,
1084 /* *** Configure RSS RETA *** */
1085 struct cmd_config_rss_reta {
1086 cmdline_fixed_string_t port;
1087 cmdline_fixed_string_t keyword;
1089 cmdline_fixed_string_t name;
1090 cmdline_fixed_string_t list_name;
1091 cmdline_fixed_string_t list_of_items;
1095 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1102 const char *p, *p0 = str;
1109 unsigned long int_fld[_NUM_FLD];
1110 char *str_fld[_NUM_FLD];
1112 while ((p = strchr(p0,'(')) != NULL) {
1114 if((p0 = strchr(p,')')) == NULL)
1118 if(size >= sizeof(s))
1121 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1122 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1124 for (i = 0; i < _NUM_FLD; i++) {
1126 int_fld[i] = strtoul(str_fld[i], &end, 0);
1127 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1131 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1132 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1134 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1135 printf("Invalid RETA hash index=%d",hash_index);
1139 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1140 reta_conf->mask_lo |= (1ULL << hash_index);
1142 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1144 reta_conf->reta[hash_index] = nb_queue;
1151 cmd_set_rss_reta_parsed(void *parsed_result,
1152 __attribute__((unused)) struct cmdline *cl,
1153 __attribute__((unused)) void *data)
1156 struct rte_eth_rss_reta reta_conf;
1157 struct cmd_config_rss_reta *res = parsed_result;
1159 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1160 if (!strcmp(res->list_name, "reta")) {
1161 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1162 printf("Invalid RSS Redirection Table config entered\n");
1165 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1167 printf("Bad redirection table parameter, return code = %d \n",ret);
1171 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1172 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1173 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1174 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1175 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1176 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1177 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1178 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1179 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1180 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1181 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1182 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1184 cmdline_parse_inst_t cmd_config_rss_reta = {
1185 .f = cmd_set_rss_reta_parsed,
1187 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1189 (void *)&cmd_config_rss_reta_port,
1190 (void *)&cmd_config_rss_reta_keyword,
1191 (void *)&cmd_config_rss_reta_port_id,
1192 (void *)&cmd_config_rss_reta_name,
1193 (void *)&cmd_config_rss_reta_list_name,
1194 (void *)&cmd_config_rss_reta_list_of_items,
1199 /* *** SHOW PORT INFO *** */
1200 struct cmd_showport_reta {
1201 cmdline_fixed_string_t show;
1202 cmdline_fixed_string_t port;
1204 cmdline_fixed_string_t rss;
1205 cmdline_fixed_string_t reta;
1210 static void cmd_showport_reta_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1214 struct cmd_showport_reta *res = parsed_result;
1215 struct rte_eth_rss_reta reta_conf;
1217 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1218 printf("Invalid RSS Redirection Table config entered\n");
1222 reta_conf.mask_lo = res->mask_lo;
1223 reta_conf.mask_hi = res->mask_hi;
1225 port_rss_reta_info(res->port_id,&reta_conf);
1228 cmdline_parse_token_string_t cmd_showport_reta_show =
1229 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1230 cmdline_parse_token_string_t cmd_showport_reta_port =
1231 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1232 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1233 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1234 cmdline_parse_token_string_t cmd_showport_reta_rss =
1235 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1236 cmdline_parse_token_string_t cmd_showport_reta_reta =
1237 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1238 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1239 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1240 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1241 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1243 cmdline_parse_inst_t cmd_showport_reta = {
1244 .f = cmd_showport_reta_parsed,
1246 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1247 (mask_lo and mask_hi is UINT64)",
1249 (void *)&cmd_showport_reta_show,
1250 (void *)&cmd_showport_reta_port,
1251 (void *)&cmd_showport_reta_port_id,
1252 (void *)&cmd_showport_reta_rss,
1253 (void *)&cmd_showport_reta_reta,
1254 (void *)&cmd_showport_reta_mask_lo,
1255 (void *)&cmd_showport_reta_mask_hi,
1260 /* *** Configure DCB *** */
1261 struct cmd_config_dcb {
1262 cmdline_fixed_string_t port;
1263 cmdline_fixed_string_t config;
1265 cmdline_fixed_string_t dcb;
1266 cmdline_fixed_string_t vt;
1267 cmdline_fixed_string_t vt_en;
1269 cmdline_fixed_string_t pfc;
1270 cmdline_fixed_string_t pfc_en;
1274 cmd_config_dcb_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_config_dcb *res = parsed_result;
1279 struct dcb_config dcb_conf;
1280 portid_t port_id = res->port_id;
1281 struct rte_port *port;
1283 port = &ports[port_id];
1284 /** Check if the port is not started **/
1285 if (port->port_status != RTE_PORT_STOPPED) {
1286 printf("Please stop port %d first\n",port_id);
1290 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1291 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1292 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1296 /* DCB in VT mode */
1297 if (!strncmp(res->vt_en, "on",2))
1298 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1300 dcb_conf.dcb_mode = DCB_ENABLED;
1302 if (!strncmp(res->pfc_en, "on",2)) {
1303 dcb_conf.pfc_en = 1;
1306 dcb_conf.pfc_en = 0;
1308 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1309 printf("Cannot initialize network ports\n");
1313 cmd_reconfig_device_queue(port_id, 1, 1);
1316 cmdline_parse_token_string_t cmd_config_dcb_port =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1318 cmdline_parse_token_string_t cmd_config_dcb_config =
1319 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1320 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1321 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1322 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1324 cmdline_parse_token_string_t cmd_config_dcb_vt =
1325 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1326 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1328 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1329 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1330 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1332 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1335 cmdline_parse_inst_t cmd_config_dcb = {
1336 .f = cmd_config_dcb_parsed,
1338 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1340 (void *)&cmd_config_dcb_port,
1341 (void *)&cmd_config_dcb_config,
1342 (void *)&cmd_config_dcb_port_id,
1343 (void *)&cmd_config_dcb_dcb,
1344 (void *)&cmd_config_dcb_vt,
1345 (void *)&cmd_config_dcb_vt_en,
1346 (void *)&cmd_config_dcb_num_tcs,
1347 (void *)&cmd_config_dcb_pfc,
1348 (void *)&cmd_config_dcb_pfc_en,
1353 /* *** configure number of packets per burst *** */
1354 struct cmd_config_burst {
1355 cmdline_fixed_string_t port;
1356 cmdline_fixed_string_t keyword;
1357 cmdline_fixed_string_t all;
1358 cmdline_fixed_string_t name;
1363 cmd_config_burst_parsed(void *parsed_result,
1364 __attribute__((unused)) struct cmdline *cl,
1365 __attribute__((unused)) void *data)
1367 struct cmd_config_burst *res = parsed_result;
1369 if (!all_ports_stopped()) {
1370 printf("Please stop all ports first\n");
1374 if (!strcmp(res->name, "burst")) {
1375 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1376 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1379 nb_pkt_per_burst = res->value;
1381 printf("Unknown parameter\n");
1387 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1390 cmdline_parse_token_string_t cmd_config_burst_port =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1392 cmdline_parse_token_string_t cmd_config_burst_keyword =
1393 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1394 cmdline_parse_token_string_t cmd_config_burst_all =
1395 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1396 cmdline_parse_token_string_t cmd_config_burst_name =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1398 cmdline_parse_token_num_t cmd_config_burst_value =
1399 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1401 cmdline_parse_inst_t cmd_config_burst = {
1402 .f = cmd_config_burst_parsed,
1404 .help_str = "port config all burst value",
1406 (void *)&cmd_config_burst_port,
1407 (void *)&cmd_config_burst_keyword,
1408 (void *)&cmd_config_burst_all,
1409 (void *)&cmd_config_burst_name,
1410 (void *)&cmd_config_burst_value,
1415 /* *** configure rx/tx queues *** */
1416 struct cmd_config_thresh {
1417 cmdline_fixed_string_t port;
1418 cmdline_fixed_string_t keyword;
1419 cmdline_fixed_string_t all;
1420 cmdline_fixed_string_t name;
1425 cmd_config_thresh_parsed(void *parsed_result,
1426 __attribute__((unused)) struct cmdline *cl,
1427 __attribute__((unused)) void *data)
1429 struct cmd_config_thresh *res = parsed_result;
1431 if (!all_ports_stopped()) {
1432 printf("Please stop all ports first\n");
1436 if (!strcmp(res->name, "txpt"))
1437 tx_thresh.pthresh = res->value;
1438 else if(!strcmp(res->name, "txht"))
1439 tx_thresh.hthresh = res->value;
1440 else if(!strcmp(res->name, "txwt"))
1441 tx_thresh.wthresh = res->value;
1442 else if(!strcmp(res->name, "rxpt"))
1443 rx_thresh.pthresh = res->value;
1444 else if(!strcmp(res->name, "rxht"))
1445 rx_thresh.hthresh = res->value;
1446 else if(!strcmp(res->name, "rxwt"))
1447 rx_thresh.wthresh = res->value;
1449 printf("Unknown parameter\n");
1455 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1458 cmdline_parse_token_string_t cmd_config_thresh_port =
1459 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1460 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1462 cmdline_parse_token_string_t cmd_config_thresh_all =
1463 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1464 cmdline_parse_token_string_t cmd_config_thresh_name =
1465 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1466 "txpt#txht#txwt#rxpt#rxht#rxwt");
1467 cmdline_parse_token_num_t cmd_config_thresh_value =
1468 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1470 cmdline_parse_inst_t cmd_config_thresh = {
1471 .f = cmd_config_thresh_parsed,
1473 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1475 (void *)&cmd_config_thresh_port,
1476 (void *)&cmd_config_thresh_keyword,
1477 (void *)&cmd_config_thresh_all,
1478 (void *)&cmd_config_thresh_name,
1479 (void *)&cmd_config_thresh_value,
1484 /* *** configure free/rs threshold *** */
1485 struct cmd_config_threshold {
1486 cmdline_fixed_string_t port;
1487 cmdline_fixed_string_t keyword;
1488 cmdline_fixed_string_t all;
1489 cmdline_fixed_string_t name;
1494 cmd_config_threshold_parsed(void *parsed_result,
1495 __attribute__((unused)) struct cmdline *cl,
1496 __attribute__((unused)) void *data)
1498 struct cmd_config_threshold *res = parsed_result;
1500 if (!all_ports_stopped()) {
1501 printf("Please stop all ports first\n");
1505 if (!strcmp(res->name, "txfreet"))
1506 tx_free_thresh = res->value;
1507 else if (!strcmp(res->name, "txrst"))
1508 tx_rs_thresh = res->value;
1509 else if (!strcmp(res->name, "rxfreet"))
1510 rx_free_thresh = res->value;
1512 printf("Unknown parameter\n");
1518 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1521 cmdline_parse_token_string_t cmd_config_threshold_port =
1522 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1523 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1524 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1526 cmdline_parse_token_string_t cmd_config_threshold_all =
1527 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1528 cmdline_parse_token_string_t cmd_config_threshold_name =
1529 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1530 "txfreet#txrst#rxfreet");
1531 cmdline_parse_token_num_t cmd_config_threshold_value =
1532 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1534 cmdline_parse_inst_t cmd_config_threshold = {
1535 .f = cmd_config_threshold_parsed,
1537 .help_str = "port config all txfreet|txrst|rxfreet value",
1539 (void *)&cmd_config_threshold_port,
1540 (void *)&cmd_config_threshold_keyword,
1541 (void *)&cmd_config_threshold_all,
1542 (void *)&cmd_config_threshold_name,
1543 (void *)&cmd_config_threshold_value,
1549 struct cmd_stop_result {
1550 cmdline_fixed_string_t stop;
1553 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1554 __attribute__((unused)) struct cmdline *cl,
1555 __attribute__((unused)) void *data)
1557 stop_packet_forwarding();
1560 cmdline_parse_token_string_t cmd_stop_stop =
1561 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1563 cmdline_parse_inst_t cmd_stop = {
1564 .f = cmd_stop_parsed,
1566 .help_str = "stop - stop packet forwarding",
1568 (void *)&cmd_stop_stop,
1573 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1576 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1577 unsigned int *parsed_items, int check_unique_values)
1579 unsigned int nb_item;
1587 * First parse all items in the list and store their value.
1592 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1594 if ((c >= '0') && (c <= '9')) {
1595 value = (unsigned int) (value * 10 + (c - '0'));
1600 printf("character %c is not a decimal digit\n", c);
1604 printf("No valid value before comma\n");
1607 if (nb_item < max_items) {
1608 parsed_items[nb_item] = value;
1614 if (nb_item >= max_items) {
1615 printf("Number of %s = %u > %u (maximum items)\n",
1616 item_name, nb_item + 1, max_items);
1619 parsed_items[nb_item++] = value;
1620 if (! check_unique_values)
1624 * Then, check that all values in the list are differents.
1625 * No optimization here...
1627 for (i = 0; i < nb_item; i++) {
1628 for (j = i + 1; j < nb_item; j++) {
1629 if (parsed_items[j] == parsed_items[i]) {
1630 printf("duplicated %s %u at index %u and %u\n",
1631 item_name, parsed_items[i], i, j);
1639 struct cmd_set_list_result {
1640 cmdline_fixed_string_t cmd_keyword;
1641 cmdline_fixed_string_t list_name;
1642 cmdline_fixed_string_t list_of_items;
1645 static void cmd_set_list_parsed(void *parsed_result,
1646 __attribute__((unused)) struct cmdline *cl,
1647 __attribute__((unused)) void *data)
1649 struct cmd_set_list_result *res;
1651 unsigned int lcorelist[RTE_MAX_LCORE];
1652 unsigned int portlist[RTE_MAX_ETHPORTS];
1654 unsigned int nb_item;
1656 res = parsed_result;
1657 if (!strcmp(res->list_name, "corelist")) {
1658 nb_item = parse_item_list(res->list_of_items, "core",
1660 parsed_items.lcorelist, 1);
1662 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1665 if (!strcmp(res->list_name, "portlist")) {
1666 nb_item = parse_item_list(res->list_of_items, "port",
1668 parsed_items.portlist, 1);
1670 set_fwd_ports_list(parsed_items.portlist, nb_item);
1674 cmdline_parse_token_string_t cmd_set_list_keyword =
1675 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1677 cmdline_parse_token_string_t cmd_set_list_name =
1678 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1679 "corelist#portlist");
1680 cmdline_parse_token_string_t cmd_set_list_of_items =
1681 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1684 cmdline_parse_inst_t cmd_set_fwd_list = {
1685 .f = cmd_set_list_parsed,
1687 .help_str = "set corelist|portlist x[,y]*",
1689 (void *)&cmd_set_list_keyword,
1690 (void *)&cmd_set_list_name,
1691 (void *)&cmd_set_list_of_items,
1696 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1698 struct cmd_setmask_result {
1699 cmdline_fixed_string_t set;
1700 cmdline_fixed_string_t mask;
1704 static void cmd_set_mask_parsed(void *parsed_result,
1705 __attribute__((unused)) struct cmdline *cl,
1706 __attribute__((unused)) void *data)
1708 struct cmd_setmask_result *res = parsed_result;
1710 if (!strcmp(res->mask, "coremask"))
1711 set_fwd_lcores_mask(res->hexavalue);
1712 else if (!strcmp(res->mask, "portmask"))
1713 set_fwd_ports_mask(res->hexavalue);
1716 cmdline_parse_token_string_t cmd_setmask_set =
1717 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1718 cmdline_parse_token_string_t cmd_setmask_mask =
1719 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1720 "coremask#portmask");
1721 cmdline_parse_token_num_t cmd_setmask_value =
1722 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1724 cmdline_parse_inst_t cmd_set_fwd_mask = {
1725 .f = cmd_set_mask_parsed,
1727 .help_str = "set coremask|portmask hexadecimal value",
1729 (void *)&cmd_setmask_set,
1730 (void *)&cmd_setmask_mask,
1731 (void *)&cmd_setmask_value,
1737 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1739 struct cmd_set_result {
1740 cmdline_fixed_string_t set;
1741 cmdline_fixed_string_t what;
1745 static void cmd_set_parsed(void *parsed_result,
1746 __attribute__((unused)) struct cmdline *cl,
1747 __attribute__((unused)) void *data)
1749 struct cmd_set_result *res = parsed_result;
1750 if (!strcmp(res->what, "nbport"))
1751 set_fwd_ports_number(res->value);
1752 else if (!strcmp(res->what, "nbcore"))
1753 set_fwd_lcores_number(res->value);
1754 else if (!strcmp(res->what, "burst"))
1755 set_nb_pkt_per_burst(res->value);
1756 else if (!strcmp(res->what, "verbose"))
1757 set_verbose_level(res->value);
1760 cmdline_parse_token_string_t cmd_set_set =
1761 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1762 cmdline_parse_token_string_t cmd_set_what =
1763 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1764 "nbport#nbcore#burst#verbose");
1765 cmdline_parse_token_num_t cmd_set_value =
1766 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1768 cmdline_parse_inst_t cmd_set_numbers = {
1769 .f = cmd_set_parsed,
1771 .help_str = "set nbport|nbcore|burst|verbose value",
1773 (void *)&cmd_set_set,
1774 (void *)&cmd_set_what,
1775 (void *)&cmd_set_value,
1780 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1782 struct cmd_set_txpkts_result {
1783 cmdline_fixed_string_t cmd_keyword;
1784 cmdline_fixed_string_t txpkts;
1785 cmdline_fixed_string_t seg_lengths;
1789 cmd_set_txpkts_parsed(void *parsed_result,
1790 __attribute__((unused)) struct cmdline *cl,
1791 __attribute__((unused)) void *data)
1793 struct cmd_set_txpkts_result *res;
1794 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1795 unsigned int nb_segs;
1797 res = parsed_result;
1798 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1799 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1801 set_tx_pkt_segments(seg_lengths, nb_segs);
1804 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1805 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1806 cmd_keyword, "set");
1807 cmdline_parse_token_string_t cmd_set_txpkts_name =
1808 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1810 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1811 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1814 cmdline_parse_inst_t cmd_set_txpkts = {
1815 .f = cmd_set_txpkts_parsed,
1817 .help_str = "set txpkts x[,y]*",
1819 (void *)&cmd_set_txpkts_keyword,
1820 (void *)&cmd_set_txpkts_name,
1821 (void *)&cmd_set_txpkts_lengths,
1826 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1827 struct cmd_rx_vlan_filter_all_result {
1828 cmdline_fixed_string_t rx_vlan;
1829 cmdline_fixed_string_t what;
1830 cmdline_fixed_string_t all;
1835 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1836 __attribute__((unused)) struct cmdline *cl,
1837 __attribute__((unused)) void *data)
1839 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1841 if (!strcmp(res->what, "add"))
1842 rx_vlan_all_filter_set(res->port_id, 1);
1844 rx_vlan_all_filter_set(res->port_id, 0);
1847 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1848 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1849 rx_vlan, "rx_vlan");
1850 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1851 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1853 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1854 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1856 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1857 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1860 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1861 .f = cmd_rx_vlan_filter_all_parsed,
1863 .help_str = "add/remove all identifiers to/from the set of VLAN "
1864 "Identifiers filtered by a port",
1866 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1867 (void *)&cmd_rx_vlan_filter_all_what,
1868 (void *)&cmd_rx_vlan_filter_all_all,
1869 (void *)&cmd_rx_vlan_filter_all_portid,
1874 /* *** VLAN OFFLOAD SET ON A PORT *** */
1875 struct cmd_vlan_offload_result {
1876 cmdline_fixed_string_t vlan;
1877 cmdline_fixed_string_t set;
1878 cmdline_fixed_string_t what;
1879 cmdline_fixed_string_t on;
1880 cmdline_fixed_string_t port_id;
1884 cmd_vlan_offload_parsed(void *parsed_result,
1885 __attribute__((unused)) struct cmdline *cl,
1886 __attribute__((unused)) void *data)
1889 struct cmd_vlan_offload_result *res = parsed_result;
1892 portid_t port_id = 0;
1896 len = strnlen(str, STR_TOKEN_SIZE);
1898 /* Get port_id first */
1906 tmp = strtoul(str, NULL, 0);
1907 /* If port_id greater that what portid_t can represent, return */
1908 if(tmp >= RTE_MAX_ETHPORTS)
1910 port_id = (portid_t)tmp;
1912 if (!strcmp(res->on, "on"))
1917 if (!strcmp(res->what, "strip"))
1918 rx_vlan_strip_set(port_id, on);
1919 else if(!strcmp(res->what, "stripq")){
1920 uint16_t queue_id = 0;
1922 /* No queue_id, return */
1925 tmp = strtoul(str + i + 1, NULL, 0);
1926 /* If queue_id greater that what 16-bits can represent, return */
1930 queue_id = (uint16_t)tmp;
1931 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1933 else if (!strcmp(res->what, "filter"))
1934 rx_vlan_filter_set(port_id, on);
1936 vlan_extend_set(port_id, on);
1941 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1944 cmdline_parse_token_string_t cmd_vlan_offload_set =
1945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1947 cmdline_parse_token_string_t cmd_vlan_offload_what =
1948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1949 what, "strip#filter#qinq#stripq");
1950 cmdline_parse_token_string_t cmd_vlan_offload_on =
1951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1953 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1957 cmdline_parse_inst_t cmd_vlan_offload = {
1958 .f = cmd_vlan_offload_parsed,
1960 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1961 " qinq(extended) for both rx/tx sides ",
1963 (void *)&cmd_vlan_offload_vlan,
1964 (void *)&cmd_vlan_offload_set,
1965 (void *)&cmd_vlan_offload_what,
1966 (void *)&cmd_vlan_offload_on,
1967 (void *)&cmd_vlan_offload_portid,
1972 /* *** VLAN TPID SET ON A PORT *** */
1973 struct cmd_vlan_tpid_result {
1974 cmdline_fixed_string_t vlan;
1975 cmdline_fixed_string_t set;
1976 cmdline_fixed_string_t what;
1982 cmd_vlan_tpid_parsed(void *parsed_result,
1983 __attribute__((unused)) struct cmdline *cl,
1984 __attribute__((unused)) void *data)
1986 struct cmd_vlan_tpid_result *res = parsed_result;
1987 vlan_tpid_set(res->port_id, res->tp_id);
1991 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1994 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1997 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2000 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2001 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2003 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2004 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2007 cmdline_parse_inst_t cmd_vlan_tpid = {
2008 .f = cmd_vlan_tpid_parsed,
2010 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2012 (void *)&cmd_vlan_tpid_vlan,
2013 (void *)&cmd_vlan_tpid_set,
2014 (void *)&cmd_vlan_tpid_what,
2015 (void *)&cmd_vlan_tpid_tpid,
2016 (void *)&cmd_vlan_tpid_portid,
2021 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2022 struct cmd_rx_vlan_filter_result {
2023 cmdline_fixed_string_t rx_vlan;
2024 cmdline_fixed_string_t what;
2030 cmd_rx_vlan_filter_parsed(void *parsed_result,
2031 __attribute__((unused)) struct cmdline *cl,
2032 __attribute__((unused)) void *data)
2034 struct cmd_rx_vlan_filter_result *res = parsed_result;
2036 if (!strcmp(res->what, "add"))
2037 rx_vft_set(res->port_id, res->vlan_id, 1);
2039 rx_vft_set(res->port_id, res->vlan_id, 0);
2042 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2043 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2044 rx_vlan, "rx_vlan");
2045 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2046 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2048 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2049 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2051 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2052 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2055 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2056 .f = cmd_rx_vlan_filter_parsed,
2058 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2059 "Identifiers filtered by a port",
2061 (void *)&cmd_rx_vlan_filter_rx_vlan,
2062 (void *)&cmd_rx_vlan_filter_what,
2063 (void *)&cmd_rx_vlan_filter_vlanid,
2064 (void *)&cmd_rx_vlan_filter_portid,
2069 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2070 struct cmd_tx_vlan_set_result {
2071 cmdline_fixed_string_t tx_vlan;
2072 cmdline_fixed_string_t set;
2078 cmd_tx_vlan_set_parsed(void *parsed_result,
2079 __attribute__((unused)) struct cmdline *cl,
2080 __attribute__((unused)) void *data)
2082 struct cmd_tx_vlan_set_result *res = parsed_result;
2083 tx_vlan_set(res->port_id, res->vlan_id);
2086 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2087 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2088 tx_vlan, "tx_vlan");
2089 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2090 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2092 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2093 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2095 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2096 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2099 cmdline_parse_inst_t cmd_tx_vlan_set = {
2100 .f = cmd_tx_vlan_set_parsed,
2102 .help_str = "enable hardware insertion of a VLAN header with a given "
2103 "TAG Identifier in packets sent on a port",
2105 (void *)&cmd_tx_vlan_set_tx_vlan,
2106 (void *)&cmd_tx_vlan_set_set,
2107 (void *)&cmd_tx_vlan_set_vlanid,
2108 (void *)&cmd_tx_vlan_set_portid,
2113 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2114 struct cmd_tx_vlan_reset_result {
2115 cmdline_fixed_string_t tx_vlan;
2116 cmdline_fixed_string_t reset;
2121 cmd_tx_vlan_reset_parsed(void *parsed_result,
2122 __attribute__((unused)) struct cmdline *cl,
2123 __attribute__((unused)) void *data)
2125 struct cmd_tx_vlan_reset_result *res = parsed_result;
2127 tx_vlan_reset(res->port_id);
2130 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2131 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2132 tx_vlan, "tx_vlan");
2133 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2134 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2136 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2137 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2140 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2141 .f = cmd_tx_vlan_reset_parsed,
2143 .help_str = "disable hardware insertion of a VLAN header in packets "
2146 (void *)&cmd_tx_vlan_reset_tx_vlan,
2147 (void *)&cmd_tx_vlan_reset_reset,
2148 (void *)&cmd_tx_vlan_reset_portid,
2154 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2155 struct cmd_tx_cksum_set_result {
2156 cmdline_fixed_string_t tx_cksum;
2157 cmdline_fixed_string_t set;
2163 cmd_tx_cksum_set_parsed(void *parsed_result,
2164 __attribute__((unused)) struct cmdline *cl,
2165 __attribute__((unused)) void *data)
2167 struct cmd_tx_cksum_set_result *res = parsed_result;
2169 tx_cksum_set(res->port_id, res->cksum_mask);
2172 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2173 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2174 tx_cksum, "tx_checksum");
2175 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2176 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2178 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2179 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2181 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2182 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2185 cmdline_parse_inst_t cmd_tx_cksum_set = {
2186 .f = cmd_tx_cksum_set_parsed,
2188 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2189 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2190 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2192 (void *)&cmd_tx_cksum_set_tx_cksum,
2193 (void *)&cmd_tx_cksum_set_set,
2194 (void *)&cmd_tx_cksum_set_cksum_mask,
2195 (void *)&cmd_tx_cksum_set_portid,
2200 /* *** SET FORWARDING MODE *** */
2201 struct cmd_set_fwd_mode_result {
2202 cmdline_fixed_string_t set;
2203 cmdline_fixed_string_t fwd;
2204 cmdline_fixed_string_t mode;
2207 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2208 __attribute__((unused)) struct cmdline *cl,
2209 __attribute__((unused)) void *data)
2211 struct cmd_set_fwd_mode_result *res = parsed_result;
2213 set_pkt_forwarding_mode(res->mode);
2216 cmdline_parse_token_string_t cmd_setfwd_set =
2217 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2218 cmdline_parse_token_string_t cmd_setfwd_fwd =
2219 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2220 cmdline_parse_token_string_t cmd_setfwd_mode =
2221 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2222 #ifdef RTE_LIBRTE_IEEE1588
2223 "io#mac#rxonly#txonly#csum#ieee1588");
2225 "io#mac#rxonly#txonly#csum");
2228 cmdline_parse_inst_t cmd_set_fwd_mode = {
2229 .f = cmd_set_fwd_mode_parsed,
2231 #ifdef RTE_LIBRTE_IEEE1588
2232 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2233 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2235 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2236 " RXONLY, CSUM or TXONLY packet forwarding mode",
2239 (void *)&cmd_setfwd_set,
2240 (void *)&cmd_setfwd_fwd,
2241 (void *)&cmd_setfwd_mode,
2246 /* *** SET PROMISC MODE *** */
2247 struct cmd_set_promisc_mode_result {
2248 cmdline_fixed_string_t set;
2249 cmdline_fixed_string_t promisc;
2250 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2251 uint8_t port_num; /* valid if "allports" argument == 0 */
2252 cmdline_fixed_string_t mode;
2255 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2256 __attribute__((unused)) struct cmdline *cl,
2259 struct cmd_set_promisc_mode_result *res = parsed_result;
2263 if (!strcmp(res->mode, "on"))
2270 for (i = 0; i < nb_ports; i++) {
2272 rte_eth_promiscuous_enable(i);
2274 rte_eth_promiscuous_disable(i);
2279 rte_eth_promiscuous_enable(res->port_num);
2281 rte_eth_promiscuous_disable(res->port_num);
2285 cmdline_parse_token_string_t cmd_setpromisc_set =
2286 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2287 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2288 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2290 cmdline_parse_token_string_t cmd_setpromisc_portall =
2291 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2293 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2294 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2296 cmdline_parse_token_string_t cmd_setpromisc_mode =
2297 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2300 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2301 .f = cmd_set_promisc_mode_parsed,
2303 .help_str = "set promisc all on|off: set promisc mode for all ports",
2305 (void *)&cmd_setpromisc_set,
2306 (void *)&cmd_setpromisc_promisc,
2307 (void *)&cmd_setpromisc_portall,
2308 (void *)&cmd_setpromisc_mode,
2313 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2314 .f = cmd_set_promisc_mode_parsed,
2316 .help_str = "set promisc X on|off: set promisc mode on port X",
2318 (void *)&cmd_setpromisc_set,
2319 (void *)&cmd_setpromisc_promisc,
2320 (void *)&cmd_setpromisc_portnum,
2321 (void *)&cmd_setpromisc_mode,
2326 /* *** SET ALLMULTI MODE *** */
2327 struct cmd_set_allmulti_mode_result {
2328 cmdline_fixed_string_t set;
2329 cmdline_fixed_string_t allmulti;
2330 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2331 uint8_t port_num; /* valid if "allports" argument == 0 */
2332 cmdline_fixed_string_t mode;
2335 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2336 __attribute__((unused)) struct cmdline *cl,
2339 struct cmd_set_allmulti_mode_result *res = parsed_result;
2343 if (!strcmp(res->mode, "on"))
2350 for (i = 0; i < nb_ports; i++) {
2352 rte_eth_allmulticast_enable(i);
2354 rte_eth_allmulticast_disable(i);
2359 rte_eth_allmulticast_enable(res->port_num);
2361 rte_eth_allmulticast_disable(res->port_num);
2365 cmdline_parse_token_string_t cmd_setallmulti_set =
2366 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2367 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2368 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2370 cmdline_parse_token_string_t cmd_setallmulti_portall =
2371 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2373 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2374 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2376 cmdline_parse_token_string_t cmd_setallmulti_mode =
2377 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2380 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2381 .f = cmd_set_allmulti_mode_parsed,
2383 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2385 (void *)&cmd_setallmulti_set,
2386 (void *)&cmd_setallmulti_allmulti,
2387 (void *)&cmd_setallmulti_portall,
2388 (void *)&cmd_setallmulti_mode,
2393 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2394 .f = cmd_set_allmulti_mode_parsed,
2396 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2398 (void *)&cmd_setallmulti_set,
2399 (void *)&cmd_setallmulti_allmulti,
2400 (void *)&cmd_setallmulti_portnum,
2401 (void *)&cmd_setallmulti_mode,
2406 /* *** ADD/REMOVE A PKT FILTER *** */
2407 struct cmd_pkt_filter_result {
2408 cmdline_fixed_string_t pkt_filter;
2410 cmdline_fixed_string_t protocol;
2411 cmdline_fixed_string_t src;
2412 cmdline_ipaddr_t ip_src;
2414 cmdline_fixed_string_t dst;
2415 cmdline_ipaddr_t ip_dst;
2417 cmdline_fixed_string_t flexbytes;
2418 uint16_t flexbytes_value;
2419 cmdline_fixed_string_t vlan;
2421 cmdline_fixed_string_t queue;
2423 cmdline_fixed_string_t soft;
2428 cmd_pkt_filter_parsed(void *parsed_result,
2429 __attribute__((unused)) struct cmdline *cl,
2430 __attribute__((unused)) void *data)
2432 struct rte_fdir_filter fdir_filter;
2433 struct cmd_pkt_filter_result *res = parsed_result;
2435 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2437 if (res->ip_src.family == AF_INET)
2438 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2440 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2441 &(res->ip_src.addr.ipv6),
2442 sizeof(struct in6_addr));
2444 if (res->ip_dst.family == AF_INET)
2445 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2447 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2448 &(res->ip_dst.addr.ipv6),
2449 sizeof(struct in6_addr));
2451 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2452 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2454 if (!strcmp(res->protocol, "udp"))
2455 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2456 else if (!strcmp(res->protocol, "tcp"))
2457 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2458 else if (!strcmp(res->protocol, "sctp"))
2459 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2460 else /* default only IP */
2461 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2463 if (res->ip_dst.family == AF_INET6)
2464 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2466 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2468 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2469 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2471 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2472 fdir_add_signature_filter(res->port_id, res->queue_id,
2474 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2475 fdir_update_signature_filter(res->port_id, res->queue_id,
2477 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2478 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2479 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2480 fdir_add_perfect_filter(res->port_id, res->soft_id,
2482 (uint8_t) (res->queue_id < 0),
2484 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2485 fdir_update_perfect_filter(res->port_id, res->soft_id,
2487 (uint8_t) (res->queue_id < 0),
2489 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2490 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2496 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2497 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2499 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2500 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2501 protocol, "ip#tcp#udp#sctp");
2502 cmdline_parse_token_string_t cmd_pkt_filter_src =
2503 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2505 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2506 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2508 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2509 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2511 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2512 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2514 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2515 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2517 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2518 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2520 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2521 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2522 flexbytes, "flexbytes");
2523 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2524 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2525 flexbytes_value, UINT16);
2526 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2527 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2529 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2530 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2532 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2533 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2535 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2536 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2538 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2539 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2541 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2542 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2546 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2547 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2548 pkt_filter, "add_signature_filter");
2549 cmdline_parse_inst_t cmd_add_signature_filter = {
2550 .f = cmd_pkt_filter_parsed,
2552 .help_str = "add a signature filter",
2554 (void *)&cmd_pkt_filter_add_signature_filter,
2555 (void *)&cmd_pkt_filter_port_id,
2556 (void *)&cmd_pkt_filter_protocol,
2557 (void *)&cmd_pkt_filter_src,
2558 (void *)&cmd_pkt_filter_ip_src,
2559 (void *)&cmd_pkt_filter_port_src,
2560 (void *)&cmd_pkt_filter_dst,
2561 (void *)&cmd_pkt_filter_ip_dst,
2562 (void *)&cmd_pkt_filter_port_dst,
2563 (void *)&cmd_pkt_filter_flexbytes,
2564 (void *)&cmd_pkt_filter_flexbytes_value,
2565 (void *)&cmd_pkt_filter_vlan,
2566 (void *)&cmd_pkt_filter_vlan_id,
2567 (void *)&cmd_pkt_filter_queue,
2568 (void *)&cmd_pkt_filter_queue_id,
2574 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2575 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2576 pkt_filter, "upd_signature_filter");
2577 cmdline_parse_inst_t cmd_upd_signature_filter = {
2578 .f = cmd_pkt_filter_parsed,
2580 .help_str = "update a signature filter",
2582 (void *)&cmd_pkt_filter_upd_signature_filter,
2583 (void *)&cmd_pkt_filter_port_id,
2584 (void *)&cmd_pkt_filter_protocol,
2585 (void *)&cmd_pkt_filter_src,
2586 (void *)&cmd_pkt_filter_ip_src,
2587 (void *)&cmd_pkt_filter_port_src,
2588 (void *)&cmd_pkt_filter_dst,
2589 (void *)&cmd_pkt_filter_ip_dst,
2590 (void *)&cmd_pkt_filter_port_dst,
2591 (void *)&cmd_pkt_filter_flexbytes,
2592 (void *)&cmd_pkt_filter_flexbytes_value,
2593 (void *)&cmd_pkt_filter_vlan,
2594 (void *)&cmd_pkt_filter_vlan_id,
2595 (void *)&cmd_pkt_filter_queue,
2596 (void *)&cmd_pkt_filter_queue_id,
2602 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2603 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2604 pkt_filter, "rm_signature_filter");
2605 cmdline_parse_inst_t cmd_rm_signature_filter = {
2606 .f = cmd_pkt_filter_parsed,
2608 .help_str = "remove a signature filter",
2610 (void *)&cmd_pkt_filter_rm_signature_filter,
2611 (void *)&cmd_pkt_filter_port_id,
2612 (void *)&cmd_pkt_filter_protocol,
2613 (void *)&cmd_pkt_filter_src,
2614 (void *)&cmd_pkt_filter_ip_src,
2615 (void *)&cmd_pkt_filter_port_src,
2616 (void *)&cmd_pkt_filter_dst,
2617 (void *)&cmd_pkt_filter_ip_dst,
2618 (void *)&cmd_pkt_filter_port_dst,
2619 (void *)&cmd_pkt_filter_flexbytes,
2620 (void *)&cmd_pkt_filter_flexbytes_value,
2621 (void *)&cmd_pkt_filter_vlan,
2622 (void *)&cmd_pkt_filter_vlan_id,
2628 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2629 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2630 pkt_filter, "add_perfect_filter");
2631 cmdline_parse_inst_t cmd_add_perfect_filter = {
2632 .f = cmd_pkt_filter_parsed,
2634 .help_str = "add a perfect filter",
2636 (void *)&cmd_pkt_filter_add_perfect_filter,
2637 (void *)&cmd_pkt_filter_port_id,
2638 (void *)&cmd_pkt_filter_protocol,
2639 (void *)&cmd_pkt_filter_src,
2640 (void *)&cmd_pkt_filter_ip_src,
2641 (void *)&cmd_pkt_filter_port_src,
2642 (void *)&cmd_pkt_filter_dst,
2643 (void *)&cmd_pkt_filter_ip_dst,
2644 (void *)&cmd_pkt_filter_port_dst,
2645 (void *)&cmd_pkt_filter_flexbytes,
2646 (void *)&cmd_pkt_filter_flexbytes_value,
2647 (void *)&cmd_pkt_filter_vlan,
2648 (void *)&cmd_pkt_filter_vlan_id,
2649 (void *)&cmd_pkt_filter_queue,
2650 (void *)&cmd_pkt_filter_queue_id,
2651 (void *)&cmd_pkt_filter_soft,
2652 (void *)&cmd_pkt_filter_soft_id,
2658 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2659 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2660 pkt_filter, "upd_perfect_filter");
2661 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2662 .f = cmd_pkt_filter_parsed,
2664 .help_str = "update a perfect filter",
2666 (void *)&cmd_pkt_filter_upd_perfect_filter,
2667 (void *)&cmd_pkt_filter_port_id,
2668 (void *)&cmd_pkt_filter_protocol,
2669 (void *)&cmd_pkt_filter_src,
2670 (void *)&cmd_pkt_filter_ip_src,
2671 (void *)&cmd_pkt_filter_port_src,
2672 (void *)&cmd_pkt_filter_dst,
2673 (void *)&cmd_pkt_filter_ip_dst,
2674 (void *)&cmd_pkt_filter_port_dst,
2675 (void *)&cmd_pkt_filter_flexbytes,
2676 (void *)&cmd_pkt_filter_flexbytes_value,
2677 (void *)&cmd_pkt_filter_vlan,
2678 (void *)&cmd_pkt_filter_vlan_id,
2679 (void *)&cmd_pkt_filter_queue,
2680 (void *)&cmd_pkt_filter_queue_id,
2681 (void *)&cmd_pkt_filter_soft,
2682 (void *)&cmd_pkt_filter_soft_id,
2688 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2689 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2690 pkt_filter, "rm_perfect_filter");
2691 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2692 .f = cmd_pkt_filter_parsed,
2694 .help_str = "remove a perfect filter",
2696 (void *)&cmd_pkt_filter_rm_perfect_filter,
2697 (void *)&cmd_pkt_filter_port_id,
2698 (void *)&cmd_pkt_filter_protocol,
2699 (void *)&cmd_pkt_filter_src,
2700 (void *)&cmd_pkt_filter_ip_src,
2701 (void *)&cmd_pkt_filter_port_src,
2702 (void *)&cmd_pkt_filter_dst,
2703 (void *)&cmd_pkt_filter_ip_dst,
2704 (void *)&cmd_pkt_filter_port_dst,
2705 (void *)&cmd_pkt_filter_flexbytes,
2706 (void *)&cmd_pkt_filter_flexbytes_value,
2707 (void *)&cmd_pkt_filter_vlan,
2708 (void *)&cmd_pkt_filter_vlan_id,
2709 (void *)&cmd_pkt_filter_soft,
2710 (void *)&cmd_pkt_filter_soft_id,
2715 /* *** SETUP MASKS FILTER *** */
2716 struct cmd_pkt_filter_masks_result {
2717 cmdline_fixed_string_t filter_mask;
2719 cmdline_fixed_string_t src_mask;
2720 uint32_t ip_src_mask;
2721 uint16_t ipv6_src_mask;
2722 uint16_t port_src_mask;
2723 cmdline_fixed_string_t dst_mask;
2724 uint32_t ip_dst_mask;
2725 uint16_t ipv6_dst_mask;
2726 uint16_t port_dst_mask;
2727 cmdline_fixed_string_t flexbytes;
2728 uint8_t flexbytes_value;
2729 cmdline_fixed_string_t vlan_id;
2730 uint8_t vlan_id_value;
2731 cmdline_fixed_string_t vlan_prio;
2732 uint8_t vlan_prio_value;
2733 cmdline_fixed_string_t only_ip_flow;
2734 uint8_t only_ip_flow_value;
2735 cmdline_fixed_string_t comp_ipv6_dst;
2736 uint8_t comp_ipv6_dst_value;
2740 cmd_pkt_filter_masks_parsed(void *parsed_result,
2741 __attribute__((unused)) struct cmdline *cl,
2742 __attribute__((unused)) void *data)
2744 struct rte_fdir_masks fdir_masks;
2745 struct cmd_pkt_filter_masks_result *res = parsed_result;
2747 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2749 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2750 fdir_masks.vlan_id = res->vlan_id_value;
2751 fdir_masks.vlan_prio = res->vlan_prio_value;
2752 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2753 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2754 fdir_masks.src_port_mask = res->port_src_mask;
2755 fdir_masks.dst_port_mask = res->port_dst_mask;
2756 fdir_masks.flexbytes = res->flexbytes_value;
2758 fdir_set_masks(res->port_id, &fdir_masks);
2761 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2762 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2763 filter_mask, "set_masks_filter");
2764 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2765 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2767 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2768 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2769 only_ip_flow, "only_ip_flow");
2770 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2771 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2772 only_ip_flow_value, UINT8);
2773 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2774 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2775 src_mask, "src_mask");
2776 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2777 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2778 ip_src_mask, UINT32);
2779 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2780 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2781 port_src_mask, UINT16);
2782 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2783 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2784 dst_mask, "dst_mask");
2785 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2786 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2787 ip_dst_mask, UINT32);
2788 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2789 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2790 port_dst_mask, UINT16);
2791 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2792 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2793 flexbytes, "flexbytes");
2794 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2795 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2796 flexbytes_value, UINT8);
2797 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2798 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2799 vlan_id, "vlan_id");
2800 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2801 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2802 vlan_id_value, UINT8);
2803 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2804 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2805 vlan_prio, "vlan_prio");
2806 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2807 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2808 vlan_prio_value, UINT8);
2810 cmdline_parse_inst_t cmd_set_masks_filter = {
2811 .f = cmd_pkt_filter_masks_parsed,
2813 .help_str = "setup masks filter",
2815 (void *)&cmd_pkt_filter_masks_filter_mask,
2816 (void *)&cmd_pkt_filter_masks_port_id,
2817 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2818 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2819 (void *)&cmd_pkt_filter_masks_src_mask,
2820 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2821 (void *)&cmd_pkt_filter_masks_port_src_mask,
2822 (void *)&cmd_pkt_filter_masks_dst_mask,
2823 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2824 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2825 (void *)&cmd_pkt_filter_masks_flexbytes,
2826 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2827 (void *)&cmd_pkt_filter_masks_vlan_id,
2828 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2829 (void *)&cmd_pkt_filter_masks_vlan_prio,
2830 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2836 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2837 __attribute__((unused)) struct cmdline *cl,
2838 __attribute__((unused)) void *data)
2840 struct rte_fdir_masks fdir_masks;
2841 struct cmd_pkt_filter_masks_result *res = parsed_result;
2843 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2845 fdir_masks.set_ipv6_mask = 1;
2846 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2847 fdir_masks.vlan_id = res->vlan_id_value;
2848 fdir_masks.vlan_prio = res->vlan_prio_value;
2849 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2850 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2851 fdir_masks.src_port_mask = res->port_src_mask;
2852 fdir_masks.dst_port_mask = res->port_dst_mask;
2853 fdir_masks.flexbytes = res->flexbytes_value;
2854 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2856 fdir_set_masks(res->port_id, &fdir_masks);
2859 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2860 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2861 filter_mask, "set_ipv6_masks_filter");
2862 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2863 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2864 ipv6_src_mask, UINT16);
2865 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2866 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2867 ipv6_dst_mask, UINT16);
2869 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2870 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2871 comp_ipv6_dst, "compare_dst");
2872 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2873 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2874 comp_ipv6_dst_value, UINT8);
2876 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2877 .f = cmd_pkt_filter_masks_ipv6_parsed,
2879 .help_str = "setup ipv6 masks filter",
2881 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2882 (void *)&cmd_pkt_filter_masks_port_id,
2883 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2884 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2885 (void *)&cmd_pkt_filter_masks_src_mask,
2886 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2887 (void *)&cmd_pkt_filter_masks_port_src_mask,
2888 (void *)&cmd_pkt_filter_masks_dst_mask,
2889 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2890 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2891 (void *)&cmd_pkt_filter_masks_flexbytes,
2892 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2893 (void *)&cmd_pkt_filter_masks_vlan_id,
2894 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2895 (void *)&cmd_pkt_filter_masks_vlan_prio,
2896 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2897 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2898 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2903 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2904 struct cmd_link_flow_ctrl_set_result {
2905 cmdline_fixed_string_t set;
2906 cmdline_fixed_string_t flow_ctrl;
2907 cmdline_fixed_string_t rx;
2908 cmdline_fixed_string_t rx_lfc_mode;
2909 cmdline_fixed_string_t tx;
2910 cmdline_fixed_string_t tx_lfc_mode;
2911 uint32_t high_water;
2913 uint16_t pause_time;
2919 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2920 __attribute__((unused)) struct cmdline *cl,
2921 __attribute__((unused)) void *data)
2923 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2924 struct rte_eth_fc_conf fc_conf;
2925 int rx_fc_enable, tx_fc_enable;
2929 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2930 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2931 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2932 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2934 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2935 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2938 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2939 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2941 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2942 fc_conf.high_water = res->high_water;
2943 fc_conf.low_water = res->low_water;
2944 fc_conf.pause_time = res->pause_time;
2945 fc_conf.send_xon = res->send_xon;
2947 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2949 printf("bad flow contrl parameter, return code = %d \n", ret);
2952 cmdline_parse_token_string_t cmd_lfc_set_set =
2953 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2955 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2956 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2957 flow_ctrl, "flow_ctrl");
2958 cmdline_parse_token_string_t cmd_lfc_set_rx =
2959 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2961 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2962 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2963 rx_lfc_mode, "on#off");
2964 cmdline_parse_token_string_t cmd_lfc_set_tx =
2965 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2967 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2968 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2969 tx_lfc_mode, "on#off");
2970 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2971 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2972 high_water, UINT32);
2973 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2974 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2976 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2977 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2978 pause_time, UINT16);
2979 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2980 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2982 cmdline_parse_token_num_t cmd_lfc_set_portid =
2983 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2986 cmdline_parse_inst_t cmd_link_flow_control_set = {
2987 .f = cmd_link_flow_ctrl_set_parsed,
2989 .help_str = "Configure the Ethernet link flow control...",
2991 (void *)&cmd_lfc_set_set,
2992 (void *)&cmd_lfc_set_flow_ctrl,
2993 (void *)&cmd_lfc_set_rx,
2994 (void *)&cmd_lfc_set_rx_mode,
2995 (void *)&cmd_lfc_set_tx,
2996 (void *)&cmd_lfc_set_tx_mode,
2997 (void *)&cmd_lfc_set_high_water,
2998 (void *)&cmd_lfc_set_low_water,
2999 (void *)&cmd_lfc_set_pause_time,
3000 (void *)&cmd_lfc_set_send_xon,
3001 (void *)&cmd_lfc_set_portid,
3006 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3007 struct cmd_priority_flow_ctrl_set_result {
3008 cmdline_fixed_string_t set;
3009 cmdline_fixed_string_t pfc_ctrl;
3010 cmdline_fixed_string_t rx;
3011 cmdline_fixed_string_t rx_pfc_mode;
3012 cmdline_fixed_string_t tx;
3013 cmdline_fixed_string_t tx_pfc_mode;
3014 uint32_t high_water;
3016 uint16_t pause_time;
3022 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3023 __attribute__((unused)) struct cmdline *cl,
3024 __attribute__((unused)) void *data)
3026 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3027 struct rte_eth_pfc_conf pfc_conf;
3028 int rx_fc_enable, tx_fc_enable;
3032 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3033 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3034 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3035 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3037 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3038 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3041 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3042 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3043 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3044 pfc_conf.fc.high_water = res->high_water;
3045 pfc_conf.fc.low_water = res->low_water;
3046 pfc_conf.fc.pause_time = res->pause_time;
3047 pfc_conf.priority = res->priority;
3049 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3051 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3054 cmdline_parse_token_string_t cmd_pfc_set_set =
3055 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3057 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3058 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3059 pfc_ctrl, "pfc_ctrl");
3060 cmdline_parse_token_string_t cmd_pfc_set_rx =
3061 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3063 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3064 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3065 rx_pfc_mode, "on#off");
3066 cmdline_parse_token_string_t cmd_pfc_set_tx =
3067 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3069 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3070 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3071 tx_pfc_mode, "on#off");
3072 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3073 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3074 high_water, UINT32);
3075 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3076 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3078 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3079 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3080 pause_time, UINT16);
3081 cmdline_parse_token_num_t cmd_pfc_set_priority =
3082 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3084 cmdline_parse_token_num_t cmd_pfc_set_portid =
3085 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3088 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3089 .f = cmd_priority_flow_ctrl_set_parsed,
3091 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3092 tx on|off high_water low_water pause_time priority port_id",
3094 (void *)&cmd_pfc_set_set,
3095 (void *)&cmd_pfc_set_flow_ctrl,
3096 (void *)&cmd_pfc_set_rx,
3097 (void *)&cmd_pfc_set_rx_mode,
3098 (void *)&cmd_pfc_set_tx,
3099 (void *)&cmd_pfc_set_tx_mode,
3100 (void *)&cmd_pfc_set_high_water,
3101 (void *)&cmd_pfc_set_low_water,
3102 (void *)&cmd_pfc_set_pause_time,
3103 (void *)&cmd_pfc_set_priority,
3104 (void *)&cmd_pfc_set_portid,
3109 /* *** RESET CONFIGURATION *** */
3110 struct cmd_reset_result {
3111 cmdline_fixed_string_t reset;
3112 cmdline_fixed_string_t def;
3115 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3117 __attribute__((unused)) void *data)
3119 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3120 set_def_fwd_config();
3123 cmdline_parse_token_string_t cmd_reset_set =
3124 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3125 cmdline_parse_token_string_t cmd_reset_def =
3126 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3129 cmdline_parse_inst_t cmd_reset = {
3130 .f = cmd_reset_parsed,
3132 .help_str = "set default: reset default forwarding configuration",
3134 (void *)&cmd_reset_set,
3135 (void *)&cmd_reset_def,
3140 /* *** START FORWARDING *** */
3141 struct cmd_start_result {
3142 cmdline_fixed_string_t start;
3145 cmdline_parse_token_string_t cmd_start_start =
3146 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3148 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3149 __attribute__((unused)) struct cmdline *cl,
3150 __attribute__((unused)) void *data)
3152 start_packet_forwarding(0);
3155 cmdline_parse_inst_t cmd_start = {
3156 .f = cmd_start_parsed,
3158 .help_str = "start packet forwarding",
3160 (void *)&cmd_start_start,
3165 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3166 struct cmd_start_tx_first_result {
3167 cmdline_fixed_string_t start;
3168 cmdline_fixed_string_t tx_first;
3172 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3173 __attribute__((unused)) struct cmdline *cl,
3174 __attribute__((unused)) void *data)
3176 start_packet_forwarding(1);
3179 cmdline_parse_token_string_t cmd_start_tx_first_start =
3180 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3182 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3183 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3184 tx_first, "tx_first");
3186 cmdline_parse_inst_t cmd_start_tx_first = {
3187 .f = cmd_start_tx_first_parsed,
3189 .help_str = "start packet forwarding, after sending 1 burst of packets",
3191 (void *)&cmd_start_tx_first_start,
3192 (void *)&cmd_start_tx_first_tx_first,
3197 /* *** SHOW CFG *** */
3198 struct cmd_showcfg_result {
3199 cmdline_fixed_string_t show;
3200 cmdline_fixed_string_t cfg;
3201 cmdline_fixed_string_t what;
3204 static void cmd_showcfg_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_showcfg_result *res = parsed_result;
3209 if (!strcmp(res->what, "rxtx"))
3210 rxtx_config_display();
3211 else if (!strcmp(res->what, "cores"))
3212 fwd_lcores_config_display();
3213 else if (!strcmp(res->what, "fwd"))
3214 fwd_config_display();
3217 cmdline_parse_token_string_t cmd_showcfg_show =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3219 cmdline_parse_token_string_t cmd_showcfg_port =
3220 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3221 cmdline_parse_token_string_t cmd_showcfg_what =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3225 cmdline_parse_inst_t cmd_showcfg = {
3226 .f = cmd_showcfg_parsed,
3228 .help_str = "show config rxtx|cores|fwd",
3230 (void *)&cmd_showcfg_show,
3231 (void *)&cmd_showcfg_port,
3232 (void *)&cmd_showcfg_what,
3237 /* *** SHOW ALL PORT INFO *** */
3238 struct cmd_showportall_result {
3239 cmdline_fixed_string_t show;
3240 cmdline_fixed_string_t port;
3241 cmdline_fixed_string_t what;
3242 cmdline_fixed_string_t all;
3245 static void cmd_showportall_parsed(void *parsed_result,
3246 __attribute__((unused)) struct cmdline *cl,
3247 __attribute__((unused)) void *data)
3251 struct cmd_showportall_result *res = parsed_result;
3252 if (!strcmp(res->show, "clear")) {
3253 if (!strcmp(res->what, "stats"))
3254 for (i = 0; i < nb_ports; i++)
3256 } else if (!strcmp(res->what, "info"))
3257 for (i = 0; i < nb_ports; i++)
3258 port_infos_display(i);
3259 else if (!strcmp(res->what, "stats"))
3260 for (i = 0; i < nb_ports; i++)
3261 nic_stats_display(i);
3262 else if (!strcmp(res->what, "fdir"))
3263 for (i = 0; i < nb_ports; i++)
3265 else if (!strcmp(res->what, "stat_qmap"))
3266 for (i = 0; i < nb_ports; i++)
3267 nic_stats_mapping_display(i);
3270 cmdline_parse_token_string_t cmd_showportall_show =
3271 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3273 cmdline_parse_token_string_t cmd_showportall_port =
3274 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3275 cmdline_parse_token_string_t cmd_showportall_what =
3276 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3277 "info#stats#fdir#stat_qmap");
3278 cmdline_parse_token_string_t cmd_showportall_all =
3279 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3280 cmdline_parse_inst_t cmd_showportall = {
3281 .f = cmd_showportall_parsed,
3283 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3285 (void *)&cmd_showportall_show,
3286 (void *)&cmd_showportall_port,
3287 (void *)&cmd_showportall_what,
3288 (void *)&cmd_showportall_all,
3293 /* *** SHOW PORT INFO *** */
3294 struct cmd_showport_result {
3295 cmdline_fixed_string_t show;
3296 cmdline_fixed_string_t port;
3297 cmdline_fixed_string_t what;
3301 static void cmd_showport_parsed(void *parsed_result,
3302 __attribute__((unused)) struct cmdline *cl,
3303 __attribute__((unused)) void *data)
3305 struct cmd_showport_result *res = parsed_result;
3306 if (!strcmp(res->show, "clear")) {
3307 if (!strcmp(res->what, "stats"))
3308 nic_stats_clear(res->portnum);
3309 } else if (!strcmp(res->what, "info"))
3310 port_infos_display(res->portnum);
3311 else if (!strcmp(res->what, "stats"))
3312 nic_stats_display(res->portnum);
3313 else if (!strcmp(res->what, "fdir"))
3314 fdir_get_infos(res->portnum);
3315 else if (!strcmp(res->what, "stat_qmap"))
3316 nic_stats_mapping_display(res->portnum);
3319 cmdline_parse_token_string_t cmd_showport_show =
3320 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3322 cmdline_parse_token_string_t cmd_showport_port =
3323 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3324 cmdline_parse_token_string_t cmd_showport_what =
3325 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3326 "info#stats#fdir#stat_qmap");
3327 cmdline_parse_token_num_t cmd_showport_portnum =
3328 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3330 cmdline_parse_inst_t cmd_showport = {
3331 .f = cmd_showport_parsed,
3333 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3335 (void *)&cmd_showport_show,
3336 (void *)&cmd_showport_port,
3337 (void *)&cmd_showport_what,
3338 (void *)&cmd_showport_portnum,
3343 /* *** READ PORT REGISTER *** */
3344 struct cmd_read_reg_result {
3345 cmdline_fixed_string_t read;
3346 cmdline_fixed_string_t reg;
3352 cmd_read_reg_parsed(void *parsed_result,
3353 __attribute__((unused)) struct cmdline *cl,
3354 __attribute__((unused)) void *data)
3356 struct cmd_read_reg_result *res = parsed_result;
3357 port_reg_display(res->port_id, res->reg_off);
3360 cmdline_parse_token_string_t cmd_read_reg_read =
3361 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3362 cmdline_parse_token_string_t cmd_read_reg_reg =
3363 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3364 cmdline_parse_token_num_t cmd_read_reg_port_id =
3365 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3366 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3367 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3369 cmdline_parse_inst_t cmd_read_reg = {
3370 .f = cmd_read_reg_parsed,
3372 .help_str = "read reg port_id reg_off",
3374 (void *)&cmd_read_reg_read,
3375 (void *)&cmd_read_reg_reg,
3376 (void *)&cmd_read_reg_port_id,
3377 (void *)&cmd_read_reg_reg_off,
3382 /* *** READ PORT REGISTER BIT FIELD *** */
3383 struct cmd_read_reg_bit_field_result {
3384 cmdline_fixed_string_t read;
3385 cmdline_fixed_string_t regfield;
3393 cmd_read_reg_bit_field_parsed(void *parsed_result,
3394 __attribute__((unused)) struct cmdline *cl,
3395 __attribute__((unused)) void *data)
3397 struct cmd_read_reg_bit_field_result *res = parsed_result;
3398 port_reg_bit_field_display(res->port_id, res->reg_off,
3399 res->bit1_pos, res->bit2_pos);
3402 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3405 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3406 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3407 regfield, "regfield");
3408 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3409 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3411 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3412 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3414 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3417 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3418 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3421 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3422 .f = cmd_read_reg_bit_field_parsed,
3424 .help_str = "read regfield port_id reg_off bit_x bit_y "
3425 "(read register bit field between bit_x and bit_y included)",
3427 (void *)&cmd_read_reg_bit_field_read,
3428 (void *)&cmd_read_reg_bit_field_regfield,
3429 (void *)&cmd_read_reg_bit_field_port_id,
3430 (void *)&cmd_read_reg_bit_field_reg_off,
3431 (void *)&cmd_read_reg_bit_field_bit1_pos,
3432 (void *)&cmd_read_reg_bit_field_bit2_pos,
3437 /* *** READ PORT REGISTER BIT *** */
3438 struct cmd_read_reg_bit_result {
3439 cmdline_fixed_string_t read;
3440 cmdline_fixed_string_t regbit;
3447 cmd_read_reg_bit_parsed(void *parsed_result,
3448 __attribute__((unused)) struct cmdline *cl,
3449 __attribute__((unused)) void *data)
3451 struct cmd_read_reg_bit_result *res = parsed_result;
3452 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3455 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3456 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3457 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3458 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3460 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3461 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3462 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3464 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3465 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3467 cmdline_parse_inst_t cmd_read_reg_bit = {
3468 .f = cmd_read_reg_bit_parsed,
3470 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3472 (void *)&cmd_read_reg_bit_read,
3473 (void *)&cmd_read_reg_bit_regbit,
3474 (void *)&cmd_read_reg_bit_port_id,
3475 (void *)&cmd_read_reg_bit_reg_off,
3476 (void *)&cmd_read_reg_bit_bit_pos,
3481 /* *** WRITE PORT REGISTER *** */
3482 struct cmd_write_reg_result {
3483 cmdline_fixed_string_t write;
3484 cmdline_fixed_string_t reg;
3491 cmd_write_reg_parsed(void *parsed_result,
3492 __attribute__((unused)) struct cmdline *cl,
3493 __attribute__((unused)) void *data)
3495 struct cmd_write_reg_result *res = parsed_result;
3496 port_reg_set(res->port_id, res->reg_off, res->value);
3499 cmdline_parse_token_string_t cmd_write_reg_write =
3500 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3501 cmdline_parse_token_string_t cmd_write_reg_reg =
3502 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3503 cmdline_parse_token_num_t cmd_write_reg_port_id =
3504 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3505 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3506 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3507 cmdline_parse_token_num_t cmd_write_reg_value =
3508 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3510 cmdline_parse_inst_t cmd_write_reg = {
3511 .f = cmd_write_reg_parsed,
3513 .help_str = "write reg port_id reg_off reg_value",
3515 (void *)&cmd_write_reg_write,
3516 (void *)&cmd_write_reg_reg,
3517 (void *)&cmd_write_reg_port_id,
3518 (void *)&cmd_write_reg_reg_off,
3519 (void *)&cmd_write_reg_value,
3524 /* *** WRITE PORT REGISTER BIT FIELD *** */
3525 struct cmd_write_reg_bit_field_result {
3526 cmdline_fixed_string_t write;
3527 cmdline_fixed_string_t regfield;
3536 cmd_write_reg_bit_field_parsed(void *parsed_result,
3537 __attribute__((unused)) struct cmdline *cl,
3538 __attribute__((unused)) void *data)
3540 struct cmd_write_reg_bit_field_result *res = parsed_result;
3541 port_reg_bit_field_set(res->port_id, res->reg_off,
3542 res->bit1_pos, res->bit2_pos, res->value);
3545 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3546 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3548 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3549 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3550 regfield, "regfield");
3551 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3552 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3554 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3555 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3557 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3558 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3560 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3561 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3563 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3564 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3567 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3568 .f = cmd_write_reg_bit_field_parsed,
3570 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3571 "(set register bit field between bit_x and bit_y included)",
3573 (void *)&cmd_write_reg_bit_field_write,
3574 (void *)&cmd_write_reg_bit_field_regfield,
3575 (void *)&cmd_write_reg_bit_field_port_id,
3576 (void *)&cmd_write_reg_bit_field_reg_off,
3577 (void *)&cmd_write_reg_bit_field_bit1_pos,
3578 (void *)&cmd_write_reg_bit_field_bit2_pos,
3579 (void *)&cmd_write_reg_bit_field_value,
3584 /* *** WRITE PORT REGISTER BIT *** */
3585 struct cmd_write_reg_bit_result {
3586 cmdline_fixed_string_t write;
3587 cmdline_fixed_string_t regbit;
3595 cmd_write_reg_bit_parsed(void *parsed_result,
3596 __attribute__((unused)) struct cmdline *cl,
3597 __attribute__((unused)) void *data)
3599 struct cmd_write_reg_bit_result *res = parsed_result;
3600 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3603 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3604 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3606 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3607 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3609 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3610 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3611 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3613 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3614 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3615 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3616 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3618 cmdline_parse_inst_t cmd_write_reg_bit = {
3619 .f = cmd_write_reg_bit_parsed,
3621 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3623 (void *)&cmd_write_reg_bit_write,
3624 (void *)&cmd_write_reg_bit_regbit,
3625 (void *)&cmd_write_reg_bit_port_id,
3626 (void *)&cmd_write_reg_bit_reg_off,
3627 (void *)&cmd_write_reg_bit_bit_pos,
3628 (void *)&cmd_write_reg_bit_value,
3633 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3634 struct cmd_read_rxd_txd_result {
3635 cmdline_fixed_string_t read;
3636 cmdline_fixed_string_t rxd_txd;
3643 cmd_read_rxd_txd_parsed(void *parsed_result,
3644 __attribute__((unused)) struct cmdline *cl,
3645 __attribute__((unused)) void *data)
3647 struct cmd_read_rxd_txd_result *res = parsed_result;
3649 if (!strcmp(res->rxd_txd, "rxd"))
3650 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3651 else if (!strcmp(res->rxd_txd, "txd"))
3652 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3655 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3656 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3657 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3658 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3660 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3661 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3662 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3663 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3664 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3665 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3667 cmdline_parse_inst_t cmd_read_rxd_txd = {
3668 .f = cmd_read_rxd_txd_parsed,
3670 .help_str = "read rxd|txd port_id queue_id rxd_id",
3672 (void *)&cmd_read_rxd_txd_read,
3673 (void *)&cmd_read_rxd_txd_rxd_txd,
3674 (void *)&cmd_read_rxd_txd_port_id,
3675 (void *)&cmd_read_rxd_txd_queue_id,
3676 (void *)&cmd_read_rxd_txd_desc_id,
3682 struct cmd_quit_result {
3683 cmdline_fixed_string_t quit;
3686 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3688 __attribute__((unused)) void *data)
3694 cmdline_parse_token_string_t cmd_quit_quit =
3695 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3697 cmdline_parse_inst_t cmd_quit = {
3698 .f = cmd_quit_parsed,
3700 .help_str = "exit application",
3702 (void *)&cmd_quit_quit,
3707 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3708 struct cmd_mac_addr_result {
3709 cmdline_fixed_string_t mac_addr_cmd;
3710 cmdline_fixed_string_t what;
3712 struct ether_addr address;
3715 static void cmd_mac_addr_parsed(void *parsed_result,
3716 __attribute__((unused)) struct cmdline *cl,
3717 __attribute__((unused)) void *data)
3719 struct cmd_mac_addr_result *res = parsed_result;
3722 if (strcmp(res->what, "add") == 0)
3723 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3725 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3727 /* check the return value and print it if is < 0 */
3729 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3733 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3734 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3736 cmdline_parse_token_string_t cmd_mac_addr_what =
3737 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3739 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3740 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3741 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3742 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3744 cmdline_parse_inst_t cmd_mac_addr = {
3745 .f = cmd_mac_addr_parsed,
3747 .help_str = "mac_addr add|remove X <address>: "
3748 "add/remove MAC address on port X",
3750 (void *)&cmd_mac_addr_cmd,
3751 (void *)&cmd_mac_addr_what,
3752 (void *)&cmd_mac_addr_portnum,
3753 (void *)&cmd_mac_addr_addr,
3759 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3760 struct cmd_set_qmap_result {
3761 cmdline_fixed_string_t set;
3762 cmdline_fixed_string_t qmap;
3763 cmdline_fixed_string_t what;
3770 cmd_set_qmap_parsed(void *parsed_result,
3771 __attribute__((unused)) struct cmdline *cl,
3772 __attribute__((unused)) void *data)
3774 struct cmd_set_qmap_result *res = parsed_result;
3775 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3777 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3780 cmdline_parse_token_string_t cmd_setqmap_set =
3781 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3783 cmdline_parse_token_string_t cmd_setqmap_qmap =
3784 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3786 cmdline_parse_token_string_t cmd_setqmap_what =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3789 cmdline_parse_token_num_t cmd_setqmap_portid =
3790 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3792 cmdline_parse_token_num_t cmd_setqmap_queueid =
3793 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3795 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3796 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3799 cmdline_parse_inst_t cmd_set_qmap = {
3800 .f = cmd_set_qmap_parsed,
3802 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3804 (void *)&cmd_setqmap_set,
3805 (void *)&cmd_setqmap_qmap,
3806 (void *)&cmd_setqmap_what,
3807 (void *)&cmd_setqmap_portid,
3808 (void *)&cmd_setqmap_queueid,
3809 (void *)&cmd_setqmap_mapvalue,
3814 /* ******************************************************************************** */
3816 /* list of instructions */
3817 cmdline_parse_ctx_t main_ctx[] = {
3818 (cmdline_parse_inst_t *)&cmd_help_brief,
3819 (cmdline_parse_inst_t *)&cmd_help_long,
3820 (cmdline_parse_inst_t *)&cmd_quit,
3821 (cmdline_parse_inst_t *)&cmd_showport,
3822 (cmdline_parse_inst_t *)&cmd_showportall,
3823 (cmdline_parse_inst_t *)&cmd_showcfg,
3824 (cmdline_parse_inst_t *)&cmd_start,
3825 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3826 (cmdline_parse_inst_t *)&cmd_reset,
3827 (cmdline_parse_inst_t *)&cmd_set_numbers,
3828 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3829 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3830 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3831 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3832 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3833 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3834 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3835 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3836 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3837 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3838 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3839 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3840 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3841 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3842 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3843 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3844 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
3845 (cmdline_parse_inst_t *)&cmd_config_dcb,
3846 (cmdline_parse_inst_t *)&cmd_read_reg,
3847 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3848 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3849 (cmdline_parse_inst_t *)&cmd_write_reg,
3850 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3851 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3852 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3853 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3854 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3855 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3856 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3857 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3858 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3859 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3860 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3861 (cmdline_parse_inst_t *)&cmd_stop,
3862 (cmdline_parse_inst_t *)&cmd_mac_addr,
3863 (cmdline_parse_inst_t *)&cmd_set_qmap,
3864 (cmdline_parse_inst_t *)&cmd_operate_port,
3865 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3866 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3867 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3868 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3869 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3870 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3871 (cmdline_parse_inst_t *)&cmd_config_rss,
3872 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
3873 (cmdline_parse_inst_t *)&cmd_showport_reta,
3874 (cmdline_parse_inst_t *)&cmd_config_burst,
3875 (cmdline_parse_inst_t *)&cmd_config_thresh,
3876 (cmdline_parse_inst_t *)&cmd_config_threshold,
3880 /* prompt function, called from main on MASTER lcore */
3886 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3890 cmdline_interact(cl);
3891 cmdline_stdin_exit(cl);
3895 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3897 if (id < nb_ports) {
3898 /* check if need_reconfig has been set to 1 */
3899 if (ports[id].need_reconfig == 0)
3900 ports[id].need_reconfig = dev;
3901 /* check if need_reconfig_queues has been set to 1 */
3902 if (ports[id].need_reconfig_queues == 0)
3903 ports[id].need_reconfig_queues = queue;
3907 for (pid = 0; pid < nb_ports; pid++) {
3908 /* check if need_reconfig has been set to 1 */
3909 if (ports[pid].need_reconfig == 0)
3910 ports[pid].need_reconfig = dev;
3911 /* check if need_reconfig_queues has been set to 1 */
3912 if (ports[pid].need_reconfig_queues == 0)
3913 ports[pid].need_reconfig_queues = queue;