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>
84 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
87 struct cmd_help_result {
88 cmdline_fixed_string_t help;
91 static void cmd_help_parsed(__attribute__((unused)) void *parsed_result,
93 __attribute__((unused)) void *data)
100 "This commandline can be used to configure forwarding\n"
103 "Display informations:\n"
104 "---------------------\n"
105 "- show port info|stats|fdir|stat_qmap X|all\n"
106 " Diplays information or stats or stats queue mapping on port X, or all\n"
107 "- clear port stats X|all\n"
108 " Clear stats for port X, or all\n"
109 "- show config rxtx|cores|fwd\n"
110 " Displays the given configuration\n"
111 "- read reg port_id reg_off\n"
112 " Displays value of a port register\n"
113 "- read regfield port_id reg_off bit_x bit_y\n"
114 " Displays value of a port register bit field\n"
115 "- read regbit port_id reg_off bit_x\n"
116 " Displays value of a port register bit\n"
117 "- read rxd port_id queue_id rxd_id\n"
118 " Displays a RX descriptor of a port RX queue\n"
119 "- read txd port_id queue_id txd_id\n"
120 " Displays a TX descriptor of a port TX queue\n"
125 "Modifications are taken into account once "
126 "forwarding is restarted.\n"
128 " Set forwarding to default configuration\n"
129 "- set nbport|nbcore|burst|verbose X\n"
130 " Set number of ports, number of cores, number "
131 "of packets per burst,\n or verbose level to X\n"
132 "- set txpkts x[,y]*\n"
133 " Set the length of each segment of TXONLY packets\n"
134 "- set coremask|portmask X\n"
135 " Set the hexadecimal mask of forwarding cores / "
137 "- set corelist|portlist x[,y]*\n"
138 " Set the list of forwarding cores / forwarding "
140 "- vlan set strip|filter|qinq on/off port_id\n"
141 " Set the VLAN strip, filter, QinQ(extended) on a port"
142 "- rx_vlan add/rm vlan_id|all port_id\n"
143 " Set the VLAN filter table, add/remove vlan_id, or all "
144 "identifiers, to/from the set of VLAN Identifiers\n"
145 "filtered by port_id\n"
146 "- rx_vlan set tpid value port_id\n"
147 " Set Outer VLAN TPID for Packet Filtering on a port \n"
148 "- tx_vlan set vlan_id port_id\n"
149 " Set hardware insertion of VLAN ID in packets sent on a port\n"
150 "- tx_vlan reset port_id\n"
151 " Disable hardware insertion of a VLAN header in "
152 "packets sent on port_id\n"
153 "- tx_checksum set mask port_id\n"
154 " Enable hardware insertion of checksum offload with "
155 "the 4-bit mask (0~0xf)\n in packets sent on port_id\n"
156 " Please check the NIC datasheet for HW limits\n"
157 " bit 0 - insert ip checksum offload if set \n"
158 " bit 1 - insert udp checksum offload if set \n"
159 " bit 2 - insert tcp checksum offload if set\n"
160 " bit 3 - insert sctp checksum offload if set\n"
161 #ifdef RTE_LIBRTE_IEEE1588
162 "- set fwd io|mac|rxonly|txonly|csum|ieee1588\n"
163 " Set IO, MAC, RXONLY, TXONLY, CSUM or IEEE1588 "
164 "packet forwarding mode\n"
166 "- set fwd io|mac|rxonly|txonly|csum\n"
167 " Set IO, MAC, RXONLY, CSUM or TXONLY packet "
170 "- mac_addr add|remove X <xx:xx:xx:xx:xx:xx>\n"
171 " Add/Remove the MAC address <xx:xx:xx:xx:xx:xx> on port X\n"
172 "- set promisc|allmulti [all|X] on|off\n"
173 " Set/unset promisc|allmulti mode on port X, or all\n"
174 "- set flow_ctrl rx on|off tx on|off high_water low_water "
175 "pause_time send_xon port_id \n"
176 " Set the link flow control parameter on the port \n"
177 "- write reg port_id reg_off value\n"
178 " Set value of a port register\n"
179 "- write regfield port_id reg_off bit_x bit_y value\n"
180 " Set bit field value of a port register\n"
181 "- write regbit port_id reg_off bit_x value\n"
182 " Set bit value of a port register\n"
183 "- set stat_qmap tx|rx port_id queue_id qmapping\n"
184 " Set statistics mapping (qmapping 0..15) for tx|rx queue_id on port_id\n"
185 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2 on port 0 to mapping 5\n"
188 "Control forwarding:\n"
189 "-------------------\n"
191 " Start packet forwarding with current config\n"
193 " Start packet forwarding with current config"
194 " after sending one burst\n of packets\n"
196 " Stop packet forwarding, and displays accumulated"
200 "Flow director mode:\n"
201 "-------------------\n"
202 "- add_signature_filter port_id ip|udp|tcp|sctp src\n"
203 " ip_src_address port_src dst ip_dst_address port_dst\n"
204 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
205 "- upd_signature_filter port_id ip|udp|tcp|sctp src \n"
206 " ip_src_address port_src dst ip_dst_address port_dst\n"
207 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
208 "- rm_signature_filter port_id ip|udp|tcp|sctp src\n"
209 " ip_src_address port_src dst ip_dst_address port_dst\n"
210 " flexbytes flexbytes_values vlan vlan_id\n"
211 "- add_perfect_filter port_id ip|udp|tcp|sctp src\n"
212 " ip_src_address port_src dst ip_dst_address port_dst\n"
213 " flexbytes flexbytes_values vlan vlan_id queue \n"
214 " queue_id soft soft_id\n"
215 "- upd_perfect_filter port_id ip|udp|tcp|sctp src\n"
216 " ip_src_address port_src dst ip_dst_address port_dst\n"
217 " flexbytes flexbytes_values vlan vlan_id queue queue_id\n"
218 "- rm_perfect_filter port_id ip|udp|tcp|sctp src\n"
219 " ip_src_address port_src dst ip_dst_address port_dst\n"
220 " flexbytes flexbytes_values vlan vlan_id soft soft_id\n"
221 "- set_masks_filter port_id only_ip_flow 0|1 src_mask\n"
222 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
223 " port_dst_mask flexbytes 0|1 vlan_id 0|1 vlan_prio 0|1\n"
224 "- set_ipv6_masks_filter port_id only_ip_flow 0|1 src_mask\n"
225 " ip_src_mask port_src_mask dst_mask ip_dst_mask\n"
226 " port_dst_mask flexbytes 0|1 vlan_id 0|1\n"
227 " vlan_prio 0|1 compare_dst 0|1\n"
232 "- port start|stop|close all|X\n"
233 " start/stop/close all ports or port X\n"
234 "- port config all|X speed 10|100|1000|10000|auto "
235 "duplex half|full|auto\n"
236 " set speed for all ports or port X\n"
237 "- port config all rxq|txq|rxd|txd value\n"
238 " set number for rxq/txq/rxd/txd\n"
239 "- port config all max-pkt-len value\n"
240 " set the max packet lenght\n"
241 "- port config all crc-strip|rx-cksum|hw-vlan|drop-en on|off\n"
242 " set crc-strip/rx-checksum/hardware-vlan/drop_en on or off"
244 "- port config all rss ip|udp|none\n"
246 "- port config port-id dcb vt on|off nb-tcs pfc on|off\n"
248 "- port config all burst value\n"
249 " set the number of packet per burst\n"
250 "- port config all txpt|txht|txwt|rxpt|rxht|rxwt value\n"
251 " set ring prefetch/host/writeback threshold for "
253 "- port config all txfreet|txrst|rxfreet value\n"
254 " set free threshold for rx/tx, or set tx rs bit "
261 " Quit to prompt in linux, and reboot on baremetal\n"
265 cmdline_parse_token_string_t cmd_help_help =
266 TOKEN_STRING_INITIALIZER(struct cmd_help_result, help, "help");
268 cmdline_parse_inst_t cmd_help = {
269 .f = cmd_help_parsed,
271 .help_str = "show help",
273 (void *)&cmd_help_help,
278 /* *** start/stop/close all ports *** */
279 struct cmd_operate_port_result {
280 cmdline_fixed_string_t keyword;
281 cmdline_fixed_string_t name;
282 cmdline_fixed_string_t value;
285 static void cmd_operate_port_parsed(void *parsed_result,
286 __attribute__((unused)) struct cmdline *cl,
287 __attribute__((unused)) void *data)
289 struct cmd_operate_port_result *res = parsed_result;
291 if (!strcmp(res->name, "start"))
292 start_port(RTE_PORT_ALL);
293 else if (!strcmp(res->name, "stop"))
294 stop_port(RTE_PORT_ALL);
295 else if (!strcmp(res->name, "close"))
296 close_port(RTE_PORT_ALL);
298 printf("Unknown parameter\n");
301 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
302 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
304 cmdline_parse_token_string_t cmd_operate_port_all_port =
305 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
307 cmdline_parse_token_string_t cmd_operate_port_all_all =
308 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
310 cmdline_parse_inst_t cmd_operate_port = {
311 .f = cmd_operate_port_parsed,
313 .help_str = "port start|stop|close all: start/stop/close all ports",
315 (void *)&cmd_operate_port_all_cmd,
316 (void *)&cmd_operate_port_all_port,
317 (void *)&cmd_operate_port_all_all,
322 /* *** start/stop/close specific port *** */
323 struct cmd_operate_specific_port_result {
324 cmdline_fixed_string_t keyword;
325 cmdline_fixed_string_t name;
329 static void cmd_operate_specific_port_parsed(void *parsed_result,
330 __attribute__((unused)) struct cmdline *cl,
331 __attribute__((unused)) void *data)
333 struct cmd_operate_specific_port_result *res = parsed_result;
335 if (!strcmp(res->name, "start"))
336 start_port(res->value);
337 else if (!strcmp(res->name, "stop"))
338 stop_port(res->value);
339 else if (!strcmp(res->name, "close"))
340 close_port(res->value);
342 printf("Unknown parameter\n");
345 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
346 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
348 cmdline_parse_token_string_t cmd_operate_specific_port_port =
349 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
350 name, "start#stop#close");
351 cmdline_parse_token_num_t cmd_operate_specific_port_id =
352 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
355 cmdline_parse_inst_t cmd_operate_specific_port = {
356 .f = cmd_operate_specific_port_parsed,
358 .help_str = "port start|stop|close X: start/stop/close port X",
360 (void *)&cmd_operate_specific_port_cmd,
361 (void *)&cmd_operate_specific_port_port,
362 (void *)&cmd_operate_specific_port_id,
367 /* *** configure speed for all ports *** */
368 struct cmd_config_speed_all {
369 cmdline_fixed_string_t port;
370 cmdline_fixed_string_t keyword;
371 cmdline_fixed_string_t all;
372 cmdline_fixed_string_t item1;
373 cmdline_fixed_string_t item2;
374 cmdline_fixed_string_t value1;
375 cmdline_fixed_string_t value2;
379 cmd_config_speed_all_parsed(void *parsed_result,
380 __attribute__((unused)) struct cmdline *cl,
381 __attribute__((unused)) void *data)
383 struct cmd_config_speed_all *res = parsed_result;
384 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
385 uint16_t link_duplex = 0;
388 if (!all_ports_stopped()) {
389 printf("Please stop all ports first\n");
393 if (!strcmp(res->value1, "10"))
394 link_speed = ETH_LINK_SPEED_10;
395 else if (!strcmp(res->value1, "100"))
396 link_speed = ETH_LINK_SPEED_100;
397 else if (!strcmp(res->value1, "1000"))
398 link_speed = ETH_LINK_SPEED_1000;
399 else if (!strcmp(res->value1, "10000"))
400 link_speed = ETH_LINK_SPEED_10000;
401 else if (!strcmp(res->value1, "auto"))
402 link_speed = ETH_LINK_SPEED_AUTONEG;
404 printf("Unknown parameter\n");
408 if (!strcmp(res->value2, "half"))
409 link_duplex = ETH_LINK_HALF_DUPLEX;
410 else if (!strcmp(res->value2, "full"))
411 link_duplex = ETH_LINK_FULL_DUPLEX;
412 else if (!strcmp(res->value2, "auto"))
413 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
415 printf("Unknown parameter\n");
419 for (pid = 0; pid < nb_ports; pid++) {
420 ports[pid].dev_conf.link_speed = link_speed;
421 ports[pid].dev_conf.link_duplex = link_duplex;
424 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
427 cmdline_parse_token_string_t cmd_config_speed_all_port =
428 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
429 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
430 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
432 cmdline_parse_token_string_t cmd_config_speed_all_all =
433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
434 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
435 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
436 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
437 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
438 "10#100#1000#10000#auto");
439 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
440 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
441 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
442 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
445 cmdline_parse_inst_t cmd_config_speed_all = {
446 .f = cmd_config_speed_all_parsed,
448 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
451 (void *)&cmd_config_speed_all_port,
452 (void *)&cmd_config_speed_all_keyword,
453 (void *)&cmd_config_speed_all_all,
454 (void *)&cmd_config_speed_all_item1,
455 (void *)&cmd_config_speed_all_value1,
456 (void *)&cmd_config_speed_all_item2,
457 (void *)&cmd_config_speed_all_value2,
462 /* *** configure speed for specific port *** */
463 struct cmd_config_speed_specific {
464 cmdline_fixed_string_t port;
465 cmdline_fixed_string_t keyword;
467 cmdline_fixed_string_t item1;
468 cmdline_fixed_string_t item2;
469 cmdline_fixed_string_t value1;
470 cmdline_fixed_string_t value2;
474 cmd_config_speed_specific_parsed(void *parsed_result,
475 __attribute__((unused)) struct cmdline *cl,
476 __attribute__((unused)) void *data)
478 struct cmd_config_speed_specific *res = parsed_result;
479 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
480 uint16_t link_duplex = 0;
482 if (!all_ports_stopped()) {
483 printf("Please stop all ports first\n");
487 if (res->id >= nb_ports) {
488 printf("Port id %d must be less than %d\n", res->id, nb_ports);
492 if (!strcmp(res->value1, "10"))
493 link_speed = ETH_LINK_SPEED_10;
494 else if (!strcmp(res->value1, "100"))
495 link_speed = ETH_LINK_SPEED_100;
496 else if (!strcmp(res->value1, "1000"))
497 link_speed = ETH_LINK_SPEED_1000;
498 else if (!strcmp(res->value1, "10000"))
499 link_speed = ETH_LINK_SPEED_10000;
500 else if (!strcmp(res->value1, "auto"))
501 link_speed = ETH_LINK_SPEED_AUTONEG;
503 printf("Unknown parameter\n");
507 if (!strcmp(res->value2, "half"))
508 link_duplex = ETH_LINK_HALF_DUPLEX;
509 else if (!strcmp(res->value2, "full"))
510 link_duplex = ETH_LINK_FULL_DUPLEX;
511 else if (!strcmp(res->value2, "auto"))
512 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
514 printf("Unknown parameter\n");
518 ports[res->id].dev_conf.link_speed = link_speed;
519 ports[res->id].dev_conf.link_duplex = link_duplex;
521 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
525 cmdline_parse_token_string_t cmd_config_speed_specific_port =
526 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
528 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
529 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
531 cmdline_parse_token_num_t cmd_config_speed_specific_id =
532 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
533 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
534 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
536 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
537 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
538 "10#100#1000#10000#auto");
539 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
540 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
542 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
543 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
546 cmdline_parse_inst_t cmd_config_speed_specific = {
547 .f = cmd_config_speed_specific_parsed,
549 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
552 (void *)&cmd_config_speed_specific_port,
553 (void *)&cmd_config_speed_specific_keyword,
554 (void *)&cmd_config_speed_specific_id,
555 (void *)&cmd_config_speed_specific_item1,
556 (void *)&cmd_config_speed_specific_value1,
557 (void *)&cmd_config_speed_specific_item2,
558 (void *)&cmd_config_speed_specific_value2,
563 /* *** configure txq/rxq, txd/rxd *** */
564 struct cmd_config_rx_tx {
565 cmdline_fixed_string_t port;
566 cmdline_fixed_string_t keyword;
567 cmdline_fixed_string_t all;
568 cmdline_fixed_string_t name;
573 cmd_config_rx_tx_parsed(void *parsed_result,
574 __attribute__((unused)) struct cmdline *cl,
575 __attribute__((unused)) void *data)
577 struct cmd_config_rx_tx *res = parsed_result;
579 if (!all_ports_stopped()) {
580 printf("Please stop all ports first\n");
584 if (!strcmp(res->name, "rxq")) {
585 if (res->value <= 0) {
586 printf("rxq %d invalid - must be > 0\n", res->value);
591 else if (!strcmp(res->name, "txq")) {
592 if (res->value <= 0) {
593 printf("txq %d invalid - must be > 0\n", res->value);
598 else if (!strcmp(res->name, "rxd")) {
599 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
600 printf("rxd %d invalid - must be > 0 && <= %d\n",
601 res->value, RTE_TEST_RX_DESC_MAX);
605 } else if (!strcmp(res->name, "txd")) {
606 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
607 printf("txd %d invalid - must be > 0 && <= %d\n",
608 res->value, RTE_TEST_TX_DESC_MAX);
613 printf("Unknown parameter\n");
619 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
622 cmdline_parse_token_string_t cmd_config_rx_tx_port =
623 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
624 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
625 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
626 cmdline_parse_token_string_t cmd_config_rx_tx_all =
627 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
628 cmdline_parse_token_string_t cmd_config_rx_tx_name =
629 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
631 cmdline_parse_token_num_t cmd_config_rx_tx_value =
632 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
634 cmdline_parse_inst_t cmd_config_rx_tx = {
635 .f = cmd_config_rx_tx_parsed,
637 .help_str = "port config all rxq|txq|rxd|txd value",
639 (void *)&cmd_config_rx_tx_port,
640 (void *)&cmd_config_rx_tx_keyword,
641 (void *)&cmd_config_rx_tx_all,
642 (void *)&cmd_config_rx_tx_name,
643 (void *)&cmd_config_rx_tx_value,
648 /* *** config max packet length *** */
649 struct cmd_config_max_pkt_len_result {
650 cmdline_fixed_string_t port;
651 cmdline_fixed_string_t keyword;
652 cmdline_fixed_string_t all;
653 cmdline_fixed_string_t name;
658 cmd_config_max_pkt_len_parsed(void *parsed_result,
659 __attribute__((unused)) struct cmdline *cl,
660 __attribute__((unused)) void *data)
662 struct cmd_config_max_pkt_len_result *res = parsed_result;
664 if (!all_ports_stopped()) {
665 printf("Please stop all ports first\n");
669 if (!strcmp(res->name, "max-pkt-len")) {
670 if (res->value < ETHER_MIN_LEN) {
671 printf("max-pkt-len can not be less than %d\n",
675 if (res->value == rx_mode.max_rx_pkt_len)
678 rx_mode.max_rx_pkt_len = res->value;
679 if (res->value > ETHER_MAX_LEN)
680 rx_mode.jumbo_frame = 1;
682 rx_mode.jumbo_frame = 0;
684 printf("Unknown parameter\n");
690 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
693 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
694 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
696 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
697 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
699 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
700 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
702 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
703 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
705 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
706 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
709 cmdline_parse_inst_t cmd_config_max_pkt_len = {
710 .f = cmd_config_max_pkt_len_parsed,
712 .help_str = "port config all max-pkt-len value",
714 (void *)&cmd_config_max_pkt_len_port,
715 (void *)&cmd_config_max_pkt_len_keyword,
716 (void *)&cmd_config_max_pkt_len_all,
717 (void *)&cmd_config_max_pkt_len_name,
718 (void *)&cmd_config_max_pkt_len_value,
723 /* *** configure rx mode *** */
724 struct cmd_config_rx_mode_flag {
725 cmdline_fixed_string_t port;
726 cmdline_fixed_string_t keyword;
727 cmdline_fixed_string_t all;
728 cmdline_fixed_string_t name;
729 cmdline_fixed_string_t value;
733 cmd_config_rx_mode_flag_parsed(void *parsed_result,
734 __attribute__((unused)) struct cmdline *cl,
735 __attribute__((unused)) void *data)
737 struct cmd_config_rx_mode_flag *res = parsed_result;
739 if (!all_ports_stopped()) {
740 printf("Please stop all ports first\n");
744 if (!strcmp(res->name, "crc-strip")) {
745 if (!strcmp(res->value, "on"))
746 rx_mode.hw_strip_crc = 1;
747 else if (!strcmp(res->value, "off"))
748 rx_mode.hw_strip_crc = 0;
750 printf("Unknown parameter\n");
753 } else if (!strcmp(res->name, "rx-cksum")) {
754 if (!strcmp(res->value, "on"))
755 rx_mode.hw_ip_checksum = 1;
756 else if (!strcmp(res->value, "off"))
757 rx_mode.hw_ip_checksum = 0;
759 printf("Unknown parameter\n");
762 } else if (!strcmp(res->name, "hw-vlan")) {
763 if (!strcmp(res->value, "on")) {
764 rx_mode.hw_vlan_filter = 1;
765 rx_mode.hw_vlan_strip = 1;
767 else if (!strcmp(res->value, "off")) {
768 rx_mode.hw_vlan_filter = 0;
769 rx_mode.hw_vlan_strip = 0;
772 printf("Unknown parameter\n");
775 } else if (!strcmp(res->name, "drop-en")) {
776 if (!strcmp(res->value, "on"))
778 else if (!strcmp(res->value, "off"))
781 printf("Unknown parameter\n");
785 printf("Unknown parameter\n");
791 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
794 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
795 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
796 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
797 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
799 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
800 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
801 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
802 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
803 "crc-strip#rx-cksum#hw-vlan");
804 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
805 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
808 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
809 .f = cmd_config_rx_mode_flag_parsed,
811 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
813 (void *)&cmd_config_rx_mode_flag_port,
814 (void *)&cmd_config_rx_mode_flag_keyword,
815 (void *)&cmd_config_rx_mode_flag_all,
816 (void *)&cmd_config_rx_mode_flag_name,
817 (void *)&cmd_config_rx_mode_flag_value,
822 /* *** configure rss *** */
823 struct cmd_config_rss {
824 cmdline_fixed_string_t port;
825 cmdline_fixed_string_t keyword;
826 cmdline_fixed_string_t all;
827 cmdline_fixed_string_t name;
828 cmdline_fixed_string_t value;
832 cmd_config_rss_parsed(void *parsed_result,
833 __attribute__((unused)) struct cmdline *cl,
834 __attribute__((unused)) void *data)
836 struct cmd_config_rss *res = parsed_result;
838 if (!all_ports_stopped()) {
839 printf("Please stop all ports first\n");
843 if (!strcmp(res->value, "ip"))
844 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
845 else if (!strcmp(res->value, "udp"))
846 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
847 else if (!strcmp(res->value, "none"))
850 printf("Unknown parameter\n");
856 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
859 cmdline_parse_token_string_t cmd_config_rss_port =
860 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
861 cmdline_parse_token_string_t cmd_config_rss_keyword =
862 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
863 cmdline_parse_token_string_t cmd_config_rss_all =
864 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
865 cmdline_parse_token_string_t cmd_config_rss_name =
866 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
867 cmdline_parse_token_string_t cmd_config_rss_value =
868 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
870 cmdline_parse_inst_t cmd_config_rss = {
871 .f = cmd_config_rss_parsed,
873 .help_str = "port config all rss ip|udp|none",
875 (void *)&cmd_config_rss_port,
876 (void *)&cmd_config_rss_keyword,
877 (void *)&cmd_config_rss_all,
878 (void *)&cmd_config_rss_name,
879 (void *)&cmd_config_rss_value,
884 /* *** Configure DCB *** */
885 struct cmd_config_dcb {
886 cmdline_fixed_string_t port;
887 cmdline_fixed_string_t config;
889 cmdline_fixed_string_t dcb;
890 cmdline_fixed_string_t vt;
891 cmdline_fixed_string_t vt_en;
893 cmdline_fixed_string_t pfc;
894 cmdline_fixed_string_t pfc_en;
898 cmd_config_dcb_parsed(void *parsed_result,
899 __attribute__((unused)) struct cmdline *cl,
900 __attribute__((unused)) void *data)
902 struct cmd_config_dcb *res = parsed_result;
903 struct dcb_config dcb_conf;
904 portid_t port_id = res->port_id;
905 struct rte_port *port;
907 port = &ports[port_id];
908 /** Check if the port is not started **/
909 if (port->port_status != RTE_PORT_STOPPED) {
910 printf("Please stop port %d first\n",port_id);
914 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
915 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
916 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
921 if (!strncmp(res->vt_en, "on",2))
922 dcb_conf.dcb_mode = DCB_VT_ENABLED;
924 dcb_conf.dcb_mode = DCB_ENABLED;
926 if (!strncmp(res->pfc_en, "on",2)) {
932 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
933 printf("Cannot initialize network ports\n");
937 cmd_reconfig_device_queue(port_id, 1, 1);
940 cmdline_parse_token_string_t cmd_config_dcb_port =
941 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
942 cmdline_parse_token_string_t cmd_config_dcb_config =
943 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
944 cmdline_parse_token_num_t cmd_config_dcb_port_id =
945 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
946 cmdline_parse_token_string_t cmd_config_dcb_dcb =
947 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
948 cmdline_parse_token_string_t cmd_config_dcb_vt =
949 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
950 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
951 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
952 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
953 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
954 cmdline_parse_token_string_t cmd_config_dcb_pfc=
955 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
956 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
957 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
959 cmdline_parse_inst_t cmd_config_dcb = {
960 .f = cmd_config_dcb_parsed,
962 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
964 (void *)&cmd_config_dcb_port,
965 (void *)&cmd_config_dcb_config,
966 (void *)&cmd_config_dcb_port_id,
967 (void *)&cmd_config_dcb_dcb,
968 (void *)&cmd_config_dcb_vt,
969 (void *)&cmd_config_dcb_vt_en,
970 (void *)&cmd_config_dcb_num_tcs,
971 (void *)&cmd_config_dcb_pfc,
972 (void *)&cmd_config_dcb_pfc_en,
977 /* *** configure number of packets per burst *** */
978 struct cmd_config_burst {
979 cmdline_fixed_string_t port;
980 cmdline_fixed_string_t keyword;
981 cmdline_fixed_string_t all;
982 cmdline_fixed_string_t name;
987 cmd_config_burst_parsed(void *parsed_result,
988 __attribute__((unused)) struct cmdline *cl,
989 __attribute__((unused)) void *data)
991 struct cmd_config_burst *res = parsed_result;
993 if (!all_ports_stopped()) {
994 printf("Please stop all ports first\n");
998 if (!strcmp(res->name, "burst")) {
999 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1000 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1003 nb_pkt_per_burst = res->value;
1005 printf("Unknown parameter\n");
1011 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1014 cmdline_parse_token_string_t cmd_config_burst_port =
1015 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1016 cmdline_parse_token_string_t cmd_config_burst_keyword =
1017 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1018 cmdline_parse_token_string_t cmd_config_burst_all =
1019 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1020 cmdline_parse_token_string_t cmd_config_burst_name =
1021 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1022 cmdline_parse_token_num_t cmd_config_burst_value =
1023 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1025 cmdline_parse_inst_t cmd_config_burst = {
1026 .f = cmd_config_burst_parsed,
1028 .help_str = "port config all burst value",
1030 (void *)&cmd_config_burst_port,
1031 (void *)&cmd_config_burst_keyword,
1032 (void *)&cmd_config_burst_all,
1033 (void *)&cmd_config_burst_name,
1034 (void *)&cmd_config_burst_value,
1039 /* *** configure rx/tx queues *** */
1040 struct cmd_config_thresh {
1041 cmdline_fixed_string_t port;
1042 cmdline_fixed_string_t keyword;
1043 cmdline_fixed_string_t all;
1044 cmdline_fixed_string_t name;
1049 cmd_config_thresh_parsed(void *parsed_result,
1050 __attribute__((unused)) struct cmdline *cl,
1051 __attribute__((unused)) void *data)
1053 struct cmd_config_thresh *res = parsed_result;
1055 if (!all_ports_stopped()) {
1056 printf("Please stop all ports first\n");
1060 if (!strcmp(res->name, "txpt"))
1061 tx_thresh.pthresh = res->value;
1062 else if(!strcmp(res->name, "txht"))
1063 tx_thresh.hthresh = res->value;
1064 else if(!strcmp(res->name, "txwt"))
1065 tx_thresh.wthresh = res->value;
1066 else if(!strcmp(res->name, "rxpt"))
1067 rx_thresh.pthresh = res->value;
1068 else if(!strcmp(res->name, "rxht"))
1069 rx_thresh.hthresh = res->value;
1070 else if(!strcmp(res->name, "rxwt"))
1071 rx_thresh.wthresh = res->value;
1073 printf("Unknown parameter\n");
1079 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1082 cmdline_parse_token_string_t cmd_config_thresh_port =
1083 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1084 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1085 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1086 cmdline_parse_token_string_t cmd_config_thresh_all =
1087 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1088 cmdline_parse_token_string_t cmd_config_thresh_name =
1089 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1090 "txpt#txht#txwt#rxpt#rxht#rxwt");
1091 cmdline_parse_token_num_t cmd_config_thresh_value =
1092 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1094 cmdline_parse_inst_t cmd_config_thresh = {
1095 .f = cmd_config_thresh_parsed,
1097 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1099 (void *)&cmd_config_thresh_port,
1100 (void *)&cmd_config_thresh_keyword,
1101 (void *)&cmd_config_thresh_all,
1102 (void *)&cmd_config_thresh_name,
1103 (void *)&cmd_config_thresh_value,
1108 /* *** configure free/rs threshold *** */
1109 struct cmd_config_threshold {
1110 cmdline_fixed_string_t port;
1111 cmdline_fixed_string_t keyword;
1112 cmdline_fixed_string_t all;
1113 cmdline_fixed_string_t name;
1118 cmd_config_threshold_parsed(void *parsed_result,
1119 __attribute__((unused)) struct cmdline *cl,
1120 __attribute__((unused)) void *data)
1122 struct cmd_config_threshold *res = parsed_result;
1124 if (!all_ports_stopped()) {
1125 printf("Please stop all ports first\n");
1129 if (!strcmp(res->name, "txfreet"))
1130 tx_free_thresh = res->value;
1131 else if (!strcmp(res->name, "txrst"))
1132 tx_rs_thresh = res->value;
1133 else if (!strcmp(res->name, "rxfreet"))
1134 rx_free_thresh = res->value;
1136 printf("Unknown parameter\n");
1142 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1145 cmdline_parse_token_string_t cmd_config_threshold_port =
1146 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1147 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1148 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1150 cmdline_parse_token_string_t cmd_config_threshold_all =
1151 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1152 cmdline_parse_token_string_t cmd_config_threshold_name =
1153 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1154 "txfreet#txrst#rxfreet");
1155 cmdline_parse_token_num_t cmd_config_threshold_value =
1156 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1158 cmdline_parse_inst_t cmd_config_threshold = {
1159 .f = cmd_config_threshold_parsed,
1161 .help_str = "port config all txfreet|txrst|rxfreet value",
1163 (void *)&cmd_config_threshold_port,
1164 (void *)&cmd_config_threshold_keyword,
1165 (void *)&cmd_config_threshold_all,
1166 (void *)&cmd_config_threshold_name,
1167 (void *)&cmd_config_threshold_value,
1173 struct cmd_stop_result {
1174 cmdline_fixed_string_t stop;
1177 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1178 __attribute__((unused)) struct cmdline *cl,
1179 __attribute__((unused)) void *data)
1181 stop_packet_forwarding();
1184 cmdline_parse_token_string_t cmd_stop_stop =
1185 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1187 cmdline_parse_inst_t cmd_stop = {
1188 .f = cmd_stop_parsed,
1190 .help_str = "stop - stop packet forwarding",
1192 (void *)&cmd_stop_stop,
1197 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1200 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1201 unsigned int *parsed_items, int check_unique_values)
1203 unsigned int nb_item;
1211 * First parse all items in the list and store their value.
1216 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1218 if ((c >= '0') && (c <= '9')) {
1219 value = (unsigned int) (value * 10 + (c - '0'));
1224 printf("character %c is not a decimal digit\n", c);
1228 printf("No valid value before comma\n");
1231 if (nb_item < max_items) {
1232 parsed_items[nb_item] = value;
1238 if (nb_item >= max_items) {
1239 printf("Number of %s = %u > %u (maximum items)\n",
1240 item_name, nb_item + 1, max_items);
1243 parsed_items[nb_item++] = value;
1244 if (! check_unique_values)
1248 * Then, check that all values in the list are differents.
1249 * No optimization here...
1251 for (i = 0; i < nb_item; i++) {
1252 for (j = i + 1; j < nb_item; j++) {
1253 if (parsed_items[j] == parsed_items[i]) {
1254 printf("duplicated %s %u at index %u and %u\n",
1255 item_name, parsed_items[i], i, j);
1263 struct cmd_set_list_result {
1264 cmdline_fixed_string_t cmd_keyword;
1265 cmdline_fixed_string_t list_name;
1266 cmdline_fixed_string_t list_of_items;
1269 static void cmd_set_list_parsed(void *parsed_result,
1270 __attribute__((unused)) struct cmdline *cl,
1271 __attribute__((unused)) void *data)
1273 struct cmd_set_list_result *res;
1275 unsigned int lcorelist[RTE_MAX_LCORE];
1276 unsigned int portlist[RTE_MAX_ETHPORTS];
1278 unsigned int nb_item;
1280 res = parsed_result;
1281 if (!strcmp(res->list_name, "corelist")) {
1282 nb_item = parse_item_list(res->list_of_items, "core",
1284 parsed_items.lcorelist, 1);
1286 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1289 if (!strcmp(res->list_name, "portlist")) {
1290 nb_item = parse_item_list(res->list_of_items, "port",
1292 parsed_items.portlist, 1);
1294 set_fwd_ports_list(parsed_items.portlist, nb_item);
1298 cmdline_parse_token_string_t cmd_set_list_keyword =
1299 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1301 cmdline_parse_token_string_t cmd_set_list_name =
1302 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1303 "corelist#portlist");
1304 cmdline_parse_token_string_t cmd_set_list_of_items =
1305 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1308 cmdline_parse_inst_t cmd_set_fwd_list = {
1309 .f = cmd_set_list_parsed,
1311 .help_str = "set corelist|portlist x[,y]*",
1313 (void *)&cmd_set_list_keyword,
1314 (void *)&cmd_set_list_name,
1315 (void *)&cmd_set_list_of_items,
1320 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1322 struct cmd_setmask_result {
1323 cmdline_fixed_string_t set;
1324 cmdline_fixed_string_t mask;
1328 static void cmd_set_mask_parsed(void *parsed_result,
1329 __attribute__((unused)) struct cmdline *cl,
1330 __attribute__((unused)) void *data)
1332 struct cmd_setmask_result *res = parsed_result;
1334 if (!strcmp(res->mask, "coremask"))
1335 set_fwd_lcores_mask(res->hexavalue);
1336 else if (!strcmp(res->mask, "portmask"))
1337 set_fwd_ports_mask(res->hexavalue);
1340 cmdline_parse_token_string_t cmd_setmask_set =
1341 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1342 cmdline_parse_token_string_t cmd_setmask_mask =
1343 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1344 "coremask#portmask");
1345 cmdline_parse_token_num_t cmd_setmask_value =
1346 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1348 cmdline_parse_inst_t cmd_set_fwd_mask = {
1349 .f = cmd_set_mask_parsed,
1351 .help_str = "set coremask|portmask hexadecimal value",
1353 (void *)&cmd_setmask_set,
1354 (void *)&cmd_setmask_mask,
1355 (void *)&cmd_setmask_value,
1361 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1363 struct cmd_set_result {
1364 cmdline_fixed_string_t set;
1365 cmdline_fixed_string_t what;
1369 static void cmd_set_parsed(void *parsed_result,
1370 __attribute__((unused)) struct cmdline *cl,
1371 __attribute__((unused)) void *data)
1373 struct cmd_set_result *res = parsed_result;
1374 if (!strcmp(res->what, "nbport"))
1375 set_fwd_ports_number(res->value);
1376 else if (!strcmp(res->what, "nbcore"))
1377 set_fwd_lcores_number(res->value);
1378 else if (!strcmp(res->what, "burst"))
1379 set_nb_pkt_per_burst(res->value);
1380 else if (!strcmp(res->what, "verbose"))
1381 set_verbose_level(res->value);
1384 cmdline_parse_token_string_t cmd_set_set =
1385 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1386 cmdline_parse_token_string_t cmd_set_what =
1387 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1388 "nbport#nbcore#burst#verbose");
1389 cmdline_parse_token_num_t cmd_set_value =
1390 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1392 cmdline_parse_inst_t cmd_set_numbers = {
1393 .f = cmd_set_parsed,
1395 .help_str = "set nbport|nbcore|burst|verbose value",
1397 (void *)&cmd_set_set,
1398 (void *)&cmd_set_what,
1399 (void *)&cmd_set_value,
1404 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1406 struct cmd_set_txpkts_result {
1407 cmdline_fixed_string_t cmd_keyword;
1408 cmdline_fixed_string_t txpkts;
1409 cmdline_fixed_string_t seg_lengths;
1413 cmd_set_txpkts_parsed(void *parsed_result,
1414 __attribute__((unused)) struct cmdline *cl,
1415 __attribute__((unused)) void *data)
1417 struct cmd_set_txpkts_result *res;
1418 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1419 unsigned int nb_segs;
1421 res = parsed_result;
1422 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1423 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1425 set_tx_pkt_segments(seg_lengths, nb_segs);
1428 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1429 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1430 cmd_keyword, "set");
1431 cmdline_parse_token_string_t cmd_set_txpkts_name =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1434 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1435 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1438 cmdline_parse_inst_t cmd_set_txpkts = {
1439 .f = cmd_set_txpkts_parsed,
1441 .help_str = "set txpkts x[,y]*",
1443 (void *)&cmd_set_txpkts_keyword,
1444 (void *)&cmd_set_txpkts_name,
1445 (void *)&cmd_set_txpkts_lengths,
1450 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1451 struct cmd_rx_vlan_filter_all_result {
1452 cmdline_fixed_string_t rx_vlan;
1453 cmdline_fixed_string_t what;
1454 cmdline_fixed_string_t all;
1459 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1460 __attribute__((unused)) struct cmdline *cl,
1461 __attribute__((unused)) void *data)
1463 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1465 if (!strcmp(res->what, "add"))
1466 rx_vlan_all_filter_set(res->port_id, 1);
1468 rx_vlan_all_filter_set(res->port_id, 0);
1471 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1472 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1473 rx_vlan, "rx_vlan");
1474 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1475 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1477 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1478 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1480 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1481 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1484 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1485 .f = cmd_rx_vlan_filter_all_parsed,
1487 .help_str = "add/remove all identifiers to/from the set of VLAN "
1488 "Identifiers filtered by a port",
1490 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1491 (void *)&cmd_rx_vlan_filter_all_what,
1492 (void *)&cmd_rx_vlan_filter_all_all,
1493 (void *)&cmd_rx_vlan_filter_all_portid,
1498 /* *** VLAN OFFLOAD SET ON A PORT *** */
1499 struct cmd_vlan_offload_result {
1500 cmdline_fixed_string_t vlan;
1501 cmdline_fixed_string_t set;
1502 cmdline_fixed_string_t what;
1503 cmdline_fixed_string_t on;
1504 cmdline_fixed_string_t port_id;
1508 cmd_vlan_offload_parsed(void *parsed_result,
1509 __attribute__((unused)) struct cmdline *cl,
1510 __attribute__((unused)) void *data)
1513 struct cmd_vlan_offload_result *res = parsed_result;
1516 portid_t port_id = 0;
1520 len = strnlen(str, STR_TOKEN_SIZE);
1522 /* Get port_id first */
1530 tmp = strtoul(str, NULL, 0);
1531 /* If port_id greater that what portid_t can represent, return */
1534 port_id = (portid_t)tmp;
1536 if (!strcmp(res->on, "on"))
1541 if (!strcmp(res->what, "strip"))
1542 rx_vlan_strip_set(port_id, on);
1543 else if(!strcmp(res->what, "stripq")){
1544 uint16_t queue_id = 0;
1546 /* No queue_id, return */
1549 tmp = strtoul(str + i + 1, NULL, 0);
1550 /* If queue_id greater that what 16-bits can represent, return */
1554 queue_id = (uint16_t)tmp;
1555 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1557 else if (!strcmp(res->what, "filter"))
1558 rx_vlan_filter_set(port_id, on);
1560 vlan_extend_set(port_id, on);
1565 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1566 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1568 cmdline_parse_token_string_t cmd_vlan_offload_set =
1569 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1571 cmdline_parse_token_string_t cmd_vlan_offload_what =
1572 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1573 what, "strip#filter#qinq#stripq");
1574 cmdline_parse_token_string_t cmd_vlan_offload_on =
1575 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1577 cmdline_parse_token_string_t cmd_vlan_offload_portid =
1578 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1581 cmdline_parse_inst_t cmd_vlan_offload = {
1582 .f = cmd_vlan_offload_parsed,
1584 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
1585 " qinq(extended) for both rx/tx sides ",
1587 (void *)&cmd_vlan_offload_vlan,
1588 (void *)&cmd_vlan_offload_set,
1589 (void *)&cmd_vlan_offload_what,
1590 (void *)&cmd_vlan_offload_on,
1591 (void *)&cmd_vlan_offload_portid,
1596 /* *** VLAN TPID SET ON A PORT *** */
1597 struct cmd_vlan_tpid_result {
1598 cmdline_fixed_string_t vlan;
1599 cmdline_fixed_string_t set;
1600 cmdline_fixed_string_t what;
1606 cmd_vlan_tpid_parsed(void *parsed_result,
1607 __attribute__((unused)) struct cmdline *cl,
1608 __attribute__((unused)) void *data)
1610 struct cmd_vlan_tpid_result *res = parsed_result;
1611 vlan_tpid_set(res->port_id, res->tp_id);
1615 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
1616 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1618 cmdline_parse_token_string_t cmd_vlan_tpid_set =
1619 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1621 cmdline_parse_token_string_t cmd_vlan_tpid_what =
1622 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
1624 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
1625 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1627 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
1628 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
1631 cmdline_parse_inst_t cmd_vlan_tpid = {
1632 .f = cmd_vlan_tpid_parsed,
1634 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
1636 (void *)&cmd_vlan_tpid_vlan,
1637 (void *)&cmd_vlan_tpid_set,
1638 (void *)&cmd_vlan_tpid_what,
1639 (void *)&cmd_vlan_tpid_tpid,
1640 (void *)&cmd_vlan_tpid_portid,
1645 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
1646 struct cmd_rx_vlan_filter_result {
1647 cmdline_fixed_string_t rx_vlan;
1648 cmdline_fixed_string_t what;
1654 cmd_rx_vlan_filter_parsed(void *parsed_result,
1655 __attribute__((unused)) struct cmdline *cl,
1656 __attribute__((unused)) void *data)
1658 struct cmd_rx_vlan_filter_result *res = parsed_result;
1660 if (!strcmp(res->what, "add"))
1661 rx_vft_set(res->port_id, res->vlan_id, 1);
1663 rx_vft_set(res->port_id, res->vlan_id, 0);
1666 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
1667 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1668 rx_vlan, "rx_vlan");
1669 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
1670 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
1672 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
1673 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1675 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
1676 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
1679 cmdline_parse_inst_t cmd_rx_vlan_filter = {
1680 .f = cmd_rx_vlan_filter_parsed,
1682 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
1683 "Identifiers filtered by a port",
1685 (void *)&cmd_rx_vlan_filter_rx_vlan,
1686 (void *)&cmd_rx_vlan_filter_what,
1687 (void *)&cmd_rx_vlan_filter_vlanid,
1688 (void *)&cmd_rx_vlan_filter_portid,
1693 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1694 struct cmd_tx_vlan_set_result {
1695 cmdline_fixed_string_t tx_vlan;
1696 cmdline_fixed_string_t set;
1702 cmd_tx_vlan_set_parsed(void *parsed_result,
1703 __attribute__((unused)) struct cmdline *cl,
1704 __attribute__((unused)) void *data)
1706 struct cmd_tx_vlan_set_result *res = parsed_result;
1707 tx_vlan_set(res->port_id, res->vlan_id);
1710 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
1711 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1712 tx_vlan, "tx_vlan");
1713 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
1714 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
1716 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
1717 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1719 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
1720 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
1723 cmdline_parse_inst_t cmd_tx_vlan_set = {
1724 .f = cmd_tx_vlan_set_parsed,
1726 .help_str = "enable hardware insertion of a VLAN header with a given "
1727 "TAG Identifier in packets sent on a port",
1729 (void *)&cmd_tx_vlan_set_tx_vlan,
1730 (void *)&cmd_tx_vlan_set_set,
1731 (void *)&cmd_tx_vlan_set_vlanid,
1732 (void *)&cmd_tx_vlan_set_portid,
1737 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
1738 struct cmd_tx_vlan_reset_result {
1739 cmdline_fixed_string_t tx_vlan;
1740 cmdline_fixed_string_t reset;
1745 cmd_tx_vlan_reset_parsed(void *parsed_result,
1746 __attribute__((unused)) struct cmdline *cl,
1747 __attribute__((unused)) void *data)
1749 struct cmd_tx_vlan_reset_result *res = parsed_result;
1751 tx_vlan_reset(res->port_id);
1754 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
1755 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1756 tx_vlan, "tx_vlan");
1757 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
1758 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
1760 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
1761 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
1764 cmdline_parse_inst_t cmd_tx_vlan_reset = {
1765 .f = cmd_tx_vlan_reset_parsed,
1767 .help_str = "disable hardware insertion of a VLAN header in packets "
1770 (void *)&cmd_tx_vlan_reset_tx_vlan,
1771 (void *)&cmd_tx_vlan_reset_reset,
1772 (void *)&cmd_tx_vlan_reset_portid,
1778 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
1779 struct cmd_tx_cksum_set_result {
1780 cmdline_fixed_string_t tx_cksum;
1781 cmdline_fixed_string_t set;
1787 cmd_tx_cksum_set_parsed(void *parsed_result,
1788 __attribute__((unused)) struct cmdline *cl,
1789 __attribute__((unused)) void *data)
1791 struct cmd_tx_cksum_set_result *res = parsed_result;
1793 tx_cksum_set(res->port_id, res->cksum_mask);
1796 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
1797 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1798 tx_cksum, "tx_checksum");
1799 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
1800 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
1802 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
1803 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1805 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
1806 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
1809 cmdline_parse_inst_t cmd_tx_cksum_set = {
1810 .f = cmd_tx_cksum_set_parsed,
1812 .help_str = "enable hardware insertion of L3/L4checksum with a given "
1813 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
1814 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
1816 (void *)&cmd_tx_cksum_set_tx_cksum,
1817 (void *)&cmd_tx_cksum_set_set,
1818 (void *)&cmd_tx_cksum_set_cksum_mask,
1819 (void *)&cmd_tx_cksum_set_portid,
1824 /* *** SET FORWARDING MODE *** */
1825 struct cmd_set_fwd_mode_result {
1826 cmdline_fixed_string_t set;
1827 cmdline_fixed_string_t fwd;
1828 cmdline_fixed_string_t mode;
1831 static void cmd_set_fwd_mode_parsed(void *parsed_result,
1832 __attribute__((unused)) struct cmdline *cl,
1833 __attribute__((unused)) void *data)
1835 struct cmd_set_fwd_mode_result *res = parsed_result;
1837 set_pkt_forwarding_mode(res->mode);
1840 cmdline_parse_token_string_t cmd_setfwd_set =
1841 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
1842 cmdline_parse_token_string_t cmd_setfwd_fwd =
1843 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
1844 cmdline_parse_token_string_t cmd_setfwd_mode =
1845 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
1846 #ifdef RTE_LIBRTE_IEEE1588
1847 "io#mac#rxonly#txonly#csum#ieee1588");
1849 "io#mac#rxonly#txonly#csum");
1852 cmdline_parse_inst_t cmd_set_fwd_mode = {
1853 .f = cmd_set_fwd_mode_parsed,
1855 #ifdef RTE_LIBRTE_IEEE1588
1856 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
1857 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
1859 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
1860 " RXONLY, CSUM or TXONLY packet forwarding mode",
1863 (void *)&cmd_setfwd_set,
1864 (void *)&cmd_setfwd_fwd,
1865 (void *)&cmd_setfwd_mode,
1870 /* *** SET PROMISC MODE *** */
1871 struct cmd_set_promisc_mode_result {
1872 cmdline_fixed_string_t set;
1873 cmdline_fixed_string_t promisc;
1874 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1875 uint8_t port_num; /* valid if "allports" argument == 0 */
1876 cmdline_fixed_string_t mode;
1879 static void cmd_set_promisc_mode_parsed(void *parsed_result,
1880 __attribute__((unused)) struct cmdline *cl,
1883 struct cmd_set_promisc_mode_result *res = parsed_result;
1887 if (!strcmp(res->mode, "on"))
1894 for (i = 0; i < nb_ports; i++) {
1896 rte_eth_promiscuous_enable(i);
1898 rte_eth_promiscuous_disable(i);
1903 rte_eth_promiscuous_enable(res->port_num);
1905 rte_eth_promiscuous_disable(res->port_num);
1909 cmdline_parse_token_string_t cmd_setpromisc_set =
1910 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
1911 cmdline_parse_token_string_t cmd_setpromisc_promisc =
1912 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
1914 cmdline_parse_token_string_t cmd_setpromisc_portall =
1915 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
1917 cmdline_parse_token_num_t cmd_setpromisc_portnum =
1918 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
1920 cmdline_parse_token_string_t cmd_setpromisc_mode =
1921 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
1924 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
1925 .f = cmd_set_promisc_mode_parsed,
1927 .help_str = "set promisc all on|off: set promisc mode for all ports",
1929 (void *)&cmd_setpromisc_set,
1930 (void *)&cmd_setpromisc_promisc,
1931 (void *)&cmd_setpromisc_portall,
1932 (void *)&cmd_setpromisc_mode,
1937 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
1938 .f = cmd_set_promisc_mode_parsed,
1940 .help_str = "set promisc X on|off: set promisc mode on port X",
1942 (void *)&cmd_setpromisc_set,
1943 (void *)&cmd_setpromisc_promisc,
1944 (void *)&cmd_setpromisc_portnum,
1945 (void *)&cmd_setpromisc_mode,
1950 /* *** SET ALLMULTI MODE *** */
1951 struct cmd_set_allmulti_mode_result {
1952 cmdline_fixed_string_t set;
1953 cmdline_fixed_string_t allmulti;
1954 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
1955 uint8_t port_num; /* valid if "allports" argument == 0 */
1956 cmdline_fixed_string_t mode;
1959 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
1960 __attribute__((unused)) struct cmdline *cl,
1963 struct cmd_set_allmulti_mode_result *res = parsed_result;
1967 if (!strcmp(res->mode, "on"))
1974 for (i = 0; i < nb_ports; i++) {
1976 rte_eth_allmulticast_enable(i);
1978 rte_eth_allmulticast_disable(i);
1983 rte_eth_allmulticast_enable(res->port_num);
1985 rte_eth_allmulticast_disable(res->port_num);
1989 cmdline_parse_token_string_t cmd_setallmulti_set =
1990 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
1991 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
1992 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
1994 cmdline_parse_token_string_t cmd_setallmulti_portall =
1995 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
1997 cmdline_parse_token_num_t cmd_setallmulti_portnum =
1998 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2000 cmdline_parse_token_string_t cmd_setallmulti_mode =
2001 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2004 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2005 .f = cmd_set_allmulti_mode_parsed,
2007 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2009 (void *)&cmd_setallmulti_set,
2010 (void *)&cmd_setallmulti_allmulti,
2011 (void *)&cmd_setallmulti_portall,
2012 (void *)&cmd_setallmulti_mode,
2017 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2018 .f = cmd_set_allmulti_mode_parsed,
2020 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2022 (void *)&cmd_setallmulti_set,
2023 (void *)&cmd_setallmulti_allmulti,
2024 (void *)&cmd_setallmulti_portnum,
2025 (void *)&cmd_setallmulti_mode,
2030 /* *** ADD/REMOVE A PKT FILTER *** */
2031 struct cmd_pkt_filter_result {
2032 cmdline_fixed_string_t pkt_filter;
2034 cmdline_fixed_string_t protocol;
2035 cmdline_fixed_string_t src;
2036 cmdline_ipaddr_t ip_src;
2038 cmdline_fixed_string_t dst;
2039 cmdline_ipaddr_t ip_dst;
2041 cmdline_fixed_string_t flexbytes;
2042 uint16_t flexbytes_value;
2043 cmdline_fixed_string_t vlan;
2045 cmdline_fixed_string_t queue;
2047 cmdline_fixed_string_t soft;
2052 cmd_pkt_filter_parsed(void *parsed_result,
2053 __attribute__((unused)) struct cmdline *cl,
2054 __attribute__((unused)) void *data)
2056 struct rte_fdir_filter fdir_filter;
2057 struct cmd_pkt_filter_result *res = parsed_result;
2059 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2061 if (res->ip_src.family == AF_INET)
2062 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2064 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2065 &(res->ip_src.addr.ipv6),
2066 sizeof(struct in6_addr));
2068 if (res->ip_dst.family == AF_INET)
2069 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2071 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2072 &(res->ip_dst.addr.ipv6),
2073 sizeof(struct in6_addr));
2075 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2076 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2078 if (!strcmp(res->protocol, "udp"))
2079 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2080 else if (!strcmp(res->protocol, "tcp"))
2081 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2082 else if (!strcmp(res->protocol, "sctp"))
2083 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2084 else /* default only IP */
2085 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2087 if (res->ip_dst.family == AF_INET6)
2088 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2090 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2092 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2093 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2095 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2096 fdir_add_signature_filter(res->port_id, res->queue_id,
2098 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2099 fdir_update_signature_filter(res->port_id, res->queue_id,
2101 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2102 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2103 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2104 fdir_add_perfect_filter(res->port_id, res->soft_id,
2106 (uint8_t) (res->queue_id < 0),
2108 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2109 fdir_update_perfect_filter(res->port_id, res->soft_id,
2111 (uint8_t) (res->queue_id < 0),
2113 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2114 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2120 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2121 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2123 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2124 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2125 protocol, "ip#tcp#udp#sctp");
2126 cmdline_parse_token_string_t cmd_pkt_filter_src =
2127 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2129 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2130 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2132 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2133 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2135 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2136 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2138 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2139 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2141 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2142 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2144 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2145 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2146 flexbytes, "flexbytes");
2147 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2148 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2149 flexbytes_value, UINT16);
2150 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2151 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2153 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2154 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2156 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2157 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2159 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2160 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2162 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2163 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2165 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2166 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2170 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2171 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2172 pkt_filter, "add_signature_filter");
2173 cmdline_parse_inst_t cmd_add_signature_filter = {
2174 .f = cmd_pkt_filter_parsed,
2176 .help_str = "add a signature filter",
2178 (void *)&cmd_pkt_filter_add_signature_filter,
2179 (void *)&cmd_pkt_filter_port_id,
2180 (void *)&cmd_pkt_filter_protocol,
2181 (void *)&cmd_pkt_filter_src,
2182 (void *)&cmd_pkt_filter_ip_src,
2183 (void *)&cmd_pkt_filter_port_src,
2184 (void *)&cmd_pkt_filter_dst,
2185 (void *)&cmd_pkt_filter_ip_dst,
2186 (void *)&cmd_pkt_filter_port_dst,
2187 (void *)&cmd_pkt_filter_flexbytes,
2188 (void *)&cmd_pkt_filter_flexbytes_value,
2189 (void *)&cmd_pkt_filter_vlan,
2190 (void *)&cmd_pkt_filter_vlan_id,
2191 (void *)&cmd_pkt_filter_queue,
2192 (void *)&cmd_pkt_filter_queue_id,
2198 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2199 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2200 pkt_filter, "upd_signature_filter");
2201 cmdline_parse_inst_t cmd_upd_signature_filter = {
2202 .f = cmd_pkt_filter_parsed,
2204 .help_str = "update a signature filter",
2206 (void *)&cmd_pkt_filter_upd_signature_filter,
2207 (void *)&cmd_pkt_filter_port_id,
2208 (void *)&cmd_pkt_filter_protocol,
2209 (void *)&cmd_pkt_filter_src,
2210 (void *)&cmd_pkt_filter_ip_src,
2211 (void *)&cmd_pkt_filter_port_src,
2212 (void *)&cmd_pkt_filter_dst,
2213 (void *)&cmd_pkt_filter_ip_dst,
2214 (void *)&cmd_pkt_filter_port_dst,
2215 (void *)&cmd_pkt_filter_flexbytes,
2216 (void *)&cmd_pkt_filter_flexbytes_value,
2217 (void *)&cmd_pkt_filter_vlan,
2218 (void *)&cmd_pkt_filter_vlan_id,
2219 (void *)&cmd_pkt_filter_queue,
2220 (void *)&cmd_pkt_filter_queue_id,
2226 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2227 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2228 pkt_filter, "rm_signature_filter");
2229 cmdline_parse_inst_t cmd_rm_signature_filter = {
2230 .f = cmd_pkt_filter_parsed,
2232 .help_str = "remove a signature filter",
2234 (void *)&cmd_pkt_filter_rm_signature_filter,
2235 (void *)&cmd_pkt_filter_port_id,
2236 (void *)&cmd_pkt_filter_protocol,
2237 (void *)&cmd_pkt_filter_src,
2238 (void *)&cmd_pkt_filter_ip_src,
2239 (void *)&cmd_pkt_filter_port_src,
2240 (void *)&cmd_pkt_filter_dst,
2241 (void *)&cmd_pkt_filter_ip_dst,
2242 (void *)&cmd_pkt_filter_port_dst,
2243 (void *)&cmd_pkt_filter_flexbytes,
2244 (void *)&cmd_pkt_filter_flexbytes_value,
2245 (void *)&cmd_pkt_filter_vlan,
2246 (void *)&cmd_pkt_filter_vlan_id,
2252 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2253 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2254 pkt_filter, "add_perfect_filter");
2255 cmdline_parse_inst_t cmd_add_perfect_filter = {
2256 .f = cmd_pkt_filter_parsed,
2258 .help_str = "add a perfect filter",
2260 (void *)&cmd_pkt_filter_add_perfect_filter,
2261 (void *)&cmd_pkt_filter_port_id,
2262 (void *)&cmd_pkt_filter_protocol,
2263 (void *)&cmd_pkt_filter_src,
2264 (void *)&cmd_pkt_filter_ip_src,
2265 (void *)&cmd_pkt_filter_port_src,
2266 (void *)&cmd_pkt_filter_dst,
2267 (void *)&cmd_pkt_filter_ip_dst,
2268 (void *)&cmd_pkt_filter_port_dst,
2269 (void *)&cmd_pkt_filter_flexbytes,
2270 (void *)&cmd_pkt_filter_flexbytes_value,
2271 (void *)&cmd_pkt_filter_vlan,
2272 (void *)&cmd_pkt_filter_vlan_id,
2273 (void *)&cmd_pkt_filter_queue,
2274 (void *)&cmd_pkt_filter_queue_id,
2275 (void *)&cmd_pkt_filter_soft,
2276 (void *)&cmd_pkt_filter_soft_id,
2282 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2283 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2284 pkt_filter, "upd_perfect_filter");
2285 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2286 .f = cmd_pkt_filter_parsed,
2288 .help_str = "update a perfect filter",
2290 (void *)&cmd_pkt_filter_upd_perfect_filter,
2291 (void *)&cmd_pkt_filter_port_id,
2292 (void *)&cmd_pkt_filter_protocol,
2293 (void *)&cmd_pkt_filter_src,
2294 (void *)&cmd_pkt_filter_ip_src,
2295 (void *)&cmd_pkt_filter_port_src,
2296 (void *)&cmd_pkt_filter_dst,
2297 (void *)&cmd_pkt_filter_ip_dst,
2298 (void *)&cmd_pkt_filter_port_dst,
2299 (void *)&cmd_pkt_filter_flexbytes,
2300 (void *)&cmd_pkt_filter_flexbytes_value,
2301 (void *)&cmd_pkt_filter_vlan,
2302 (void *)&cmd_pkt_filter_vlan_id,
2303 (void *)&cmd_pkt_filter_queue,
2304 (void *)&cmd_pkt_filter_queue_id,
2305 (void *)&cmd_pkt_filter_soft,
2306 (void *)&cmd_pkt_filter_soft_id,
2312 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2313 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2314 pkt_filter, "rm_perfect_filter");
2315 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2316 .f = cmd_pkt_filter_parsed,
2318 .help_str = "remove a perfect filter",
2320 (void *)&cmd_pkt_filter_rm_perfect_filter,
2321 (void *)&cmd_pkt_filter_port_id,
2322 (void *)&cmd_pkt_filter_protocol,
2323 (void *)&cmd_pkt_filter_src,
2324 (void *)&cmd_pkt_filter_ip_src,
2325 (void *)&cmd_pkt_filter_port_src,
2326 (void *)&cmd_pkt_filter_dst,
2327 (void *)&cmd_pkt_filter_ip_dst,
2328 (void *)&cmd_pkt_filter_port_dst,
2329 (void *)&cmd_pkt_filter_flexbytes,
2330 (void *)&cmd_pkt_filter_flexbytes_value,
2331 (void *)&cmd_pkt_filter_vlan,
2332 (void *)&cmd_pkt_filter_vlan_id,
2333 (void *)&cmd_pkt_filter_soft,
2334 (void *)&cmd_pkt_filter_soft_id,
2339 /* *** SETUP MASKS FILTER *** */
2340 struct cmd_pkt_filter_masks_result {
2341 cmdline_fixed_string_t filter_mask;
2343 cmdline_fixed_string_t src_mask;
2344 uint32_t ip_src_mask;
2345 uint16_t ipv6_src_mask;
2346 uint16_t port_src_mask;
2347 cmdline_fixed_string_t dst_mask;
2348 uint32_t ip_dst_mask;
2349 uint16_t ipv6_dst_mask;
2350 uint16_t port_dst_mask;
2351 cmdline_fixed_string_t flexbytes;
2352 uint8_t flexbytes_value;
2353 cmdline_fixed_string_t vlan_id;
2354 uint8_t vlan_id_value;
2355 cmdline_fixed_string_t vlan_prio;
2356 uint8_t vlan_prio_value;
2357 cmdline_fixed_string_t only_ip_flow;
2358 uint8_t only_ip_flow_value;
2359 cmdline_fixed_string_t comp_ipv6_dst;
2360 uint8_t comp_ipv6_dst_value;
2364 cmd_pkt_filter_masks_parsed(void *parsed_result,
2365 __attribute__((unused)) struct cmdline *cl,
2366 __attribute__((unused)) void *data)
2368 struct rte_fdir_masks fdir_masks;
2369 struct cmd_pkt_filter_masks_result *res = parsed_result;
2371 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2373 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2374 fdir_masks.vlan_id = res->vlan_id_value;
2375 fdir_masks.vlan_prio = res->vlan_prio_value;
2376 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2377 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2378 fdir_masks.src_port_mask = res->port_src_mask;
2379 fdir_masks.dst_port_mask = res->port_dst_mask;
2380 fdir_masks.flexbytes = res->flexbytes_value;
2382 fdir_set_masks(res->port_id, &fdir_masks);
2385 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2386 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2387 filter_mask, "set_masks_filter");
2388 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2389 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2391 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2392 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2393 only_ip_flow, "only_ip_flow");
2394 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2395 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2396 only_ip_flow_value, UINT8);
2397 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2398 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2399 src_mask, "src_mask");
2400 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2401 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2402 ip_src_mask, UINT32);
2403 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2404 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2405 port_src_mask, UINT16);
2406 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2407 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2408 dst_mask, "dst_mask");
2409 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2410 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2411 ip_dst_mask, UINT32);
2412 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2413 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2414 port_dst_mask, UINT16);
2415 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2416 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2417 flexbytes, "flexbytes");
2418 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2419 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2420 flexbytes_value, UINT8);
2421 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2422 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2423 vlan_id, "vlan_id");
2424 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2425 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2426 vlan_id_value, UINT8);
2427 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2428 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2429 vlan_prio, "vlan_prio");
2430 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2431 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2432 vlan_prio_value, UINT8);
2434 cmdline_parse_inst_t cmd_set_masks_filter = {
2435 .f = cmd_pkt_filter_masks_parsed,
2437 .help_str = "setup masks filter",
2439 (void *)&cmd_pkt_filter_masks_filter_mask,
2440 (void *)&cmd_pkt_filter_masks_port_id,
2441 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2442 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2443 (void *)&cmd_pkt_filter_masks_src_mask,
2444 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2445 (void *)&cmd_pkt_filter_masks_port_src_mask,
2446 (void *)&cmd_pkt_filter_masks_dst_mask,
2447 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2448 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2449 (void *)&cmd_pkt_filter_masks_flexbytes,
2450 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2451 (void *)&cmd_pkt_filter_masks_vlan_id,
2452 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2453 (void *)&cmd_pkt_filter_masks_vlan_prio,
2454 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2460 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2461 __attribute__((unused)) struct cmdline *cl,
2462 __attribute__((unused)) void *data)
2464 struct rte_fdir_masks fdir_masks;
2465 struct cmd_pkt_filter_masks_result *res = parsed_result;
2467 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2469 fdir_masks.set_ipv6_mask = 1;
2470 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2471 fdir_masks.vlan_id = res->vlan_id_value;
2472 fdir_masks.vlan_prio = res->vlan_prio_value;
2473 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2474 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2475 fdir_masks.src_port_mask = res->port_src_mask;
2476 fdir_masks.dst_port_mask = res->port_dst_mask;
2477 fdir_masks.flexbytes = res->flexbytes_value;
2478 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2480 fdir_set_masks(res->port_id, &fdir_masks);
2483 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2484 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2485 filter_mask, "set_ipv6_masks_filter");
2486 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2487 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2488 ipv6_src_mask, UINT16);
2489 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2490 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2491 ipv6_dst_mask, UINT16);
2493 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2494 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2495 comp_ipv6_dst, "compare_dst");
2496 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2497 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2498 comp_ipv6_dst_value, UINT8);
2500 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2501 .f = cmd_pkt_filter_masks_ipv6_parsed,
2503 .help_str = "setup ipv6 masks filter",
2505 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2506 (void *)&cmd_pkt_filter_masks_port_id,
2507 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2508 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2509 (void *)&cmd_pkt_filter_masks_src_mask,
2510 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2511 (void *)&cmd_pkt_filter_masks_port_src_mask,
2512 (void *)&cmd_pkt_filter_masks_dst_mask,
2513 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2514 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2515 (void *)&cmd_pkt_filter_masks_flexbytes,
2516 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2517 (void *)&cmd_pkt_filter_masks_vlan_id,
2518 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2519 (void *)&cmd_pkt_filter_masks_vlan_prio,
2520 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2521 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2522 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2527 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2528 struct cmd_link_flow_ctrl_set_result {
2529 cmdline_fixed_string_t set;
2530 cmdline_fixed_string_t flow_ctrl;
2531 cmdline_fixed_string_t rx;
2532 cmdline_fixed_string_t rx_lfc_mode;
2533 cmdline_fixed_string_t tx;
2534 cmdline_fixed_string_t tx_lfc_mode;
2535 uint32_t high_water;
2537 uint16_t pause_time;
2543 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
2544 __attribute__((unused)) struct cmdline *cl,
2545 __attribute__((unused)) void *data)
2547 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
2548 struct rte_eth_fc_conf fc_conf;
2549 int rx_fc_enable, tx_fc_enable;
2553 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
2554 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
2555 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
2556 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
2558 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
2559 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
2562 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
2563 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
2565 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
2566 fc_conf.high_water = res->high_water;
2567 fc_conf.low_water = res->low_water;
2568 fc_conf.pause_time = res->pause_time;
2569 fc_conf.send_xon = res->send_xon;
2571 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
2573 printf("bad flow contrl parameter, return code = %d \n", ret);
2576 cmdline_parse_token_string_t cmd_lfc_set_set =
2577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2579 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
2580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2581 flow_ctrl, "flow_ctrl");
2582 cmdline_parse_token_string_t cmd_lfc_set_rx =
2583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2585 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
2586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2587 rx_lfc_mode, "on#off");
2588 cmdline_parse_token_string_t cmd_lfc_set_tx =
2589 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2591 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
2592 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2593 tx_lfc_mode, "on#off");
2594 cmdline_parse_token_num_t cmd_lfc_set_high_water =
2595 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2596 high_water, UINT32);
2597 cmdline_parse_token_num_t cmd_lfc_set_low_water =
2598 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2600 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
2601 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2602 pause_time, UINT16);
2603 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
2604 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2606 cmdline_parse_token_num_t cmd_lfc_set_portid =
2607 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
2610 cmdline_parse_inst_t cmd_link_flow_control_set = {
2611 .f = cmd_link_flow_ctrl_set_parsed,
2613 .help_str = "Configure the Ethernet link flow control...",
2615 (void *)&cmd_lfc_set_set,
2616 (void *)&cmd_lfc_set_flow_ctrl,
2617 (void *)&cmd_lfc_set_rx,
2618 (void *)&cmd_lfc_set_rx_mode,
2619 (void *)&cmd_lfc_set_tx,
2620 (void *)&cmd_lfc_set_tx_mode,
2621 (void *)&cmd_lfc_set_high_water,
2622 (void *)&cmd_lfc_set_low_water,
2623 (void *)&cmd_lfc_set_pause_time,
2624 (void *)&cmd_lfc_set_send_xon,
2625 (void *)&cmd_lfc_set_portid,
2630 /* *** RESET CONFIGURATION *** */
2631 struct cmd_reset_result {
2632 cmdline_fixed_string_t reset;
2633 cmdline_fixed_string_t def;
2636 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
2638 __attribute__((unused)) void *data)
2640 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
2641 set_def_fwd_config();
2644 cmdline_parse_token_string_t cmd_reset_set =
2645 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
2646 cmdline_parse_token_string_t cmd_reset_def =
2647 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
2650 cmdline_parse_inst_t cmd_reset = {
2651 .f = cmd_reset_parsed,
2653 .help_str = "set default: reset default forwarding configuration",
2655 (void *)&cmd_reset_set,
2656 (void *)&cmd_reset_def,
2661 /* *** START FORWARDING *** */
2662 struct cmd_start_result {
2663 cmdline_fixed_string_t start;
2666 cmdline_parse_token_string_t cmd_start_start =
2667 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
2669 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
2670 __attribute__((unused)) struct cmdline *cl,
2671 __attribute__((unused)) void *data)
2673 start_packet_forwarding(0);
2676 cmdline_parse_inst_t cmd_start = {
2677 .f = cmd_start_parsed,
2679 .help_str = "start packet forwarding",
2681 (void *)&cmd_start_start,
2686 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
2687 struct cmd_start_tx_first_result {
2688 cmdline_fixed_string_t start;
2689 cmdline_fixed_string_t tx_first;
2693 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 start_packet_forwarding(1);
2700 cmdline_parse_token_string_t cmd_start_tx_first_start =
2701 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
2703 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
2704 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
2705 tx_first, "tx_first");
2707 cmdline_parse_inst_t cmd_start_tx_first = {
2708 .f = cmd_start_tx_first_parsed,
2710 .help_str = "start packet forwarding, after sending 1 burst of packets",
2712 (void *)&cmd_start_tx_first_start,
2713 (void *)&cmd_start_tx_first_tx_first,
2718 /* *** SHOW CFG *** */
2719 struct cmd_showcfg_result {
2720 cmdline_fixed_string_t show;
2721 cmdline_fixed_string_t cfg;
2722 cmdline_fixed_string_t what;
2725 static void cmd_showcfg_parsed(void *parsed_result,
2726 __attribute__((unused)) struct cmdline *cl,
2727 __attribute__((unused)) void *data)
2729 struct cmd_showcfg_result *res = parsed_result;
2730 if (!strcmp(res->what, "rxtx"))
2731 rxtx_config_display();
2732 else if (!strcmp(res->what, "cores"))
2733 fwd_lcores_config_display();
2734 else if (!strcmp(res->what, "fwd"))
2735 fwd_config_display();
2738 cmdline_parse_token_string_t cmd_showcfg_show =
2739 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
2740 cmdline_parse_token_string_t cmd_showcfg_port =
2741 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
2742 cmdline_parse_token_string_t cmd_showcfg_what =
2743 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
2746 cmdline_parse_inst_t cmd_showcfg = {
2747 .f = cmd_showcfg_parsed,
2749 .help_str = "show config rxtx|cores|fwd",
2751 (void *)&cmd_showcfg_show,
2752 (void *)&cmd_showcfg_port,
2753 (void *)&cmd_showcfg_what,
2758 /* *** SHOW ALL PORT INFO *** */
2759 struct cmd_showportall_result {
2760 cmdline_fixed_string_t show;
2761 cmdline_fixed_string_t port;
2762 cmdline_fixed_string_t what;
2763 cmdline_fixed_string_t all;
2766 static void cmd_showportall_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2768 __attribute__((unused)) void *data)
2772 struct cmd_showportall_result *res = parsed_result;
2773 if (!strcmp(res->show, "clear")) {
2774 if (!strcmp(res->what, "stats"))
2775 for (i = 0; i < nb_ports; i++)
2777 } else if (!strcmp(res->what, "info"))
2778 for (i = 0; i < nb_ports; i++)
2779 port_infos_display(i);
2780 else if (!strcmp(res->what, "stats"))
2781 for (i = 0; i < nb_ports; i++)
2782 nic_stats_display(i);
2783 else if (!strcmp(res->what, "fdir"))
2784 for (i = 0; i < nb_ports; i++)
2786 else if (!strcmp(res->what, "stat_qmap"))
2787 for (i = 0; i < nb_ports; i++)
2788 nic_stats_mapping_display(i);
2791 cmdline_parse_token_string_t cmd_showportall_show =
2792 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
2794 cmdline_parse_token_string_t cmd_showportall_port =
2795 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
2796 cmdline_parse_token_string_t cmd_showportall_what =
2797 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
2798 "info#stats#fdir#stat_qmap");
2799 cmdline_parse_token_string_t cmd_showportall_all =
2800 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
2801 cmdline_parse_inst_t cmd_showportall = {
2802 .f = cmd_showportall_parsed,
2804 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
2806 (void *)&cmd_showportall_show,
2807 (void *)&cmd_showportall_port,
2808 (void *)&cmd_showportall_what,
2809 (void *)&cmd_showportall_all,
2814 /* *** SHOW PORT INFO *** */
2815 struct cmd_showport_result {
2816 cmdline_fixed_string_t show;
2817 cmdline_fixed_string_t port;
2818 cmdline_fixed_string_t what;
2822 static void cmd_showport_parsed(void *parsed_result,
2823 __attribute__((unused)) struct cmdline *cl,
2824 __attribute__((unused)) void *data)
2826 struct cmd_showport_result *res = parsed_result;
2827 if (!strcmp(res->show, "clear")) {
2828 if (!strcmp(res->what, "stats"))
2829 nic_stats_clear(res->portnum);
2830 } else if (!strcmp(res->what, "info"))
2831 port_infos_display(res->portnum);
2832 else if (!strcmp(res->what, "stats"))
2833 nic_stats_display(res->portnum);
2834 else if (!strcmp(res->what, "fdir"))
2835 fdir_get_infos(res->portnum);
2836 else if (!strcmp(res->what, "stat_qmap"))
2837 nic_stats_mapping_display(res->portnum);
2840 cmdline_parse_token_string_t cmd_showport_show =
2841 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
2843 cmdline_parse_token_string_t cmd_showport_port =
2844 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
2845 cmdline_parse_token_string_t cmd_showport_what =
2846 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
2847 "info#stats#fdir#stat_qmap");
2848 cmdline_parse_token_num_t cmd_showport_portnum =
2849 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
2851 cmdline_parse_inst_t cmd_showport = {
2852 .f = cmd_showport_parsed,
2854 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
2856 (void *)&cmd_showport_show,
2857 (void *)&cmd_showport_port,
2858 (void *)&cmd_showport_what,
2859 (void *)&cmd_showport_portnum,
2864 /* *** READ PORT REGISTER *** */
2865 struct cmd_read_reg_result {
2866 cmdline_fixed_string_t read;
2867 cmdline_fixed_string_t reg;
2873 cmd_read_reg_parsed(void *parsed_result,
2874 __attribute__((unused)) struct cmdline *cl,
2875 __attribute__((unused)) void *data)
2877 struct cmd_read_reg_result *res = parsed_result;
2878 port_reg_display(res->port_id, res->reg_off);
2881 cmdline_parse_token_string_t cmd_read_reg_read =
2882 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
2883 cmdline_parse_token_string_t cmd_read_reg_reg =
2884 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
2885 cmdline_parse_token_num_t cmd_read_reg_port_id =
2886 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
2887 cmdline_parse_token_num_t cmd_read_reg_reg_off =
2888 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
2890 cmdline_parse_inst_t cmd_read_reg = {
2891 .f = cmd_read_reg_parsed,
2893 .help_str = "read reg port_id reg_off",
2895 (void *)&cmd_read_reg_read,
2896 (void *)&cmd_read_reg_reg,
2897 (void *)&cmd_read_reg_port_id,
2898 (void *)&cmd_read_reg_reg_off,
2903 /* *** READ PORT REGISTER BIT FIELD *** */
2904 struct cmd_read_reg_bit_field_result {
2905 cmdline_fixed_string_t read;
2906 cmdline_fixed_string_t regfield;
2914 cmd_read_reg_bit_field_parsed(void *parsed_result,
2915 __attribute__((unused)) struct cmdline *cl,
2916 __attribute__((unused)) void *data)
2918 struct cmd_read_reg_bit_field_result *res = parsed_result;
2919 port_reg_bit_field_display(res->port_id, res->reg_off,
2920 res->bit1_pos, res->bit2_pos);
2923 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
2924 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
2926 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
2927 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
2928 regfield, "regfield");
2929 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
2930 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
2932 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
2933 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
2935 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
2936 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
2938 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
2939 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
2942 cmdline_parse_inst_t cmd_read_reg_bit_field = {
2943 .f = cmd_read_reg_bit_field_parsed,
2945 .help_str = "read regfield port_id reg_off bit_x bit_y "
2946 "(read register bit field between bit_x and bit_y included)",
2948 (void *)&cmd_read_reg_bit_field_read,
2949 (void *)&cmd_read_reg_bit_field_regfield,
2950 (void *)&cmd_read_reg_bit_field_port_id,
2951 (void *)&cmd_read_reg_bit_field_reg_off,
2952 (void *)&cmd_read_reg_bit_field_bit1_pos,
2953 (void *)&cmd_read_reg_bit_field_bit2_pos,
2958 /* *** READ PORT REGISTER BIT *** */
2959 struct cmd_read_reg_bit_result {
2960 cmdline_fixed_string_t read;
2961 cmdline_fixed_string_t regbit;
2968 cmd_read_reg_bit_parsed(void *parsed_result,
2969 __attribute__((unused)) struct cmdline *cl,
2970 __attribute__((unused)) void *data)
2972 struct cmd_read_reg_bit_result *res = parsed_result;
2973 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
2976 cmdline_parse_token_string_t cmd_read_reg_bit_read =
2977 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
2978 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
2979 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
2981 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
2982 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
2983 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
2984 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
2985 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
2986 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
2988 cmdline_parse_inst_t cmd_read_reg_bit = {
2989 .f = cmd_read_reg_bit_parsed,
2991 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
2993 (void *)&cmd_read_reg_bit_read,
2994 (void *)&cmd_read_reg_bit_regbit,
2995 (void *)&cmd_read_reg_bit_port_id,
2996 (void *)&cmd_read_reg_bit_reg_off,
2997 (void *)&cmd_read_reg_bit_bit_pos,
3002 /* *** WRITE PORT REGISTER *** */
3003 struct cmd_write_reg_result {
3004 cmdline_fixed_string_t write;
3005 cmdline_fixed_string_t reg;
3012 cmd_write_reg_parsed(void *parsed_result,
3013 __attribute__((unused)) struct cmdline *cl,
3014 __attribute__((unused)) void *data)
3016 struct cmd_write_reg_result *res = parsed_result;
3017 port_reg_set(res->port_id, res->reg_off, res->value);
3020 cmdline_parse_token_string_t cmd_write_reg_write =
3021 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3022 cmdline_parse_token_string_t cmd_write_reg_reg =
3023 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3024 cmdline_parse_token_num_t cmd_write_reg_port_id =
3025 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3026 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3027 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3028 cmdline_parse_token_num_t cmd_write_reg_value =
3029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3031 cmdline_parse_inst_t cmd_write_reg = {
3032 .f = cmd_write_reg_parsed,
3034 .help_str = "write reg port_id reg_off reg_value",
3036 (void *)&cmd_write_reg_write,
3037 (void *)&cmd_write_reg_reg,
3038 (void *)&cmd_write_reg_port_id,
3039 (void *)&cmd_write_reg_reg_off,
3040 (void *)&cmd_write_reg_value,
3045 /* *** WRITE PORT REGISTER BIT FIELD *** */
3046 struct cmd_write_reg_bit_field_result {
3047 cmdline_fixed_string_t write;
3048 cmdline_fixed_string_t regfield;
3057 cmd_write_reg_bit_field_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3059 __attribute__((unused)) void *data)
3061 struct cmd_write_reg_bit_field_result *res = parsed_result;
3062 port_reg_bit_field_set(res->port_id, res->reg_off,
3063 res->bit1_pos, res->bit2_pos, res->value);
3066 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3067 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3069 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3070 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3071 regfield, "regfield");
3072 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3073 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3075 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3076 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3078 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3079 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3081 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3082 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3084 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3085 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3088 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3089 .f = cmd_write_reg_bit_field_parsed,
3091 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3092 "(set register bit field between bit_x and bit_y included)",
3094 (void *)&cmd_write_reg_bit_field_write,
3095 (void *)&cmd_write_reg_bit_field_regfield,
3096 (void *)&cmd_write_reg_bit_field_port_id,
3097 (void *)&cmd_write_reg_bit_field_reg_off,
3098 (void *)&cmd_write_reg_bit_field_bit1_pos,
3099 (void *)&cmd_write_reg_bit_field_bit2_pos,
3100 (void *)&cmd_write_reg_bit_field_value,
3105 /* *** WRITE PORT REGISTER BIT *** */
3106 struct cmd_write_reg_bit_result {
3107 cmdline_fixed_string_t write;
3108 cmdline_fixed_string_t regbit;
3116 cmd_write_reg_bit_parsed(void *parsed_result,
3117 __attribute__((unused)) struct cmdline *cl,
3118 __attribute__((unused)) void *data)
3120 struct cmd_write_reg_bit_result *res = parsed_result;
3121 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3124 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3125 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3127 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3128 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3130 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3131 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3132 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3134 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3135 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3136 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3137 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3139 cmdline_parse_inst_t cmd_write_reg_bit = {
3140 .f = cmd_write_reg_bit_parsed,
3142 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3144 (void *)&cmd_write_reg_bit_write,
3145 (void *)&cmd_write_reg_bit_regbit,
3146 (void *)&cmd_write_reg_bit_port_id,
3147 (void *)&cmd_write_reg_bit_reg_off,
3148 (void *)&cmd_write_reg_bit_bit_pos,
3149 (void *)&cmd_write_reg_bit_value,
3154 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3155 struct cmd_read_rxd_txd_result {
3156 cmdline_fixed_string_t read;
3157 cmdline_fixed_string_t rxd_txd;
3164 cmd_read_rxd_txd_parsed(void *parsed_result,
3165 __attribute__((unused)) struct cmdline *cl,
3166 __attribute__((unused)) void *data)
3168 struct cmd_read_rxd_txd_result *res = parsed_result;
3170 if (!strcmp(res->rxd_txd, "rxd"))
3171 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3172 else if (!strcmp(res->rxd_txd, "txd"))
3173 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3176 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3177 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3178 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3179 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3181 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3182 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3183 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3184 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3185 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3186 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3188 cmdline_parse_inst_t cmd_read_rxd_txd = {
3189 .f = cmd_read_rxd_txd_parsed,
3191 .help_str = "read rxd|txd port_id queue_id rxd_id",
3193 (void *)&cmd_read_rxd_txd_read,
3194 (void *)&cmd_read_rxd_txd_rxd_txd,
3195 (void *)&cmd_read_rxd_txd_port_id,
3196 (void *)&cmd_read_rxd_txd_queue_id,
3197 (void *)&cmd_read_rxd_txd_desc_id,
3203 struct cmd_quit_result {
3204 cmdline_fixed_string_t quit;
3207 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3209 __attribute__((unused)) void *data)
3215 cmdline_parse_token_string_t cmd_quit_quit =
3216 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3218 cmdline_parse_inst_t cmd_quit = {
3219 .f = cmd_quit_parsed,
3221 .help_str = "exit application",
3223 (void *)&cmd_quit_quit,
3228 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3229 struct cmd_mac_addr_result {
3230 cmdline_fixed_string_t mac_addr_cmd;
3231 cmdline_fixed_string_t what;
3233 struct ether_addr address;
3236 static void cmd_mac_addr_parsed(void *parsed_result,
3237 __attribute__((unused)) struct cmdline *cl,
3238 __attribute__((unused)) void *data)
3240 struct cmd_mac_addr_result *res = parsed_result;
3243 if (strcmp(res->what, "add") == 0)
3244 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3246 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3248 /* check the return value and print it if is < 0 */
3250 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3254 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3255 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3257 cmdline_parse_token_string_t cmd_mac_addr_what =
3258 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3260 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3261 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3262 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3263 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3265 cmdline_parse_inst_t cmd_mac_addr = {
3266 .f = cmd_mac_addr_parsed,
3268 .help_str = "mac_addr add|remove X <address>: "
3269 "add/remove MAC address on port X",
3271 (void *)&cmd_mac_addr_cmd,
3272 (void *)&cmd_mac_addr_what,
3273 (void *)&cmd_mac_addr_portnum,
3274 (void *)&cmd_mac_addr_addr,
3280 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3281 struct cmd_set_qmap_result {
3282 cmdline_fixed_string_t set;
3283 cmdline_fixed_string_t qmap;
3284 cmdline_fixed_string_t what;
3291 cmd_set_qmap_parsed(void *parsed_result,
3292 __attribute__((unused)) struct cmdline *cl,
3293 __attribute__((unused)) void *data)
3295 struct cmd_set_qmap_result *res = parsed_result;
3296 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3298 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3301 cmdline_parse_token_string_t cmd_setqmap_set =
3302 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3304 cmdline_parse_token_string_t cmd_setqmap_qmap =
3305 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3307 cmdline_parse_token_string_t cmd_setqmap_what =
3308 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3310 cmdline_parse_token_num_t cmd_setqmap_portid =
3311 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3313 cmdline_parse_token_num_t cmd_setqmap_queueid =
3314 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3316 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3317 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3320 cmdline_parse_inst_t cmd_set_qmap = {
3321 .f = cmd_set_qmap_parsed,
3323 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3325 (void *)&cmd_setqmap_set,
3326 (void *)&cmd_setqmap_qmap,
3327 (void *)&cmd_setqmap_what,
3328 (void *)&cmd_setqmap_portid,
3329 (void *)&cmd_setqmap_queueid,
3330 (void *)&cmd_setqmap_mapvalue,
3335 /* ******************************************************************************** */
3337 /* list of instructions */
3338 cmdline_parse_ctx_t main_ctx[] = {
3339 (cmdline_parse_inst_t *)&cmd_help,
3340 (cmdline_parse_inst_t *)&cmd_quit,
3341 (cmdline_parse_inst_t *)&cmd_showport,
3342 (cmdline_parse_inst_t *)&cmd_showportall,
3343 (cmdline_parse_inst_t *)&cmd_showcfg,
3344 (cmdline_parse_inst_t *)&cmd_start,
3345 (cmdline_parse_inst_t *)&cmd_start_tx_first,
3346 (cmdline_parse_inst_t *)&cmd_reset,
3347 (cmdline_parse_inst_t *)&cmd_set_numbers,
3348 (cmdline_parse_inst_t *)&cmd_set_txpkts,
3349 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
3350 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
3351 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
3352 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
3353 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
3354 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
3355 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
3356 (cmdline_parse_inst_t *)&cmd_vlan_offload,
3357 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
3358 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
3359 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
3360 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
3361 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
3362 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
3363 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
3364 (cmdline_parse_inst_t *)&cmd_config_dcb,
3365 (cmdline_parse_inst_t *)&cmd_read_reg,
3366 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
3367 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
3368 (cmdline_parse_inst_t *)&cmd_write_reg,
3369 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
3370 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
3371 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
3372 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
3373 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
3374 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
3375 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
3376 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
3377 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
3378 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
3379 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
3380 (cmdline_parse_inst_t *)&cmd_stop,
3381 (cmdline_parse_inst_t *)&cmd_mac_addr,
3382 (cmdline_parse_inst_t *)&cmd_set_qmap,
3383 (cmdline_parse_inst_t *)&cmd_operate_port,
3384 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
3385 (cmdline_parse_inst_t *)&cmd_config_speed_all,
3386 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
3387 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
3388 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
3389 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
3390 (cmdline_parse_inst_t *)&cmd_config_rss,
3391 (cmdline_parse_inst_t *)&cmd_config_burst,
3392 (cmdline_parse_inst_t *)&cmd_config_thresh,
3393 (cmdline_parse_inst_t *)&cmd_config_threshold,
3397 /* prompt function, called from main on MASTER lcore */
3403 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
3407 cmdline_interact(cl);
3408 cmdline_stdin_exit(cl);
3412 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
3414 if (id < nb_ports) {
3415 /* check if need_reconfig has been set to 1 */
3416 if (ports[id].need_reconfig == 0)
3417 ports[id].need_reconfig = dev;
3418 /* check if need_reconfig_queues has been set to 1 */
3419 if (ports[id].need_reconfig_queues == 0)
3420 ports[id].need_reconfig_queues = queue;
3424 for (pid = 0; pid < nb_ports; pid++) {
3425 /* check if need_reconfig has been set to 1 */
3426 if (ports[pid].need_reconfig == 0)
3427 ports[pid].need_reconfig = dev;
3428 /* check if need_reconfig_queues has been set to 1 */
3429 if (ports[pid].need_reconfig_queues == 0)
3430 ports[pid].need_reconfig_queues = queue;