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 X|all\n"
104 " Diplays information or stats 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"
180 "Control forwarding:\n"
181 "-------------------\n"
183 " Start packet forwarding with current config\n"
185 " Start packet forwarding with current config"
186 " after sending one burst\n of packets\n"
188 " Stop packet forwarding, and displays accumulated"
192 "Flow director mode:\n"
193 "-------------------\n"
194 "- add_signature_filter port_id ip|udp|tcp|sctp src\n"
195 " ip_src_address port_src dst ip_dst_address port_dst\n"
196 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
197 "- upd_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 "- rm_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\n"
203 "- add_perfect_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 queue \n"
206 " queue_id soft soft_id\n"
207 "- upd_perfect_filter port_id ip|udp|tcp|sctp src\n"
208 " ip_src_address port_src dst ip_dst_address port_dst\n"
209 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
210 "- rm_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 soft soft_id\n"
213 "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
214 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
215 " port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
221 " Quit to prompt in linux, and reboot on baremetal\n"
225 cmdline_parse_token_string_t cmd_help_help =
226 TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
228 cmdline_parse_inst_t cmd_help = {
229 .f = cmd_help_parsed,
231 .help_str = "show help",
233 (void *)&cmd_help_help,
239 struct cmd_stop_result {
240 cmdline_fixed_string_t stop;
243 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
244 __attribute__((unused)) struct cmdline *cl,
245 __attribute__((unused)) void *data)
247 stop_packet_forwarding();
250 cmdline_parse_token_string_t cmd_stop_stop =
251 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
253 cmdline_parse_inst_t cmd_stop = {
254 .f = cmd_stop_parsed,
256 .help_str = "stop - stop packet forwarding",
258 (void *)&cmd_stop_stop,
263 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
266 parse_item_list(char* str, const char* item_name, unsigned int max_items,
267 unsigned int *parsed_items, int check_unique_values)
269 unsigned int nb_item;
277 * First parse all items in the list and store their value.
282 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
284 if ((c >= '0') && (c <= '9')) {
285 value = (unsigned int) (value * 10 + (c - '0'));
290 printf("character %c is not a decimal digit\n", c);
294 printf("No valid value before comma\n");
297 if (nb_item < max_items) {
298 parsed_items[nb_item] = value;
304 if (nb_item >= max_items) {
305 printf("Number of %s = %u > %u (maximum items)\n",
306 item_name, nb_item + 1, max_items);
309 parsed_items[nb_item++] = value;
310 if (! check_unique_values)
314 * Then, check that all values in the list are differents.
315 * No optimization here...
317 for (i = 0; i < nb_item; i++) {
318 for (j = i + 1; j < nb_item; j++) {
319 if (parsed_items[j] == parsed_items[i]) {
320 printf("duplicated %s %u at index %u and %u\n",
321 item_name, parsed_items[i], i, j);
329 struct cmd_set_list_result {
330 cmdline_fixed_string_t cmd_keyword;
331 cmdline_fixed_string_t list_name;
332 cmdline_fixed_string_t list_of_items;
335 static void cmd_set_list_parsed(void *parsed_result,
336 __attribute__((unused)) struct cmdline *cl,
337 __attribute__((unused)) void *data)
339 struct cmd_set_list_result *res;
341 unsigned int lcorelist[RTE_MAX_LCORE];
342 unsigned int portlist[RTE_MAX_ETHPORTS];
344 unsigned int nb_item;
347 if (!strcmp(res->list_name, "corelist")) {
348 nb_item = parse_item_list(res->list_of_items, "core",
350 parsed_items.lcorelist, 1);
352 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
355 if (!strcmp(res->list_name, "portlist")) {
356 nb_item = parse_item_list(res->list_of_items, "port",
358 parsed_items.portlist, 1);
360 set_fwd_ports_list(parsed_items.portlist, nb_item);
364 cmdline_parse_token_string_t cmd_set_list_keyword =
365 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
367 cmdline_parse_token_string_t cmd_set_list_name =
368 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
369 "corelist#portlist");
370 cmdline_parse_token_string_t cmd_set_list_of_items =
371 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
374 cmdline_parse_inst_t cmd_set_fwd_list = {
375 .f = cmd_set_list_parsed,
377 .help_str = "set corelist|portlist x[,y]*",
379 (void *)&cmd_set_list_keyword,
380 (void *)&cmd_set_list_name,
381 (void *)&cmd_set_list_of_items,
386 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
388 struct cmd_setmask_result {
389 cmdline_fixed_string_t set;
390 cmdline_fixed_string_t mask;
394 static void cmd_set_mask_parsed(void *parsed_result,
395 __attribute__((unused)) struct cmdline *cl,
396 __attribute__((unused)) void *data)
398 struct cmd_setmask_result *res = parsed_result;
400 if (!strcmp(res->mask, "coremask"))
401 set_fwd_lcores_mask(res->hexavalue);
402 else if (!strcmp(res->mask, "portmask"))
403 set_fwd_ports_mask(res->hexavalue);
406 cmdline_parse_token_string_t cmd_setmask_set =
407 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
408 cmdline_parse_token_string_t cmd_setmask_mask =
409 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
410 "coremask#portmask");
411 cmdline_parse_token_num_t cmd_setmask_value =
412 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
414 cmdline_parse_inst_t cmd_set_fwd_mask = {
415 .f = cmd_set_mask_parsed,
417 .help_str = "set coremask|portmask hexadecimal value",
419 (void *)&cmd_setmask_set,
420 (void *)&cmd_setmask_mask,
421 (void *)&cmd_setmask_value,
427 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
429 struct cmd_set_result {
430 cmdline_fixed_string_t set;
431 cmdline_fixed_string_t what;
435 static void cmd_set_parsed(void *parsed_result,
436 __attribute__((unused)) struct cmdline *cl,
437 __attribute__((unused)) void *data)
439 struct cmd_set_result *res = parsed_result;
440 if (!strcmp(res->what, "nbport"))
441 set_fwd_ports_number(res->value);
442 else if (!strcmp(res->what, "nbcore"))
443 set_fwd_lcores_number(res->value);
444 else if (!strcmp(res->what, "burst"))
445 set_nb_pkt_per_burst(res->value);
446 else if (!strcmp(res->what, "verbose"))
447 set_verbose_level(res->value);
450 cmdline_parse_token_string_t cmd_set_set =
451 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
452 cmdline_parse_token_string_t cmd_set_what =
453 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
454 "nbport#nbcore#burst#verbose");
455 cmdline_parse_token_num_t cmd_set_value =
456 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
458 cmdline_parse_inst_t cmd_set_numbers = {
461 .help_str = "set nbport|nbcore|burst|verbose value",
463 (void *)&cmd_set_set,
464 (void *)&cmd_set_what,
465 (void *)&cmd_set_value,
470 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
472 struct cmd_set_txpkts_result {
473 cmdline_fixed_string_t cmd_keyword;
474 cmdline_fixed_string_t txpkts;
475 cmdline_fixed_string_t seg_lengths;
479 cmd_set_txpkts_parsed(void *parsed_result,
480 __attribute__((unused)) struct cmdline *cl,
481 __attribute__((unused)) void *data)
483 struct cmd_set_txpkts_result *res;
484 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
485 unsigned int nb_segs;
488 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
489 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
491 set_tx_pkt_segments(seg_lengths, nb_segs);
494 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
495 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
497 cmdline_parse_token_string_t cmd_set_txpkts_name =
498 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
500 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
501 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
504 cmdline_parse_inst_t cmd_set_txpkts = {
505 .f = cmd_set_txpkts_parsed,
507 .help_str = "set txpkts x[,y]*",
509 (void *)&cmd_set_txpkts_keyword,
510 (void *)&cmd_set_txpkts_name,
511 (void *)&cmd_set_txpkts_lengths,
516 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
517 struct cmd_rx_vlan_filter_all_result {
518 cmdline_fixed_string_t rx_vlan;
519 cmdline_fixed_string_t what;
520 cmdline_fixed_string_t all;
525 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
526 __attribute__((unused)) struct cmdline *cl,
527 __attribute__((unused)) void *data)
529 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
531 if (!strcmp(res->what, "add"))
532 rx_vlan_all_filter_set(res->port_id, 1);
534 rx_vlan_all_filter_set(res->port_id, 0);
537 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
538 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
540 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
541 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
543 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
544 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
546 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
547 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
550 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
551 .f = cmd_rx_vlan_filter_all_parsed,
553 .help_str = "add/remove all identifiers to/from the set of VLAN "
554 "Identifiers filtered by a port",
556 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
557 (void *)&cmd_rx_vlan_filter_all_what,
558 (void *)&cmd_rx_vlan_filter_all_all,
559 (void *)&cmd_rx_vlan_filter_all_portid,
564 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
565 struct cmd_rx_vlan_filter_result {
566 cmdline_fixed_string_t rx_vlan;
567 cmdline_fixed_string_t what;
573 cmd_rx_vlan_filter_parsed(void *parsed_result,
574 __attribute__((unused)) struct cmdline *cl,
575 __attribute__((unused)) void *data)
577 struct cmd_rx_vlan_filter_result *res = parsed_result;
579 if (!strcmp(res->what, "add"))
580 rx_vlan_filter_set(res->port_id, res->vlan_id, 1);
582 rx_vlan_filter_set(res->port_id, res->vlan_id, 0);
585 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
586 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
588 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
589 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
591 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
592 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
594 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
595 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
598 cmdline_parse_inst_t cmd_rx_vlan_filter = {
599 .f = cmd_rx_vlan_filter_parsed,
601 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
602 "Identifiers filtered by a port",
604 (void *)&cmd_rx_vlan_filter_rx_vlan,
605 (void *)&cmd_rx_vlan_filter_what,
606 (void *)&cmd_rx_vlan_filter_vlanid,
607 (void *)&cmd_rx_vlan_filter_portid,
612 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
613 struct cmd_tx_vlan_set_result {
614 cmdline_fixed_string_t tx_vlan;
615 cmdline_fixed_string_t set;
621 cmd_tx_vlan_set_parsed(void *parsed_result,
622 __attribute__((unused)) struct cmdline *cl,
623 __attribute__((unused)) void *data)
625 struct cmd_tx_vlan_set_result *res = parsed_result;
627 tx_vlan_set(res->port_id, res->vlan_id);
630 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
631 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
633 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
634 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
636 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
637 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
639 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
640 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
643 cmdline_parse_inst_t cmd_tx_vlan_set = {
644 .f = cmd_tx_vlan_set_parsed,
646 .help_str = "enable hardware insertion of a VLAN header with a given "
647 "TAG Identifier in packets sent on a port",
649 (void *)&cmd_tx_vlan_set_tx_vlan,
650 (void *)&cmd_tx_vlan_set_set,
651 (void *)&cmd_tx_vlan_set_vlanid,
652 (void *)&cmd_tx_vlan_set_portid,
657 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
658 struct cmd_tx_vlan_reset_result {
659 cmdline_fixed_string_t tx_vlan;
660 cmdline_fixed_string_t reset;
665 cmd_tx_vlan_reset_parsed(void *parsed_result,
666 __attribute__((unused)) struct cmdline *cl,
667 __attribute__((unused)) void *data)
669 struct cmd_tx_vlan_reset_result *res = parsed_result;
671 tx_vlan_reset(res->port_id);
674 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
675 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
677 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
678 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
680 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
681 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
684 cmdline_parse_inst_t cmd_tx_vlan_reset = {
685 .f = cmd_tx_vlan_reset_parsed,
687 .help_str = "disable hardware insertion of a VLAN header in packets "
690 (void *)&cmd_tx_vlan_reset_tx_vlan,
691 (void *)&cmd_tx_vlan_reset_reset,
692 (void *)&cmd_tx_vlan_reset_portid,
698 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
699 struct cmd_tx_cksum_set_result {
700 cmdline_fixed_string_t tx_cksum;
701 cmdline_fixed_string_t set;
707 cmd_tx_cksum_set_parsed(void *parsed_result,
708 __attribute__((unused)) struct cmdline *cl,
709 __attribute__((unused)) void *data)
711 struct cmd_tx_cksum_set_result *res = parsed_result;
713 tx_cksum_set(res->port_id, res->cksum_mask);
716 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
717 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
718 tx_cksum, "tx_checksum");
719 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
720 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
722 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
723 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
725 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
726 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
729 cmdline_parse_inst_t cmd_tx_cksum_set = {
730 .f = cmd_tx_cksum_set_parsed,
732 .help_str = "enable hardware insertion of L3/L4checksum with a given "
733 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
734 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
736 (void *)&cmd_tx_cksum_set_tx_cksum,
737 (void *)&cmd_tx_cksum_set_set,
738 (void *)&cmd_tx_cksum_set_cksum_mask,
739 (void *)&cmd_tx_cksum_set_portid,
744 /* *** SET FORWARDING MODE *** */
745 struct cmd_set_fwd_mode_result {
746 cmdline_fixed_string_t set;
747 cmdline_fixed_string_t fwd;
748 cmdline_fixed_string_t mode;
751 static void cmd_set_fwd_mode_parsed(void *parsed_result,
752 __attribute__((unused)) struct cmdline *cl,
753 __attribute__((unused)) void *data)
755 struct cmd_set_fwd_mode_result *res = parsed_result;
757 set_pkt_forwarding_mode(res->mode);
760 cmdline_parse_token_string_t cmd_setfwd_set =
761 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
762 cmdline_parse_token_string_t cmd_setfwd_fwd =
763 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
764 cmdline_parse_token_string_t cmd_setfwd_mode =
765 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
766 #ifdef RTE_LIBRTE_IEEE1588
767 "io#mac#rxonly#txonly#csum#ieee1588");
769 "io#mac#rxonly#txonly#csum");
772 cmdline_parse_inst_t cmd_set_fwd_mode = {
773 .f = cmd_set_fwd_mode_parsed,
775 #ifdef RTE_LIBRTE_IEEE1588
776 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
777 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
779 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
780 " RXONLY, CSUM or TXONLY packet forwarding mode",
783 (void *)&cmd_setfwd_set,
784 (void *)&cmd_setfwd_fwd,
785 (void *)&cmd_setfwd_mode,
790 /* *** SET PROMISC MODE *** */
791 struct cmd_set_promisc_mode_result {
792 cmdline_fixed_string_t set;
793 cmdline_fixed_string_t promisc;
794 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
795 uint8_t port_num; /* valid if "allports" argument == 0 */
796 cmdline_fixed_string_t mode;
799 static void cmd_set_promisc_mode_parsed(void *parsed_result,
800 __attribute__((unused)) struct cmdline *cl,
803 struct cmd_set_promisc_mode_result *res = parsed_result;
807 if (!strcmp(res->mode, "on"))
814 for (i = 0; i < nb_ports; i++) {
816 rte_eth_promiscuous_enable(i);
818 rte_eth_promiscuous_disable(i);
823 rte_eth_promiscuous_enable(res->port_num);
825 rte_eth_promiscuous_disable(res->port_num);
829 cmdline_parse_token_string_t cmd_setpromisc_set =
830 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
831 cmdline_parse_token_string_t cmd_setpromisc_promisc =
832 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
834 cmdline_parse_token_string_t cmd_setpromisc_portall =
835 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
837 cmdline_parse_token_num_t cmd_setpromisc_portnum =
838 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
840 cmdline_parse_token_string_t cmd_setpromisc_mode =
841 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
844 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
845 .f = cmd_set_promisc_mode_parsed,
847 .help_str = "set promisc all on|off: set promisc mode for all ports",
849 (void *)&cmd_setpromisc_set,
850 (void *)&cmd_setpromisc_promisc,
851 (void *)&cmd_setpromisc_portall,
852 (void *)&cmd_setpromisc_mode,
857 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
858 .f = cmd_set_promisc_mode_parsed,
860 .help_str = "set promisc X on|off: set promisc mode on port X",
862 (void *)&cmd_setpromisc_set,
863 (void *)&cmd_setpromisc_promisc,
864 (void *)&cmd_setpromisc_portnum,
865 (void *)&cmd_setpromisc_mode,
870 /* *** SET ALLMULTI MODE *** */
871 struct cmd_set_allmulti_mode_result {
872 cmdline_fixed_string_t set;
873 cmdline_fixed_string_t allmulti;
874 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
875 uint8_t port_num; /* valid if "allports" argument == 0 */
876 cmdline_fixed_string_t mode;
879 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
880 __attribute__((unused)) struct cmdline *cl,
883 struct cmd_set_allmulti_mode_result *res = parsed_result;
887 if (!strcmp(res->mode, "on"))
894 for (i = 0; i < nb_ports; i++) {
896 rte_eth_allmulticast_enable(i);
898 rte_eth_allmulticast_disable(i);
903 rte_eth_allmulticast_enable(res->port_num);
905 rte_eth_allmulticast_disable(res->port_num);
909 cmdline_parse_token_string_t cmd_setallmulti_set =
910 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
911 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
914 cmdline_parse_token_string_t cmd_setallmulti_portall =
915 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
917 cmdline_parse_token_num_t cmd_setallmulti_portnum =
918 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
920 cmdline_parse_token_string_t cmd_setallmulti_mode =
921 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
924 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
925 .f = cmd_set_allmulti_mode_parsed,
927 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
929 (void *)&cmd_setallmulti_set,
930 (void *)&cmd_setallmulti_allmulti,
931 (void *)&cmd_setallmulti_portall,
932 (void *)&cmd_setallmulti_mode,
937 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
938 .f = cmd_set_allmulti_mode_parsed,
940 .help_str = "set allmulti X on|off: set allmulti mode on port X",
942 (void *)&cmd_setallmulti_set,
943 (void *)&cmd_setallmulti_allmulti,
944 (void *)&cmd_setallmulti_portnum,
945 (void *)&cmd_setallmulti_mode,
950 /* *** ADD/REMOVE A PKT FILTER *** */
951 struct cmd_pkt_filter_result {
952 cmdline_fixed_string_t pkt_filter;
954 cmdline_fixed_string_t protocol;
955 cmdline_fixed_string_t src;
956 cmdline_ipaddr_t ip_src;
958 cmdline_fixed_string_t dst;
959 cmdline_ipaddr_t ip_dst;
961 cmdline_fixed_string_t flexbytes;
962 uint16_t flexbytes_value;
963 cmdline_fixed_string_t vlan;
965 cmdline_fixed_string_t queue;
967 cmdline_fixed_string_t soft;
972 cmd_pkt_filter_parsed(void *parsed_result,
973 __attribute__((unused)) struct cmdline *cl,
974 __attribute__((unused)) void *data)
976 struct rte_fdir_filter fdir_filter;
977 struct cmd_pkt_filter_result *res = parsed_result;
979 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
981 if (res->ip_src.family == AF_INET)
982 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
984 memcpy(&(fdir_filter.ip_src.ipv6_addr),
985 &(res->ip_src.addr.ipv6),
986 sizeof(struct in6_addr));
988 if (res->ip_dst.family == AF_INET)
989 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
991 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
992 &(res->ip_dst.addr.ipv6),
993 sizeof(struct in6_addr));
995 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
996 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
998 if (!strcmp(res->protocol, "udp"))
999 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
1000 else if (!strcmp(res->protocol, "tcp"))
1001 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
1002 else if (!strcmp(res->protocol, "sctp"))
1003 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
1004 else /* default only IP */
1005 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
1007 if (res->ip_dst.family == AF_INET6)
1008 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
1010 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
1012 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
1013 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
1015 if (!strcmp(res->pkt_filter, "add_signature_filter"))
1016 fdir_add_signature_filter(res->port_id, res->queue_id,
1018 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
1019 fdir_update_signature_filter(res->port_id, res->queue_id,
1021 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
1022 fdir_remove_signature_filter(res->port_id, &fdir_filter);
1023 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
1024 fdir_add_perfect_filter(res->port_id, res->soft_id,
1026 (uint8_t) (res->queue_id < 0),
1028 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
1029 fdir_update_perfect_filter(res->port_id, res->soft_id,
1031 (uint8_t) (res->queue_id < 0),
1033 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
1034 fdir_remove_perfect_filter(res->port_id, res->soft_id,
1040 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
1041 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1043 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
1044 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1045 protocol, "ip#tcp#udp#sctp");
1046 cmdline_parse_token_string_t cmd_pkt_filter_src =
1047 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1049 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
1050 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
1052 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
1053 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1055 cmdline_parse_token_string_t cmd_pkt_filter_dst =
1056 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1058 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
1059 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
1061 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
1062 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1064 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
1065 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1066 flexbytes, "flexbytes");
1067 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
1068 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1069 flexbytes_value, UINT16);
1070 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
1071 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1073 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
1074 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1076 cmdline_parse_token_string_t cmd_pkt_filter_queue =
1077 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1079 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
1080 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1082 cmdline_parse_token_string_t cmd_pkt_filter_soft =
1083 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1085 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
1086 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
1090 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
1091 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1092 pkt_filter, "add_signature_filter");
1093 cmdline_parse_inst_t cmd_add_signature_filter = {
1094 .f = cmd_pkt_filter_parsed,
1096 .help_str = "add a signature filter",
1098 (void *)&cmd_pkt_filter_add_signature_filter,
1099 (void *)&cmd_pkt_filter_port_id,
1100 (void *)&cmd_pkt_filter_protocol,
1101 (void *)&cmd_pkt_filter_src,
1102 (void *)&cmd_pkt_filter_ip_src,
1103 (void *)&cmd_pkt_filter_port_src,
1104 (void *)&cmd_pkt_filter_dst,
1105 (void *)&cmd_pkt_filter_ip_dst,
1106 (void *)&cmd_pkt_filter_port_dst,
1107 (void *)&cmd_pkt_filter_flexbytes,
1108 (void *)&cmd_pkt_filter_flexbytes_value,
1109 (void *)&cmd_pkt_filter_vlan,
1110 (void *)&cmd_pkt_filter_vlan_id,
1111 (void *)&cmd_pkt_filter_queue,
1112 (void *)&cmd_pkt_filter_queue_id,
1118 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
1119 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1120 pkt_filter, "upd_signature_filter");
1121 cmdline_parse_inst_t cmd_upd_signature_filter = {
1122 .f = cmd_pkt_filter_parsed,
1124 .help_str = "update a signature filter",
1126 (void *)&cmd_pkt_filter_upd_signature_filter,
1127 (void *)&cmd_pkt_filter_port_id,
1128 (void *)&cmd_pkt_filter_protocol,
1129 (void *)&cmd_pkt_filter_src,
1130 (void *)&cmd_pkt_filter_ip_src,
1131 (void *)&cmd_pkt_filter_port_src,
1132 (void *)&cmd_pkt_filter_dst,
1133 (void *)&cmd_pkt_filter_ip_dst,
1134 (void *)&cmd_pkt_filter_port_dst,
1135 (void *)&cmd_pkt_filter_flexbytes,
1136 (void *)&cmd_pkt_filter_flexbytes_value,
1137 (void *)&cmd_pkt_filter_vlan,
1138 (void *)&cmd_pkt_filter_vlan_id,
1139 (void *)&cmd_pkt_filter_queue,
1140 (void *)&cmd_pkt_filter_queue_id,
1146 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
1147 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1148 pkt_filter, "rm_signature_filter");
1149 cmdline_parse_inst_t cmd_rm_signature_filter = {
1150 .f = cmd_pkt_filter_parsed,
1152 .help_str = "remove a signature filter",
1154 (void *)&cmd_pkt_filter_rm_signature_filter,
1155 (void *)&cmd_pkt_filter_port_id,
1156 (void *)&cmd_pkt_filter_protocol,
1157 (void *)&cmd_pkt_filter_src,
1158 (void *)&cmd_pkt_filter_ip_src,
1159 (void *)&cmd_pkt_filter_port_src,
1160 (void *)&cmd_pkt_filter_dst,
1161 (void *)&cmd_pkt_filter_ip_dst,
1162 (void *)&cmd_pkt_filter_port_dst,
1163 (void *)&cmd_pkt_filter_flexbytes,
1164 (void *)&cmd_pkt_filter_flexbytes_value,
1165 (void *)&cmd_pkt_filter_vlan,
1166 (void *)&cmd_pkt_filter_vlan_id,
1172 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
1173 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1174 pkt_filter, "add_perfect_filter");
1175 cmdline_parse_inst_t cmd_add_perfect_filter = {
1176 .f = cmd_pkt_filter_parsed,
1178 .help_str = "add a perfect filter",
1180 (void *)&cmd_pkt_filter_add_perfect_filter,
1181 (void *)&cmd_pkt_filter_port_id,
1182 (void *)&cmd_pkt_filter_protocol,
1183 (void *)&cmd_pkt_filter_src,
1184 (void *)&cmd_pkt_filter_ip_src,
1185 (void *)&cmd_pkt_filter_port_src,
1186 (void *)&cmd_pkt_filter_dst,
1187 (void *)&cmd_pkt_filter_ip_dst,
1188 (void *)&cmd_pkt_filter_port_dst,
1189 (void *)&cmd_pkt_filter_flexbytes,
1190 (void *)&cmd_pkt_filter_flexbytes_value,
1191 (void *)&cmd_pkt_filter_vlan,
1192 (void *)&cmd_pkt_filter_vlan_id,
1193 (void *)&cmd_pkt_filter_queue,
1194 (void *)&cmd_pkt_filter_queue_id,
1195 (void *)&cmd_pkt_filter_soft,
1196 (void *)&cmd_pkt_filter_soft_id,
1202 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
1203 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1204 pkt_filter, "upd_perfect_filter");
1205 cmdline_parse_inst_t cmd_upd_perfect_filter = {
1206 .f = cmd_pkt_filter_parsed,
1208 .help_str = "update a perfect filter",
1210 (void *)&cmd_pkt_filter_upd_perfect_filter,
1211 (void *)&cmd_pkt_filter_port_id,
1212 (void *)&cmd_pkt_filter_protocol,
1213 (void *)&cmd_pkt_filter_src,
1214 (void *)&cmd_pkt_filter_ip_src,
1215 (void *)&cmd_pkt_filter_port_src,
1216 (void *)&cmd_pkt_filter_dst,
1217 (void *)&cmd_pkt_filter_ip_dst,
1218 (void *)&cmd_pkt_filter_port_dst,
1219 (void *)&cmd_pkt_filter_flexbytes,
1220 (void *)&cmd_pkt_filter_flexbytes_value,
1221 (void *)&cmd_pkt_filter_vlan,
1222 (void *)&cmd_pkt_filter_vlan_id,
1223 (void *)&cmd_pkt_filter_queue,
1224 (void *)&cmd_pkt_filter_queue_id,
1225 (void *)&cmd_pkt_filter_soft,
1226 (void *)&cmd_pkt_filter_soft_id,
1232 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
1233 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
1234 pkt_filter, "rm_perfect_filter");
1235 cmdline_parse_inst_t cmd_rm_perfect_filter = {
1236 .f = cmd_pkt_filter_parsed,
1238 .help_str = "remove a perfect filter",
1240 (void *)&cmd_pkt_filter_rm_perfect_filter,
1241 (void *)&cmd_pkt_filter_port_id,
1242 (void *)&cmd_pkt_filter_protocol,
1243 (void *)&cmd_pkt_filter_src,
1244 (void *)&cmd_pkt_filter_ip_src,
1245 (void *)&cmd_pkt_filter_port_src,
1246 (void *)&cmd_pkt_filter_dst,
1247 (void *)&cmd_pkt_filter_ip_dst,
1248 (void *)&cmd_pkt_filter_port_dst,
1249 (void *)&cmd_pkt_filter_flexbytes,
1250 (void *)&cmd_pkt_filter_flexbytes_value,
1251 (void *)&cmd_pkt_filter_vlan,
1252 (void *)&cmd_pkt_filter_vlan_id,
1253 (void *)&cmd_pkt_filter_soft,
1254 (void *)&cmd_pkt_filter_soft_id,
1259 /* *** SETUP MASKS FILTER *** */
1260 struct cmd_pkt_filter_masks_result {
1261 cmdline_fixed_string_t filter_mask;
1263 cmdline_fixed_string_t src_mask;
1264 uint32_t ip_src_mask;
1265 uint16_t port_src_mask;
1266 cmdline_fixed_string_t dst_mask;
1267 uint32_t ip_dst_mask;
1268 uint16_t port_dst_mask;
1269 cmdline_fixed_string_t flexbytes;
1270 uint8_t flexbytes_value;
1271 cmdline_fixed_string_t vlan_id;
1272 uint8_t vlan_id_value;
1273 cmdline_fixed_string_t vlan_prio;
1274 uint8_t vlan_prio_value;
1275 cmdline_fixed_string_t only_ip_flow;
1276 uint8_t only_ip_flow_value;
1280 cmd_pkt_filter_masks_parsed(void *parsed_result,
1281 __attribute__((unused)) struct cmdline *cl,
1282 __attribute__((unused)) void *data)
1284 struct rte_fdir_masks fdir_masks;
1285 struct cmd_pkt_filter_masks_result *res = parsed_result;
1287 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
1289 fdir_masks.only_ip_flow = res->only_ip_flow_value;
1290 fdir_masks.vlan_id = res->vlan_id_value;
1291 fdir_masks.vlan_prio = res->vlan_prio_value;
1292 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
1293 fdir_masks.src_ipv4_mask = res->ip_src_mask;
1294 fdir_masks.src_port_mask = res->port_src_mask;
1295 fdir_masks.dst_port_mask = res->port_dst_mask;
1296 fdir_masks.flexbytes = res->flexbytes_value;
1298 fdir_set_masks(res->port_id, &fdir_masks);
1301 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
1302 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1303 filter_mask, "set_masks_filter");
1304 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
1305 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1307 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
1308 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1309 only_ip_flow, "only_ip_flow");
1310 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
1311 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1312 only_ip_flow_value, UINT8);
1313 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
1314 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1315 src_mask, "src_mask");
1316 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
1317 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1318 ip_src_mask, UINT32);
1319 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
1320 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1321 port_src_mask, UINT16);
1322 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
1323 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1324 src_mask, "dst_mask");
1325 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
1326 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1327 ip_dst_mask, UINT32);
1328 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
1329 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1330 port_dst_mask, UINT16);
1331 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
1332 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1333 flexbytes, "flexbytes");
1334 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
1335 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1336 flexbytes_value, UINT8);
1337 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
1338 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1339 vlan_id, "vlan_id");
1340 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
1341 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1342 vlan_id_value, UINT8);
1343 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
1344 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
1345 vlan_prio, "vlan_prio");
1346 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
1347 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
1348 vlan_prio_value, UINT8);
1350 cmdline_parse_inst_t cmd_set_masks_filter = {
1351 .f = cmd_pkt_filter_masks_parsed,
1353 .help_str = "setup masks filter",
1355 (void *)&cmd_pkt_filter_masks_filter_mask,
1356 (void *)&cmd_pkt_filter_masks_port_id,
1357 (void *)&cmd_pkt_filter_masks_only_ip_flow,
1358 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
1359 (void *)&cmd_pkt_filter_masks_src_mask,
1360 (void *)&cmd_pkt_filter_masks_ip_src_mask,
1361 (void *)&cmd_pkt_filter_masks_port_src_mask,
1362 (void *)&cmd_pkt_filter_masks_dst_mask,
1363 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
1364 (void *)&cmd_pkt_filter_masks_port_dst_mask,
1365 (void *)&cmd_pkt_filter_masks_flexbytes,
1366 (void *)&cmd_pkt_filter_masks_flexbytes_value,
1367 (void *)&cmd_pkt_filter_masks_vlan_id,
1368 (void *)&cmd_pkt_filter_masks_vlan_id_value,
1369 (void *)&cmd_pkt_filter_masks_vlan_prio,
1370 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
1375 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
1376 struct cmd_link_flow_ctrl_set_result {
1377 cmdline_fixed_string_t set;
1378 cmdline_fixed_string_t flow_ctrl;
1379 cmdline_fixed_string_t rx;
1380 cmdline_fixed_string_t rx_lfc_mode;
1381 cmdline_fixed_string_t tx;
1382 cmdline_fixed_string_t tx_lfc_mode;
1383 uint32_t high_water;
1385 uint16_t pause_time;
1391 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
1392 __attribute__((unused)) struct cmdline *cl,
1393 __attribute__((unused)) void *data)
1395 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
1396 struct rte_eth_fc_conf fc_conf;
1397 int rx_fc_enable, tx_fc_enable;
1401 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
1402 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
1403 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
1404 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
1406 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
1407 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
1410 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
1411 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
1413 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
1414 fc_conf.high_water = res->high_water;
1415 fc_conf.low_water = res->low_water;
1416 fc_conf.pause_time = res->pause_time;
1417 fc_conf.send_xon = res->send_xon;
1419 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
1421 printf("bad flow contrl parameter, return code = %d \n", ret);
1424 cmdline_parse_token_string_t cmd_lfc_set_set =
1425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1427 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
1428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1429 flow_ctrl, "flow_ctrl");
1430 cmdline_parse_token_string_t cmd_lfc_set_rx =
1431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1433 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
1434 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1435 rx_lfc_mode, "on#off");
1436 cmdline_parse_token_string_t cmd_lfc_set_tx =
1437 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1439 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
1440 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1441 tx_lfc_mode, "on#off");
1442 cmdline_parse_token_num_t cmd_lfc_set_high_water =
1443 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1444 high_water, UINT32);
1445 cmdline_parse_token_num_t cmd_lfc_set_low_water =
1446 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1448 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
1449 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1450 pause_time, UINT16);
1451 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
1452 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1454 cmdline_parse_token_num_t cmd_lfc_set_portid =
1455 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
1458 cmdline_parse_inst_t cmd_link_flow_control_set = {
1459 .f = cmd_link_flow_ctrl_set_parsed,
1461 .help_str = "Configure the Ethernet link flow control...",
1463 (void *)&cmd_lfc_set_set,
1464 (void *)&cmd_lfc_set_flow_ctrl,
1465 (void *)&cmd_lfc_set_rx,
1466 (void *)&cmd_lfc_set_rx_mode,
1467 (void *)&cmd_lfc_set_tx,
1468 (void *)&cmd_lfc_set_tx_mode,
1469 (void *)&cmd_lfc_set_high_water,
1470 (void *)&cmd_lfc_set_low_water,
1471 (void *)&cmd_lfc_set_pause_time,
1472 (void *)&cmd_lfc_set_send_xon,
1473 (void *)&cmd_lfc_set_portid,
1478 /* *** RESET CONFIGURATION *** */
1479 struct cmd_reset_result {
1480 cmdline_fixed_string_t reset;
1481 cmdline_fixed_string_t def;
1484 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
1486 __attribute__((unused)) void *data)
1488 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
1489 set_def_fwd_config();
1492 cmdline_parse_token_string_t cmd_reset_set =
1493 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
1494 cmdline_parse_token_string_t cmd_reset_def =
1495 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
1498 cmdline_parse_inst_t cmd_reset = {
1499 .f = cmd_reset_parsed,
1501 .help_str = "set default: reset default forwarding configuration",
1503 (void *)&cmd_reset_set,
1504 (void *)&cmd_reset_def,
1509 /* *** START FORWARDING *** */
1510 struct cmd_start_result {
1511 cmdline_fixed_string_t start;
1514 cmdline_parse_token_string_t cmd_start_start =
1515 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
1517 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
1518 __attribute__((unused)) struct cmdline *cl,
1519 __attribute__((unused)) void *data)
1521 start_packet_forwarding(0);
1524 cmdline_parse_inst_t cmd_start = {
1525 .f = cmd_start_parsed,
1527 .help_str = "start packet forwarding",
1529 (void *)&cmd_start_start,
1534 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
1535 struct cmd_start_tx_first_result {
1536 cmdline_fixed_string_t start;
1537 cmdline_fixed_string_t tx_first;
1541 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
1542 __attribute__((unused)) struct cmdline *cl,
1543 __attribute__((unused)) void *data)
1545 start_packet_forwarding(1);
1548 cmdline_parse_token_string_t cmd_start_tx_first_start =
1549 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
1551 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
1552 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
1553 tx_first, "tx_first");
1555 cmdline_parse_inst_t cmd_start_tx_first = {
1556 .f = cmd_start_tx_first_parsed,
1558 .help_str = "start packet forwarding, after sending 1 burst of packets",
1560 (void *)&cmd_start_tx_first_start,
1561 (void *)&cmd_start_tx_first_tx_first,
1566 /* *** SHOW CFG *** */
1567 struct cmd_showcfg_result {
1568 cmdline_fixed_string_t show;
1569 cmdline_fixed_string_t cfg;
1570 cmdline_fixed_string_t what;
1573 static void cmd_showcfg_parsed(void *parsed_result,
1574 __attribute__((unused)) struct cmdline *cl,
1575 __attribute__((unused)) void *data)
1577 struct cmd_showcfg_result *res = parsed_result;
1578 if (!strcmp(res->what, "rxtx"))
1579 rxtx_config_display();
1580 else if (!strcmp(res->what, "cores"))
1581 fwd_lcores_config_display();
1582 else if (!strcmp(res->what, "fwd"))
1583 fwd_config_display();
1586 cmdline_parse_token_string_t cmd_showcfg_show =
1587 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
1588 cmdline_parse_token_string_t cmd_showcfg_port =
1589 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
1590 cmdline_parse_token_string_t cmd_showcfg_what =
1591 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
1594 cmdline_parse_inst_t cmd_showcfg = {
1595 .f = cmd_showcfg_parsed,
1597 .help_str = "show config rxtx|cores|fwd",
1599 (void *)&cmd_showcfg_show,
1600 (void *)&cmd_showcfg_port,
1601 (void *)&cmd_showcfg_what,
1606 /* *** SHOW ALL PORT INFO *** */
1607 struct cmd_showportall_result {
1608 cmdline_fixed_string_t show;
1609 cmdline_fixed_string_t port;
1610 cmdline_fixed_string_t what;
1611 cmdline_fixed_string_t all;
1614 static void cmd_showportall_parsed(void *parsed_result,
1615 __attribute__((unused)) struct cmdline *cl,
1616 __attribute__((unused)) void *data)
1620 struct cmd_showportall_result *res = parsed_result;
1621 if (!strcmp(res->show, "clear")) {
1622 if (!strcmp(res->what, "stats"))
1623 for (i = 0; i < nb_ports; i++)
1625 } else if (!strcmp(res->what, "info"))
1626 for (i = 0; i < nb_ports; i++)
1627 port_infos_display(i);
1628 else if (!strcmp(res->what, "stats"))
1629 for (i = 0; i < nb_ports; i++)
1630 nic_stats_display(i);
1631 else if (!strcmp(res->what, "fdir"))
1632 for (i = 0; i < nb_ports; i++)
1636 cmdline_parse_token_string_t cmd_showportall_show =
1637 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
1639 cmdline_parse_token_string_t cmd_showportall_port =
1640 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
1641 cmdline_parse_token_string_t cmd_showportall_what =
1642 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
1644 cmdline_parse_token_string_t cmd_showportall_all =
1645 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
1646 cmdline_parse_inst_t cmd_showportall = {
1647 .f = cmd_showportall_parsed,
1649 .help_str = "show|clear port info|stats|fdir all",
1651 (void *)&cmd_showportall_show,
1652 (void *)&cmd_showportall_port,
1653 (void *)&cmd_showportall_what,
1654 (void *)&cmd_showportall_all,
1659 /* *** SHOW PORT INFO *** */
1660 struct cmd_showport_result {
1661 cmdline_fixed_string_t show;
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t what;
1667 static void cmd_showport_parsed(void *parsed_result,
1668 __attribute__((unused)) struct cmdline *cl,
1669 __attribute__((unused)) void *data)
1671 struct cmd_showport_result *res = parsed_result;
1672 if (!strcmp(res->show, "clear")) {
1673 if (!strcmp(res->what, "stats"))
1674 nic_stats_clear(res->portnum);
1675 } else if (!strcmp(res->what, "info"))
1676 port_infos_display(res->portnum);
1677 else if (!strcmp(res->what, "stats"))
1678 nic_stats_display(res->portnum);
1679 else if (!strcmp(res->what, "fdir"))
1680 fdir_get_infos(res->portnum);
1683 cmdline_parse_token_string_t cmd_showport_show =
1684 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
1686 cmdline_parse_token_string_t cmd_showport_port =
1687 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
1688 cmdline_parse_token_string_t cmd_showport_what =
1689 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
1691 cmdline_parse_token_num_t cmd_showport_portnum =
1692 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
1694 cmdline_parse_inst_t cmd_showport = {
1695 .f = cmd_showport_parsed,
1697 .help_str = "show|clear port info|stats|fdir X (X = port number)",
1699 (void *)&cmd_showport_show,
1700 (void *)&cmd_showport_port,
1701 (void *)&cmd_showport_what,
1702 (void *)&cmd_showport_portnum,
1707 /* *** READ PORT REGISTER *** */
1708 struct cmd_read_reg_result {
1709 cmdline_fixed_string_t read;
1710 cmdline_fixed_string_t reg;
1716 cmd_read_reg_parsed(void *parsed_result,
1717 __attribute__((unused)) struct cmdline *cl,
1718 __attribute__((unused)) void *data)
1720 struct cmd_read_reg_result *res = parsed_result;
1721 port_reg_display(res->port_id, res->reg_off);
1724 cmdline_parse_token_string_t cmd_read_reg_read =
1725 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
1726 cmdline_parse_token_string_t cmd_read_reg_reg =
1727 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
1728 cmdline_parse_token_num_t cmd_read_reg_port_id =
1729 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
1730 cmdline_parse_token_num_t cmd_read_reg_reg_off =
1731 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
1733 cmdline_parse_inst_t cmd_read_reg = {
1734 .f = cmd_read_reg_parsed,
1736 .help_str = "read reg port_id reg_off",
1738 (void *)&cmd_read_reg_read,
1739 (void *)&cmd_read_reg_reg,
1740 (void *)&cmd_read_reg_port_id,
1741 (void *)&cmd_read_reg_reg_off,
1746 /* *** READ PORT REGISTER BIT FIELD *** */
1747 struct cmd_read_reg_bit_field_result {
1748 cmdline_fixed_string_t read;
1749 cmdline_fixed_string_t regfield;
1757 cmd_read_reg_bit_field_parsed(void *parsed_result,
1758 __attribute__((unused)) struct cmdline *cl,
1759 __attribute__((unused)) void *data)
1761 struct cmd_read_reg_bit_field_result *res = parsed_result;
1762 port_reg_bit_field_display(res->port_id, res->reg_off,
1763 res->bit1_pos, res->bit2_pos);
1766 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
1767 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
1769 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
1770 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
1771 regfield, "regfield");
1772 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
1773 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
1775 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
1776 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
1778 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
1779 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
1781 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
1782 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
1785 cmdline_parse_inst_t cmd_read_reg_bit_field = {
1786 .f = cmd_read_reg_bit_field_parsed,
1788 .help_str = "read regfield port_id reg_off bit_x bit_y "
1789 "(read register bit field between bit_x and bit_y included)",
1791 (void *)&cmd_read_reg_bit_field_read,
1792 (void *)&cmd_read_reg_bit_field_regfield,
1793 (void *)&cmd_read_reg_bit_field_port_id,
1794 (void *)&cmd_read_reg_bit_field_reg_off,
1795 (void *)&cmd_read_reg_bit_field_bit1_pos,
1796 (void *)&cmd_read_reg_bit_field_bit2_pos,
1801 /* *** READ PORT REGISTER BIT *** */
1802 struct cmd_read_reg_bit_result {
1803 cmdline_fixed_string_t read;
1804 cmdline_fixed_string_t regbit;
1811 cmd_read_reg_bit_parsed(void *parsed_result,
1812 __attribute__((unused)) struct cmdline *cl,
1813 __attribute__((unused)) void *data)
1815 struct cmd_read_reg_bit_result *res = parsed_result;
1816 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
1819 cmdline_parse_token_string_t cmd_read_reg_bit_read =
1820 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
1821 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
1822 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
1824 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
1825 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
1826 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
1827 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
1828 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
1829 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
1831 cmdline_parse_inst_t cmd_read_reg_bit = {
1832 .f = cmd_read_reg_bit_parsed,
1834 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
1836 (void *)&cmd_read_reg_bit_read,
1837 (void *)&cmd_read_reg_bit_regbit,
1838 (void *)&cmd_read_reg_bit_port_id,
1839 (void *)&cmd_read_reg_bit_reg_off,
1840 (void *)&cmd_read_reg_bit_bit_pos,
1845 /* *** WRITE PORT REGISTER *** */
1846 struct cmd_write_reg_result {
1847 cmdline_fixed_string_t write;
1848 cmdline_fixed_string_t reg;
1855 cmd_write_reg_parsed(void *parsed_result,
1856 __attribute__((unused)) struct cmdline *cl,
1857 __attribute__((unused)) void *data)
1859 struct cmd_write_reg_result *res = parsed_result;
1860 port_reg_set(res->port_id, res->reg_off, res->value);
1863 cmdline_parse_token_string_t cmd_write_reg_write =
1864 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
1865 cmdline_parse_token_string_t cmd_write_reg_reg =
1866 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
1867 cmdline_parse_token_num_t cmd_write_reg_port_id =
1868 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
1869 cmdline_parse_token_num_t cmd_write_reg_reg_off =
1870 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
1871 cmdline_parse_token_num_t cmd_write_reg_value =
1872 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
1874 cmdline_parse_inst_t cmd_write_reg = {
1875 .f = cmd_write_reg_parsed,
1877 .help_str = "write reg port_id reg_off reg_value",
1879 (void *)&cmd_write_reg_write,
1880 (void *)&cmd_write_reg_reg,
1881 (void *)&cmd_write_reg_port_id,
1882 (void *)&cmd_write_reg_reg_off,
1883 (void *)&cmd_write_reg_value,
1888 /* *** WRITE PORT REGISTER BIT FIELD *** */
1889 struct cmd_write_reg_bit_field_result {
1890 cmdline_fixed_string_t write;
1891 cmdline_fixed_string_t regfield;
1900 cmd_write_reg_bit_field_parsed(void *parsed_result,
1901 __attribute__((unused)) struct cmdline *cl,
1902 __attribute__((unused)) void *data)
1904 struct cmd_write_reg_bit_field_result *res = parsed_result;
1905 port_reg_bit_field_set(res->port_id, res->reg_off,
1906 res->bit1_pos, res->bit2_pos, res->value);
1909 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
1910 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
1912 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
1913 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
1914 regfield, "regfield");
1915 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
1916 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
1918 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
1919 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
1921 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
1922 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
1924 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
1925 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
1927 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
1928 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
1931 cmdline_parse_inst_t cmd_write_reg_bit_field = {
1932 .f = cmd_write_reg_bit_field_parsed,
1934 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
1935 "(set register bit field between bit_x and bit_y included)",
1937 (void *)&cmd_write_reg_bit_field_write,
1938 (void *)&cmd_write_reg_bit_field_regfield,
1939 (void *)&cmd_write_reg_bit_field_port_id,
1940 (void *)&cmd_write_reg_bit_field_reg_off,
1941 (void *)&cmd_write_reg_bit_field_bit1_pos,
1942 (void *)&cmd_write_reg_bit_field_bit2_pos,
1943 (void *)&cmd_write_reg_bit_field_value,
1948 /* *** WRITE PORT REGISTER BIT *** */
1949 struct cmd_write_reg_bit_result {
1950 cmdline_fixed_string_t write;
1951 cmdline_fixed_string_t regbit;
1959 cmd_write_reg_bit_parsed(void *parsed_result,
1960 __attribute__((unused)) struct cmdline *cl,
1961 __attribute__((unused)) void *data)
1963 struct cmd_write_reg_bit_result *res = parsed_result;
1964 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
1967 cmdline_parse_token_string_t cmd_write_reg_bit_write =
1968 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
1970 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
1971 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
1973 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
1974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
1975 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
1976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
1977 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
1978 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
1979 cmdline_parse_token_num_t cmd_write_reg_bit_value =
1980 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
1982 cmdline_parse_inst_t cmd_write_reg_bit = {
1983 .f = cmd_write_reg_bit_parsed,
1985 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
1987 (void *)&cmd_write_reg_bit_write,
1988 (void *)&cmd_write_reg_bit_regbit,
1989 (void *)&cmd_write_reg_bit_port_id,
1990 (void *)&cmd_write_reg_bit_reg_off,
1991 (void *)&cmd_write_reg_bit_bit_pos,
1992 (void *)&cmd_write_reg_bit_value,
1997 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
1998 struct cmd_read_rxd_txd_result {
1999 cmdline_fixed_string_t read;
2000 cmdline_fixed_string_t rxd_txd;
2007 cmd_read_rxd_txd_parsed(void *parsed_result,
2008 __attribute__((unused)) struct cmdline *cl,
2009 __attribute__((unused)) void *data)
2011 struct cmd_read_rxd_txd_result *res = parsed_result;
2013 if (!strcmp(res->rxd_txd, "rxd"))
2014 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
2015 else if (!strcmp(res->rxd_txd, "txd"))
2016 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
2019 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
2020 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
2021 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
2022 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
2024 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
2025 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
2026 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
2027 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
2028 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
2029 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
2031 cmdline_parse_inst_t cmd_read_rxd_txd = {
2032 .f = cmd_read_rxd_txd_parsed,
2034 .help_str = "read rxd|txd port_id queue_id rxd_id",
2036 (void *)&cmd_read_rxd_txd_read,
2037 (void *)&cmd_read_rxd_txd_rxd_txd,
2038 (void *)&cmd_read_rxd_txd_port_id,
2039 (void *)&cmd_read_rxd_txd_queue_id,
2040 (void *)&cmd_read_rxd_txd_desc_id,
2046 struct cmd_quit_result {
2047 cmdline_fixed_string_t quit;
2050 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
2052 __attribute__((unused)) void *data)
2058 cmdline_parse_token_string_t cmd_quit_quit =
2059 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
2061 cmdline_parse_inst_t cmd_quit = {
2062 .f = cmd_quit_parsed,
2064 .help_str = "exit application",
2066 (void *)&cmd_quit_quit,
2071 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
2072 struct cmd_mac_addr_result {
2073 cmdline_fixed_string_t mac_addr_cmd;
2074 cmdline_fixed_string_t what;
2076 struct ether_addr address;
2079 static void cmd_mac_addr_parsed(void *parsed_result,
2080 __attribute__((unused)) struct cmdline *cl,
2081 __attribute__((unused)) void *data)
2083 struct cmd_mac_addr_result *res = parsed_result;
2086 if (strcmp(res->what, "add") == 0)
2087 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
2089 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
2091 /* check the return value and print it if is < 0 */
2093 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
2097 cmdline_parse_token_string_t cmd_mac_addr_cmd =
2098 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
2100 cmdline_parse_token_string_t cmd_mac_addr_what =
2101 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
2103 cmdline_parse_token_num_t cmd_mac_addr_portnum =
2104 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
2105 cmdline_parse_token_string_t cmd_mac_addr_addr =
2106 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
2108 cmdline_parse_inst_t cmd_mac_addr = {
2109 .f = cmd_mac_addr_parsed,
2111 .help_str = "mac_addr add|remove X <address>: "
2112 "add/remove MAC address on port X",
2114 (void *)&cmd_mac_addr_cmd,
2115 (void *)&cmd_mac_addr_what,
2116 (void *)&cmd_mac_addr_portnum,
2117 (void *)&cmd_mac_addr_addr,
2123 /* list of instructions */
2124 cmdline_parse_ctx_t main_ctx[] = {
2125 (cmdline_parse_inst_t *)&cmd_help,
2126 (cmdline_parse_inst_t *)&cmd_quit,
2127 (cmdline_parse_inst_t *)&cmd_showport,
2128 (cmdline_parse_inst_t *)&cmd_showportall,
2129 (cmdline_parse_inst_t *)&cmd_showcfg,
2130 (cmdline_parse_inst_t *)&cmd_start,
2131 (cmdline_parse_inst_t *)&cmd_start_tx_first,
2132 (cmdline_parse_inst_t *)&cmd_reset,
2133 (cmdline_parse_inst_t *)&cmd_set_numbers,
2134 (cmdline_parse_inst_t *)&cmd_set_txpkts,
2135 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
2136 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
2137 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
2138 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
2139 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
2140 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
2141 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
2142 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
2143 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
2144 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
2145 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
2146 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
2147 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
2148 (cmdline_parse_inst_t *)&cmd_read_reg,
2149 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
2150 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
2151 (cmdline_parse_inst_t *)&cmd_write_reg,
2152 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
2153 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
2154 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
2155 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
2156 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
2157 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
2158 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
2159 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
2160 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
2161 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
2162 (cmdline_parse_inst_t *)&cmd_stop,
2163 (cmdline_parse_inst_t *)&cmd_mac_addr,
2167 /* prompt function, called from main on MASTER lcore */
2173 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
2177 cmdline_interact(cl);
2178 cmdline_stdin_exit(cl);