4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 #include <net/socket.h>
46 #include <netinet/in.h>
48 #include <sys/queue.h>
50 #include <rte_common.h>
51 #include <rte_byteorder.h>
53 #include <rte_debug.h>
54 #include <rte_cycles.h>
55 #include <rte_memory.h>
56 #include <rte_memzone.h>
57 #include <rte_launch.h>
58 #include <rte_tailq.h>
60 #include <rte_per_lcore.h>
61 #include <rte_lcore.h>
62 #include <rte_atomic.h>
63 #include <rte_branch_prediction.h>
65 #include <rte_mempool.h>
66 #include <rte_interrupts.h>
68 #include <rte_ether.h>
69 #include <rte_ethdev.h>
70 #include <rte_string_fns.h>
72 #include <cmdline_rdline.h>
73 #include <cmdline_parse.h>
74 #include <cmdline_parse_num.h>
75 #include <cmdline_parse_string.h>
76 #include <cmdline_parse_ipaddr.h>
77 #include <cmdline_parse_etheraddr.h>
78 #include <cmdline_socket.h>
83 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
85 /* *** Help command with introduction. *** */
86 struct cmd_help_brief_result {
87 cmdline_fixed_string_t help;
90 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
92 __attribute__((unused)) void *data)
97 "Help is available for the following sections:\n\n"
98 " help control : Start and stop forwarding.\n"
99 " help display : Displaying port, stats and config "
101 " help config : Configuration information.\n"
102 " help ports : Configuring ports.\n"
103 " help flowdir : Flow Director filter help.\n"
104 " help registers : Reading and setting port registers.\n"
105 " help all : All of the above sections.\n\n"
110 cmdline_parse_token_string_t cmd_help_brief_help =
111 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
113 cmdline_parse_inst_t cmd_help_brief = {
114 .f = cmd_help_brief_parsed,
116 .help_str = "show help",
118 (void *)&cmd_help_brief_help,
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125 cmdline_fixed_string_t help;
126 cmdline_fixed_string_t section;
129 static void cmd_help_long_parsed(void *parsed_result,
131 __attribute__((unused)) void *data)
134 struct cmd_help_long_result *res = parsed_result;
136 if (!strcmp(res->section, "all"))
139 if (show_all || !strcmp(res->section, "control")) {
144 "Control forwarding:\n"
145 "-------------------\n\n"
148 " Start packet forwarding with current configuration.\n\n"
151 " Start packet forwarding with current config"
152 " after sending one burst of packets.\n\n"
155 " Stop packet forwarding, and display accumulated"
159 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
163 if (show_all || !strcmp(res->section, "display")) {
171 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
172 " Display information for port_id, or all.\n\n"
174 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
175 " Clear information for port_id, or all.\n\n"
177 "show config (rxtx|cores|fwd)\n"
178 " Display the given configuration.\n\n"
180 "read rxd (port_id) (queue_id) (rxd_id)\n"
181 " Display an RX descriptor of a port RX queue.\n\n"
183 "read txd (port_id) (queue_id) (txd_id)\n"
184 " Display a TX descriptor of a port TX queue.\n\n"
188 if (show_all || !strcmp(res->section, "config")) {
194 "Configuration changes only become active when"
195 " forwarding is started/restarted.\n\n"
198 " Reset forwarding to the default configuration.\n\n"
200 "set verbose (level)\n"
201 " Set the debug verbosity level X.\n\n"
204 " Set number of ports.\n\n"
207 " Set number of cores.\n\n"
209 "set coremask (mask)\n"
210 " Set the forwarding cores hexadecimal mask.\n\n"
212 "set portmask (mask)\n"
213 " Set the forwarding ports hexadecimal mask.\n\n"
216 " Set number of packets per burst.\n\n"
218 "set txpkts (x[,y]*)\n"
219 " Set the length of each segment of TXONLY"
222 "set corelist (x[,y]*)\n"
223 " Set the list of forwarding cores.\n\n"
225 "set portlist (x[,y]*)\n"
226 " Set the list of forwarding ports.\n\n"
228 "vlan set strip (on|off) (port_id)\n"
229 " Set the VLAN strip on a port.\n\n"
231 "vlan set filter (on|off) (port_id)\n"
232 " Set the VLAN filter on a port.\n\n"
234 "vlan set qinq (on|off) (port_id)\n"
235 " Set the VLAN QinQ (extended queue in queue)"
238 "vlan set tpid (value) (port_id)\n"
239 " Set the outer VLAN TPID for Packet Filtering on"
242 "rx_vlan add (vlan_id|all) (port_id)\n"
243 " Add a vlan_id, or all identifiers, to the set"
244 " of VLAN identifiers filtered by port_id.\n\n"
246 "rx_vlan rm (vlan_id|all) (port_id)\n"
247 " Remove a vlan_id, or all identifiers, from the set"
248 " of VLAN identifiers filtered by port_id.\n\n"
250 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
251 " Add a vlan_id, to the set of VLAN identifiers"
252 "filtered for VF(s) from port_id.\n\n"
254 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
255 " Remove a vlan_id, to the set of VLAN identifiers"
256 "filtered for VF(s) from port_id.\n\n"
258 "rx_vlan set tpid (value) (port_id)\n"
259 " Set the outer VLAN TPID for Packet Filtering on"
262 "tx_vlan set vlan_id (port_id)\n"
263 " Set hardware insertion of VLAN ID in packets sent"
266 "tx_vlan reset (port_id)\n"
267 " Disable hardware insertion of a VLAN header in"
268 " packets sent on a port.\n\n"
270 "tx_checksum set mask (port_id)\n"
271 " Enable hardware insertion of checksum offload with"
272 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
273 " bit 0 - insert ip checksum offload if set\n"
274 " bit 1 - insert udp checksum offload if set\n"
275 " bit 2 - insert tcp checksum offload if set\n"
276 " bit 3 - insert sctp checksum offload if set\n"
277 " Please check the NIC datasheet for HW limits.\n\n"
279 #ifdef RTE_LIBRTE_IEEE1588
280 "set fwd (io|mac|rxonly|txonly|csum|ieee1588)\n"
281 " Set IO, MAC, RXONLY, CSUM or TXONLY or ieee1588"
282 " packet forwarding mode.\n\n"
285 "set fwd (io|mac|rxonly|txonly|csum)\n"
286 " Set IO, MAC, RXONLY, CSUM or TXONLY packet"
287 " forwarding mode.\n\n"
290 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
291 " Add a MAC address on port_id.\n\n"
293 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
294 " Remove a MAC address from port_id.\n\n"
296 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
297 " Add a MAC address for a VF on the port.\n\n"
299 "set port (port_id) uta (mac_address|all) (on|off)\n"
300 " Add/Remove a or all unicast hash filter(s)"
303 "set promisc (port_id|all) (on|off)\n"
304 " Set the promiscuous mode on port_id, or all.\n\n"
306 "set allmulti (port_id|all) (on|off)\n"
307 " Set the allmulti mode on port_id, or all.\n\n"
309 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
310 " (low_water) (pause_time) (send_xon) (port_id)\n"
311 " Set the link flow control parameter on a port.\n\n"
313 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
314 " (low_water) (pause_time) (priority) (port_id)\n"
315 " Set the priority flow control parameter on a"
318 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
319 " Set statistics mapping (qmapping 0..15) for RX/TX"
321 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
322 " on port 0 to mapping 5.\n\n"
324 "set port (port_id) vf (vf_id) rx|tx on|off \n"
325 " Enable/Disable a VF receive/tranmit from a port\n\n"
327 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
329 " AUPE:accepts untagged VLAN;"
330 "ROPE:accept unicast hash\n\n"
331 " BAM:accepts broadcast packets;"
332 "MPE:accepts all multicast packets\n\n"
333 " Enable/Disable a VF receive mode of a port\n\n"
335 "set port (port_id) mirror-rule (rule_id)"
336 "(pool-mirror|vlan-mirror)\n"
337 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
338 " Set pool or vlan type mirror rule on a port.\n"
339 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
340 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
343 "set port (port_id) mirror-rule (rule_id)"
344 "(uplink-mirror|downlink-mirror) dst-pool"
345 "(pool_id) (on|off)\n"
346 " Set uplink or downlink type mirror rule on a port.\n"
347 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
348 " 0 on' enable mirror income traffic to pool 0.\n\n"
350 "reset port (port_id) mirror-rule (rule_id)\n"
351 " Reset a mirror rule.\n\n"
358 if (show_all || !strcmp(res->section, "flowdir")) {
363 "Flow director mode:\n"
364 "-------------------\n\n"
366 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
367 " src (src_ip_address) (src_port)"
368 " dst (dst_ip_address) (dst_port)"
369 " flexbytes (flexbytes_values) vlan (vlan_id)"
370 " queue (queue_id)\n"
371 " Add a signature filter.\n\n"
373 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
374 " src (src_ip_address) (src_port)"
375 " dst (dst_ip_address) (dst_port)"
376 " flexbytes (flexbytes_values) vlan (vlan_id)"
377 " queue (queue_id)\n"
378 " Update a signature filter.\n\n"
380 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
381 " src (src_ip_address) (src_port)"
382 " dst (dst_ip_address) (dst_port)"
383 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
384 " Remove a signature filter.\n\n"
386 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
387 " src (src_ip_address) (src_port)"
388 " dst (dst_ip_address) (dst_port)"
389 " flexbytes (flexbytes_values) vlan (vlan_id)"
390 " queue (queue_id) soft (soft_id)\n"
391 " Add a perfect filter.\n\n"
393 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
394 " src (src_ip_address) (src_port)"
395 " dst (dst_ip_address) (dst_port)"
396 " flexbytes (flexbytes_values) vlan (vlan_id)"
397 " queue (queue_id)\n"
398 " Update a perfect filter.\n\n"
400 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
401 " src (src_ip_address) (src_port)"
402 " dst (dst_ip_address) (dst_port)"
403 " flexbytes (flexbytes_values) vlan (vlan_id)"
405 " Remove a perfect filter.\n\n"
407 "set_masks_filter (port_id) only_ip_flow (0|1)"
408 " src_mask (ip_src_mask) (src_port_mask)"
409 " dst_mask (ip_dst_mask) (dst_port_mask)"
410 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
411 " Set IPv4 filter masks.\n\n"
413 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
414 " src_mask (ip_src_mask) (src_port_mask)"
415 " dst_mask (ip_dst_mask) (dst_port_mask)"
416 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
417 " compare_dst (0|1)\n"
418 " Set IPv6 filter masks.\n\n"
422 if (show_all || !strcmp(res->section, "ports")) {
428 "----------------\n\n"
430 "port start (port_id|all)\n"
431 " Start all ports or port_id.\n\n"
433 "port stop (port_id|all)\n"
434 " Stop all ports or port_id.\n\n"
436 "port close (port_id|all)\n"
437 " Close all ports or port_id.\n\n"
439 "port config (port_id|all) speed (10|100|1000|10000|auto)"
440 " duplex (half|full|auto)\n"
441 " Set speed and duplex for all ports or port_id\n\n"
443 "port config all (rxq|txq|rxd|txd) (value)\n"
444 " Set number for rxq/txq/rxd/txd.\n\n"
446 "port config all max-pkt-len (value)\n"
447 " Set the max packet length.\n\n"
449 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
451 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
454 "port config all rss (ip|udp|none)\n"
455 " Set the RSS mode.\n\n"
457 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
458 " Set the RSS redirection table.\n\n"
460 "port config (port_id) dcb vt (on|off) (traffic_class)"
462 " Set the DCB mode.\n\n"
464 "port config all burst (value)\n"
465 " Set the number of packets per burst.\n\n"
467 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
469 " Set the ring prefetch/host/writeback threshold"
470 " for tx/rx queue.\n\n"
472 "port config all (txfreet|txrst|rxfreet) (value)\n"
473 " Set free threshold for rx/tx, or set"
474 " tx rs bit threshold.\n\n"
478 if (show_all || !strcmp(res->section, "registers")) {
486 "read reg (port_id) (address)\n"
487 " Display value of a port register.\n\n"
489 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
490 " Display a port register bit field.\n\n"
492 "read regbit (port_id) (address) (bit_x)\n"
493 " Display a single port register bit.\n\n"
495 "write reg (port_id) (address) (value)\n"
496 " Set value of a port register.\n\n"
498 "write regfield (port_id) (address) (bit_x) (bit_y)"
500 " Set bit field of a port register.\n\n"
502 "write regbit (port_id) (address) (bit_x) (value)\n"
503 " Set single bit value of a port register.\n\n"
508 cmdline_parse_token_string_t cmd_help_long_help =
509 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
511 cmdline_parse_token_string_t cmd_help_long_section =
512 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
513 "all#control#display#config#flowdir#"
516 cmdline_parse_inst_t cmd_help_long = {
517 .f = cmd_help_long_parsed,
519 .help_str = "show help",
521 (void *)&cmd_help_long_help,
522 (void *)&cmd_help_long_section,
528 /* *** start/stop/close all ports *** */
529 struct cmd_operate_port_result {
530 cmdline_fixed_string_t keyword;
531 cmdline_fixed_string_t name;
532 cmdline_fixed_string_t value;
535 static void cmd_operate_port_parsed(void *parsed_result,
536 __attribute__((unused)) struct cmdline *cl,
537 __attribute__((unused)) void *data)
539 struct cmd_operate_port_result *res = parsed_result;
541 if (!strcmp(res->name, "start"))
542 start_port(RTE_PORT_ALL);
543 else if (!strcmp(res->name, "stop"))
544 stop_port(RTE_PORT_ALL);
545 else if (!strcmp(res->name, "close"))
546 close_port(RTE_PORT_ALL);
548 printf("Unknown parameter\n");
551 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
552 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
554 cmdline_parse_token_string_t cmd_operate_port_all_port =
555 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
557 cmdline_parse_token_string_t cmd_operate_port_all_all =
558 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
560 cmdline_parse_inst_t cmd_operate_port = {
561 .f = cmd_operate_port_parsed,
563 .help_str = "port start|stop|close all: start/stop/close all ports",
565 (void *)&cmd_operate_port_all_cmd,
566 (void *)&cmd_operate_port_all_port,
567 (void *)&cmd_operate_port_all_all,
572 /* *** start/stop/close specific port *** */
573 struct cmd_operate_specific_port_result {
574 cmdline_fixed_string_t keyword;
575 cmdline_fixed_string_t name;
579 static void cmd_operate_specific_port_parsed(void *parsed_result,
580 __attribute__((unused)) struct cmdline *cl,
581 __attribute__((unused)) void *data)
583 struct cmd_operate_specific_port_result *res = parsed_result;
585 if (!strcmp(res->name, "start"))
586 start_port(res->value);
587 else if (!strcmp(res->name, "stop"))
588 stop_port(res->value);
589 else if (!strcmp(res->name, "close"))
590 close_port(res->value);
592 printf("Unknown parameter\n");
595 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
596 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
598 cmdline_parse_token_string_t cmd_operate_specific_port_port =
599 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
600 name, "start#stop#close");
601 cmdline_parse_token_num_t cmd_operate_specific_port_id =
602 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
605 cmdline_parse_inst_t cmd_operate_specific_port = {
606 .f = cmd_operate_specific_port_parsed,
608 .help_str = "port start|stop|close X: start/stop/close port X",
610 (void *)&cmd_operate_specific_port_cmd,
611 (void *)&cmd_operate_specific_port_port,
612 (void *)&cmd_operate_specific_port_id,
617 /* *** configure speed for all ports *** */
618 struct cmd_config_speed_all {
619 cmdline_fixed_string_t port;
620 cmdline_fixed_string_t keyword;
621 cmdline_fixed_string_t all;
622 cmdline_fixed_string_t item1;
623 cmdline_fixed_string_t item2;
624 cmdline_fixed_string_t value1;
625 cmdline_fixed_string_t value2;
629 cmd_config_speed_all_parsed(void *parsed_result,
630 __attribute__((unused)) struct cmdline *cl,
631 __attribute__((unused)) void *data)
633 struct cmd_config_speed_all *res = parsed_result;
634 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
635 uint16_t link_duplex = 0;
638 if (!all_ports_stopped()) {
639 printf("Please stop all ports first\n");
643 if (!strcmp(res->value1, "10"))
644 link_speed = ETH_LINK_SPEED_10;
645 else if (!strcmp(res->value1, "100"))
646 link_speed = ETH_LINK_SPEED_100;
647 else if (!strcmp(res->value1, "1000"))
648 link_speed = ETH_LINK_SPEED_1000;
649 else if (!strcmp(res->value1, "10000"))
650 link_speed = ETH_LINK_SPEED_10000;
651 else if (!strcmp(res->value1, "auto"))
652 link_speed = ETH_LINK_SPEED_AUTONEG;
654 printf("Unknown parameter\n");
658 if (!strcmp(res->value2, "half"))
659 link_duplex = ETH_LINK_HALF_DUPLEX;
660 else if (!strcmp(res->value2, "full"))
661 link_duplex = ETH_LINK_FULL_DUPLEX;
662 else if (!strcmp(res->value2, "auto"))
663 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
665 printf("Unknown parameter\n");
669 for (pid = 0; pid < nb_ports; pid++) {
670 ports[pid].dev_conf.link_speed = link_speed;
671 ports[pid].dev_conf.link_duplex = link_duplex;
674 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
677 cmdline_parse_token_string_t cmd_config_speed_all_port =
678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
679 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
680 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
682 cmdline_parse_token_string_t cmd_config_speed_all_all =
683 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
684 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
685 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
686 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
687 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
688 "10#100#1000#10000#auto");
689 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
690 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
691 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
692 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
695 cmdline_parse_inst_t cmd_config_speed_all = {
696 .f = cmd_config_speed_all_parsed,
698 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
701 (void *)&cmd_config_speed_all_port,
702 (void *)&cmd_config_speed_all_keyword,
703 (void *)&cmd_config_speed_all_all,
704 (void *)&cmd_config_speed_all_item1,
705 (void *)&cmd_config_speed_all_value1,
706 (void *)&cmd_config_speed_all_item2,
707 (void *)&cmd_config_speed_all_value2,
712 /* *** configure speed for specific port *** */
713 struct cmd_config_speed_specific {
714 cmdline_fixed_string_t port;
715 cmdline_fixed_string_t keyword;
717 cmdline_fixed_string_t item1;
718 cmdline_fixed_string_t item2;
719 cmdline_fixed_string_t value1;
720 cmdline_fixed_string_t value2;
724 cmd_config_speed_specific_parsed(void *parsed_result,
725 __attribute__((unused)) struct cmdline *cl,
726 __attribute__((unused)) void *data)
728 struct cmd_config_speed_specific *res = parsed_result;
729 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
730 uint16_t link_duplex = 0;
732 if (!all_ports_stopped()) {
733 printf("Please stop all ports first\n");
737 if (res->id >= nb_ports) {
738 printf("Port id %d must be less than %d\n", res->id, nb_ports);
742 if (!strcmp(res->value1, "10"))
743 link_speed = ETH_LINK_SPEED_10;
744 else if (!strcmp(res->value1, "100"))
745 link_speed = ETH_LINK_SPEED_100;
746 else if (!strcmp(res->value1, "1000"))
747 link_speed = ETH_LINK_SPEED_1000;
748 else if (!strcmp(res->value1, "10000"))
749 link_speed = ETH_LINK_SPEED_10000;
750 else if (!strcmp(res->value1, "auto"))
751 link_speed = ETH_LINK_SPEED_AUTONEG;
753 printf("Unknown parameter\n");
757 if (!strcmp(res->value2, "half"))
758 link_duplex = ETH_LINK_HALF_DUPLEX;
759 else if (!strcmp(res->value2, "full"))
760 link_duplex = ETH_LINK_FULL_DUPLEX;
761 else if (!strcmp(res->value2, "auto"))
762 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
764 printf("Unknown parameter\n");
768 ports[res->id].dev_conf.link_speed = link_speed;
769 ports[res->id].dev_conf.link_duplex = link_duplex;
771 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
775 cmdline_parse_token_string_t cmd_config_speed_specific_port =
776 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
778 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
779 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
781 cmdline_parse_token_num_t cmd_config_speed_specific_id =
782 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
783 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
784 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
786 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
787 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
788 "10#100#1000#10000#auto");
789 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
790 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
792 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
793 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
796 cmdline_parse_inst_t cmd_config_speed_specific = {
797 .f = cmd_config_speed_specific_parsed,
799 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
802 (void *)&cmd_config_speed_specific_port,
803 (void *)&cmd_config_speed_specific_keyword,
804 (void *)&cmd_config_speed_specific_id,
805 (void *)&cmd_config_speed_specific_item1,
806 (void *)&cmd_config_speed_specific_value1,
807 (void *)&cmd_config_speed_specific_item2,
808 (void *)&cmd_config_speed_specific_value2,
813 /* *** configure txq/rxq, txd/rxd *** */
814 struct cmd_config_rx_tx {
815 cmdline_fixed_string_t port;
816 cmdline_fixed_string_t keyword;
817 cmdline_fixed_string_t all;
818 cmdline_fixed_string_t name;
823 cmd_config_rx_tx_parsed(void *parsed_result,
824 __attribute__((unused)) struct cmdline *cl,
825 __attribute__((unused)) void *data)
827 struct cmd_config_rx_tx *res = parsed_result;
829 if (!all_ports_stopped()) {
830 printf("Please stop all ports first\n");
834 if (!strcmp(res->name, "rxq")) {
835 if (res->value <= 0) {
836 printf("rxq %d invalid - must be > 0\n", res->value);
841 else if (!strcmp(res->name, "txq")) {
842 if (res->value <= 0) {
843 printf("txq %d invalid - must be > 0\n", res->value);
848 else if (!strcmp(res->name, "rxd")) {
849 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
850 printf("rxd %d invalid - must be > 0 && <= %d\n",
851 res->value, RTE_TEST_RX_DESC_MAX);
855 } else if (!strcmp(res->name, "txd")) {
856 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
857 printf("txd %d invalid - must be > 0 && <= %d\n",
858 res->value, RTE_TEST_TX_DESC_MAX);
863 printf("Unknown parameter\n");
869 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
872 cmdline_parse_token_string_t cmd_config_rx_tx_port =
873 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
874 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
875 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
876 cmdline_parse_token_string_t cmd_config_rx_tx_all =
877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
878 cmdline_parse_token_string_t cmd_config_rx_tx_name =
879 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
881 cmdline_parse_token_num_t cmd_config_rx_tx_value =
882 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
884 cmdline_parse_inst_t cmd_config_rx_tx = {
885 .f = cmd_config_rx_tx_parsed,
887 .help_str = "port config all rxq|txq|rxd|txd value",
889 (void *)&cmd_config_rx_tx_port,
890 (void *)&cmd_config_rx_tx_keyword,
891 (void *)&cmd_config_rx_tx_all,
892 (void *)&cmd_config_rx_tx_name,
893 (void *)&cmd_config_rx_tx_value,
898 /* *** config max packet length *** */
899 struct cmd_config_max_pkt_len_result {
900 cmdline_fixed_string_t port;
901 cmdline_fixed_string_t keyword;
902 cmdline_fixed_string_t all;
903 cmdline_fixed_string_t name;
908 cmd_config_max_pkt_len_parsed(void *parsed_result,
909 __attribute__((unused)) struct cmdline *cl,
910 __attribute__((unused)) void *data)
912 struct cmd_config_max_pkt_len_result *res = parsed_result;
914 if (!all_ports_stopped()) {
915 printf("Please stop all ports first\n");
919 if (!strcmp(res->name, "max-pkt-len")) {
920 if (res->value < ETHER_MIN_LEN) {
921 printf("max-pkt-len can not be less than %d\n",
925 if (res->value == rx_mode.max_rx_pkt_len)
928 rx_mode.max_rx_pkt_len = res->value;
929 if (res->value > ETHER_MAX_LEN)
930 rx_mode.jumbo_frame = 1;
932 rx_mode.jumbo_frame = 0;
934 printf("Unknown parameter\n");
940 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
943 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
944 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
946 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
947 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
949 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
950 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
952 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
953 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
955 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
956 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
959 cmdline_parse_inst_t cmd_config_max_pkt_len = {
960 .f = cmd_config_max_pkt_len_parsed,
962 .help_str = "port config all max-pkt-len value",
964 (void *)&cmd_config_max_pkt_len_port,
965 (void *)&cmd_config_max_pkt_len_keyword,
966 (void *)&cmd_config_max_pkt_len_all,
967 (void *)&cmd_config_max_pkt_len_name,
968 (void *)&cmd_config_max_pkt_len_value,
973 /* *** configure rx mode *** */
974 struct cmd_config_rx_mode_flag {
975 cmdline_fixed_string_t port;
976 cmdline_fixed_string_t keyword;
977 cmdline_fixed_string_t all;
978 cmdline_fixed_string_t name;
979 cmdline_fixed_string_t value;
983 cmd_config_rx_mode_flag_parsed(void *parsed_result,
984 __attribute__((unused)) struct cmdline *cl,
985 __attribute__((unused)) void *data)
987 struct cmd_config_rx_mode_flag *res = parsed_result;
989 if (!all_ports_stopped()) {
990 printf("Please stop all ports first\n");
994 if (!strcmp(res->name, "crc-strip")) {
995 if (!strcmp(res->value, "on"))
996 rx_mode.hw_strip_crc = 1;
997 else if (!strcmp(res->value, "off"))
998 rx_mode.hw_strip_crc = 0;
1000 printf("Unknown parameter\n");
1003 } else if (!strcmp(res->name, "rx-cksum")) {
1004 if (!strcmp(res->value, "on"))
1005 rx_mode.hw_ip_checksum = 1;
1006 else if (!strcmp(res->value, "off"))
1007 rx_mode.hw_ip_checksum = 0;
1009 printf("Unknown parameter\n");
1012 } else if (!strcmp(res->name, "hw-vlan")) {
1013 if (!strcmp(res->value, "on")) {
1014 rx_mode.hw_vlan_filter = 1;
1015 rx_mode.hw_vlan_strip = 1;
1017 else if (!strcmp(res->value, "off")) {
1018 rx_mode.hw_vlan_filter = 0;
1019 rx_mode.hw_vlan_strip = 0;
1022 printf("Unknown parameter\n");
1025 } else if (!strcmp(res->name, "drop-en")) {
1026 if (!strcmp(res->value, "on"))
1028 else if (!strcmp(res->value, "off"))
1031 printf("Unknown parameter\n");
1035 printf("Unknown parameter\n");
1041 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1044 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1045 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1046 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1047 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1049 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1050 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1051 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1052 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1053 "crc-strip#rx-cksum#hw-vlan");
1054 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1055 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1058 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1059 .f = cmd_config_rx_mode_flag_parsed,
1061 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1063 (void *)&cmd_config_rx_mode_flag_port,
1064 (void *)&cmd_config_rx_mode_flag_keyword,
1065 (void *)&cmd_config_rx_mode_flag_all,
1066 (void *)&cmd_config_rx_mode_flag_name,
1067 (void *)&cmd_config_rx_mode_flag_value,
1072 /* *** configure rss *** */
1073 struct cmd_config_rss {
1074 cmdline_fixed_string_t port;
1075 cmdline_fixed_string_t keyword;
1076 cmdline_fixed_string_t all;
1077 cmdline_fixed_string_t name;
1078 cmdline_fixed_string_t value;
1082 cmd_config_rss_parsed(void *parsed_result,
1083 __attribute__((unused)) struct cmdline *cl,
1084 __attribute__((unused)) void *data)
1086 struct cmd_config_rss *res = parsed_result;
1088 if (!all_ports_stopped()) {
1089 printf("Please stop all ports first\n");
1093 if (!strcmp(res->value, "ip"))
1094 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1095 else if (!strcmp(res->value, "udp"))
1096 rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
1097 else if (!strcmp(res->value, "none"))
1100 printf("Unknown parameter\n");
1106 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1109 cmdline_parse_token_string_t cmd_config_rss_port =
1110 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1111 cmdline_parse_token_string_t cmd_config_rss_keyword =
1112 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1113 cmdline_parse_token_string_t cmd_config_rss_all =
1114 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1115 cmdline_parse_token_string_t cmd_config_rss_name =
1116 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1117 cmdline_parse_token_string_t cmd_config_rss_value =
1118 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1120 cmdline_parse_inst_t cmd_config_rss = {
1121 .f = cmd_config_rss_parsed,
1123 .help_str = "port config all rss ip|udp|none",
1125 (void *)&cmd_config_rss_port,
1126 (void *)&cmd_config_rss_keyword,
1127 (void *)&cmd_config_rss_all,
1128 (void *)&cmd_config_rss_name,
1129 (void *)&cmd_config_rss_value,
1134 /* *** Configure RSS RETA *** */
1135 struct cmd_config_rss_reta {
1136 cmdline_fixed_string_t port;
1137 cmdline_fixed_string_t keyword;
1139 cmdline_fixed_string_t name;
1140 cmdline_fixed_string_t list_name;
1141 cmdline_fixed_string_t list_of_items;
1145 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1152 const char *p, *p0 = str;
1159 unsigned long int_fld[_NUM_FLD];
1160 char *str_fld[_NUM_FLD];
1162 while ((p = strchr(p0,'(')) != NULL) {
1164 if((p0 = strchr(p,')')) == NULL)
1168 if(size >= sizeof(s))
1171 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1172 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1174 for (i = 0; i < _NUM_FLD; i++) {
1176 int_fld[i] = strtoul(str_fld[i], &end, 0);
1177 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1181 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1182 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1184 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1185 printf("Invalid RETA hash index=%d",hash_index);
1189 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1190 reta_conf->mask_lo |= (1ULL << hash_index);
1192 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1194 reta_conf->reta[hash_index] = nb_queue;
1201 cmd_set_rss_reta_parsed(void *parsed_result,
1202 __attribute__((unused)) struct cmdline *cl,
1203 __attribute__((unused)) void *data)
1206 struct rte_eth_rss_reta reta_conf;
1207 struct cmd_config_rss_reta *res = parsed_result;
1209 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1210 if (!strcmp(res->list_name, "reta")) {
1211 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1212 printf("Invalid RSS Redirection Table config entered\n");
1215 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1217 printf("Bad redirection table parameter, return code = %d \n",ret);
1221 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1222 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1223 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1225 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1226 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1227 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1228 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1229 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1230 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1231 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1232 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1234 cmdline_parse_inst_t cmd_config_rss_reta = {
1235 .f = cmd_set_rss_reta_parsed,
1237 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1239 (void *)&cmd_config_rss_reta_port,
1240 (void *)&cmd_config_rss_reta_keyword,
1241 (void *)&cmd_config_rss_reta_port_id,
1242 (void *)&cmd_config_rss_reta_name,
1243 (void *)&cmd_config_rss_reta_list_name,
1244 (void *)&cmd_config_rss_reta_list_of_items,
1249 /* *** SHOW PORT INFO *** */
1250 struct cmd_showport_reta {
1251 cmdline_fixed_string_t show;
1252 cmdline_fixed_string_t port;
1254 cmdline_fixed_string_t rss;
1255 cmdline_fixed_string_t reta;
1260 static void cmd_showport_reta_parsed(void *parsed_result,
1261 __attribute__((unused)) struct cmdline *cl,
1262 __attribute__((unused)) void *data)
1264 struct cmd_showport_reta *res = parsed_result;
1265 struct rte_eth_rss_reta reta_conf;
1267 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1268 printf("Invalid RSS Redirection Table config entered\n");
1272 reta_conf.mask_lo = res->mask_lo;
1273 reta_conf.mask_hi = res->mask_hi;
1275 port_rss_reta_info(res->port_id,&reta_conf);
1278 cmdline_parse_token_string_t cmd_showport_reta_show =
1279 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1280 cmdline_parse_token_string_t cmd_showport_reta_port =
1281 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1282 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1283 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1284 cmdline_parse_token_string_t cmd_showport_reta_rss =
1285 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1286 cmdline_parse_token_string_t cmd_showport_reta_reta =
1287 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1288 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1289 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1290 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1291 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1293 cmdline_parse_inst_t cmd_showport_reta = {
1294 .f = cmd_showport_reta_parsed,
1296 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1297 (mask_lo and mask_hi is UINT64)",
1299 (void *)&cmd_showport_reta_show,
1300 (void *)&cmd_showport_reta_port,
1301 (void *)&cmd_showport_reta_port_id,
1302 (void *)&cmd_showport_reta_rss,
1303 (void *)&cmd_showport_reta_reta,
1304 (void *)&cmd_showport_reta_mask_lo,
1305 (void *)&cmd_showport_reta_mask_hi,
1310 /* *** Configure DCB *** */
1311 struct cmd_config_dcb {
1312 cmdline_fixed_string_t port;
1313 cmdline_fixed_string_t config;
1315 cmdline_fixed_string_t dcb;
1316 cmdline_fixed_string_t vt;
1317 cmdline_fixed_string_t vt_en;
1319 cmdline_fixed_string_t pfc;
1320 cmdline_fixed_string_t pfc_en;
1324 cmd_config_dcb_parsed(void *parsed_result,
1325 __attribute__((unused)) struct cmdline *cl,
1326 __attribute__((unused)) void *data)
1328 struct cmd_config_dcb *res = parsed_result;
1329 struct dcb_config dcb_conf;
1330 portid_t port_id = res->port_id;
1331 struct rte_port *port;
1333 port = &ports[port_id];
1334 /** Check if the port is not started **/
1335 if (port->port_status != RTE_PORT_STOPPED) {
1336 printf("Please stop port %d first\n",port_id);
1340 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1341 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1342 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1346 /* DCB in VT mode */
1347 if (!strncmp(res->vt_en, "on",2))
1348 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1350 dcb_conf.dcb_mode = DCB_ENABLED;
1352 if (!strncmp(res->pfc_en, "on",2)) {
1353 dcb_conf.pfc_en = 1;
1356 dcb_conf.pfc_en = 0;
1358 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1359 printf("Cannot initialize network ports\n");
1363 cmd_reconfig_device_queue(port_id, 1, 1);
1366 cmdline_parse_token_string_t cmd_config_dcb_port =
1367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1368 cmdline_parse_token_string_t cmd_config_dcb_config =
1369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1370 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1371 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1372 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1374 cmdline_parse_token_string_t cmd_config_dcb_vt =
1375 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1376 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1377 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1378 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1379 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1380 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1381 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1382 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1383 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1385 cmdline_parse_inst_t cmd_config_dcb = {
1386 .f = cmd_config_dcb_parsed,
1388 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1390 (void *)&cmd_config_dcb_port,
1391 (void *)&cmd_config_dcb_config,
1392 (void *)&cmd_config_dcb_port_id,
1393 (void *)&cmd_config_dcb_dcb,
1394 (void *)&cmd_config_dcb_vt,
1395 (void *)&cmd_config_dcb_vt_en,
1396 (void *)&cmd_config_dcb_num_tcs,
1397 (void *)&cmd_config_dcb_pfc,
1398 (void *)&cmd_config_dcb_pfc_en,
1403 /* *** configure number of packets per burst *** */
1404 struct cmd_config_burst {
1405 cmdline_fixed_string_t port;
1406 cmdline_fixed_string_t keyword;
1407 cmdline_fixed_string_t all;
1408 cmdline_fixed_string_t name;
1413 cmd_config_burst_parsed(void *parsed_result,
1414 __attribute__((unused)) struct cmdline *cl,
1415 __attribute__((unused)) void *data)
1417 struct cmd_config_burst *res = parsed_result;
1419 if (!all_ports_stopped()) {
1420 printf("Please stop all ports first\n");
1424 if (!strcmp(res->name, "burst")) {
1425 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1426 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1429 nb_pkt_per_burst = res->value;
1431 printf("Unknown parameter\n");
1437 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1440 cmdline_parse_token_string_t cmd_config_burst_port =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1442 cmdline_parse_token_string_t cmd_config_burst_keyword =
1443 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1444 cmdline_parse_token_string_t cmd_config_burst_all =
1445 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1446 cmdline_parse_token_string_t cmd_config_burst_name =
1447 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1448 cmdline_parse_token_num_t cmd_config_burst_value =
1449 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1451 cmdline_parse_inst_t cmd_config_burst = {
1452 .f = cmd_config_burst_parsed,
1454 .help_str = "port config all burst value",
1456 (void *)&cmd_config_burst_port,
1457 (void *)&cmd_config_burst_keyword,
1458 (void *)&cmd_config_burst_all,
1459 (void *)&cmd_config_burst_name,
1460 (void *)&cmd_config_burst_value,
1465 /* *** configure rx/tx queues *** */
1466 struct cmd_config_thresh {
1467 cmdline_fixed_string_t port;
1468 cmdline_fixed_string_t keyword;
1469 cmdline_fixed_string_t all;
1470 cmdline_fixed_string_t name;
1475 cmd_config_thresh_parsed(void *parsed_result,
1476 __attribute__((unused)) struct cmdline *cl,
1477 __attribute__((unused)) void *data)
1479 struct cmd_config_thresh *res = parsed_result;
1481 if (!all_ports_stopped()) {
1482 printf("Please stop all ports first\n");
1486 if (!strcmp(res->name, "txpt"))
1487 tx_thresh.pthresh = res->value;
1488 else if(!strcmp(res->name, "txht"))
1489 tx_thresh.hthresh = res->value;
1490 else if(!strcmp(res->name, "txwt"))
1491 tx_thresh.wthresh = res->value;
1492 else if(!strcmp(res->name, "rxpt"))
1493 rx_thresh.pthresh = res->value;
1494 else if(!strcmp(res->name, "rxht"))
1495 rx_thresh.hthresh = res->value;
1496 else if(!strcmp(res->name, "rxwt"))
1497 rx_thresh.wthresh = res->value;
1499 printf("Unknown parameter\n");
1505 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1508 cmdline_parse_token_string_t cmd_config_thresh_port =
1509 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1510 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1511 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1512 cmdline_parse_token_string_t cmd_config_thresh_all =
1513 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1514 cmdline_parse_token_string_t cmd_config_thresh_name =
1515 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1516 "txpt#txht#txwt#rxpt#rxht#rxwt");
1517 cmdline_parse_token_num_t cmd_config_thresh_value =
1518 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1520 cmdline_parse_inst_t cmd_config_thresh = {
1521 .f = cmd_config_thresh_parsed,
1523 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1525 (void *)&cmd_config_thresh_port,
1526 (void *)&cmd_config_thresh_keyword,
1527 (void *)&cmd_config_thresh_all,
1528 (void *)&cmd_config_thresh_name,
1529 (void *)&cmd_config_thresh_value,
1534 /* *** configure free/rs threshold *** */
1535 struct cmd_config_threshold {
1536 cmdline_fixed_string_t port;
1537 cmdline_fixed_string_t keyword;
1538 cmdline_fixed_string_t all;
1539 cmdline_fixed_string_t name;
1544 cmd_config_threshold_parsed(void *parsed_result,
1545 __attribute__((unused)) struct cmdline *cl,
1546 __attribute__((unused)) void *data)
1548 struct cmd_config_threshold *res = parsed_result;
1550 if (!all_ports_stopped()) {
1551 printf("Please stop all ports first\n");
1555 if (!strcmp(res->name, "txfreet"))
1556 tx_free_thresh = res->value;
1557 else if (!strcmp(res->name, "txrst"))
1558 tx_rs_thresh = res->value;
1559 else if (!strcmp(res->name, "rxfreet"))
1560 rx_free_thresh = res->value;
1562 printf("Unknown parameter\n");
1568 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1571 cmdline_parse_token_string_t cmd_config_threshold_port =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1573 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1576 cmdline_parse_token_string_t cmd_config_threshold_all =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1578 cmdline_parse_token_string_t cmd_config_threshold_name =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1580 "txfreet#txrst#rxfreet");
1581 cmdline_parse_token_num_t cmd_config_threshold_value =
1582 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1584 cmdline_parse_inst_t cmd_config_threshold = {
1585 .f = cmd_config_threshold_parsed,
1587 .help_str = "port config all txfreet|txrst|rxfreet value",
1589 (void *)&cmd_config_threshold_port,
1590 (void *)&cmd_config_threshold_keyword,
1591 (void *)&cmd_config_threshold_all,
1592 (void *)&cmd_config_threshold_name,
1593 (void *)&cmd_config_threshold_value,
1599 struct cmd_stop_result {
1600 cmdline_fixed_string_t stop;
1603 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1604 __attribute__((unused)) struct cmdline *cl,
1605 __attribute__((unused)) void *data)
1607 stop_packet_forwarding();
1610 cmdline_parse_token_string_t cmd_stop_stop =
1611 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1613 cmdline_parse_inst_t cmd_stop = {
1614 .f = cmd_stop_parsed,
1616 .help_str = "stop - stop packet forwarding",
1618 (void *)&cmd_stop_stop,
1623 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1626 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1627 unsigned int *parsed_items, int check_unique_values)
1629 unsigned int nb_item;
1637 * First parse all items in the list and store their value.
1642 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1644 if ((c >= '0') && (c <= '9')) {
1645 value = (unsigned int) (value * 10 + (c - '0'));
1650 printf("character %c is not a decimal digit\n", c);
1654 printf("No valid value before comma\n");
1657 if (nb_item < max_items) {
1658 parsed_items[nb_item] = value;
1664 if (nb_item >= max_items) {
1665 printf("Number of %s = %u > %u (maximum items)\n",
1666 item_name, nb_item + 1, max_items);
1669 parsed_items[nb_item++] = value;
1670 if (! check_unique_values)
1674 * Then, check that all values in the list are differents.
1675 * No optimization here...
1677 for (i = 0; i < nb_item; i++) {
1678 for (j = i + 1; j < nb_item; j++) {
1679 if (parsed_items[j] == parsed_items[i]) {
1680 printf("duplicated %s %u at index %u and %u\n",
1681 item_name, parsed_items[i], i, j);
1689 struct cmd_set_list_result {
1690 cmdline_fixed_string_t cmd_keyword;
1691 cmdline_fixed_string_t list_name;
1692 cmdline_fixed_string_t list_of_items;
1695 static void cmd_set_list_parsed(void *parsed_result,
1696 __attribute__((unused)) struct cmdline *cl,
1697 __attribute__((unused)) void *data)
1699 struct cmd_set_list_result *res;
1701 unsigned int lcorelist[RTE_MAX_LCORE];
1702 unsigned int portlist[RTE_MAX_ETHPORTS];
1704 unsigned int nb_item;
1706 res = parsed_result;
1707 if (!strcmp(res->list_name, "corelist")) {
1708 nb_item = parse_item_list(res->list_of_items, "core",
1710 parsed_items.lcorelist, 1);
1712 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1715 if (!strcmp(res->list_name, "portlist")) {
1716 nb_item = parse_item_list(res->list_of_items, "port",
1718 parsed_items.portlist, 1);
1720 set_fwd_ports_list(parsed_items.portlist, nb_item);
1724 cmdline_parse_token_string_t cmd_set_list_keyword =
1725 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1727 cmdline_parse_token_string_t cmd_set_list_name =
1728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1729 "corelist#portlist");
1730 cmdline_parse_token_string_t cmd_set_list_of_items =
1731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1734 cmdline_parse_inst_t cmd_set_fwd_list = {
1735 .f = cmd_set_list_parsed,
1737 .help_str = "set corelist|portlist x[,y]*",
1739 (void *)&cmd_set_list_keyword,
1740 (void *)&cmd_set_list_name,
1741 (void *)&cmd_set_list_of_items,
1746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
1748 struct cmd_setmask_result {
1749 cmdline_fixed_string_t set;
1750 cmdline_fixed_string_t mask;
1754 static void cmd_set_mask_parsed(void *parsed_result,
1755 __attribute__((unused)) struct cmdline *cl,
1756 __attribute__((unused)) void *data)
1758 struct cmd_setmask_result *res = parsed_result;
1760 if (!strcmp(res->mask, "coremask"))
1761 set_fwd_lcores_mask(res->hexavalue);
1762 else if (!strcmp(res->mask, "portmask"))
1763 set_fwd_ports_mask(res->hexavalue);
1766 cmdline_parse_token_string_t cmd_setmask_set =
1767 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
1768 cmdline_parse_token_string_t cmd_setmask_mask =
1769 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
1770 "coremask#portmask");
1771 cmdline_parse_token_num_t cmd_setmask_value =
1772 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
1774 cmdline_parse_inst_t cmd_set_fwd_mask = {
1775 .f = cmd_set_mask_parsed,
1777 .help_str = "set coremask|portmask hexadecimal value",
1779 (void *)&cmd_setmask_set,
1780 (void *)&cmd_setmask_mask,
1781 (void *)&cmd_setmask_value,
1787 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
1789 struct cmd_set_result {
1790 cmdline_fixed_string_t set;
1791 cmdline_fixed_string_t what;
1795 static void cmd_set_parsed(void *parsed_result,
1796 __attribute__((unused)) struct cmdline *cl,
1797 __attribute__((unused)) void *data)
1799 struct cmd_set_result *res = parsed_result;
1800 if (!strcmp(res->what, "nbport"))
1801 set_fwd_ports_number(res->value);
1802 else if (!strcmp(res->what, "nbcore"))
1803 set_fwd_lcores_number(res->value);
1804 else if (!strcmp(res->what, "burst"))
1805 set_nb_pkt_per_burst(res->value);
1806 else if (!strcmp(res->what, "verbose"))
1807 set_verbose_level(res->value);
1810 cmdline_parse_token_string_t cmd_set_set =
1811 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
1812 cmdline_parse_token_string_t cmd_set_what =
1813 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
1814 "nbport#nbcore#burst#verbose");
1815 cmdline_parse_token_num_t cmd_set_value =
1816 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
1818 cmdline_parse_inst_t cmd_set_numbers = {
1819 .f = cmd_set_parsed,
1821 .help_str = "set nbport|nbcore|burst|verbose value",
1823 (void *)&cmd_set_set,
1824 (void *)&cmd_set_what,
1825 (void *)&cmd_set_value,
1830 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
1832 struct cmd_set_txpkts_result {
1833 cmdline_fixed_string_t cmd_keyword;
1834 cmdline_fixed_string_t txpkts;
1835 cmdline_fixed_string_t seg_lengths;
1839 cmd_set_txpkts_parsed(void *parsed_result,
1840 __attribute__((unused)) struct cmdline *cl,
1841 __attribute__((unused)) void *data)
1843 struct cmd_set_txpkts_result *res;
1844 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
1845 unsigned int nb_segs;
1847 res = parsed_result;
1848 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
1849 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
1851 set_tx_pkt_segments(seg_lengths, nb_segs);
1854 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
1855 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1856 cmd_keyword, "set");
1857 cmdline_parse_token_string_t cmd_set_txpkts_name =
1858 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1860 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
1861 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
1864 cmdline_parse_inst_t cmd_set_txpkts = {
1865 .f = cmd_set_txpkts_parsed,
1867 .help_str = "set txpkts x[,y]*",
1869 (void *)&cmd_set_txpkts_keyword,
1870 (void *)&cmd_set_txpkts_name,
1871 (void *)&cmd_set_txpkts_lengths,
1876 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
1877 struct cmd_rx_vlan_filter_all_result {
1878 cmdline_fixed_string_t rx_vlan;
1879 cmdline_fixed_string_t what;
1880 cmdline_fixed_string_t all;
1885 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
1886 __attribute__((unused)) struct cmdline *cl,
1887 __attribute__((unused)) void *data)
1889 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
1891 if (!strcmp(res->what, "add"))
1892 rx_vlan_all_filter_set(res->port_id, 1);
1894 rx_vlan_all_filter_set(res->port_id, 0);
1897 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
1898 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1899 rx_vlan, "rx_vlan");
1900 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
1901 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1903 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
1904 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1906 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
1907 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
1910 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
1911 .f = cmd_rx_vlan_filter_all_parsed,
1913 .help_str = "add/remove all identifiers to/from the set of VLAN "
1914 "Identifiers filtered by a port",
1916 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
1917 (void *)&cmd_rx_vlan_filter_all_what,
1918 (void *)&cmd_rx_vlan_filter_all_all,
1919 (void *)&cmd_rx_vlan_filter_all_portid,
1924 /* *** VLAN OFFLOAD SET ON A PORT *** */
1925 struct cmd_vlan_offload_result {
1926 cmdline_fixed_string_t vlan;
1927 cmdline_fixed_string_t set;
1928 cmdline_fixed_string_t what;
1929 cmdline_fixed_string_t on;
1930 cmdline_fixed_string_t port_id;
1934 cmd_vlan_offload_parsed(void *parsed_result,
1935 __attribute__((unused)) struct cmdline *cl,
1936 __attribute__((unused)) void *data)
1939 struct cmd_vlan_offload_result *res = parsed_result;
1942 portid_t port_id = 0;
1946 len = strnlen(str, STR_TOKEN_SIZE);
1948 /* Get port_id first */
1956 tmp = strtoul(str, NULL, 0);
1957 /* If port_id greater that what portid_t can represent, return */
1958 if(tmp >= RTE_MAX_ETHPORTS)
1960 port_id = (portid_t)tmp;
1962 if (!strcmp(res->on, "on"))
1967 if (!strcmp(res->what, "strip"))
1968 rx_vlan_strip_set(port_id, on);
1969 else if(!strcmp(res->what, "stripq")){
1970 uint16_t queue_id = 0;
1972 /* No queue_id, return */
1975 tmp = strtoul(str + i + 1, NULL, 0);
1976 /* If queue_id greater that what 16-bits can represent, return */
1980 queue_id = (uint16_t)tmp;
1981 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
1983 else if (!strcmp(res->what, "filter"))
1984 rx_vlan_filter_set(port_id, on);
1986 vlan_extend_set(port_id, on);
1991 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
1992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1994 cmdline_parse_token_string_t cmd_vlan_offload_set =
1995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1997 cmdline_parse_token_string_t cmd_vlan_offload_what =
1998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
1999 what, "strip#filter#qinq#stripq");
2000 cmdline_parse_token_string_t cmd_vlan_offload_on =
2001 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2003 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2004 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2007 cmdline_parse_inst_t cmd_vlan_offload = {
2008 .f = cmd_vlan_offload_parsed,
2010 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2011 " qinq(extended) for both rx/tx sides ",
2013 (void *)&cmd_vlan_offload_vlan,
2014 (void *)&cmd_vlan_offload_set,
2015 (void *)&cmd_vlan_offload_what,
2016 (void *)&cmd_vlan_offload_on,
2017 (void *)&cmd_vlan_offload_portid,
2022 /* *** VLAN TPID SET ON A PORT *** */
2023 struct cmd_vlan_tpid_result {
2024 cmdline_fixed_string_t vlan;
2025 cmdline_fixed_string_t set;
2026 cmdline_fixed_string_t what;
2032 cmd_vlan_tpid_parsed(void *parsed_result,
2033 __attribute__((unused)) struct cmdline *cl,
2034 __attribute__((unused)) void *data)
2036 struct cmd_vlan_tpid_result *res = parsed_result;
2037 vlan_tpid_set(res->port_id, res->tp_id);
2041 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2042 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2044 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2045 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2047 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2048 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2050 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2051 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2053 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2054 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2057 cmdline_parse_inst_t cmd_vlan_tpid = {
2058 .f = cmd_vlan_tpid_parsed,
2060 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2062 (void *)&cmd_vlan_tpid_vlan,
2063 (void *)&cmd_vlan_tpid_set,
2064 (void *)&cmd_vlan_tpid_what,
2065 (void *)&cmd_vlan_tpid_tpid,
2066 (void *)&cmd_vlan_tpid_portid,
2071 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2072 struct cmd_rx_vlan_filter_result {
2073 cmdline_fixed_string_t rx_vlan;
2074 cmdline_fixed_string_t what;
2080 cmd_rx_vlan_filter_parsed(void *parsed_result,
2081 __attribute__((unused)) struct cmdline *cl,
2082 __attribute__((unused)) void *data)
2084 struct cmd_rx_vlan_filter_result *res = parsed_result;
2086 if (!strcmp(res->what, "add"))
2087 rx_vft_set(res->port_id, res->vlan_id, 1);
2089 rx_vft_set(res->port_id, res->vlan_id, 0);
2092 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2093 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2094 rx_vlan, "rx_vlan");
2095 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2096 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2098 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2099 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2101 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2102 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2105 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2106 .f = cmd_rx_vlan_filter_parsed,
2108 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2109 "Identifiers filtered by a port",
2111 (void *)&cmd_rx_vlan_filter_rx_vlan,
2112 (void *)&cmd_rx_vlan_filter_what,
2113 (void *)&cmd_rx_vlan_filter_vlanid,
2114 (void *)&cmd_rx_vlan_filter_portid,
2119 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2120 struct cmd_tx_vlan_set_result {
2121 cmdline_fixed_string_t tx_vlan;
2122 cmdline_fixed_string_t set;
2128 cmd_tx_vlan_set_parsed(void *parsed_result,
2129 __attribute__((unused)) struct cmdline *cl,
2130 __attribute__((unused)) void *data)
2132 struct cmd_tx_vlan_set_result *res = parsed_result;
2133 tx_vlan_set(res->port_id, res->vlan_id);
2136 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2137 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2138 tx_vlan, "tx_vlan");
2139 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2140 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2142 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2143 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2145 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2146 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2149 cmdline_parse_inst_t cmd_tx_vlan_set = {
2150 .f = cmd_tx_vlan_set_parsed,
2152 .help_str = "enable hardware insertion of a VLAN header with a given "
2153 "TAG Identifier in packets sent on a port",
2155 (void *)&cmd_tx_vlan_set_tx_vlan,
2156 (void *)&cmd_tx_vlan_set_set,
2157 (void *)&cmd_tx_vlan_set_vlanid,
2158 (void *)&cmd_tx_vlan_set_portid,
2163 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2164 struct cmd_tx_vlan_reset_result {
2165 cmdline_fixed_string_t tx_vlan;
2166 cmdline_fixed_string_t reset;
2171 cmd_tx_vlan_reset_parsed(void *parsed_result,
2172 __attribute__((unused)) struct cmdline *cl,
2173 __attribute__((unused)) void *data)
2175 struct cmd_tx_vlan_reset_result *res = parsed_result;
2177 tx_vlan_reset(res->port_id);
2180 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2181 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2182 tx_vlan, "tx_vlan");
2183 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2184 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2186 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2187 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2190 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2191 .f = cmd_tx_vlan_reset_parsed,
2193 .help_str = "disable hardware insertion of a VLAN header in packets "
2196 (void *)&cmd_tx_vlan_reset_tx_vlan,
2197 (void *)&cmd_tx_vlan_reset_reset,
2198 (void *)&cmd_tx_vlan_reset_portid,
2204 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2205 struct cmd_tx_cksum_set_result {
2206 cmdline_fixed_string_t tx_cksum;
2207 cmdline_fixed_string_t set;
2213 cmd_tx_cksum_set_parsed(void *parsed_result,
2214 __attribute__((unused)) struct cmdline *cl,
2215 __attribute__((unused)) void *data)
2217 struct cmd_tx_cksum_set_result *res = parsed_result;
2219 tx_cksum_set(res->port_id, res->cksum_mask);
2222 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2223 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2224 tx_cksum, "tx_checksum");
2225 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2226 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2228 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2229 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2231 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2232 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2235 cmdline_parse_inst_t cmd_tx_cksum_set = {
2236 .f = cmd_tx_cksum_set_parsed,
2238 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2239 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2240 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2242 (void *)&cmd_tx_cksum_set_tx_cksum,
2243 (void *)&cmd_tx_cksum_set_set,
2244 (void *)&cmd_tx_cksum_set_cksum_mask,
2245 (void *)&cmd_tx_cksum_set_portid,
2250 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2251 struct cmd_set_flush_rx {
2252 cmdline_fixed_string_t set;
2253 cmdline_fixed_string_t flush_rx;
2254 cmdline_fixed_string_t mode;
2258 cmd_set_flush_rx_parsed(void *parsed_result,
2259 __attribute__((unused)) struct cmdline *cl,
2260 __attribute__((unused)) void *data)
2262 struct cmd_set_flush_rx *res = parsed_result;
2263 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2266 cmdline_parse_token_string_t cmd_setflushrx_set =
2267 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2269 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2270 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2271 flush_rx, "flush_rx");
2272 cmdline_parse_token_string_t cmd_setflushrx_mode =
2273 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2277 cmdline_parse_inst_t cmd_set_flush_rx = {
2278 .f = cmd_set_flush_rx_parsed,
2279 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2282 (void *)&cmd_setflushrx_set,
2283 (void *)&cmd_setflushrx_flush_rx,
2284 (void *)&cmd_setflushrx_mode,
2289 /* *** SET FORWARDING MODE *** */
2290 struct cmd_set_fwd_mode_result {
2291 cmdline_fixed_string_t set;
2292 cmdline_fixed_string_t fwd;
2293 cmdline_fixed_string_t mode;
2296 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2297 __attribute__((unused)) struct cmdline *cl,
2298 __attribute__((unused)) void *data)
2300 struct cmd_set_fwd_mode_result *res = parsed_result;
2302 set_pkt_forwarding_mode(res->mode);
2305 cmdline_parse_token_string_t cmd_setfwd_set =
2306 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2307 cmdline_parse_token_string_t cmd_setfwd_fwd =
2308 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2309 cmdline_parse_token_string_t cmd_setfwd_mode =
2310 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2311 #ifdef RTE_LIBRTE_IEEE1588
2312 "io#mac#rxonly#txonly#csum#ieee1588");
2314 "io#mac#rxonly#txonly#csum");
2317 cmdline_parse_inst_t cmd_set_fwd_mode = {
2318 .f = cmd_set_fwd_mode_parsed,
2320 #ifdef RTE_LIBRTE_IEEE1588
2321 .help_str = "set fwd io|mac|rxonly|txonly|csum|ieee1588 - set IO, MAC,"
2322 " RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode",
2324 .help_str = "set fwd io|mac|rxonly|txonly|csum - set IO, MAC,"
2325 " RXONLY, CSUM or TXONLY packet forwarding mode",
2328 (void *)&cmd_setfwd_set,
2329 (void *)&cmd_setfwd_fwd,
2330 (void *)&cmd_setfwd_mode,
2335 /* *** SET PROMISC MODE *** */
2336 struct cmd_set_promisc_mode_result {
2337 cmdline_fixed_string_t set;
2338 cmdline_fixed_string_t promisc;
2339 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2340 uint8_t port_num; /* valid if "allports" argument == 0 */
2341 cmdline_fixed_string_t mode;
2344 static void cmd_set_promisc_mode_parsed(void *parsed_result,
2345 __attribute__((unused)) struct cmdline *cl,
2348 struct cmd_set_promisc_mode_result *res = parsed_result;
2352 if (!strcmp(res->mode, "on"))
2359 for (i = 0; i < nb_ports; i++) {
2361 rte_eth_promiscuous_enable(i);
2363 rte_eth_promiscuous_disable(i);
2368 rte_eth_promiscuous_enable(res->port_num);
2370 rte_eth_promiscuous_disable(res->port_num);
2374 cmdline_parse_token_string_t cmd_setpromisc_set =
2375 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
2376 cmdline_parse_token_string_t cmd_setpromisc_promisc =
2377 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
2379 cmdline_parse_token_string_t cmd_setpromisc_portall =
2380 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
2382 cmdline_parse_token_num_t cmd_setpromisc_portnum =
2383 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
2385 cmdline_parse_token_string_t cmd_setpromisc_mode =
2386 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
2389 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
2390 .f = cmd_set_promisc_mode_parsed,
2392 .help_str = "set promisc all on|off: set promisc mode for all ports",
2394 (void *)&cmd_setpromisc_set,
2395 (void *)&cmd_setpromisc_promisc,
2396 (void *)&cmd_setpromisc_portall,
2397 (void *)&cmd_setpromisc_mode,
2402 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
2403 .f = cmd_set_promisc_mode_parsed,
2405 .help_str = "set promisc X on|off: set promisc mode on port X",
2407 (void *)&cmd_setpromisc_set,
2408 (void *)&cmd_setpromisc_promisc,
2409 (void *)&cmd_setpromisc_portnum,
2410 (void *)&cmd_setpromisc_mode,
2415 /* *** SET ALLMULTI MODE *** */
2416 struct cmd_set_allmulti_mode_result {
2417 cmdline_fixed_string_t set;
2418 cmdline_fixed_string_t allmulti;
2419 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
2420 uint8_t port_num; /* valid if "allports" argument == 0 */
2421 cmdline_fixed_string_t mode;
2424 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
2425 __attribute__((unused)) struct cmdline *cl,
2428 struct cmd_set_allmulti_mode_result *res = parsed_result;
2432 if (!strcmp(res->mode, "on"))
2439 for (i = 0; i < nb_ports; i++) {
2441 rte_eth_allmulticast_enable(i);
2443 rte_eth_allmulticast_disable(i);
2448 rte_eth_allmulticast_enable(res->port_num);
2450 rte_eth_allmulticast_disable(res->port_num);
2454 cmdline_parse_token_string_t cmd_setallmulti_set =
2455 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
2456 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
2457 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
2459 cmdline_parse_token_string_t cmd_setallmulti_portall =
2460 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
2462 cmdline_parse_token_num_t cmd_setallmulti_portnum =
2463 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
2465 cmdline_parse_token_string_t cmd_setallmulti_mode =
2466 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
2469 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
2470 .f = cmd_set_allmulti_mode_parsed,
2472 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
2474 (void *)&cmd_setallmulti_set,
2475 (void *)&cmd_setallmulti_allmulti,
2476 (void *)&cmd_setallmulti_portall,
2477 (void *)&cmd_setallmulti_mode,
2482 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
2483 .f = cmd_set_allmulti_mode_parsed,
2485 .help_str = "set allmulti X on|off: set allmulti mode on port X",
2487 (void *)&cmd_setallmulti_set,
2488 (void *)&cmd_setallmulti_allmulti,
2489 (void *)&cmd_setallmulti_portnum,
2490 (void *)&cmd_setallmulti_mode,
2495 /* *** ADD/REMOVE A PKT FILTER *** */
2496 struct cmd_pkt_filter_result {
2497 cmdline_fixed_string_t pkt_filter;
2499 cmdline_fixed_string_t protocol;
2500 cmdline_fixed_string_t src;
2501 cmdline_ipaddr_t ip_src;
2503 cmdline_fixed_string_t dst;
2504 cmdline_ipaddr_t ip_dst;
2506 cmdline_fixed_string_t flexbytes;
2507 uint16_t flexbytes_value;
2508 cmdline_fixed_string_t vlan;
2510 cmdline_fixed_string_t queue;
2512 cmdline_fixed_string_t soft;
2517 cmd_pkt_filter_parsed(void *parsed_result,
2518 __attribute__((unused)) struct cmdline *cl,
2519 __attribute__((unused)) void *data)
2521 struct rte_fdir_filter fdir_filter;
2522 struct cmd_pkt_filter_result *res = parsed_result;
2524 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
2526 if (res->ip_src.family == AF_INET)
2527 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
2529 memcpy(&(fdir_filter.ip_src.ipv6_addr),
2530 &(res->ip_src.addr.ipv6),
2531 sizeof(struct in6_addr));
2533 if (res->ip_dst.family == AF_INET)
2534 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
2536 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
2537 &(res->ip_dst.addr.ipv6),
2538 sizeof(struct in6_addr));
2540 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
2541 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
2543 if (!strcmp(res->protocol, "udp"))
2544 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
2545 else if (!strcmp(res->protocol, "tcp"))
2546 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
2547 else if (!strcmp(res->protocol, "sctp"))
2548 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
2549 else /* default only IP */
2550 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
2552 if (res->ip_dst.family == AF_INET6)
2553 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
2555 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
2557 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
2558 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
2560 if (!strcmp(res->pkt_filter, "add_signature_filter"))
2561 fdir_add_signature_filter(res->port_id, res->queue_id,
2563 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
2564 fdir_update_signature_filter(res->port_id, res->queue_id,
2566 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
2567 fdir_remove_signature_filter(res->port_id, &fdir_filter);
2568 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
2569 fdir_add_perfect_filter(res->port_id, res->soft_id,
2571 (uint8_t) (res->queue_id < 0),
2573 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
2574 fdir_update_perfect_filter(res->port_id, res->soft_id,
2576 (uint8_t) (res->queue_id < 0),
2578 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
2579 fdir_remove_perfect_filter(res->port_id, res->soft_id,
2585 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
2586 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2588 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
2589 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2590 protocol, "ip#tcp#udp#sctp");
2591 cmdline_parse_token_string_t cmd_pkt_filter_src =
2592 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2594 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
2595 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2597 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
2598 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2600 cmdline_parse_token_string_t cmd_pkt_filter_dst =
2601 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2603 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
2604 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
2606 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
2607 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2609 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
2610 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2611 flexbytes, "flexbytes");
2612 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
2613 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2614 flexbytes_value, UINT16);
2615 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
2616 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2618 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
2619 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2621 cmdline_parse_token_string_t cmd_pkt_filter_queue =
2622 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2624 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
2625 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2627 cmdline_parse_token_string_t cmd_pkt_filter_soft =
2628 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2630 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
2631 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
2635 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
2636 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2637 pkt_filter, "add_signature_filter");
2638 cmdline_parse_inst_t cmd_add_signature_filter = {
2639 .f = cmd_pkt_filter_parsed,
2641 .help_str = "add a signature filter",
2643 (void *)&cmd_pkt_filter_add_signature_filter,
2644 (void *)&cmd_pkt_filter_port_id,
2645 (void *)&cmd_pkt_filter_protocol,
2646 (void *)&cmd_pkt_filter_src,
2647 (void *)&cmd_pkt_filter_ip_src,
2648 (void *)&cmd_pkt_filter_port_src,
2649 (void *)&cmd_pkt_filter_dst,
2650 (void *)&cmd_pkt_filter_ip_dst,
2651 (void *)&cmd_pkt_filter_port_dst,
2652 (void *)&cmd_pkt_filter_flexbytes,
2653 (void *)&cmd_pkt_filter_flexbytes_value,
2654 (void *)&cmd_pkt_filter_vlan,
2655 (void *)&cmd_pkt_filter_vlan_id,
2656 (void *)&cmd_pkt_filter_queue,
2657 (void *)&cmd_pkt_filter_queue_id,
2663 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
2664 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2665 pkt_filter, "upd_signature_filter");
2666 cmdline_parse_inst_t cmd_upd_signature_filter = {
2667 .f = cmd_pkt_filter_parsed,
2669 .help_str = "update a signature filter",
2671 (void *)&cmd_pkt_filter_upd_signature_filter,
2672 (void *)&cmd_pkt_filter_port_id,
2673 (void *)&cmd_pkt_filter_protocol,
2674 (void *)&cmd_pkt_filter_src,
2675 (void *)&cmd_pkt_filter_ip_src,
2676 (void *)&cmd_pkt_filter_port_src,
2677 (void *)&cmd_pkt_filter_dst,
2678 (void *)&cmd_pkt_filter_ip_dst,
2679 (void *)&cmd_pkt_filter_port_dst,
2680 (void *)&cmd_pkt_filter_flexbytes,
2681 (void *)&cmd_pkt_filter_flexbytes_value,
2682 (void *)&cmd_pkt_filter_vlan,
2683 (void *)&cmd_pkt_filter_vlan_id,
2684 (void *)&cmd_pkt_filter_queue,
2685 (void *)&cmd_pkt_filter_queue_id,
2691 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
2692 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2693 pkt_filter, "rm_signature_filter");
2694 cmdline_parse_inst_t cmd_rm_signature_filter = {
2695 .f = cmd_pkt_filter_parsed,
2697 .help_str = "remove a signature filter",
2699 (void *)&cmd_pkt_filter_rm_signature_filter,
2700 (void *)&cmd_pkt_filter_port_id,
2701 (void *)&cmd_pkt_filter_protocol,
2702 (void *)&cmd_pkt_filter_src,
2703 (void *)&cmd_pkt_filter_ip_src,
2704 (void *)&cmd_pkt_filter_port_src,
2705 (void *)&cmd_pkt_filter_dst,
2706 (void *)&cmd_pkt_filter_ip_dst,
2707 (void *)&cmd_pkt_filter_port_dst,
2708 (void *)&cmd_pkt_filter_flexbytes,
2709 (void *)&cmd_pkt_filter_flexbytes_value,
2710 (void *)&cmd_pkt_filter_vlan,
2711 (void *)&cmd_pkt_filter_vlan_id,
2717 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
2718 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2719 pkt_filter, "add_perfect_filter");
2720 cmdline_parse_inst_t cmd_add_perfect_filter = {
2721 .f = cmd_pkt_filter_parsed,
2723 .help_str = "add a perfect filter",
2725 (void *)&cmd_pkt_filter_add_perfect_filter,
2726 (void *)&cmd_pkt_filter_port_id,
2727 (void *)&cmd_pkt_filter_protocol,
2728 (void *)&cmd_pkt_filter_src,
2729 (void *)&cmd_pkt_filter_ip_src,
2730 (void *)&cmd_pkt_filter_port_src,
2731 (void *)&cmd_pkt_filter_dst,
2732 (void *)&cmd_pkt_filter_ip_dst,
2733 (void *)&cmd_pkt_filter_port_dst,
2734 (void *)&cmd_pkt_filter_flexbytes,
2735 (void *)&cmd_pkt_filter_flexbytes_value,
2736 (void *)&cmd_pkt_filter_vlan,
2737 (void *)&cmd_pkt_filter_vlan_id,
2738 (void *)&cmd_pkt_filter_queue,
2739 (void *)&cmd_pkt_filter_queue_id,
2740 (void *)&cmd_pkt_filter_soft,
2741 (void *)&cmd_pkt_filter_soft_id,
2747 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
2748 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2749 pkt_filter, "upd_perfect_filter");
2750 cmdline_parse_inst_t cmd_upd_perfect_filter = {
2751 .f = cmd_pkt_filter_parsed,
2753 .help_str = "update a perfect filter",
2755 (void *)&cmd_pkt_filter_upd_perfect_filter,
2756 (void *)&cmd_pkt_filter_port_id,
2757 (void *)&cmd_pkt_filter_protocol,
2758 (void *)&cmd_pkt_filter_src,
2759 (void *)&cmd_pkt_filter_ip_src,
2760 (void *)&cmd_pkt_filter_port_src,
2761 (void *)&cmd_pkt_filter_dst,
2762 (void *)&cmd_pkt_filter_ip_dst,
2763 (void *)&cmd_pkt_filter_port_dst,
2764 (void *)&cmd_pkt_filter_flexbytes,
2765 (void *)&cmd_pkt_filter_flexbytes_value,
2766 (void *)&cmd_pkt_filter_vlan,
2767 (void *)&cmd_pkt_filter_vlan_id,
2768 (void *)&cmd_pkt_filter_queue,
2769 (void *)&cmd_pkt_filter_queue_id,
2770 (void *)&cmd_pkt_filter_soft,
2771 (void *)&cmd_pkt_filter_soft_id,
2777 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
2778 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
2779 pkt_filter, "rm_perfect_filter");
2780 cmdline_parse_inst_t cmd_rm_perfect_filter = {
2781 .f = cmd_pkt_filter_parsed,
2783 .help_str = "remove a perfect filter",
2785 (void *)&cmd_pkt_filter_rm_perfect_filter,
2786 (void *)&cmd_pkt_filter_port_id,
2787 (void *)&cmd_pkt_filter_protocol,
2788 (void *)&cmd_pkt_filter_src,
2789 (void *)&cmd_pkt_filter_ip_src,
2790 (void *)&cmd_pkt_filter_port_src,
2791 (void *)&cmd_pkt_filter_dst,
2792 (void *)&cmd_pkt_filter_ip_dst,
2793 (void *)&cmd_pkt_filter_port_dst,
2794 (void *)&cmd_pkt_filter_flexbytes,
2795 (void *)&cmd_pkt_filter_flexbytes_value,
2796 (void *)&cmd_pkt_filter_vlan,
2797 (void *)&cmd_pkt_filter_vlan_id,
2798 (void *)&cmd_pkt_filter_soft,
2799 (void *)&cmd_pkt_filter_soft_id,
2804 /* *** SETUP MASKS FILTER *** */
2805 struct cmd_pkt_filter_masks_result {
2806 cmdline_fixed_string_t filter_mask;
2808 cmdline_fixed_string_t src_mask;
2809 uint32_t ip_src_mask;
2810 uint16_t ipv6_src_mask;
2811 uint16_t port_src_mask;
2812 cmdline_fixed_string_t dst_mask;
2813 uint32_t ip_dst_mask;
2814 uint16_t ipv6_dst_mask;
2815 uint16_t port_dst_mask;
2816 cmdline_fixed_string_t flexbytes;
2817 uint8_t flexbytes_value;
2818 cmdline_fixed_string_t vlan_id;
2819 uint8_t vlan_id_value;
2820 cmdline_fixed_string_t vlan_prio;
2821 uint8_t vlan_prio_value;
2822 cmdline_fixed_string_t only_ip_flow;
2823 uint8_t only_ip_flow_value;
2824 cmdline_fixed_string_t comp_ipv6_dst;
2825 uint8_t comp_ipv6_dst_value;
2829 cmd_pkt_filter_masks_parsed(void *parsed_result,
2830 __attribute__((unused)) struct cmdline *cl,
2831 __attribute__((unused)) void *data)
2833 struct rte_fdir_masks fdir_masks;
2834 struct cmd_pkt_filter_masks_result *res = parsed_result;
2836 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2838 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2839 fdir_masks.vlan_id = res->vlan_id_value;
2840 fdir_masks.vlan_prio = res->vlan_prio_value;
2841 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
2842 fdir_masks.src_ipv4_mask = res->ip_src_mask;
2843 fdir_masks.src_port_mask = res->port_src_mask;
2844 fdir_masks.dst_port_mask = res->port_dst_mask;
2845 fdir_masks.flexbytes = res->flexbytes_value;
2847 fdir_set_masks(res->port_id, &fdir_masks);
2850 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
2851 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2852 filter_mask, "set_masks_filter");
2853 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
2854 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2856 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
2857 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2858 only_ip_flow, "only_ip_flow");
2859 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
2860 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2861 only_ip_flow_value, UINT8);
2862 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
2863 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2864 src_mask, "src_mask");
2865 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
2866 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2867 ip_src_mask, UINT32);
2868 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
2869 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2870 port_src_mask, UINT16);
2871 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
2872 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2873 dst_mask, "dst_mask");
2874 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
2875 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2876 ip_dst_mask, UINT32);
2877 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
2878 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2879 port_dst_mask, UINT16);
2880 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
2881 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2882 flexbytes, "flexbytes");
2883 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
2884 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2885 flexbytes_value, UINT8);
2886 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
2887 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2888 vlan_id, "vlan_id");
2889 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
2890 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2891 vlan_id_value, UINT8);
2892 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
2893 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2894 vlan_prio, "vlan_prio");
2895 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
2896 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2897 vlan_prio_value, UINT8);
2899 cmdline_parse_inst_t cmd_set_masks_filter = {
2900 .f = cmd_pkt_filter_masks_parsed,
2902 .help_str = "setup masks filter",
2904 (void *)&cmd_pkt_filter_masks_filter_mask,
2905 (void *)&cmd_pkt_filter_masks_port_id,
2906 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2907 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2908 (void *)&cmd_pkt_filter_masks_src_mask,
2909 (void *)&cmd_pkt_filter_masks_ip_src_mask,
2910 (void *)&cmd_pkt_filter_masks_port_src_mask,
2911 (void *)&cmd_pkt_filter_masks_dst_mask,
2912 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
2913 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2914 (void *)&cmd_pkt_filter_masks_flexbytes,
2915 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2916 (void *)&cmd_pkt_filter_masks_vlan_id,
2917 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2918 (void *)&cmd_pkt_filter_masks_vlan_prio,
2919 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2925 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
2926 __attribute__((unused)) struct cmdline *cl,
2927 __attribute__((unused)) void *data)
2929 struct rte_fdir_masks fdir_masks;
2930 struct cmd_pkt_filter_masks_result *res = parsed_result;
2932 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
2934 fdir_masks.set_ipv6_mask = 1;
2935 fdir_masks.only_ip_flow = res->only_ip_flow_value;
2936 fdir_masks.vlan_id = res->vlan_id_value;
2937 fdir_masks.vlan_prio = res->vlan_prio_value;
2938 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
2939 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
2940 fdir_masks.src_port_mask = res->port_src_mask;
2941 fdir_masks.dst_port_mask = res->port_dst_mask;
2942 fdir_masks.flexbytes = res->flexbytes_value;
2943 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
2945 fdir_set_masks(res->port_id, &fdir_masks);
2948 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
2949 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2950 filter_mask, "set_ipv6_masks_filter");
2951 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
2952 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2953 ipv6_src_mask, UINT16);
2954 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
2955 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2956 ipv6_dst_mask, UINT16);
2958 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
2959 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
2960 comp_ipv6_dst, "compare_dst");
2961 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
2962 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
2963 comp_ipv6_dst_value, UINT8);
2965 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
2966 .f = cmd_pkt_filter_masks_ipv6_parsed,
2968 .help_str = "setup ipv6 masks filter",
2970 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
2971 (void *)&cmd_pkt_filter_masks_port_id,
2972 (void *)&cmd_pkt_filter_masks_only_ip_flow,
2973 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
2974 (void *)&cmd_pkt_filter_masks_src_mask,
2975 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
2976 (void *)&cmd_pkt_filter_masks_port_src_mask,
2977 (void *)&cmd_pkt_filter_masks_dst_mask,
2978 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
2979 (void *)&cmd_pkt_filter_masks_port_dst_mask,
2980 (void *)&cmd_pkt_filter_masks_flexbytes,
2981 (void *)&cmd_pkt_filter_masks_flexbytes_value,
2982 (void *)&cmd_pkt_filter_masks_vlan_id,
2983 (void *)&cmd_pkt_filter_masks_vlan_id_value,
2984 (void *)&cmd_pkt_filter_masks_vlan_prio,
2985 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
2986 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
2987 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
2992 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
2993 struct cmd_link_flow_ctrl_set_result {
2994 cmdline_fixed_string_t set;
2995 cmdline_fixed_string_t flow_ctrl;
2996 cmdline_fixed_string_t rx;
2997 cmdline_fixed_string_t rx_lfc_mode;
2998 cmdline_fixed_string_t tx;
2999 cmdline_fixed_string_t tx_lfc_mode;
3000 uint32_t high_water;
3002 uint16_t pause_time;
3008 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3009 __attribute__((unused)) struct cmdline *cl,
3010 __attribute__((unused)) void *data)
3012 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3013 struct rte_eth_fc_conf fc_conf;
3014 int rx_fc_enable, tx_fc_enable;
3018 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3019 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3020 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3021 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3023 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3024 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3027 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3028 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3030 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3031 fc_conf.high_water = res->high_water;
3032 fc_conf.low_water = res->low_water;
3033 fc_conf.pause_time = res->pause_time;
3034 fc_conf.send_xon = res->send_xon;
3036 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3038 printf("bad flow contrl parameter, return code = %d \n", ret);
3041 cmdline_parse_token_string_t cmd_lfc_set_set =
3042 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3044 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3045 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3046 flow_ctrl, "flow_ctrl");
3047 cmdline_parse_token_string_t cmd_lfc_set_rx =
3048 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3050 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3051 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3052 rx_lfc_mode, "on#off");
3053 cmdline_parse_token_string_t cmd_lfc_set_tx =
3054 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3056 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3057 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3058 tx_lfc_mode, "on#off");
3059 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3060 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3061 high_water, UINT32);
3062 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3063 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3065 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3066 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3067 pause_time, UINT16);
3068 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3069 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3071 cmdline_parse_token_num_t cmd_lfc_set_portid =
3072 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3075 cmdline_parse_inst_t cmd_link_flow_control_set = {
3076 .f = cmd_link_flow_ctrl_set_parsed,
3078 .help_str = "Configure the Ethernet link flow control...",
3080 (void *)&cmd_lfc_set_set,
3081 (void *)&cmd_lfc_set_flow_ctrl,
3082 (void *)&cmd_lfc_set_rx,
3083 (void *)&cmd_lfc_set_rx_mode,
3084 (void *)&cmd_lfc_set_tx,
3085 (void *)&cmd_lfc_set_tx_mode,
3086 (void *)&cmd_lfc_set_high_water,
3087 (void *)&cmd_lfc_set_low_water,
3088 (void *)&cmd_lfc_set_pause_time,
3089 (void *)&cmd_lfc_set_send_xon,
3090 (void *)&cmd_lfc_set_portid,
3095 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3096 struct cmd_priority_flow_ctrl_set_result {
3097 cmdline_fixed_string_t set;
3098 cmdline_fixed_string_t pfc_ctrl;
3099 cmdline_fixed_string_t rx;
3100 cmdline_fixed_string_t rx_pfc_mode;
3101 cmdline_fixed_string_t tx;
3102 cmdline_fixed_string_t tx_pfc_mode;
3103 uint32_t high_water;
3105 uint16_t pause_time;
3111 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3116 struct rte_eth_pfc_conf pfc_conf;
3117 int rx_fc_enable, tx_fc_enable;
3121 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3122 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3123 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3124 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3126 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3127 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3130 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3131 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3132 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3133 pfc_conf.fc.high_water = res->high_water;
3134 pfc_conf.fc.low_water = res->low_water;
3135 pfc_conf.fc.pause_time = res->pause_time;
3136 pfc_conf.priority = res->priority;
3138 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3140 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3143 cmdline_parse_token_string_t cmd_pfc_set_set =
3144 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3146 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3147 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3148 pfc_ctrl, "pfc_ctrl");
3149 cmdline_parse_token_string_t cmd_pfc_set_rx =
3150 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3152 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3153 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3154 rx_pfc_mode, "on#off");
3155 cmdline_parse_token_string_t cmd_pfc_set_tx =
3156 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3158 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3159 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3160 tx_pfc_mode, "on#off");
3161 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3162 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3163 high_water, UINT32);
3164 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3165 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3167 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3168 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3169 pause_time, UINT16);
3170 cmdline_parse_token_num_t cmd_pfc_set_priority =
3171 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3173 cmdline_parse_token_num_t cmd_pfc_set_portid =
3174 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3177 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3178 .f = cmd_priority_flow_ctrl_set_parsed,
3180 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3181 tx on|off high_water low_water pause_time priority port_id",
3183 (void *)&cmd_pfc_set_set,
3184 (void *)&cmd_pfc_set_flow_ctrl,
3185 (void *)&cmd_pfc_set_rx,
3186 (void *)&cmd_pfc_set_rx_mode,
3187 (void *)&cmd_pfc_set_tx,
3188 (void *)&cmd_pfc_set_tx_mode,
3189 (void *)&cmd_pfc_set_high_water,
3190 (void *)&cmd_pfc_set_low_water,
3191 (void *)&cmd_pfc_set_pause_time,
3192 (void *)&cmd_pfc_set_priority,
3193 (void *)&cmd_pfc_set_portid,
3198 /* *** RESET CONFIGURATION *** */
3199 struct cmd_reset_result {
3200 cmdline_fixed_string_t reset;
3201 cmdline_fixed_string_t def;
3204 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3206 __attribute__((unused)) void *data)
3208 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3209 set_def_fwd_config();
3212 cmdline_parse_token_string_t cmd_reset_set =
3213 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3214 cmdline_parse_token_string_t cmd_reset_def =
3215 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3218 cmdline_parse_inst_t cmd_reset = {
3219 .f = cmd_reset_parsed,
3221 .help_str = "set default: reset default forwarding configuration",
3223 (void *)&cmd_reset_set,
3224 (void *)&cmd_reset_def,
3229 /* *** START FORWARDING *** */
3230 struct cmd_start_result {
3231 cmdline_fixed_string_t start;
3234 cmdline_parse_token_string_t cmd_start_start =
3235 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3237 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3238 __attribute__((unused)) struct cmdline *cl,
3239 __attribute__((unused)) void *data)
3241 start_packet_forwarding(0);
3244 cmdline_parse_inst_t cmd_start = {
3245 .f = cmd_start_parsed,
3247 .help_str = "start packet forwarding",
3249 (void *)&cmd_start_start,
3254 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3255 struct cmd_start_tx_first_result {
3256 cmdline_fixed_string_t start;
3257 cmdline_fixed_string_t tx_first;
3261 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3262 __attribute__((unused)) struct cmdline *cl,
3263 __attribute__((unused)) void *data)
3265 start_packet_forwarding(1);
3268 cmdline_parse_token_string_t cmd_start_tx_first_start =
3269 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3271 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3272 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3273 tx_first, "tx_first");
3275 cmdline_parse_inst_t cmd_start_tx_first = {
3276 .f = cmd_start_tx_first_parsed,
3278 .help_str = "start packet forwarding, after sending 1 burst of packets",
3280 (void *)&cmd_start_tx_first_start,
3281 (void *)&cmd_start_tx_first_tx_first,
3286 /* *** SHOW CFG *** */
3287 struct cmd_showcfg_result {
3288 cmdline_fixed_string_t show;
3289 cmdline_fixed_string_t cfg;
3290 cmdline_fixed_string_t what;
3293 static void cmd_showcfg_parsed(void *parsed_result,
3294 __attribute__((unused)) struct cmdline *cl,
3295 __attribute__((unused)) void *data)
3297 struct cmd_showcfg_result *res = parsed_result;
3298 if (!strcmp(res->what, "rxtx"))
3299 rxtx_config_display();
3300 else if (!strcmp(res->what, "cores"))
3301 fwd_lcores_config_display();
3302 else if (!strcmp(res->what, "fwd"))
3303 fwd_config_display();
3306 cmdline_parse_token_string_t cmd_showcfg_show =
3307 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
3308 cmdline_parse_token_string_t cmd_showcfg_port =
3309 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
3310 cmdline_parse_token_string_t cmd_showcfg_what =
3311 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
3314 cmdline_parse_inst_t cmd_showcfg = {
3315 .f = cmd_showcfg_parsed,
3317 .help_str = "show config rxtx|cores|fwd",
3319 (void *)&cmd_showcfg_show,
3320 (void *)&cmd_showcfg_port,
3321 (void *)&cmd_showcfg_what,
3326 /* *** SHOW ALL PORT INFO *** */
3327 struct cmd_showportall_result {
3328 cmdline_fixed_string_t show;
3329 cmdline_fixed_string_t port;
3330 cmdline_fixed_string_t what;
3331 cmdline_fixed_string_t all;
3334 static void cmd_showportall_parsed(void *parsed_result,
3335 __attribute__((unused)) struct cmdline *cl,
3336 __attribute__((unused)) void *data)
3340 struct cmd_showportall_result *res = parsed_result;
3341 if (!strcmp(res->show, "clear")) {
3342 if (!strcmp(res->what, "stats"))
3343 for (i = 0; i < nb_ports; i++)
3345 } else if (!strcmp(res->what, "info"))
3346 for (i = 0; i < nb_ports; i++)
3347 port_infos_display(i);
3348 else if (!strcmp(res->what, "stats"))
3349 for (i = 0; i < nb_ports; i++)
3350 nic_stats_display(i);
3351 else if (!strcmp(res->what, "fdir"))
3352 for (i = 0; i < nb_ports; i++)
3354 else if (!strcmp(res->what, "stat_qmap"))
3355 for (i = 0; i < nb_ports; i++)
3356 nic_stats_mapping_display(i);
3359 cmdline_parse_token_string_t cmd_showportall_show =
3360 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
3362 cmdline_parse_token_string_t cmd_showportall_port =
3363 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
3364 cmdline_parse_token_string_t cmd_showportall_what =
3365 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
3366 "info#stats#fdir#stat_qmap");
3367 cmdline_parse_token_string_t cmd_showportall_all =
3368 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
3369 cmdline_parse_inst_t cmd_showportall = {
3370 .f = cmd_showportall_parsed,
3372 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
3374 (void *)&cmd_showportall_show,
3375 (void *)&cmd_showportall_port,
3376 (void *)&cmd_showportall_what,
3377 (void *)&cmd_showportall_all,
3382 /* *** SHOW PORT INFO *** */
3383 struct cmd_showport_result {
3384 cmdline_fixed_string_t show;
3385 cmdline_fixed_string_t port;
3386 cmdline_fixed_string_t what;
3390 static void cmd_showport_parsed(void *parsed_result,
3391 __attribute__((unused)) struct cmdline *cl,
3392 __attribute__((unused)) void *data)
3394 struct cmd_showport_result *res = parsed_result;
3395 if (!strcmp(res->show, "clear")) {
3396 if (!strcmp(res->what, "stats"))
3397 nic_stats_clear(res->portnum);
3398 } else if (!strcmp(res->what, "info"))
3399 port_infos_display(res->portnum);
3400 else if (!strcmp(res->what, "stats"))
3401 nic_stats_display(res->portnum);
3402 else if (!strcmp(res->what, "fdir"))
3403 fdir_get_infos(res->portnum);
3404 else if (!strcmp(res->what, "stat_qmap"))
3405 nic_stats_mapping_display(res->portnum);
3408 cmdline_parse_token_string_t cmd_showport_show =
3409 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
3411 cmdline_parse_token_string_t cmd_showport_port =
3412 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
3413 cmdline_parse_token_string_t cmd_showport_what =
3414 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
3415 "info#stats#fdir#stat_qmap");
3416 cmdline_parse_token_num_t cmd_showport_portnum =
3417 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
3419 cmdline_parse_inst_t cmd_showport = {
3420 .f = cmd_showport_parsed,
3422 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
3424 (void *)&cmd_showport_show,
3425 (void *)&cmd_showport_port,
3426 (void *)&cmd_showport_what,
3427 (void *)&cmd_showport_portnum,
3432 /* *** READ PORT REGISTER *** */
3433 struct cmd_read_reg_result {
3434 cmdline_fixed_string_t read;
3435 cmdline_fixed_string_t reg;
3441 cmd_read_reg_parsed(void *parsed_result,
3442 __attribute__((unused)) struct cmdline *cl,
3443 __attribute__((unused)) void *data)
3445 struct cmd_read_reg_result *res = parsed_result;
3446 port_reg_display(res->port_id, res->reg_off);
3449 cmdline_parse_token_string_t cmd_read_reg_read =
3450 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
3451 cmdline_parse_token_string_t cmd_read_reg_reg =
3452 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
3453 cmdline_parse_token_num_t cmd_read_reg_port_id =
3454 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
3455 cmdline_parse_token_num_t cmd_read_reg_reg_off =
3456 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
3458 cmdline_parse_inst_t cmd_read_reg = {
3459 .f = cmd_read_reg_parsed,
3461 .help_str = "read reg port_id reg_off",
3463 (void *)&cmd_read_reg_read,
3464 (void *)&cmd_read_reg_reg,
3465 (void *)&cmd_read_reg_port_id,
3466 (void *)&cmd_read_reg_reg_off,
3471 /* *** READ PORT REGISTER BIT FIELD *** */
3472 struct cmd_read_reg_bit_field_result {
3473 cmdline_fixed_string_t read;
3474 cmdline_fixed_string_t regfield;
3482 cmd_read_reg_bit_field_parsed(void *parsed_result,
3483 __attribute__((unused)) struct cmdline *cl,
3484 __attribute__((unused)) void *data)
3486 struct cmd_read_reg_bit_field_result *res = parsed_result;
3487 port_reg_bit_field_display(res->port_id, res->reg_off,
3488 res->bit1_pos, res->bit2_pos);
3491 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
3492 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
3494 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
3495 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
3496 regfield, "regfield");
3497 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
3498 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
3500 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
3501 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
3503 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
3504 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
3506 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
3507 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
3510 cmdline_parse_inst_t cmd_read_reg_bit_field = {
3511 .f = cmd_read_reg_bit_field_parsed,
3513 .help_str = "read regfield port_id reg_off bit_x bit_y "
3514 "(read register bit field between bit_x and bit_y included)",
3516 (void *)&cmd_read_reg_bit_field_read,
3517 (void *)&cmd_read_reg_bit_field_regfield,
3518 (void *)&cmd_read_reg_bit_field_port_id,
3519 (void *)&cmd_read_reg_bit_field_reg_off,
3520 (void *)&cmd_read_reg_bit_field_bit1_pos,
3521 (void *)&cmd_read_reg_bit_field_bit2_pos,
3526 /* *** READ PORT REGISTER BIT *** */
3527 struct cmd_read_reg_bit_result {
3528 cmdline_fixed_string_t read;
3529 cmdline_fixed_string_t regbit;
3536 cmd_read_reg_bit_parsed(void *parsed_result,
3537 __attribute__((unused)) struct cmdline *cl,
3538 __attribute__((unused)) void *data)
3540 struct cmd_read_reg_bit_result *res = parsed_result;
3541 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
3544 cmdline_parse_token_string_t cmd_read_reg_bit_read =
3545 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
3546 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
3547 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
3549 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
3550 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
3551 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
3552 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
3553 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
3554 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
3556 cmdline_parse_inst_t cmd_read_reg_bit = {
3557 .f = cmd_read_reg_bit_parsed,
3559 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
3561 (void *)&cmd_read_reg_bit_read,
3562 (void *)&cmd_read_reg_bit_regbit,
3563 (void *)&cmd_read_reg_bit_port_id,
3564 (void *)&cmd_read_reg_bit_reg_off,
3565 (void *)&cmd_read_reg_bit_bit_pos,
3570 /* *** WRITE PORT REGISTER *** */
3571 struct cmd_write_reg_result {
3572 cmdline_fixed_string_t write;
3573 cmdline_fixed_string_t reg;
3580 cmd_write_reg_parsed(void *parsed_result,
3581 __attribute__((unused)) struct cmdline *cl,
3582 __attribute__((unused)) void *data)
3584 struct cmd_write_reg_result *res = parsed_result;
3585 port_reg_set(res->port_id, res->reg_off, res->value);
3588 cmdline_parse_token_string_t cmd_write_reg_write =
3589 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
3590 cmdline_parse_token_string_t cmd_write_reg_reg =
3591 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
3592 cmdline_parse_token_num_t cmd_write_reg_port_id =
3593 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
3594 cmdline_parse_token_num_t cmd_write_reg_reg_off =
3595 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
3596 cmdline_parse_token_num_t cmd_write_reg_value =
3597 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
3599 cmdline_parse_inst_t cmd_write_reg = {
3600 .f = cmd_write_reg_parsed,
3602 .help_str = "write reg port_id reg_off reg_value",
3604 (void *)&cmd_write_reg_write,
3605 (void *)&cmd_write_reg_reg,
3606 (void *)&cmd_write_reg_port_id,
3607 (void *)&cmd_write_reg_reg_off,
3608 (void *)&cmd_write_reg_value,
3613 /* *** WRITE PORT REGISTER BIT FIELD *** */
3614 struct cmd_write_reg_bit_field_result {
3615 cmdline_fixed_string_t write;
3616 cmdline_fixed_string_t regfield;
3625 cmd_write_reg_bit_field_parsed(void *parsed_result,
3626 __attribute__((unused)) struct cmdline *cl,
3627 __attribute__((unused)) void *data)
3629 struct cmd_write_reg_bit_field_result *res = parsed_result;
3630 port_reg_bit_field_set(res->port_id, res->reg_off,
3631 res->bit1_pos, res->bit2_pos, res->value);
3634 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
3635 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
3637 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
3638 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
3639 regfield, "regfield");
3640 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
3641 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
3643 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
3644 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
3646 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
3647 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
3649 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
3650 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
3652 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
3653 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
3656 cmdline_parse_inst_t cmd_write_reg_bit_field = {
3657 .f = cmd_write_reg_bit_field_parsed,
3659 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
3660 "(set register bit field between bit_x and bit_y included)",
3662 (void *)&cmd_write_reg_bit_field_write,
3663 (void *)&cmd_write_reg_bit_field_regfield,
3664 (void *)&cmd_write_reg_bit_field_port_id,
3665 (void *)&cmd_write_reg_bit_field_reg_off,
3666 (void *)&cmd_write_reg_bit_field_bit1_pos,
3667 (void *)&cmd_write_reg_bit_field_bit2_pos,
3668 (void *)&cmd_write_reg_bit_field_value,
3673 /* *** WRITE PORT REGISTER BIT *** */
3674 struct cmd_write_reg_bit_result {
3675 cmdline_fixed_string_t write;
3676 cmdline_fixed_string_t regbit;
3684 cmd_write_reg_bit_parsed(void *parsed_result,
3685 __attribute__((unused)) struct cmdline *cl,
3686 __attribute__((unused)) void *data)
3688 struct cmd_write_reg_bit_result *res = parsed_result;
3689 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
3692 cmdline_parse_token_string_t cmd_write_reg_bit_write =
3693 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
3695 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
3696 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
3698 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
3699 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
3700 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
3701 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
3702 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
3703 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
3704 cmdline_parse_token_num_t cmd_write_reg_bit_value =
3705 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
3707 cmdline_parse_inst_t cmd_write_reg_bit = {
3708 .f = cmd_write_reg_bit_parsed,
3710 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
3712 (void *)&cmd_write_reg_bit_write,
3713 (void *)&cmd_write_reg_bit_regbit,
3714 (void *)&cmd_write_reg_bit_port_id,
3715 (void *)&cmd_write_reg_bit_reg_off,
3716 (void *)&cmd_write_reg_bit_bit_pos,
3717 (void *)&cmd_write_reg_bit_value,
3722 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
3723 struct cmd_read_rxd_txd_result {
3724 cmdline_fixed_string_t read;
3725 cmdline_fixed_string_t rxd_txd;
3732 cmd_read_rxd_txd_parsed(void *parsed_result,
3733 __attribute__((unused)) struct cmdline *cl,
3734 __attribute__((unused)) void *data)
3736 struct cmd_read_rxd_txd_result *res = parsed_result;
3738 if (!strcmp(res->rxd_txd, "rxd"))
3739 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3740 else if (!strcmp(res->rxd_txd, "txd"))
3741 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
3744 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
3745 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
3746 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
3747 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
3749 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
3750 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
3751 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
3752 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
3753 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
3754 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
3756 cmdline_parse_inst_t cmd_read_rxd_txd = {
3757 .f = cmd_read_rxd_txd_parsed,
3759 .help_str = "read rxd|txd port_id queue_id rxd_id",
3761 (void *)&cmd_read_rxd_txd_read,
3762 (void *)&cmd_read_rxd_txd_rxd_txd,
3763 (void *)&cmd_read_rxd_txd_port_id,
3764 (void *)&cmd_read_rxd_txd_queue_id,
3765 (void *)&cmd_read_rxd_txd_desc_id,
3771 struct cmd_quit_result {
3772 cmdline_fixed_string_t quit;
3775 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
3777 __attribute__((unused)) void *data)
3783 cmdline_parse_token_string_t cmd_quit_quit =
3784 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
3786 cmdline_parse_inst_t cmd_quit = {
3787 .f = cmd_quit_parsed,
3789 .help_str = "exit application",
3791 (void *)&cmd_quit_quit,
3796 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
3797 struct cmd_mac_addr_result {
3798 cmdline_fixed_string_t mac_addr_cmd;
3799 cmdline_fixed_string_t what;
3801 struct ether_addr address;
3804 static void cmd_mac_addr_parsed(void *parsed_result,
3805 __attribute__((unused)) struct cmdline *cl,
3806 __attribute__((unused)) void *data)
3808 struct cmd_mac_addr_result *res = parsed_result;
3811 if (strcmp(res->what, "add") == 0)
3812 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
3814 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
3816 /* check the return value and print it if is < 0 */
3818 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
3822 cmdline_parse_token_string_t cmd_mac_addr_cmd =
3823 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
3825 cmdline_parse_token_string_t cmd_mac_addr_what =
3826 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
3828 cmdline_parse_token_num_t cmd_mac_addr_portnum =
3829 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
3830 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
3831 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
3833 cmdline_parse_inst_t cmd_mac_addr = {
3834 .f = cmd_mac_addr_parsed,
3836 .help_str = "mac_addr add|remove X <address>: "
3837 "add/remove MAC address on port X",
3839 (void *)&cmd_mac_addr_cmd,
3840 (void *)&cmd_mac_addr_what,
3841 (void *)&cmd_mac_addr_portnum,
3842 (void *)&cmd_mac_addr_addr,
3848 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
3849 struct cmd_set_qmap_result {
3850 cmdline_fixed_string_t set;
3851 cmdline_fixed_string_t qmap;
3852 cmdline_fixed_string_t what;
3859 cmd_set_qmap_parsed(void *parsed_result,
3860 __attribute__((unused)) struct cmdline *cl,
3861 __attribute__((unused)) void *data)
3863 struct cmd_set_qmap_result *res = parsed_result;
3864 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
3866 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
3869 cmdline_parse_token_string_t cmd_setqmap_set =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3872 cmdline_parse_token_string_t cmd_setqmap_qmap =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3875 cmdline_parse_token_string_t cmd_setqmap_what =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
3878 cmdline_parse_token_num_t cmd_setqmap_portid =
3879 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3881 cmdline_parse_token_num_t cmd_setqmap_queueid =
3882 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3884 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
3885 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
3888 cmdline_parse_inst_t cmd_set_qmap = {
3889 .f = cmd_set_qmap_parsed,
3891 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
3893 (void *)&cmd_setqmap_set,
3894 (void *)&cmd_setqmap_qmap,
3895 (void *)&cmd_setqmap_what,
3896 (void *)&cmd_setqmap_portid,
3897 (void *)&cmd_setqmap_queueid,
3898 (void *)&cmd_setqmap_mapvalue,
3903 /* *** CONFIGURE UNICAST HASH TABLE *** */
3904 struct cmd_set_uc_hash_table {
3905 cmdline_fixed_string_t set;
3906 cmdline_fixed_string_t port;
3908 cmdline_fixed_string_t what;
3909 struct ether_addr address;
3910 cmdline_fixed_string_t mode;
3914 cmd_set_uc_hash_parsed(void *parsed_result,
3915 __attribute__((unused)) struct cmdline *cl,
3916 __attribute__((unused)) void *data)
3919 struct cmd_set_uc_hash_table *res = parsed_result;
3921 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
3923 if (strcmp(res->what, "uta") == 0)
3924 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
3925 &res->address,(uint8_t)is_on);
3927 printf("bad unicast hash table parameter, return code = %d \n", ret);
3931 cmdline_parse_token_string_t cmd_set_uc_hash_set =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3934 cmdline_parse_token_string_t cmd_set_uc_hash_port =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3937 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
3938 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
3940 cmdline_parse_token_string_t cmd_set_uc_hash_what =
3941 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3943 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
3944 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
3946 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
3947 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
3950 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
3951 .f = cmd_set_uc_hash_parsed,
3953 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
3955 (void *)&cmd_set_uc_hash_set,
3956 (void *)&cmd_set_uc_hash_port,
3957 (void *)&cmd_set_uc_hash_portid,
3958 (void *)&cmd_set_uc_hash_what,
3959 (void *)&cmd_set_uc_hash_mac,
3960 (void *)&cmd_set_uc_hash_mode,
3965 struct cmd_set_uc_all_hash_table {
3966 cmdline_fixed_string_t set;
3967 cmdline_fixed_string_t port;
3969 cmdline_fixed_string_t what;
3970 cmdline_fixed_string_t value;
3971 cmdline_fixed_string_t mode;
3975 cmd_set_uc_all_hash_parsed(void *parsed_result,
3976 __attribute__((unused)) struct cmdline *cl,
3977 __attribute__((unused)) void *data)
3980 struct cmd_set_uc_all_hash_table *res = parsed_result;
3982 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
3984 if ((strcmp(res->what, "uta") == 0) &&
3985 (strcmp(res->value, "all") == 0))
3986 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
3988 printf("bad unicast hash table parameter,"
3989 "return code = %d \n", ret);
3992 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
3993 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
3995 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
3996 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
3998 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
3999 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4001 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4004 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4007 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4008 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4011 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4012 .f = cmd_set_uc_all_hash_parsed,
4014 .help_str = "set port X uta all on|off (X = port number)",
4016 (void *)&cmd_set_uc_all_hash_set,
4017 (void *)&cmd_set_uc_all_hash_port,
4018 (void *)&cmd_set_uc_all_hash_portid,
4019 (void *)&cmd_set_uc_all_hash_what,
4020 (void *)&cmd_set_uc_all_hash_value,
4021 (void *)&cmd_set_uc_all_hash_mode,
4026 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4027 struct cmd_set_vf_traffic {
4028 cmdline_fixed_string_t set;
4029 cmdline_fixed_string_t port;
4031 cmdline_fixed_string_t vf;
4033 cmdline_fixed_string_t what;
4034 cmdline_fixed_string_t mode;
4038 cmd_set_vf_traffic_parsed(void *parsed_result,
4039 __attribute__((unused)) struct cmdline *cl,
4040 __attribute__((unused)) void *data)
4042 struct cmd_set_vf_traffic *res = parsed_result;
4043 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4044 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4046 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4049 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4050 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4052 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4053 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4055 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4056 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4058 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4061 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4064 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4067 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4068 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4071 cmdline_parse_inst_t cmd_set_vf_traffic = {
4072 .f = cmd_set_vf_traffic_parsed,
4074 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4076 (void *)&cmd_setvf_traffic_set,
4077 (void *)&cmd_setvf_traffic_port,
4078 (void *)&cmd_setvf_traffic_portid,
4079 (void *)&cmd_setvf_traffic_vf,
4080 (void *)&cmd_setvf_traffic_vfid,
4081 (void *)&cmd_setvf_traffic_what,
4082 (void *)&cmd_setvf_traffic_mode,
4087 /* *** CONFIGURE VF RECEIVE MODE *** */
4088 struct cmd_set_vf_rxmode {
4089 cmdline_fixed_string_t set;
4090 cmdline_fixed_string_t port;
4092 cmdline_fixed_string_t vf;
4094 cmdline_fixed_string_t what;
4095 cmdline_fixed_string_t mode;
4096 cmdline_fixed_string_t on;
4100 cmd_set_vf_rxmode_parsed(void *parsed_result,
4101 __attribute__((unused)) struct cmdline *cl,
4102 __attribute__((unused)) void *data)
4105 uint16_t rx_mode = 0;
4106 struct cmd_set_vf_rxmode *res = parsed_result;
4108 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4109 if (!strcmp(res->what,"rxmode")) {
4110 if (!strcmp(res->mode, "AUPE"))
4111 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4112 else if (!strcmp(res->mode, "ROPE"))
4113 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4114 else if (!strcmp(res->mode, "BAM"))
4115 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4116 else if (!strncmp(res->mode, "MPE",3))
4117 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4120 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4122 printf("bad VF receive mode parameter, return code = %d \n",
4126 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4129 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4132 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4133 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4135 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4136 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4138 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4139 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4141 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4142 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4144 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4146 mode, "AUPE#ROPE#BAM#MPE");
4147 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4151 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4152 .f = cmd_set_vf_rxmode_parsed,
4154 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4156 (void *)&cmd_set_vf_rxmode_set,
4157 (void *)&cmd_set_vf_rxmode_port,
4158 (void *)&cmd_set_vf_rxmode_portid,
4159 (void *)&cmd_set_vf_rxmode_vf,
4160 (void *)&cmd_set_vf_rxmode_vfid,
4161 (void *)&cmd_set_vf_rxmode_what,
4162 (void *)&cmd_set_vf_rxmode_mode,
4163 (void *)&cmd_set_vf_rxmode_on,
4168 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4169 struct cmd_vf_mac_addr_result {
4170 cmdline_fixed_string_t mac_addr_cmd;
4171 cmdline_fixed_string_t what;
4172 cmdline_fixed_string_t port;
4174 cmdline_fixed_string_t vf;
4176 struct ether_addr address;
4179 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4180 __attribute__((unused)) struct cmdline *cl,
4181 __attribute__((unused)) void *data)
4183 struct cmd_vf_mac_addr_result *res = parsed_result;
4186 if (strcmp(res->what, "add") == 0)
4187 ret = rte_eth_dev_mac_addr_add(res->port_num,
4188 &res->address, res->vf_num);
4190 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4194 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4196 mac_addr_cmd,"mac_addr");
4197 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4198 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4200 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4201 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4203 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4204 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4206 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
4207 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4209 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
4210 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
4212 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
4213 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
4216 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
4217 .f = cmd_vf_mac_addr_parsed,
4219 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
4220 "Y = VF number)add MAC address filtering for a VF on port X",
4222 (void *)&cmd_vf_mac_addr_cmd,
4223 (void *)&cmd_vf_mac_addr_what,
4224 (void *)&cmd_vf_mac_addr_port,
4225 (void *)&cmd_vf_mac_addr_portnum,
4226 (void *)&cmd_vf_mac_addr_vf,
4227 (void *)&cmd_vf_mac_addr_vfnum,
4228 (void *)&cmd_vf_mac_addr_addr,
4233 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4234 struct cmd_vf_rx_vlan_filter {
4235 cmdline_fixed_string_t rx_vlan;
4236 cmdline_fixed_string_t what;
4238 cmdline_fixed_string_t port;
4240 cmdline_fixed_string_t vf;
4245 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
4246 __attribute__((unused)) struct cmdline *cl,
4247 __attribute__((unused)) void *data)
4249 struct cmd_vf_rx_vlan_filter *res = parsed_result;
4251 if (!strcmp(res->what, "add"))
4252 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
4254 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
4257 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
4258 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4259 rx_vlan, "rx_vlan");
4260 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
4261 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4263 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
4264 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4266 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
4267 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4269 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
4270 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4272 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
4273 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4275 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
4276 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
4279 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
4280 .f = cmd_vf_rx_vlan_filter_parsed,
4282 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
4283 "Y = port number,Z = hexadecimal VF mask)",
4285 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
4286 (void *)&cmd_vf_rx_vlan_filter_what,
4287 (void *)&cmd_vf_rx_vlan_filter_vlanid,
4288 (void *)&cmd_vf_rx_vlan_filter_port,
4289 (void *)&cmd_vf_rx_vlan_filter_portid,
4290 (void *)&cmd_vf_rx_vlan_filter_vf,
4291 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
4296 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
4297 struct cmd_set_mirror_mask_result {
4298 cmdline_fixed_string_t set;
4299 cmdline_fixed_string_t port;
4301 cmdline_fixed_string_t mirror;
4303 cmdline_fixed_string_t what;
4304 cmdline_fixed_string_t value;
4305 cmdline_fixed_string_t dstpool;
4307 cmdline_fixed_string_t on;
4310 cmdline_parse_token_string_t cmd_mirror_mask_set =
4311 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4313 cmdline_parse_token_string_t cmd_mirror_mask_port =
4314 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4316 cmdline_parse_token_string_t cmd_mirror_mask_portid =
4317 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4319 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
4320 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4321 mirror, "mirror-rule");
4322 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
4323 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4325 cmdline_parse_token_string_t cmd_mirror_mask_what =
4326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4327 what, "pool-mirror#vlan-mirror");
4328 cmdline_parse_token_string_t cmd_mirror_mask_value =
4329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4331 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
4332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4333 dstpool, "dst-pool");
4334 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
4335 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
4337 cmdline_parse_token_string_t cmd_mirror_mask_on =
4338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
4342 cmd_set_mirror_mask_parsed(void *parsed_result,
4343 __attribute__((unused)) struct cmdline *cl,
4344 __attribute__((unused)) void *data)
4347 struct cmd_set_mirror_mask_result *res = parsed_result;
4348 struct rte_eth_vmdq_mirror_conf mr_conf;
4350 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4352 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
4354 mr_conf.dst_pool = res->dstpool_id;
4356 if (!strcmp(res->what, "pool-mirror")) {
4357 mr_conf.pool_mask = strtoull(res->value,NULL,16);
4358 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
4359 } else if(!strcmp(res->what, "vlan-mirror")) {
4360 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
4361 nb_item = parse_item_list(res->value, "core",
4362 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
4366 for(i=0; i < nb_item; i++) {
4367 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
4368 printf("Invalid vlan_id: must be < 4096\n");
4372 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
4373 mr_conf.vlan.vlan_mask |= 1ULL << i;
4377 if(!strcmp(res->on, "on"))
4378 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4381 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4384 printf("mirror rule add error: (%s)\n", strerror(-ret));
4387 cmdline_parse_inst_t cmd_set_mirror_mask = {
4388 .f = cmd_set_mirror_mask_parsed,
4390 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
4391 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
4393 (void *)&cmd_mirror_mask_set,
4394 (void *)&cmd_mirror_mask_port,
4395 (void *)&cmd_mirror_mask_portid,
4396 (void *)&cmd_mirror_mask_mirror,
4397 (void *)&cmd_mirror_mask_ruleid,
4398 (void *)&cmd_mirror_mask_what,
4399 (void *)&cmd_mirror_mask_value,
4400 (void *)&cmd_mirror_mask_dstpool,
4401 (void *)&cmd_mirror_mask_poolid,
4402 (void *)&cmd_mirror_mask_on,
4407 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
4408 struct cmd_set_mirror_link_result {
4409 cmdline_fixed_string_t set;
4410 cmdline_fixed_string_t port;
4412 cmdline_fixed_string_t mirror;
4414 cmdline_fixed_string_t what;
4415 cmdline_fixed_string_t dstpool;
4417 cmdline_fixed_string_t on;
4420 cmdline_parse_token_string_t cmd_mirror_link_set =
4421 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4423 cmdline_parse_token_string_t cmd_mirror_link_port =
4424 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4426 cmdline_parse_token_string_t cmd_mirror_link_portid =
4427 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4429 cmdline_parse_token_string_t cmd_mirror_link_mirror =
4430 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4431 mirror, "mirror-rule");
4432 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
4433 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4435 cmdline_parse_token_string_t cmd_mirror_link_what =
4436 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4437 what, "uplink-mirror#downlink-mirror");
4438 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
4439 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4440 dstpool, "dst-pool");
4441 cmdline_parse_token_num_t cmd_mirror_link_poolid =
4442 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
4444 cmdline_parse_token_string_t cmd_mirror_link_on =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
4449 cmd_set_mirror_link_parsed(void *parsed_result,
4450 __attribute__((unused)) struct cmdline *cl,
4451 __attribute__((unused)) void *data)
4454 struct cmd_set_mirror_link_result *res = parsed_result;
4455 struct rte_eth_vmdq_mirror_conf mr_conf;
4457 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
4458 if(!strcmp(res->what, "uplink-mirror")) {
4459 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
4460 }else if(!strcmp(res->what, "downlink-mirror"))
4461 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
4463 mr_conf.dst_pool = res->dstpool_id;
4465 if(!strcmp(res->on, "on"))
4466 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4469 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
4472 /* check the return value and print it if is < 0 */
4474 printf("mirror rule add error: (%s)\n", strerror(-ret));
4478 cmdline_parse_inst_t cmd_set_mirror_link = {
4479 .f = cmd_set_mirror_link_parsed,
4481 .help_str = "set port X mirror-rule Y uplink-mirror|"
4482 "downlink-mirror dst-pool Z on|off",
4484 (void *)&cmd_mirror_link_set,
4485 (void *)&cmd_mirror_link_port,
4486 (void *)&cmd_mirror_link_portid,
4487 (void *)&cmd_mirror_link_mirror,
4488 (void *)&cmd_mirror_link_ruleid,
4489 (void *)&cmd_mirror_link_what,
4490 (void *)&cmd_mirror_link_dstpool,
4491 (void *)&cmd_mirror_link_poolid,
4492 (void *)&cmd_mirror_link_on,
4497 /* *** RESET VM MIRROR RULE *** */
4498 struct cmd_rm_mirror_rule_result {
4499 cmdline_fixed_string_t reset;
4500 cmdline_fixed_string_t port;
4502 cmdline_fixed_string_t mirror;
4506 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
4507 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4509 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
4510 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4512 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
4513 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4515 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
4516 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
4517 mirror, "mirror-rule");
4518 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
4519 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
4523 cmd_reset_mirror_rule_parsed(void *parsed_result,
4524 __attribute__((unused)) struct cmdline *cl,
4525 __attribute__((unused)) void *data)
4528 struct cmd_set_mirror_link_result *res = parsed_result;
4530 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
4532 printf("mirror rule remove error: (%s)\n", strerror(-ret));
4535 cmdline_parse_inst_t cmd_reset_mirror_rule = {
4536 .f = cmd_reset_mirror_rule_parsed,
4538 .help_str = "reset port X mirror-rule Y",
4540 (void *)&cmd_rm_mirror_rule_reset,
4541 (void *)&cmd_rm_mirror_rule_port,
4542 (void *)&cmd_rm_mirror_rule_portid,
4543 (void *)&cmd_rm_mirror_rule_mirror,
4544 (void *)&cmd_rm_mirror_rule_ruleid,
4549 /* ******************************************************************************** */
4551 /* list of instructions */
4552 cmdline_parse_ctx_t main_ctx[] = {
4553 (cmdline_parse_inst_t *)&cmd_help_brief,
4554 (cmdline_parse_inst_t *)&cmd_help_long,
4555 (cmdline_parse_inst_t *)&cmd_quit,
4556 (cmdline_parse_inst_t *)&cmd_showport,
4557 (cmdline_parse_inst_t *)&cmd_showportall,
4558 (cmdline_parse_inst_t *)&cmd_showcfg,
4559 (cmdline_parse_inst_t *)&cmd_start,
4560 (cmdline_parse_inst_t *)&cmd_start_tx_first,
4561 (cmdline_parse_inst_t *)&cmd_reset,
4562 (cmdline_parse_inst_t *)&cmd_set_numbers,
4563 (cmdline_parse_inst_t *)&cmd_set_txpkts,
4564 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
4565 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
4566 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
4567 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
4568 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
4569 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
4570 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
4571 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
4572 (cmdline_parse_inst_t *)&cmd_vlan_offload,
4573 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
4574 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
4575 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
4576 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
4577 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
4578 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
4579 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
4580 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
4581 (cmdline_parse_inst_t *)&cmd_config_dcb,
4582 (cmdline_parse_inst_t *)&cmd_read_reg,
4583 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
4584 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
4585 (cmdline_parse_inst_t *)&cmd_write_reg,
4586 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
4587 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
4588 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
4589 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
4590 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
4591 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
4592 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
4593 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
4594 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
4595 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
4596 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
4597 (cmdline_parse_inst_t *)&cmd_stop,
4598 (cmdline_parse_inst_t *)&cmd_mac_addr,
4599 (cmdline_parse_inst_t *)&cmd_set_qmap,
4600 (cmdline_parse_inst_t *)&cmd_operate_port,
4601 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
4602 (cmdline_parse_inst_t *)&cmd_config_speed_all,
4603 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
4604 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
4605 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
4606 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
4607 (cmdline_parse_inst_t *)&cmd_config_rss,
4608 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
4609 (cmdline_parse_inst_t *)&cmd_showport_reta,
4610 (cmdline_parse_inst_t *)&cmd_config_burst,
4611 (cmdline_parse_inst_t *)&cmd_config_thresh,
4612 (cmdline_parse_inst_t *)&cmd_config_threshold,
4613 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
4614 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
4615 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
4616 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
4617 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
4618 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
4619 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
4620 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
4621 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
4625 /* prompt function, called from main on MASTER lcore */
4631 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
4635 cmdline_interact(cl);
4636 cmdline_stdin_exit(cl);
4640 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
4642 if (id < nb_ports) {
4643 /* check if need_reconfig has been set to 1 */
4644 if (ports[id].need_reconfig == 0)
4645 ports[id].need_reconfig = dev;
4646 /* check if need_reconfig_queues has been set to 1 */
4647 if (ports[id].need_reconfig_queues == 0)
4648 ports[id].need_reconfig_queues = queue;
4652 for (pid = 0; pid < nb_ports; pid++) {
4653 /* check if need_reconfig has been set to 1 */
4654 if (ports[pid].need_reconfig == 0)
4655 ports[pid].need_reconfig = dev;
4656 /* check if need_reconfig_queues has been set to 1 */
4657 if (ports[pid].need_reconfig_queues == 0)
4658 ports[pid].need_reconfig_queues = queue;