4 * Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <netinet/in.h>
49 #include <sys/queue.h>
51 #include <rte_common.h>
52 #include <rte_byteorder.h>
54 #include <rte_debug.h>
55 #include <rte_cycles.h>
56 #include <rte_memory.h>
57 #include <rte_memzone.h>
58 #include <rte_launch.h>
59 #include <rte_tailq.h>
61 #include <rte_per_lcore.h>
62 #include <rte_lcore.h>
63 #include <rte_atomic.h>
64 #include <rte_branch_prediction.h>
66 #include <rte_mempool.h>
67 #include <rte_interrupts.h>
69 #include <rte_ether.h>
70 #include <rte_ethdev.h>
71 #include <rte_string_fns.h>
73 #include <cmdline_rdline.h>
74 #include <cmdline_parse.h>
75 #include <cmdline_parse_num.h>
76 #include <cmdline_parse_string.h>
77 #include <cmdline_parse_ipaddr.h>
78 #include <cmdline_parse_etheraddr.h>
79 #include <cmdline_socket.h>
85 struct cmd_help_result {
86 cmdline_fixed_string_t help;
89 static void cmd_help_parsed(__attribute__((unused)) void *parsed_result,
91 __attribute__((unused)) void *data)
98 "This commandline can be used to configure forwarding\n"
101 "Display informations:\n"
102 "---------------------\n"
103 "- show port info|stats|fdir|stat_qmap X|all\n"
104 " Diplays information or stats or stats queue mapping on port X, or all\n"
105 "- clear port stats X|all\n"
106 " Clear stats for port X, or all\n"
107 "- show config rxtx|cores|fwd\n"
108 " Displays the given configuration\n"
109 "- read reg port_id reg_off\n"
110 " Displays value of a port register\n"
111 "- read regfield port_id reg_off bit_x bit_y\n"
112 " Displays value of a port register bit field\n"
113 "- read regbit port_id reg_off bit_x\n"
114 " Displays value of a port register bit\n"
115 "- read rxd port_id queue_id rxd_id\n"
116 " Displays a RX descriptor of a port RX queue\n"
117 "- read txd port_id queue_id txd_id\n"
118 " Displays a TX descriptor of a port TX queue\n"
123 "Modifications are taken into account once "
124 "forwarding is restarted.\n"
126 " Set forwarding to default configuration\n"
127 "- set nbport|nbcore|burst|verbose X\n"
128 " Set number of ports, number of cores, number "
129 "of packets per burst,\n or verbose level to X\n"
130 "- set txpkts x[,y]*\n"
131 " Set the length of each segment of TXONLY packets\n"
132 "- set coremask|portmask X\n"
133 " Set the hexadecimal mask of forwarding cores / "
135 "- set corelist|portlist x[,y]*\n"
136 " Set the list of forwarding cores / forwarding "
138 "- rx_vlan add/rm vlan_id|all port_id\n"
139 " Add/remove vlan_id, or all identifiers, to/from "
140 "the set of VLAN Identifiers\n filtered by port_id\n"
141 "- tx_vlan set vlan_id port_id\n"
142 " Enable hardware insertion of a VLAN header with "
143 "the Tag Identifier vlan_id\n in packets sent on"
145 "- tx_vlan reset port_id\n"
146 " Disable hardware insertion of a VLAN header in "
147 "packets sent on port_id\n"
148 "- tx_checksum set mask port_id\n"
149 " Enable hardware insertion of checksum offload with "
150 "the 4-bit mask (0~0xf)\n in packets sent on port_id\n"
151 " Please check the NIC datasheet for HW limits\n"
152 " bit 0 - insert ip checksum offload if set \n"
153 " bit 1 - insert udp checksum offload if set \n"
154 " bit 2 - insert tcp checksum offload if set\n"
155 " bit 3 - insert sctp checksum offload if set\n"
156 #ifdef RTE_LIBRTE_IEEE1588
157 "- set fwd io|mac|rxonly|txonly|csum|ieee1588\n"
158 " Set IO, MAC, RXONLY, TXONLY, CSUM or IEEE1588 "
159 "packet forwarding mode\n"
161 "- set fwd io|mac|rxonly|txonly|csum\n"
162 " Set IO, MAC, RXONLY, CSUM or TXONLY packet "
165 "- mac_addr add|remove X <xx:xx:xx:xx:xx:xx>\n"
166 " Add/Remove the MAC address <xx:xx:xx:xx:xx:xx> on port X\n"
167 "- set promisc|allmulti [all|X] on|off\n"
168 " Set/unset promisc|allmulti mode on port X, or all\n"
169 "- set flow_ctrl rx on|off tx on|off high_water low_water "
170 "pause_time send_xon port_id \n"
171 " Set the link flow control parameter on the port \n"
172 "- write reg port_id reg_off value\n"
173 " Set value of a port register\n"
174 "- write regfield port_id reg_off bit_x bit_y value\n"
175 " Set bit field value of a port register\n"
176 "- write regbit port_id reg_off bit_x value\n"
177 " Set bit value of a port register\n"
178 "- set stat_qmap tx|rx port_id queue_id qmapping\n"
179 " Set statistics mapping (qmapping 0..15) for tx|rx queue_id on port_id\n"
180 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2 on port 0 to mapping 5\n"
183 "Control forwarding:\n"
184 "-------------------\n"
186 " Start packet forwarding with current config\n"
188 " Start packet forwarding with current config"
189 " after sending one burst\n of packets\n"
191 " Stop packet forwarding, and displays accumulated"
195 "Flow director mode:\n"
196 "-------------------\n"
197 "- add_signature_filter port_id ip|udp|tcp|sctp src\n"
198 " ip_src_address port_src dst ip_dst_address port_dst\n"
199 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
200 "- upd_signature_filter port_id ip|udp|tcp|sctp src \n"
201 " ip_src_address port_src dst ip_dst_address port_dst\n"
202 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
203 "- rm_signature_filter port_id ip|udp|tcp|sctp src\n"
204 " ip_src_address port_src dst ip_dst_address port_dst\n"
205 " flexbytes flexbytes_values vlan vlan_id\n"
206 "- add_perfect_filter port_id ip|udp|tcp|sctp src\n"
207 " ip_src_address port_src dst ip_dst_address port_dst\n"
208 " flexbytes flexbytes_values vlan vlan_id queue \n"
209 " queue_id soft soft_id\n"
210 "- upd_perfect_filter port_id ip|udp|tcp|sctp src\n"
211 " ip_src_address port_src dst ip_dst_address port_dst\n"
212 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
213 "- rm_perfect_filter port_id ip|udp|tcp|sctp src\n"
214 " ip_src_address port_src dst ip_dst_address port_dst\n"
215 " flexbytes flexbytes_values vlan vlan_id soft soft_id\n"
216 "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
217 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
218 " port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
224 " Quit to prompt in linux, and reboot on baremetal\n"
228 cmdline_parse_token_string_t cmd_help_help =
229 TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
231 cmdline_parse_inst_t cmd_help = {
232 .f = cmd_help_parsed,
234 .help_str = "show help",
236 (void *)&cmd_help_help,
242 struct cmd_stop_result {
243 cmdline_fixed_string_t stop;
246 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
247 __attribute__((unused)) struct cmdline *cl,
248 __attribute__((unused)) void *data)
250 stop_packet_forwarding();
253 cmdline_parse_token_string_t cmd_stop_stop =
254 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
256 cmdline_parse_inst_t cmd_stop = {
257 .f = cmd_stop_parsed,
259 .help_str = "stop - stop packet forwarding",
261 (void *)&cmd_stop_stop,
266 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
269 parse_item_list(char* str, const char* item_name, unsigned int max_items,
270 unsigned int *parsed_items, int check_unique_values)
272 unsigned int nb_item;
280 * First parse all items in the list and store their value.
285 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
287 if ((c >= '0') && (c <= '9')) {
288 value = (unsigned int) (value * 10 + (c - '0'));
293 printf("character %c is not a decimal digit\n", c);
297 printf("No valid value before comma\n");
300 if (nb_item < max_items) {
301 parsed_items[nb_item] = value;
307 if (nb_item >= max_items) {
308 printf("Number of %s = %u > %u (maximum items)\n",
309 item_name, nb_item + 1, max_items);
312 parsed_items[nb_item++] = value;
313 if (! check_unique_values)
317 * Then, check that all values in the list are differents.
318 * No optimization here...
320 for (i = 0; i < nb_item; i++) {
321 for (j = i + 1; j < nb_item; j++) {
322 if (parsed_items[j] == parsed_items[i]) {
323 printf("duplicated %s %u at index %u and %u\n",
324 item_name, parsed_items[i], i, j);
332 struct cmd_set_list_result {
333 cmdline_fixed_string_t cmd_keyword;
334 cmdline_fixed_string_t list_name;
335 cmdline_fixed_string_t list_of_items;
338 static void cmd_set_list_parsed(void *parsed_result,
339 __attribute__((unused)) struct cmdline *cl,
340 __attribute__((unused)) void *data)
342 struct cmd_set_list_result *res;
344 unsigned int lcorelist[RTE_MAX_LCORE];
345 unsigned int portlist[RTE_MAX_ETHPORTS];
347 unsigned int nb_item;
350 if (!strcmp(res->list_name, "corelist")) {
351 nb_item = parse_item_list(res->list_of_items, "core",
353 parsed_items.lcorelist, 1);
355 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
358 if (!strcmp(res->list_name, "portlist")) {
359 nb_item = parse_item_list(res->list_of_items, "port",
361 parsed_items.portlist, 1);
363 set_fwd_ports_list(parsed_items.portlist, nb_item);
367 cmdline_parse_token_string_t cmd_set_list_keyword =
368 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
370 cmdline_parse_token_string_t cmd_set_list_name =
371 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
372 "corelist#portlist");
373 cmdline_parse_token_string_t cmd_set_list_of_items =
374 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
377 cmdline_parse_inst_t cmd_set_fwd_list = {
378 .f = cmd_set_list_parsed,
380 .help_str = "set corelist|portlist x[,y]*",
382 (void *)&cmd_set_list_keyword,
383 (void *)&cmd_set_list_name,
384 (void *)&cmd_set_list_of_items,
389 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
391 struct cmd_setmask_result {
392 cmdline_fixed_string_t set;
393 cmdline_fixed_string_t mask;
397 static void cmd_set_mask_parsed(void *parsed_result,
398 __attribute__((unused)) struct cmdline *cl,
399 __attribute__((unused)) void *data)
401 struct cmd_setmask_result *res = parsed_result;
403 if (!strcmp(res->mask, "coremask"))
404 set_fwd_lcores_mask(res->hexavalue);
405 else if (!strcmp(res->mask, "portmask"))
406 set_fwd_ports_mask(res->hexavalue);
409 cmdline_parse_token_string_t cmd_setmask_set =
410 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
411 cmdline_parse_token_string_t cmd_setmask_mask =
412 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
413 "coremask#portmask");
414 cmdline_parse_token_num_t cmd_setmask_value =
415 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
417 cmdline_parse_inst_t cmd_set_fwd_mask = {
418 .f = cmd_set_mask_parsed,
420 .help_str = "set coremask|portmask hexadecimal value",
422 (void *)&cmd_setmask_set,
423 (void *)&cmd_setmask_mask,
424 (void *)&cmd_setmask_value,
430 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
432 struct cmd_set_result {
433 cmdline_fixed_string_t set;
434 cmdline_fixed_string_t what;
438 static void cmd_set_parsed(void *parsed_result,
439 __attribute__((unused)) struct cmdline *cl,
440 __attribute__((unused)) void *data)
442 struct cmd_set_result *res = parsed_result;
443 if (!strcmp(res->what, "nbport"))
444 set_fwd_ports_number(res->value);
445 else if (!strcmp(res->what, "nbcore"))
446 set_fwd_lcores_number(res->value);
447 else if (!strcmp(res->what, "burst"))
448 set_nb_pkt_per_burst(res->value);
449 else if (!strcmp(res->what, "verbose"))
450 set_verbose_level(res->value);
453 cmdline_parse_token_string_t cmd_set_set =
454 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
455 cmdline_parse_token_string_t cmd_set_what =
456 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
457 "nbport#nbcore#burst#verbose");
458 cmdline_parse_token_num_t cmd_set_value =
459 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
461 cmdline_parse_inst_t cmd_set_numbers = {
464 .help_str = "set nbport|nbcore|burst|verbose value",
466 (void *)&cmd_set_set,
467 (void *)&cmd_set_what,
468 (void *)&cmd_set_value,
473 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
475 struct cmd_set_txpkts_result {
476 cmdline_fixed_string_t cmd_keyword;
477 cmdline_fixed_string_t txpkts;
478 cmdline_fixed_string_t seg_lengths;
482 cmd_set_txpkts_parsed(void *parsed_result,
483 __attribute__((unused)) struct cmdline *cl,
484 __attribute__((unused)) void *data)
486 struct cmd_set_txpkts_result *res;
487 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
488 unsigned int nb_segs;
491 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
492 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
494 set_tx_pkt_segments(seg_lengths, nb_segs);
497 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
498 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
500 cmdline_parse_token_string_t cmd_set_txpkts_name =
501 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
503 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
504 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
507 cmdline_parse_inst_t cmd_set_txpkts = {
508 .f = cmd_set_txpkts_parsed,
510 .help_str = "set txpkts x[,y]*",
512 (void *)&cmd_set_txpkts_keyword,
513 (void *)&cmd_set_txpkts_name,
514 (void *)&cmd_set_txpkts_lengths,
519 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
520 struct cmd_rx_vlan_filter_all_result {
521 cmdline_fixed_string_t rx_vlan;
522 cmdline_fixed_string_t what;
523 cmdline_fixed_string_t all;
528 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
529 __attribute__((unused)) struct cmdline *cl,
530 __attribute__((unused)) void *data)
532 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
534 if (!strcmp(res->what, "add"))
535 rx_vlan_all_filter_set(res->port_id, 1);
537 rx_vlan_all_filter_set(res->port_id, 0);
540 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
541 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
543 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
544 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
546 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
547 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
549 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
550 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
553 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
554 .f = cmd_rx_vlan_filter_all_parsed,
556 .help_str = "add/remove all identifiers to/from the set of VLAN "
557 "Identifiers filtered by a port",
559 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
560 (void *)&cmd_rx_vlan_filter_all_what,
561 (void *)&cmd_rx_vlan_filter_all_all,
562 (void *)&cmd_rx_vlan_filter_all_portid,
567 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
568 struct cmd_rx_vlan_filter_result {
569 cmdline_fixed_string_t rx_vlan;
570 cmdline_fixed_string_t what;
576 cmd_rx_vlan_filter_parsed(void *parsed_result,
577 __attribute__((unused)) struct cmdline *cl,
578 __attribute__((unused)) void *data)
580 struct cmd_rx_vlan_filter_result *res = parsed_result;
582 if (!strcmp(res->what, "add"))
583 rx_vlan_filter_set(res->port_id, res->vlan_id, 1);
585 rx_vlan_filter_set(res->port_id, res->vlan_id, 0);
588 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
589 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
591 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
592 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
594 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
595 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
597 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
598 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
601 cmdline_parse_inst_t cmd_rx_vlan_filter = {
602 .f = cmd_rx_vlan_filter_parsed,
604 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
605 "Identifiers filtered by a port",
607 (void *)&cmd_rx_vlan_filter_rx_vlan,
608 (void *)&cmd_rx_vlan_filter_what,
609 (void *)&cmd_rx_vlan_filter_vlanid,
610 (void *)&cmd_rx_vlan_filter_portid,
615 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
616 struct cmd_tx_vlan_set_result {
617 cmdline_fixed_string_t tx_vlan;
618 cmdline_fixed_string_t set;
624 cmd_tx_vlan_set_parsed(void *parsed_result,
625 __attribute__((unused)) struct cmdline *cl,
626 __attribute__((unused)) void *data)
628 struct cmd_tx_vlan_set_result *res = parsed_result;
630 tx_vlan_set(res->port_id, res->vlan_id);
633 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
634 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
636 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
637 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
639 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
640 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
642 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
643 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
646 cmdline_parse_inst_t cmd_tx_vlan_set = {
647 .f = cmd_tx_vlan_set_parsed,
649 .help_str = "enable hardware insertion of a VLAN header with a given "
650 "TAG Identifier in packets sent on a port",
652 (void *)&cmd_tx_vlan_set_tx_vlan,
653 (void *)&cmd_tx_vlan_set_set,
654 (void *)&cmd_tx_vlan_set_vlanid,
655 (void *)&cmd_tx_vlan_set_portid,
660 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
661 struct cmd_tx_vlan_reset_result {
662 cmdline_fixed_string_t tx_vlan;
663 cmdline_fixed_string_t reset;
668 cmd_tx_vlan_reset_parsed(void *parsed_result,
669 __attribute__((unused)) struct cmdline *cl,
670 __attribute__((unused)) void *data)
672 struct cmd_tx_vlan_reset_result *res = parsed_result;
674 tx_vlan_reset(res->port_id);
677 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
678 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
680 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
681 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
683 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
684 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
687 cmdline_parse_inst_t cmd_tx_vlan_reset = {
688 .f = cmd_tx_vlan_reset_parsed,
690 .help_str = "disable hardware insertion of a VLAN header in packets "
693 (void *)&cmd_tx_vlan_reset_tx_vlan,
694 (void *)&cmd_tx_vlan_reset_reset,
695 (void *)&cmd_tx_vlan_reset_portid,
701 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
702 struct cmd_tx_cksum_set_result {
703 cmdline_fixed_string_t tx_cksum;
704 cmdline_fixed_string_t set;
710 cmd_tx_cksum_set_parsed(void *parsed_result,
711 __attribute__((unused)) struct cmdline *cl,
712 __attribute__((unused)) void *data)
714 struct cmd_tx_cksum_set_result *res = parsed_result;
716 tx_cksum_set(res->port_id, res->cksum_mask);
719 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
720 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
721 tx_cksum, "tx_checksum");
722 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
723 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
725 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
726 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
728 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
729 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
732 cmdline_parse_inst_t cmd_tx_cksum_set = {
733 .f = cmd_tx_cksum_set_parsed,
735 .help_str = "enable hardware insertion of L3/L4checksum with a given "
736 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
737 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
739 (void *)&cmd_tx_cksum_set_tx_cksum,
740 (void *)&cmd_tx_cksum_set_set,
741 (void *)&cmd_tx_cksum_set_cksum_mask,
742 (void *)&cmd_tx_cksum_set_portid,
747 /* *** SET FORWARDING MODE *** */
748 struct cmd_set_fwd_mode_result {
749 cmdline_fixed_string_t set;
750 cmdline_fixed_string_t fwd;
751 cmdline_fixed_string_t mode;
754 static void cmd_set_fwd_mode_parsed(void *parsed_result,
755 __attribute__((unused)) struct cmdline *cl,
756 __attribute__((unused)) void *data)
758 struct cmd_set_fwd_mode_result *res = parsed_result;
760 set_pkt_forwarding_mode(res->mode);
763 cmdline_parse_token_string_t cmd_setfwd_set =
764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
765 cmdline_parse_token_string_t cmd_setfwd_fwd =
766 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
767 cmdline_parse_token_string_t cmd_setfwd_mode =
768 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
769 #ifdef RTE_LIBRTE_IEEE1588
770 "io#mac#rxonly#txonly#csum#ieee1588");
772 "io#mac#rxonly#txonly#csum");
775 cmdline_parse_inst_t cmd_set_fwd_mode = {
776 .f = cmd_set_fwd_mode_parsed,
778 #ifdef RTE_LIBRTE_IEEE1588
779 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
780 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
782 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
783 " RXONLY, CSUM or TXONLY packet forwarding mode",
786 (void *)&cmd_setfwd_set,
787 (void *)&cmd_setfwd_fwd,
788 (void *)&cmd_setfwd_mode,
793 /* *** SET PROMISC MODE *** */
794 struct cmd_set_promisc_mode_result {
795 cmdline_fixed_string_t set;
796 cmdline_fixed_string_t promisc;
797 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
798 uint8_t port_num; /* valid if "allports" argument == 0 */
799 cmdline_fixed_string_t mode;
802 static void cmd_set_promisc_mode_parsed(void *parsed_result,
803 __attribute__((unused)) struct cmdline *cl,
806 struct cmd_set_promisc_mode_result *res = parsed_result;
810 if (!strcmp(res->mode, "on"))
817 for (i = 0; i < nb_ports; i++) {
819 rte_eth_promiscuous_enable(i);
821 rte_eth_promiscuous_disable(i);
826 rte_eth_promiscuous_enable(res->port_num);
828 rte_eth_promiscuous_disable(res->port_num);
832 cmdline_parse_token_string_t cmd_setpromisc_set =
833 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
834 cmdline_parse_token_string_t cmd_setpromisc_promisc =
835 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
837 cmdline_parse_token_string_t cmd_setpromisc_portall =
838 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
840 cmdline_parse_token_num_t cmd_setpromisc_portnum =
841 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
843 cmdline_parse_token_string_t cmd_setpromisc_mode =
844 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
847 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
848 .f = cmd_set_promisc_mode_parsed,
850 .help_str = "set promisc all on|off: set promisc mode for all ports",
852 (void *)&cmd_setpromisc_set,
853 (void *)&cmd_setpromisc_promisc,
854 (void *)&cmd_setpromisc_portall,
855 (void *)&cmd_setpromisc_mode,
860 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
861 .f = cmd_set_promisc_mode_parsed,
863 .help_str = "set promisc X on|off: set promisc mode on port X",
865 (void *)&cmd_setpromisc_set,
866 (void *)&cmd_setpromisc_promisc,
867 (void *)&cmd_setpromisc_portnum,
868 (void *)&cmd_setpromisc_mode,
873 /* *** SET ALLMULTI MODE *** */
874 struct cmd_set_allmulti_mode_result {
875 cmdline_fixed_string_t set;
876 cmdline_fixed_string_t allmulti;
877 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
878 uint8_t port_num; /* valid if "allports" argument == 0 */
879 cmdline_fixed_string_t mode;
882 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
883 __attribute__((unused)) struct cmdline *cl,
886 struct cmd_set_allmulti_mode_result *res = parsed_result;
890 if (!strcmp(res->mode, "on"))
897 for (i = 0; i < nb_ports; i++) {
899 rte_eth_allmulticast_enable(i);
901 rte_eth_allmulticast_disable(i);
906 rte_eth_allmulticast_enable(res->port_num);
908 rte_eth_allmulticast_disable(res->port_num);
912 cmdline_parse_token_string_t cmd_setallmulti_set =
913 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
914 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
915 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
917 cmdline_parse_token_string_t cmd_setallmulti_portall =
918 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
920 cmdline_parse_token_num_t cmd_setallmulti_portnum =
921 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
923 cmdline_parse_token_string_t cmd_setallmulti_mode =
924 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
927 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
928 .f = cmd_set_allmulti_mode_parsed,
930 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
932 (void *)&cmd_setallmulti_set,
933 (void *)&cmd_setallmulti_allmulti,
934 (void *)&cmd_setallmulti_portall,
935 (void *)&cmd_setallmulti_mode,
940 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
941 .f = cmd_set_allmulti_mode_parsed,
943 .help_str = "set allmulti X on|off: set allmulti mode on port X",
945 (void *)&cmd_setallmulti_set,
946 (void *)&cmd_setallmulti_allmulti,
947 (void *)&cmd_setallmulti_portnum,
948 (void *)&cmd_setallmulti_mode,
953 /* *** ADD/REMOVE A PKT FILTER *** */
954 struct cmd_pkt_filter_result {
955 cmdline_fixed_string_t pkt_filter;
957 cmdline_fixed_string_t protocol;
958 cmdline_fixed_string_t src;
959 cmdline_ipaddr_t ip_src;
961 cmdline_fixed_string_t dst;
962 cmdline_ipaddr_t ip_dst;
964 cmdline_fixed_string_t flexbytes;
965 uint16_t flexbytes_value;
966 cmdline_fixed_string_t vlan;
968 cmdline_fixed_string_t queue;
970 cmdline_fixed_string_t soft;
975 cmd_pkt_filter_parsed(void *parsed_result,
976 __attribute__((unused)) struct cmdline *cl,
977 __attribute__((unused)) void *data)
979 struct rte_fdir_filter fdir_filter;
980 struct cmd_pkt_filter_result *res = parsed_result;
982 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
984 if (res->ip_src.family == AF_INET)
985 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
987 memcpy(&(fdir_filter.ip_src.ipv6_addr),
988 &(res->ip_src.addr.ipv6),
989 sizeof(struct in6_addr));
991 if (res->ip_dst.family == AF_INET)
992 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
994 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
995 &(res->ip_dst.addr.ipv6),
996 sizeof(struct in6_addr));
998 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
999 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
1001 if (!strcmp(res->protocol, "udp"))
1002 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
1003 else if (!strcmp(res->protocol, "tcp"))
1004 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
1005 else if (!strcmp(res->protocol, "sctp"))
1006 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
1007 else /* default only IP */
1008 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
1010 if (res->ip_dst.family == AF_INET6)
1011 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
1013 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
1015 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
1016 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
1018 if (!strcmp(res->pkt_filter, "add_signature_filter"))
1019 fdir_add_signature_filter(res->port_id, res->queue_id,
1021 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
1022 fdir_update_signature_filter(res->port_id, res->queue_id,
1024 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
1025 fdir_remove_signature_filter(res->port_id, &fdir_filter);
1026 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
1027 fdir_add_perfect_filter(res->port_id, res->soft_id,
1029 (uint8_t) (res->queue_id < 0),
1031 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
1032 fdir_update_perfect_filter(res->port_id, res->soft_id,
1034 (uint8_t) (res->queue_id < 0),
1036 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
1037 fdir_remove_perfect_filter(res->port_id, res->soft_id,
1043 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
1044 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1046 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
1047 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1048 protocol, "ip#tcp#udp#sctp");
1049 cmdline_parse_token_string_t cmd_pkt_filter_src =
1050 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1052 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
1053 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
1055 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
1056 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1058 cmdline_parse_token_string_t cmd_pkt_filter_dst =
1059 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1061 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
1062 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
1064 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
1065 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1067 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
1068 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1069 flexbytes, "flexbytes");
1070 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
1071 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1072 flexbytes_value, UINT16);
1073 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
1074 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1076 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
1077 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1079 cmdline_parse_token_string_t cmd_pkt_filter_queue =
1080 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1082 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
1083 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1085 cmdline_parse_token_string_t cmd_pkt_filter_soft =
1086 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1088 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
1089 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1093 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
1094 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1095 pkt_filter, "add_signature_filter");
1096 cmdline_parse_inst_t cmd_add_signature_filter = {
1097 .f = cmd_pkt_filter_parsed,
1099 .help_str = "add a signature filter",
1101 (void *)&cmd_pkt_filter_add_signature_filter,
1102 (void *)&cmd_pkt_filter_port_id,
1103 (void *)&cmd_pkt_filter_protocol,
1104 (void *)&cmd_pkt_filter_src,
1105 (void *)&cmd_pkt_filter_ip_src,
1106 (void *)&cmd_pkt_filter_port_src,
1107 (void *)&cmd_pkt_filter_dst,
1108 (void *)&cmd_pkt_filter_ip_dst,
1109 (void *)&cmd_pkt_filter_port_dst,
1110 (void *)&cmd_pkt_filter_flexbytes,
1111 (void *)&cmd_pkt_filter_flexbytes_value,
1112 (void *)&cmd_pkt_filter_vlan,
1113 (void *)&cmd_pkt_filter_vlan_id,
1114 (void *)&cmd_pkt_filter_queue,
1115 (void *)&cmd_pkt_filter_queue_id,
1121 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
1122 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1123 pkt_filter, "upd_signature_filter");
1124 cmdline_parse_inst_t cmd_upd_signature_filter = {
1125 .f = cmd_pkt_filter_parsed,
1127 .help_str = "update a signature filter",
1129 (void *)&cmd_pkt_filter_upd_signature_filter,
1130 (void *)&cmd_pkt_filter_port_id,
1131 (void *)&cmd_pkt_filter_protocol,
1132 (void *)&cmd_pkt_filter_src,
1133 (void *)&cmd_pkt_filter_ip_src,
1134 (void *)&cmd_pkt_filter_port_src,
1135 (void *)&cmd_pkt_filter_dst,
1136 (void *)&cmd_pkt_filter_ip_dst,
1137 (void *)&cmd_pkt_filter_port_dst,
1138 (void *)&cmd_pkt_filter_flexbytes,
1139 (void *)&cmd_pkt_filter_flexbytes_value,
1140 (void *)&cmd_pkt_filter_vlan,
1141 (void *)&cmd_pkt_filter_vlan_id,
1142 (void *)&cmd_pkt_filter_queue,
1143 (void *)&cmd_pkt_filter_queue_id,
1149 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
1150 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1151 pkt_filter, "rm_signature_filter");
1152 cmdline_parse_inst_t cmd_rm_signature_filter = {
1153 .f = cmd_pkt_filter_parsed,
1155 .help_str = "remove a signature filter",
1157 (void *)&cmd_pkt_filter_rm_signature_filter,
1158 (void *)&cmd_pkt_filter_port_id,
1159 (void *)&cmd_pkt_filter_protocol,
1160 (void *)&cmd_pkt_filter_src,
1161 (void *)&cmd_pkt_filter_ip_src,
1162 (void *)&cmd_pkt_filter_port_src,
1163 (void *)&cmd_pkt_filter_dst,
1164 (void *)&cmd_pkt_filter_ip_dst,
1165 (void *)&cmd_pkt_filter_port_dst,
1166 (void *)&cmd_pkt_filter_flexbytes,
1167 (void *)&cmd_pkt_filter_flexbytes_value,
1168 (void *)&cmd_pkt_filter_vlan,
1169 (void *)&cmd_pkt_filter_vlan_id,
1175 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
1176 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1177 pkt_filter, "add_perfect_filter");
1178 cmdline_parse_inst_t cmd_add_perfect_filter = {
1179 .f = cmd_pkt_filter_parsed,
1181 .help_str = "add a perfect filter",
1183 (void *)&cmd_pkt_filter_add_perfect_filter,
1184 (void *)&cmd_pkt_filter_port_id,
1185 (void *)&cmd_pkt_filter_protocol,
1186 (void *)&cmd_pkt_filter_src,
1187 (void *)&cmd_pkt_filter_ip_src,
1188 (void *)&cmd_pkt_filter_port_src,
1189 (void *)&cmd_pkt_filter_dst,
1190 (void *)&cmd_pkt_filter_ip_dst,
1191 (void *)&cmd_pkt_filter_port_dst,
1192 (void *)&cmd_pkt_filter_flexbytes,
1193 (void *)&cmd_pkt_filter_flexbytes_value,
1194 (void *)&cmd_pkt_filter_vlan,
1195 (void *)&cmd_pkt_filter_vlan_id,
1196 (void *)&cmd_pkt_filter_queue,
1197 (void *)&cmd_pkt_filter_queue_id,
1198 (void *)&cmd_pkt_filter_soft,
1199 (void *)&cmd_pkt_filter_soft_id,
1205 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
1206 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1207 pkt_filter, "upd_perfect_filter");
1208 cmdline_parse_inst_t cmd_upd_perfect_filter = {
1209 .f = cmd_pkt_filter_parsed,
1211 .help_str = "update a perfect filter",
1213 (void *)&cmd_pkt_filter_upd_perfect_filter,
1214 (void *)&cmd_pkt_filter_port_id,
1215 (void *)&cmd_pkt_filter_protocol,
1216 (void *)&cmd_pkt_filter_src,
1217 (void *)&cmd_pkt_filter_ip_src,
1218 (void *)&cmd_pkt_filter_port_src,
1219 (void *)&cmd_pkt_filter_dst,
1220 (void *)&cmd_pkt_filter_ip_dst,
1221 (void *)&cmd_pkt_filter_port_dst,
1222 (void *)&cmd_pkt_filter_flexbytes,
1223 (void *)&cmd_pkt_filter_flexbytes_value,
1224 (void *)&cmd_pkt_filter_vlan,
1225 (void *)&cmd_pkt_filter_vlan_id,
1226 (void *)&cmd_pkt_filter_queue,
1227 (void *)&cmd_pkt_filter_queue_id,
1228 (void *)&cmd_pkt_filter_soft,
1229 (void *)&cmd_pkt_filter_soft_id,
1235 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
1236 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1237 pkt_filter, "rm_perfect_filter");
1238 cmdline_parse_inst_t cmd_rm_perfect_filter = {
1239 .f = cmd_pkt_filter_parsed,
1241 .help_str = "remove a perfect filter",
1243 (void *)&cmd_pkt_filter_rm_perfect_filter,
1244 (void *)&cmd_pkt_filter_port_id,
1245 (void *)&cmd_pkt_filter_protocol,
1246 (void *)&cmd_pkt_filter_src,
1247 (void *)&cmd_pkt_filter_ip_src,
1248 (void *)&cmd_pkt_filter_port_src,
1249 (void *)&cmd_pkt_filter_dst,
1250 (void *)&cmd_pkt_filter_ip_dst,
1251 (void *)&cmd_pkt_filter_port_dst,
1252 (void *)&cmd_pkt_filter_flexbytes,
1253 (void *)&cmd_pkt_filter_flexbytes_value,
1254 (void *)&cmd_pkt_filter_vlan,
1255 (void *)&cmd_pkt_filter_vlan_id,
1256 (void *)&cmd_pkt_filter_soft,
1257 (void *)&cmd_pkt_filter_soft_id,
1262 /* *** SETUP MASKS FILTER *** */
1263 struct cmd_pkt_filter_masks_result {
1264 cmdline_fixed_string_t filter_mask;
1266 cmdline_fixed_string_t src_mask;
1267 uint32_t ip_src_mask;
1268 uint16_t port_src_mask;
1269 cmdline_fixed_string_t dst_mask;
1270 uint32_t ip_dst_mask;
1271 uint16_t port_dst_mask;
1272 cmdline_fixed_string_t flexbytes;
1273 uint8_t flexbytes_value;
1274 cmdline_fixed_string_t vlan_id;
1275 uint8_t vlan_id_value;
1276 cmdline_fixed_string_t vlan_prio;
1277 uint8_t vlan_prio_value;
1278 cmdline_fixed_string_t only_ip_flow;
1279 uint8_t only_ip_flow_value;
1283 cmd_pkt_filter_masks_parsed(void *parsed_result,
1284 __attribute__((unused)) struct cmdline *cl,
1285 __attribute__((unused)) void *data)
1287 struct rte_fdir_masks fdir_masks;
1288 struct cmd_pkt_filter_masks_result *res = parsed_result;
1290 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
1292 fdir_masks.only_ip_flow = res->only_ip_flow_value;
1293 fdir_masks.vlan_id = res->vlan_id_value;
1294 fdir_masks.vlan_prio = res->vlan_prio_value;
1295 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
1296 fdir_masks.src_ipv4_mask = res->ip_src_mask;
1297 fdir_masks.src_port_mask = res->port_src_mask;
1298 fdir_masks.dst_port_mask = res->port_dst_mask;
1299 fdir_masks.flexbytes = res->flexbytes_value;
1301 fdir_set_masks(res->port_id, &fdir_masks);
1304 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
1305 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1306 filter_mask, "set_masks_filter");
1307 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
1308 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1310 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
1311 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1312 only_ip_flow, "only_ip_flow");
1313 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
1314 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1315 only_ip_flow_value, UINT8);
1316 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
1317 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1318 src_mask, "src_mask");
1319 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
1320 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1321 ip_src_mask, UINT32);
1322 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
1323 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1324 port_src_mask, UINT16);
1325 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
1326 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1327 src_mask, "dst_mask");
1328 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
1329 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1330 ip_dst_mask, UINT32);
1331 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
1332 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1333 port_dst_mask, UINT16);
1334 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
1335 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1336 flexbytes, "flexbytes");
1337 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
1338 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1339 flexbytes_value, UINT8);
1340 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
1341 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1342 vlan_id, "vlan_id");
1343 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
1344 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1345 vlan_id_value, UINT8);
1346 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
1347 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1348 vlan_prio, "vlan_prio");
1349 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
1350 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1351 vlan_prio_value, UINT8);
1353 cmdline_parse_inst_t cmd_set_masks_filter = {
1354 .f = cmd_pkt_filter_masks_parsed,
1356 .help_str = "setup masks filter",
1358 (void *)&cmd_pkt_filter_masks_filter_mask,
1359 (void *)&cmd_pkt_filter_masks_port_id,
1360 (void *)&cmd_pkt_filter_masks_only_ip_flow,
1361 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
1362 (void *)&cmd_pkt_filter_masks_src_mask,
1363 (void *)&cmd_pkt_filter_masks_ip_src_mask,
1364 (void *)&cmd_pkt_filter_masks_port_src_mask,
1365 (void *)&cmd_pkt_filter_masks_dst_mask,
1366 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
1367 (void *)&cmd_pkt_filter_masks_port_dst_mask,
1368 (void *)&cmd_pkt_filter_masks_flexbytes,
1369 (void *)&cmd_pkt_filter_masks_flexbytes_value,
1370 (void *)&cmd_pkt_filter_masks_vlan_id,
1371 (void *)&cmd_pkt_filter_masks_vlan_id_value,
1372 (void *)&cmd_pkt_filter_masks_vlan_prio,
1373 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
1378 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
1379 struct cmd_link_flow_ctrl_set_result {
1380 cmdline_fixed_string_t set;
1381 cmdline_fixed_string_t flow_ctrl;
1382 cmdline_fixed_string_t rx;
1383 cmdline_fixed_string_t rx_lfc_mode;
1384 cmdline_fixed_string_t tx;
1385 cmdline_fixed_string_t tx_lfc_mode;
1386 uint32_t high_water;
1388 uint16_t pause_time;
1394 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
1395 __attribute__((unused)) struct cmdline *cl,
1396 __attribute__((unused)) void *data)
1398 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
1399 struct rte_eth_fc_conf fc_conf;
1400 int rx_fc_enable, tx_fc_enable;
1404 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
1405 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
1406 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
1407 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
1409 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
1410 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
1413 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
1414 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
1416 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
1417 fc_conf.high_water = res->high_water;
1418 fc_conf.low_water = res->low_water;
1419 fc_conf.pause_time = res->pause_time;
1420 fc_conf.send_xon = res->send_xon;
1422 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
1424 printf("bad flow contrl parameter, return code = %d \n", ret);
1427 cmdline_parse_token_string_t cmd_lfc_set_set =
1428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1430 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
1431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1432 flow_ctrl, "flow_ctrl");
1433 cmdline_parse_token_string_t cmd_lfc_set_rx =
1434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1436 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
1437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1438 rx_lfc_mode, "on#off");
1439 cmdline_parse_token_string_t cmd_lfc_set_tx =
1440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1442 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
1443 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1444 tx_lfc_mode, "on#off");
1445 cmdline_parse_token_num_t cmd_lfc_set_high_water =
1446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1447 high_water, UINT32);
1448 cmdline_parse_token_num_t cmd_lfc_set_low_water =
1449 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1451 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
1452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1453 pause_time, UINT16);
1454 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
1455 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1457 cmdline_parse_token_num_t cmd_lfc_set_portid =
1458 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1461 cmdline_parse_inst_t cmd_link_flow_control_set = {
1462 .f = cmd_link_flow_ctrl_set_parsed,
1464 .help_str = "Configure the Ethernet link flow control...",
1466 (void *)&cmd_lfc_set_set,
1467 (void *)&cmd_lfc_set_flow_ctrl,
1468 (void *)&cmd_lfc_set_rx,
1469 (void *)&cmd_lfc_set_rx_mode,
1470 (void *)&cmd_lfc_set_tx,
1471 (void *)&cmd_lfc_set_tx_mode,
1472 (void *)&cmd_lfc_set_high_water,
1473 (void *)&cmd_lfc_set_low_water,
1474 (void *)&cmd_lfc_set_pause_time,
1475 (void *)&cmd_lfc_set_send_xon,
1476 (void *)&cmd_lfc_set_portid,
1481 /* *** RESET CONFIGURATION *** */
1482 struct cmd_reset_result {
1483 cmdline_fixed_string_t reset;
1484 cmdline_fixed_string_t def;
1487 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
1489 __attribute__((unused)) void *data)
1491 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
1492 set_def_fwd_config();
1495 cmdline_parse_token_string_t cmd_reset_set =
1496 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
1497 cmdline_parse_token_string_t cmd_reset_def =
1498 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
1501 cmdline_parse_inst_t cmd_reset = {
1502 .f = cmd_reset_parsed,
1504 .help_str = "set default: reset default forwarding configuration",
1506 (void *)&cmd_reset_set,
1507 (void *)&cmd_reset_def,
1512 /* *** START FORWARDING *** */
1513 struct cmd_start_result {
1514 cmdline_fixed_string_t start;
1517 cmdline_parse_token_string_t cmd_start_start =
1518 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
1520 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
1521 __attribute__((unused)) struct cmdline *cl,
1522 __attribute__((unused)) void *data)
1524 start_packet_forwarding(0);
1527 cmdline_parse_inst_t cmd_start = {
1528 .f = cmd_start_parsed,
1530 .help_str = "start packet forwarding",
1532 (void *)&cmd_start_start,
1537 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
1538 struct cmd_start_tx_first_result {
1539 cmdline_fixed_string_t start;
1540 cmdline_fixed_string_t tx_first;
1544 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
1545 __attribute__((unused)) struct cmdline *cl,
1546 __attribute__((unused)) void *data)
1548 start_packet_forwarding(1);
1551 cmdline_parse_token_string_t cmd_start_tx_first_start =
1552 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
1554 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
1555 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
1556 tx_first, "tx_first");
1558 cmdline_parse_inst_t cmd_start_tx_first = {
1559 .f = cmd_start_tx_first_parsed,
1561 .help_str = "start packet forwarding, after sending 1 burst of packets",
1563 (void *)&cmd_start_tx_first_start,
1564 (void *)&cmd_start_tx_first_tx_first,
1569 /* *** SHOW CFG *** */
1570 struct cmd_showcfg_result {
1571 cmdline_fixed_string_t show;
1572 cmdline_fixed_string_t cfg;
1573 cmdline_fixed_string_t what;
1576 static void cmd_showcfg_parsed(void *parsed_result,
1577 __attribute__((unused)) struct cmdline *cl,
1578 __attribute__((unused)) void *data)
1580 struct cmd_showcfg_result *res = parsed_result;
1581 if (!strcmp(res->what, "rxtx"))
1582 rxtx_config_display();
1583 else if (!strcmp(res->what, "cores"))
1584 fwd_lcores_config_display();
1585 else if (!strcmp(res->what, "fwd"))
1586 fwd_config_display();
1589 cmdline_parse_token_string_t cmd_showcfg_show =
1590 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
1591 cmdline_parse_token_string_t cmd_showcfg_port =
1592 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
1593 cmdline_parse_token_string_t cmd_showcfg_what =
1594 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
1597 cmdline_parse_inst_t cmd_showcfg = {
1598 .f = cmd_showcfg_parsed,
1600 .help_str = "show config rxtx|cores|fwd",
1602 (void *)&cmd_showcfg_show,
1603 (void *)&cmd_showcfg_port,
1604 (void *)&cmd_showcfg_what,
1609 /* *** SHOW ALL PORT INFO *** */
1610 struct cmd_showportall_result {
1611 cmdline_fixed_string_t show;
1612 cmdline_fixed_string_t port;
1613 cmdline_fixed_string_t what;
1614 cmdline_fixed_string_t all;
1617 static void cmd_showportall_parsed(void *parsed_result,
1618 __attribute__((unused)) struct cmdline *cl,
1619 __attribute__((unused)) void *data)
1623 struct cmd_showportall_result *res = parsed_result;
1624 if (!strcmp(res->show, "clear")) {
1625 if (!strcmp(res->what, "stats"))
1626 for (i = 0; i < nb_ports; i++)
1628 } else if (!strcmp(res->what, "info"))
1629 for (i = 0; i < nb_ports; i++)
1630 port_infos_display(i);
1631 else if (!strcmp(res->what, "stats"))
1632 for (i = 0; i < nb_ports; i++)
1633 nic_stats_display(i);
1634 else if (!strcmp(res->what, "fdir"))
1635 for (i = 0; i < nb_ports; i++)
1637 else if (!strcmp(res->what, "stat_qmap"))
1638 for (i = 0; i < nb_ports; i++)
1639 nic_stats_mapping_display(i);
1642 cmdline_parse_token_string_t cmd_showportall_show =
1643 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
1645 cmdline_parse_token_string_t cmd_showportall_port =
1646 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
1647 cmdline_parse_token_string_t cmd_showportall_what =
1648 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
1649 "info#stats#fdir#stat_qmap");
1650 cmdline_parse_token_string_t cmd_showportall_all =
1651 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
1652 cmdline_parse_inst_t cmd_showportall = {
1653 .f = cmd_showportall_parsed,
1655 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
1657 (void *)&cmd_showportall_show,
1658 (void *)&cmd_showportall_port,
1659 (void *)&cmd_showportall_what,
1660 (void *)&cmd_showportall_all,
1665 /* *** SHOW PORT INFO *** */
1666 struct cmd_showport_result {
1667 cmdline_fixed_string_t show;
1668 cmdline_fixed_string_t port;
1669 cmdline_fixed_string_t what;
1673 static void cmd_showport_parsed(void *parsed_result,
1674 __attribute__((unused)) struct cmdline *cl,
1675 __attribute__((unused)) void *data)
1677 struct cmd_showport_result *res = parsed_result;
1678 if (!strcmp(res->show, "clear")) {
1679 if (!strcmp(res->what, "stats"))
1680 nic_stats_clear(res->portnum);
1681 } else if (!strcmp(res->what, "info"))
1682 port_infos_display(res->portnum);
1683 else if (!strcmp(res->what, "stats"))
1684 nic_stats_display(res->portnum);
1685 else if (!strcmp(res->what, "fdir"))
1686 fdir_get_infos(res->portnum);
1687 else if (!strcmp(res->what, "stat_qmap"))
1688 nic_stats_mapping_display(res->portnum);
1691 cmdline_parse_token_string_t cmd_showport_show =
1692 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
1694 cmdline_parse_token_string_t cmd_showport_port =
1695 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
1696 cmdline_parse_token_string_t cmd_showport_what =
1697 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
1698 "info#stats#fdir#stat_qmap");
1699 cmdline_parse_token_num_t cmd_showport_portnum =
1700 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
1702 cmdline_parse_inst_t cmd_showport = {
1703 .f = cmd_showport_parsed,
1705 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
1707 (void *)&cmd_showport_show,
1708 (void *)&cmd_showport_port,
1709 (void *)&cmd_showport_what,
1710 (void *)&cmd_showport_portnum,
1715 /* *** READ PORT REGISTER *** */
1716 struct cmd_read_reg_result {
1717 cmdline_fixed_string_t read;
1718 cmdline_fixed_string_t reg;
1724 cmd_read_reg_parsed(void *parsed_result,
1725 __attribute__((unused)) struct cmdline *cl,
1726 __attribute__((unused)) void *data)
1728 struct cmd_read_reg_result *res = parsed_result;
1729 port_reg_display(res->port_id, res->reg_off);
1732 cmdline_parse_token_string_t cmd_read_reg_read =
1733 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
1734 cmdline_parse_token_string_t cmd_read_reg_reg =
1735 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
1736 cmdline_parse_token_num_t cmd_read_reg_port_id =
1737 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
1738 cmdline_parse_token_num_t cmd_read_reg_reg_off =
1739 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
1741 cmdline_parse_inst_t cmd_read_reg = {
1742 .f = cmd_read_reg_parsed,
1744 .help_str = "read reg port_id reg_off",
1746 (void *)&cmd_read_reg_read,
1747 (void *)&cmd_read_reg_reg,
1748 (void *)&cmd_read_reg_port_id,
1749 (void *)&cmd_read_reg_reg_off,
1754 /* *** READ PORT REGISTER BIT FIELD *** */
1755 struct cmd_read_reg_bit_field_result {
1756 cmdline_fixed_string_t read;
1757 cmdline_fixed_string_t regfield;
1765 cmd_read_reg_bit_field_parsed(void *parsed_result,
1766 __attribute__((unused)) struct cmdline *cl,
1767 __attribute__((unused)) void *data)
1769 struct cmd_read_reg_bit_field_result *res = parsed_result;
1770 port_reg_bit_field_display(res->port_id, res->reg_off,
1771 res->bit1_pos, res->bit2_pos);
1774 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
1775 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
1777 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
1778 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
1779 regfield, "regfield");
1780 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
1781 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
1783 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
1784 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
1786 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
1787 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
1789 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
1790 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
1793 cmdline_parse_inst_t cmd_read_reg_bit_field = {
1794 .f = cmd_read_reg_bit_field_parsed,
1796 .help_str = "read regfield port_id reg_off bit_x bit_y "
1797 "(read register bit field between bit_x and bit_y included)",
1799 (void *)&cmd_read_reg_bit_field_read,
1800 (void *)&cmd_read_reg_bit_field_regfield,
1801 (void *)&cmd_read_reg_bit_field_port_id,
1802 (void *)&cmd_read_reg_bit_field_reg_off,
1803 (void *)&cmd_read_reg_bit_field_bit1_pos,
1804 (void *)&cmd_read_reg_bit_field_bit2_pos,
1809 /* *** READ PORT REGISTER BIT *** */
1810 struct cmd_read_reg_bit_result {
1811 cmdline_fixed_string_t read;
1812 cmdline_fixed_string_t regbit;
1819 cmd_read_reg_bit_parsed(void *parsed_result,
1820 __attribute__((unused)) struct cmdline *cl,
1821 __attribute__((unused)) void *data)
1823 struct cmd_read_reg_bit_result *res = parsed_result;
1824 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
1827 cmdline_parse_token_string_t cmd_read_reg_bit_read =
1828 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
1829 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
1830 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
1832 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
1833 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
1834 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
1835 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
1836 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
1837 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
1839 cmdline_parse_inst_t cmd_read_reg_bit = {
1840 .f = cmd_read_reg_bit_parsed,
1842 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
1844 (void *)&cmd_read_reg_bit_read,
1845 (void *)&cmd_read_reg_bit_regbit,
1846 (void *)&cmd_read_reg_bit_port_id,
1847 (void *)&cmd_read_reg_bit_reg_off,
1848 (void *)&cmd_read_reg_bit_bit_pos,
1853 /* *** WRITE PORT REGISTER *** */
1854 struct cmd_write_reg_result {
1855 cmdline_fixed_string_t write;
1856 cmdline_fixed_string_t reg;
1863 cmd_write_reg_parsed(void *parsed_result,
1864 __attribute__((unused)) struct cmdline *cl,
1865 __attribute__((unused)) void *data)
1867 struct cmd_write_reg_result *res = parsed_result;
1868 port_reg_set(res->port_id, res->reg_off, res->value);
1871 cmdline_parse_token_string_t cmd_write_reg_write =
1872 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
1873 cmdline_parse_token_string_t cmd_write_reg_reg =
1874 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
1875 cmdline_parse_token_num_t cmd_write_reg_port_id =
1876 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
1877 cmdline_parse_token_num_t cmd_write_reg_reg_off =
1878 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
1879 cmdline_parse_token_num_t cmd_write_reg_value =
1880 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
1882 cmdline_parse_inst_t cmd_write_reg = {
1883 .f = cmd_write_reg_parsed,
1885 .help_str = "write reg port_id reg_off reg_value",
1887 (void *)&cmd_write_reg_write,
1888 (void *)&cmd_write_reg_reg,
1889 (void *)&cmd_write_reg_port_id,
1890 (void *)&cmd_write_reg_reg_off,
1891 (void *)&cmd_write_reg_value,
1896 /* *** WRITE PORT REGISTER BIT FIELD *** */
1897 struct cmd_write_reg_bit_field_result {
1898 cmdline_fixed_string_t write;
1899 cmdline_fixed_string_t regfield;
1908 cmd_write_reg_bit_field_parsed(void *parsed_result,
1909 __attribute__((unused)) struct cmdline *cl,
1910 __attribute__((unused)) void *data)
1912 struct cmd_write_reg_bit_field_result *res = parsed_result;
1913 port_reg_bit_field_set(res->port_id, res->reg_off,
1914 res->bit1_pos, res->bit2_pos, res->value);
1917 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
1918 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
1920 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
1921 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
1922 regfield, "regfield");
1923 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
1924 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
1926 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
1927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
1929 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
1930 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
1932 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
1933 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
1935 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
1936 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
1939 cmdline_parse_inst_t cmd_write_reg_bit_field = {
1940 .f = cmd_write_reg_bit_field_parsed,
1942 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
1943 "(set register bit field between bit_x and bit_y included)",
1945 (void *)&cmd_write_reg_bit_field_write,
1946 (void *)&cmd_write_reg_bit_field_regfield,
1947 (void *)&cmd_write_reg_bit_field_port_id,
1948 (void *)&cmd_write_reg_bit_field_reg_off,
1949 (void *)&cmd_write_reg_bit_field_bit1_pos,
1950 (void *)&cmd_write_reg_bit_field_bit2_pos,
1951 (void *)&cmd_write_reg_bit_field_value,
1956 /* *** WRITE PORT REGISTER BIT *** */
1957 struct cmd_write_reg_bit_result {
1958 cmdline_fixed_string_t write;
1959 cmdline_fixed_string_t regbit;
1967 cmd_write_reg_bit_parsed(void *parsed_result,
1968 __attribute__((unused)) struct cmdline *cl,
1969 __attribute__((unused)) void *data)
1971 struct cmd_write_reg_bit_result *res = parsed_result;
1972 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
1975 cmdline_parse_token_string_t cmd_write_reg_bit_write =
1976 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
1978 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
1979 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
1981 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
1982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
1983 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
1984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
1985 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
1986 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
1987 cmdline_parse_token_num_t cmd_write_reg_bit_value =
1988 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
1990 cmdline_parse_inst_t cmd_write_reg_bit = {
1991 .f = cmd_write_reg_bit_parsed,
1993 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
1995 (void *)&cmd_write_reg_bit_write,
1996 (void *)&cmd_write_reg_bit_regbit,
1997 (void *)&cmd_write_reg_bit_port_id,
1998 (void *)&cmd_write_reg_bit_reg_off,
1999 (void *)&cmd_write_reg_bit_bit_pos,
2000 (void *)&cmd_write_reg_bit_value,
2005 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
2006 struct cmd_read_rxd_txd_result {
2007 cmdline_fixed_string_t read;
2008 cmdline_fixed_string_t rxd_txd;
2015 cmd_read_rxd_txd_parsed(void *parsed_result,
2016 __attribute__((unused)) struct cmdline *cl,
2017 __attribute__((unused)) void *data)
2019 struct cmd_read_rxd_txd_result *res = parsed_result;
2021 if (!strcmp(res->rxd_txd, "rxd"))
2022 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
2023 else if (!strcmp(res->rxd_txd, "txd"))
2024 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
2027 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
2028 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
2029 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
2030 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
2032 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
2033 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
2034 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
2035 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
2036 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
2037 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
2039 cmdline_parse_inst_t cmd_read_rxd_txd = {
2040 .f = cmd_read_rxd_txd_parsed,
2042 .help_str = "read rxd|txd port_id queue_id rxd_id",
2044 (void *)&cmd_read_rxd_txd_read,
2045 (void *)&cmd_read_rxd_txd_rxd_txd,
2046 (void *)&cmd_read_rxd_txd_port_id,
2047 (void *)&cmd_read_rxd_txd_queue_id,
2048 (void *)&cmd_read_rxd_txd_desc_id,
2054 struct cmd_quit_result {
2055 cmdline_fixed_string_t quit;
2058 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
2060 __attribute__((unused)) void *data)
2066 cmdline_parse_token_string_t cmd_quit_quit =
2067 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
2069 cmdline_parse_inst_t cmd_quit = {
2070 .f = cmd_quit_parsed,
2072 .help_str = "exit application",
2074 (void *)&cmd_quit_quit,
2079 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
2080 struct cmd_mac_addr_result {
2081 cmdline_fixed_string_t mac_addr_cmd;
2082 cmdline_fixed_string_t what;
2084 struct ether_addr address;
2087 static void cmd_mac_addr_parsed(void *parsed_result,
2088 __attribute__((unused)) struct cmdline *cl,
2089 __attribute__((unused)) void *data)
2091 struct cmd_mac_addr_result *res = parsed_result;
2094 if (strcmp(res->what, "add") == 0)
2095 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
2097 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
2099 /* check the return value and print it if is < 0 */
2101 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
2105 cmdline_parse_token_string_t cmd_mac_addr_cmd =
2106 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
2108 cmdline_parse_token_string_t cmd_mac_addr_what =
2109 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
2111 cmdline_parse_token_num_t cmd_mac_addr_portnum =
2112 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
2113 cmdline_parse_token_string_t cmd_mac_addr_addr =
2114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
2116 cmdline_parse_inst_t cmd_mac_addr = {
2117 .f = cmd_mac_addr_parsed,
2119 .help_str = "mac_addr add|remove X <address>: "
2120 "add/remove MAC address on port X",
2122 (void *)&cmd_mac_addr_cmd,
2123 (void *)&cmd_mac_addr_what,
2124 (void *)&cmd_mac_addr_portnum,
2125 (void *)&cmd_mac_addr_addr,
2131 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
2132 struct cmd_set_qmap_result {
2133 cmdline_fixed_string_t set;
2134 cmdline_fixed_string_t qmap;
2135 cmdline_fixed_string_t what;
2142 cmd_set_qmap_parsed(void *parsed_result,
2143 __attribute__((unused)) struct cmdline *cl,
2144 __attribute__((unused)) void *data)
2146 struct cmd_set_qmap_result *res = parsed_result;
2147 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
2149 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
2152 cmdline_parse_token_string_t cmd_setqmap_set =
2153 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
2155 cmdline_parse_token_string_t cmd_setqmap_qmap =
2156 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
2158 cmdline_parse_token_string_t cmd_setqmap_what =
2159 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
2161 cmdline_parse_token_num_t cmd_setqmap_portid =
2162 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
2164 cmdline_parse_token_num_t cmd_setqmap_queueid =
2165 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
2167 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
2168 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
2171 cmdline_parse_inst_t cmd_set_qmap = {
2172 .f = cmd_set_qmap_parsed,
2174 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
2176 (void *)&cmd_setqmap_set,
2177 (void *)&cmd_setqmap_qmap,
2178 (void *)&cmd_setqmap_what,
2179 (void *)&cmd_setqmap_portid,
2180 (void *)&cmd_setqmap_queueid,
2181 (void *)&cmd_setqmap_mapvalue,
2186 /* ******************************************************************************** */
2188 /* list of instructions */
2189 cmdline_parse_ctx_t main_ctx[] = {
2190 (cmdline_parse_inst_t *)&cmd_help,
2191 (cmdline_parse_inst_t *)&cmd_quit,
2192 (cmdline_parse_inst_t *)&cmd_showport,
2193 (cmdline_parse_inst_t *)&cmd_showportall,
2194 (cmdline_parse_inst_t *)&cmd_showcfg,
2195 (cmdline_parse_inst_t *)&cmd_start,
2196 (cmdline_parse_inst_t *)&cmd_start_tx_first,
2197 (cmdline_parse_inst_t *)&cmd_reset,
2198 (cmdline_parse_inst_t *)&cmd_set_numbers,
2199 (cmdline_parse_inst_t *)&cmd_set_txpkts,
2200 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
2201 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
2202 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
2203 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
2204 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
2205 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
2206 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
2207 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
2208 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
2209 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
2210 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
2211 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
2212 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
2213 (cmdline_parse_inst_t *)&cmd_read_reg,
2214 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
2215 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
2216 (cmdline_parse_inst_t *)&cmd_write_reg,
2217 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
2218 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
2219 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
2220 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
2221 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
2222 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
2223 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
2224 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
2225 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
2226 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
2227 (cmdline_parse_inst_t *)&cmd_stop,
2228 (cmdline_parse_inst_t *)&cmd_mac_addr,
2229 (cmdline_parse_inst_t *)&cmd_set_qmap,
2233 /* prompt function, called from main on MASTER lcore */
2239 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
2243 cmdline_interact(cl);
2244 cmdline_stdin_exit(cl);