4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 #include <net/socket.h>
48 #include <sys/socket.h>
51 #include <netinet/in.h>
53 #include <sys/queue.h>
55 #include <rte_common.h>
56 #include <rte_byteorder.h>
58 #include <rte_debug.h>
59 #include <rte_cycles.h>
60 #include <rte_memory.h>
61 #include <rte_memzone.h>
62 #include <rte_launch.h>
63 #include <rte_tailq.h>
65 #include <rte_per_lcore.h>
66 #include <rte_lcore.h>
67 #include <rte_atomic.h>
68 #include <rte_branch_prediction.h>
70 #include <rte_mempool.h>
71 #include <rte_interrupts.h>
73 #include <rte_ether.h>
74 #include <rte_ethdev.h>
75 #include <rte_string_fns.h>
76 #include <rte_devargs.h>
78 #include <cmdline_rdline.h>
79 #include <cmdline_parse.h>
80 #include <cmdline_parse_num.h>
81 #include <cmdline_parse_string.h>
82 #include <cmdline_parse_ipaddr.h>
83 #include <cmdline_parse_etheraddr.h>
84 #include <cmdline_socket.h>
86 #include <rte_pci_dev_ids.h>
90 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
93 uint8_t bypass_is_supported(portid_t port_id);
96 /* *** Help command with introduction. *** */
97 struct cmd_help_brief_result {
98 cmdline_fixed_string_t help;
101 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
103 __attribute__((unused)) void *data)
108 "Help is available for the following sections:\n\n"
109 " help control : Start and stop forwarding.\n"
110 " help display : Displaying port, stats and config "
112 " help config : Configuration information.\n"
113 " help ports : Configuring ports.\n"
114 " help flowdir : Flow Director filter help.\n"
115 " help registers : Reading and setting port registers.\n"
116 " help filters : Filters configuration help.\n"
117 " help all : All of the above sections.\n\n"
122 cmdline_parse_token_string_t cmd_help_brief_help =
123 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
125 cmdline_parse_inst_t cmd_help_brief = {
126 .f = cmd_help_brief_parsed,
128 .help_str = "show help",
130 (void *)&cmd_help_brief_help,
135 /* *** Help command with help sections. *** */
136 struct cmd_help_long_result {
137 cmdline_fixed_string_t help;
138 cmdline_fixed_string_t section;
141 static void cmd_help_long_parsed(void *parsed_result,
143 __attribute__((unused)) void *data)
146 struct cmd_help_long_result *res = parsed_result;
148 if (!strcmp(res->section, "all"))
151 if (show_all || !strcmp(res->section, "control")) {
156 "Control forwarding:\n"
157 "-------------------\n\n"
160 " Start packet forwarding with current configuration.\n\n"
163 " Start packet forwarding with current config"
164 " after sending one burst of packets.\n\n"
167 " Stop packet forwarding, and display accumulated"
171 " Quit to prompt in Linux and reboot on Baremetal.\n\n"
175 if (show_all || !strcmp(res->section, "display")) {
183 "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
184 " Display information for port_id, or all.\n\n"
186 "show port rss-hash [key]\n"
187 " Display the RSS hash functions and RSS hash key"
190 "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
191 " Clear information for port_id, or all.\n\n"
193 "show config (rxtx|cores|fwd)\n"
194 " Display the given configuration.\n\n"
196 "read rxd (port_id) (queue_id) (rxd_id)\n"
197 " Display an RX descriptor of a port RX queue.\n\n"
199 "read txd (port_id) (queue_id) (txd_id)\n"
200 " Display a TX descriptor of a port TX queue.\n\n"
204 if (show_all || !strcmp(res->section, "config")) {
210 "Configuration changes only become active when"
211 " forwarding is started/restarted.\n\n"
214 " Reset forwarding to the default configuration.\n\n"
216 "set verbose (level)\n"
217 " Set the debug verbosity level X.\n\n"
220 " Set number of ports.\n\n"
223 " Set number of cores.\n\n"
225 "set coremask (mask)\n"
226 " Set the forwarding cores hexadecimal mask.\n\n"
228 "set portmask (mask)\n"
229 " Set the forwarding ports hexadecimal mask.\n\n"
232 " Set number of packets per burst.\n\n"
234 "set burst tx delay (microseconds) retry (num)\n"
235 " Set the transmit delay time and number of retries"
236 " in mac_retry forwarding mode.\n\n"
238 "set txpkts (x[,y]*)\n"
239 " Set the length of each segment of TXONLY"
242 "set corelist (x[,y]*)\n"
243 " Set the list of forwarding cores.\n\n"
245 "set portlist (x[,y]*)\n"
246 " Set the list of forwarding ports.\n\n"
248 "vlan set strip (on|off) (port_id)\n"
249 " Set the VLAN strip on a port.\n\n"
251 "vlan set stripq (on|off) (port_id,queue_id)\n"
252 " Set the VLAN strip for a queue on a port.\n\n"
254 "vlan set filter (on|off) (port_id)\n"
255 " Set the VLAN filter on a port.\n\n"
257 "vlan set qinq (on|off) (port_id)\n"
258 " Set the VLAN QinQ (extended queue in queue)"
261 "vlan set tpid (value) (port_id)\n"
262 " Set the outer VLAN TPID for Packet Filtering on"
265 "rx_vlan add (vlan_id|all) (port_id)\n"
266 " Add a vlan_id, or all identifiers, to the set"
267 " of VLAN identifiers filtered by port_id.\n\n"
269 "rx_vlan rm (vlan_id|all) (port_id)\n"
270 " Remove a vlan_id, or all identifiers, from the set"
271 " of VLAN identifiers filtered by port_id.\n\n"
273 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
274 " Add a vlan_id, to the set of VLAN identifiers"
275 "filtered for VF(s) from port_id.\n\n"
277 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
278 " Remove a vlan_id, to the set of VLAN identifiers"
279 "filtered for VF(s) from port_id.\n\n"
281 "rx_vlan set tpid (value) (port_id)\n"
282 " Set the outer VLAN TPID for Packet Filtering on"
285 "tx_vlan set vlan_id (port_id)\n"
286 " Set hardware insertion of VLAN ID in packets sent"
289 "tx_vlan reset (port_id)\n"
290 " Disable hardware insertion of a VLAN header in"
291 " packets sent on a port.\n\n"
293 "tx_checksum set mask (port_id)\n"
294 " Enable hardware insertion of checksum offload with"
295 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
296 " bit 0 - insert ip checksum offload if set\n"
297 " bit 1 - insert udp checksum offload if set\n"
298 " bit 2 - insert tcp checksum offload if set\n"
299 " bit 3 - insert sctp checksum offload if set\n"
300 " Please check the NIC datasheet for HW limits.\n\n"
303 " Set packet forwarding mode.\n\n"
305 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
306 " Add a MAC address on port_id.\n\n"
308 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
309 " Remove a MAC address from port_id.\n\n"
311 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
312 " Add a MAC address for a VF on the port.\n\n"
314 "set port (port_id) uta (mac_address|all) (on|off)\n"
315 " Add/Remove a or all unicast hash filter(s)"
318 "set promisc (port_id|all) (on|off)\n"
319 " Set the promiscuous mode on port_id, or all.\n\n"
321 "set allmulti (port_id|all) (on|off)\n"
322 " Set the allmulti mode on port_id, or all.\n\n"
324 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
325 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
326 " (on|off) (port_id)\n"
327 " Set the link flow control parameter on a port.\n\n"
329 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
330 " (low_water) (pause_time) (priority) (port_id)\n"
331 " Set the priority flow control parameter on a"
334 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
335 " Set statistics mapping (qmapping 0..15) for RX/TX"
337 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
338 " on port 0 to mapping 5.\n\n"
340 "set port (port_id) vf (vf_id) rx|tx on|off \n"
341 " Enable/Disable a VF receive/tranmit from a port\n\n"
343 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
345 " AUPE:accepts untagged VLAN;"
346 "ROPE:accept unicast hash\n\n"
347 " BAM:accepts broadcast packets;"
348 "MPE:accepts all multicast packets\n\n"
349 " Enable/Disable a VF receive mode of a port\n\n"
351 "set port (port_id) queue (queue_id) rate (rate_num)\n"
352 " Set rate limit for a queue of a port\n\n"
354 "set port (port_id) vf (vf_id) rate (rate_num) "
355 "queue_mask (queue_mask_value)\n"
356 " Set rate limit for queues in VF of a port\n\n"
358 "set port (port_id) mirror-rule (rule_id)"
359 "(pool-mirror|vlan-mirror)\n"
360 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
361 " Set pool or vlan type mirror rule on a port.\n"
362 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
363 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
366 "set port (port_id) mirror-rule (rule_id)"
367 " (uplink-mirror|downlink-mirror) dst-pool"
368 " (pool_id) (on|off)\n"
369 " Set uplink or downlink type mirror rule on a port.\n"
370 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
371 " 0 on' enable mirror income traffic to pool 0.\n\n"
373 "reset port (port_id) mirror-rule (rule_id)\n"
374 " Reset a mirror rule.\n\n"
376 "set flush_rx (on|off)\n"
377 " Flush (default) or don't flush RX streams before"
378 " forwarding. Mainly used with PCAP drivers.\n\n"
380 #ifdef RTE_NIC_BYPASS
381 "set bypass mode (normal|bypass|isolate) (port_id)\n"
382 " Set the bypass mode for the lowest port on bypass enabled"
385 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
386 "mode (normal|bypass|isolate) (port_id)\n"
387 " Set the event required to initiate specified bypass mode for"
388 " the lowest port on a bypass enabled NIC where:\n"
389 " timeout = enable bypass after watchdog timeout.\n"
390 " os_on = enable bypass when OS/board is powered on.\n"
391 " os_off = enable bypass when OS/board is powered off.\n"
392 " power_on = enable bypass when power supply is turned on.\n"
393 " power_off = enable bypass when power supply is turned off."
396 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
397 " Set the bypass watchdog timeout to 'n' seconds"
398 " where 0 = instant.\n\n"
400 "show bypass config (port_id)\n"
401 " Show the bypass configuration for a bypass enabled NIC"
402 " using the lowest port on the NIC.\n\n"
405 , list_pkt_forwarding_modes()
410 if (show_all || !strcmp(res->section, "flowdir")) {
415 "Flow director mode:\n"
416 "-------------------\n\n"
418 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
419 " src (src_ip_address) (src_port)"
420 " dst (dst_ip_address) (dst_port)"
421 " flexbytes (flexbytes_values) vlan (vlan_id)"
422 " queue (queue_id)\n"
423 " Add a signature filter.\n\n"
425 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
426 " src (src_ip_address) (src_port)"
427 " dst (dst_ip_address) (dst_port)"
428 " flexbytes (flexbytes_values) vlan (vlan_id)"
429 " queue (queue_id)\n"
430 " Update a signature filter.\n\n"
432 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
433 " src (src_ip_address) (src_port)"
434 " dst (dst_ip_address) (dst_port)"
435 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
436 " Remove a signature filter.\n\n"
438 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
439 " src (src_ip_address) (src_port)"
440 " dst (dst_ip_address) (dst_port)"
441 " flexbytes (flexbytes_values) vlan (vlan_id)"
442 " queue (queue_id) soft (soft_id)\n"
443 " Add a perfect filter.\n\n"
445 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
446 " src (src_ip_address) (src_port)"
447 " dst (dst_ip_address) (dst_port)"
448 " flexbytes (flexbytes_values) vlan (vlan_id)"
449 " queue (queue_id)\n"
450 " Update a perfect filter.\n\n"
452 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
453 " src (src_ip_address) (src_port)"
454 " dst (dst_ip_address) (dst_port)"
455 " flexbytes (flexbytes_values) vlan (vlan_id)"
457 " Remove a perfect filter.\n\n"
459 "set_masks_filter (port_id) only_ip_flow (0|1)"
460 " src_mask (ip_src_mask) (src_port_mask)"
461 " dst_mask (ip_dst_mask) (dst_port_mask)"
462 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
463 " Set IPv4 filter masks.\n\n"
465 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
466 " src_mask (ip_src_mask) (src_port_mask)"
467 " dst_mask (ip_dst_mask) (dst_port_mask)"
468 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
469 " compare_dst (0|1)\n"
470 " Set IPv6 filter masks.\n\n"
474 if (show_all || !strcmp(res->section, "ports")) {
480 "----------------\n\n"
482 "port start (port_id|all)\n"
483 " Start all ports or port_id.\n\n"
485 "port stop (port_id|all)\n"
486 " Stop all ports or port_id.\n\n"
488 "port close (port_id|all)\n"
489 " Close all ports or port_id.\n\n"
491 "port config (port_id|all) speed (10|100|1000|10000|auto)"
492 " duplex (half|full|auto)\n"
493 " Set speed and duplex for all ports or port_id\n\n"
495 "port config all (rxq|txq|rxd|txd) (value)\n"
496 " Set number for rxq/txq/rxd/txd.\n\n"
498 "port config all max-pkt-len (value)\n"
499 " Set the max packet length.\n\n"
501 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
503 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
506 "port config all rss (ip|udp|none)\n"
507 " Set the RSS mode.\n\n"
509 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
510 " Set the RSS redirection table.\n\n"
512 "port config (port_id) dcb vt (on|off) (traffic_class)"
514 " Set the DCB mode.\n\n"
516 "port config all burst (value)\n"
517 " Set the number of packets per burst.\n\n"
519 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
521 " Set the ring prefetch/host/writeback threshold"
522 " for tx/rx queue.\n\n"
524 "port config all (txfreet|txrst|rxfreet) (value)\n"
525 " Set free threshold for rx/tx, or set"
526 " tx rs bit threshold.\n\n"
530 if (show_all || !strcmp(res->section, "registers")) {
538 "read reg (port_id) (address)\n"
539 " Display value of a port register.\n\n"
541 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
542 " Display a port register bit field.\n\n"
544 "read regbit (port_id) (address) (bit_x)\n"
545 " Display a single port register bit.\n\n"
547 "write reg (port_id) (address) (value)\n"
548 " Set value of a port register.\n\n"
550 "write regfield (port_id) (address) (bit_x) (bit_y)"
552 " Set bit field of a port register.\n\n"
554 "write regbit (port_id) (address) (bit_x) (value)\n"
555 " Set single bit value of a port register.\n\n"
558 if (show_all || !strcmp(res->section, "filters")) {
566 "add_ethertype_filter (port_id) ethertype (eth_value)"
567 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
568 " add an ethertype filter.\n\n"
570 "remove_ethertype_filter (port_id) index (idx)\n"
571 " remove an ethertype filter.\n\n"
573 "get_ethertype_filter (port_id) index (idx)\n"
574 " get info of a ethertype filter.\n\n"
576 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
577 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
578 " queue (queue_id) index (idx)\n"
579 " add a 2tuple filter.\n\n"
581 "remove_2tuple_filter (port_id) index (idx)\n"
582 " remove a 2tuple filter.\n\n"
584 "get_2tuple_filter (port_id) index (idx)\n"
585 " get info of a 2tuple filter.\n\n"
587 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
588 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
589 " mask (mask_value) flags (flags_value) priority (prio_value)"
590 " queue (queue_id) index (idx)\n"
591 " add a 5tuple filter.\n\n"
593 "remove_5tuple_filter (port_id) index (idx)\n"
594 " remove a 5tuple filter.\n\n"
596 "get_5tuple_filter (port_id) index (idx)\n"
597 " get info of a 5tuple filter.\n\n"
599 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
600 " add syn filter.\n\n"
602 "remove_syn_filter (port_id)"
603 " remove syn filter.\n\n"
605 "get_syn_filter (port_id) "
606 " get syn filter info.\n\n"
608 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
609 " priority (prio_value) queue (queue_id) index (idx)\n"
610 " add a flex filter.\n\n"
612 "remove_flex_filter (port_id) index (idx)\n"
613 " remove a flex filter.\n\n"
615 "get_flex_filter (port_id) index (idx)\n"
616 " get info of a flex filter.\n\n"
621 cmdline_parse_token_string_t cmd_help_long_help =
622 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
624 cmdline_parse_token_string_t cmd_help_long_section =
625 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
626 "all#control#display#config#flowdir#"
627 "ports#registers#filters");
629 cmdline_parse_inst_t cmd_help_long = {
630 .f = cmd_help_long_parsed,
632 .help_str = "show help",
634 (void *)&cmd_help_long_help,
635 (void *)&cmd_help_long_section,
641 /* *** start/stop/close all ports *** */
642 struct cmd_operate_port_result {
643 cmdline_fixed_string_t keyword;
644 cmdline_fixed_string_t name;
645 cmdline_fixed_string_t value;
648 static void cmd_operate_port_parsed(void *parsed_result,
649 __attribute__((unused)) struct cmdline *cl,
650 __attribute__((unused)) void *data)
652 struct cmd_operate_port_result *res = parsed_result;
654 if (!strcmp(res->name, "start"))
655 start_port(RTE_PORT_ALL);
656 else if (!strcmp(res->name, "stop"))
657 stop_port(RTE_PORT_ALL);
658 else if (!strcmp(res->name, "close"))
659 close_port(RTE_PORT_ALL);
661 printf("Unknown parameter\n");
664 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
665 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
667 cmdline_parse_token_string_t cmd_operate_port_all_port =
668 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
670 cmdline_parse_token_string_t cmd_operate_port_all_all =
671 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
673 cmdline_parse_inst_t cmd_operate_port = {
674 .f = cmd_operate_port_parsed,
676 .help_str = "port start|stop|close all: start/stop/close all ports",
678 (void *)&cmd_operate_port_all_cmd,
679 (void *)&cmd_operate_port_all_port,
680 (void *)&cmd_operate_port_all_all,
685 /* *** start/stop/close specific port *** */
686 struct cmd_operate_specific_port_result {
687 cmdline_fixed_string_t keyword;
688 cmdline_fixed_string_t name;
692 static void cmd_operate_specific_port_parsed(void *parsed_result,
693 __attribute__((unused)) struct cmdline *cl,
694 __attribute__((unused)) void *data)
696 struct cmd_operate_specific_port_result *res = parsed_result;
698 if (!strcmp(res->name, "start"))
699 start_port(res->value);
700 else if (!strcmp(res->name, "stop"))
701 stop_port(res->value);
702 else if (!strcmp(res->name, "close"))
703 close_port(res->value);
705 printf("Unknown parameter\n");
708 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
709 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
711 cmdline_parse_token_string_t cmd_operate_specific_port_port =
712 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
713 name, "start#stop#close");
714 cmdline_parse_token_num_t cmd_operate_specific_port_id =
715 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
718 cmdline_parse_inst_t cmd_operate_specific_port = {
719 .f = cmd_operate_specific_port_parsed,
721 .help_str = "port start|stop|close X: start/stop/close port X",
723 (void *)&cmd_operate_specific_port_cmd,
724 (void *)&cmd_operate_specific_port_port,
725 (void *)&cmd_operate_specific_port_id,
730 /* *** configure speed for all ports *** */
731 struct cmd_config_speed_all {
732 cmdline_fixed_string_t port;
733 cmdline_fixed_string_t keyword;
734 cmdline_fixed_string_t all;
735 cmdline_fixed_string_t item1;
736 cmdline_fixed_string_t item2;
737 cmdline_fixed_string_t value1;
738 cmdline_fixed_string_t value2;
742 cmd_config_speed_all_parsed(void *parsed_result,
743 __attribute__((unused)) struct cmdline *cl,
744 __attribute__((unused)) void *data)
746 struct cmd_config_speed_all *res = parsed_result;
747 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
748 uint16_t link_duplex = 0;
751 if (!all_ports_stopped()) {
752 printf("Please stop all ports first\n");
756 if (!strcmp(res->value1, "10"))
757 link_speed = ETH_LINK_SPEED_10;
758 else if (!strcmp(res->value1, "100"))
759 link_speed = ETH_LINK_SPEED_100;
760 else if (!strcmp(res->value1, "1000"))
761 link_speed = ETH_LINK_SPEED_1000;
762 else if (!strcmp(res->value1, "10000"))
763 link_speed = ETH_LINK_SPEED_10000;
764 else if (!strcmp(res->value1, "auto"))
765 link_speed = ETH_LINK_SPEED_AUTONEG;
767 printf("Unknown parameter\n");
771 if (!strcmp(res->value2, "half"))
772 link_duplex = ETH_LINK_HALF_DUPLEX;
773 else if (!strcmp(res->value2, "full"))
774 link_duplex = ETH_LINK_FULL_DUPLEX;
775 else if (!strcmp(res->value2, "auto"))
776 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
778 printf("Unknown parameter\n");
782 for (pid = 0; pid < nb_ports; pid++) {
783 ports[pid].dev_conf.link_speed = link_speed;
784 ports[pid].dev_conf.link_duplex = link_duplex;
787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
790 cmdline_parse_token_string_t cmd_config_speed_all_port =
791 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
792 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
793 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
795 cmdline_parse_token_string_t cmd_config_speed_all_all =
796 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
797 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
798 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
799 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
800 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
801 "10#100#1000#10000#auto");
802 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
803 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
804 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
805 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
808 cmdline_parse_inst_t cmd_config_speed_all = {
809 .f = cmd_config_speed_all_parsed,
811 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
814 (void *)&cmd_config_speed_all_port,
815 (void *)&cmd_config_speed_all_keyword,
816 (void *)&cmd_config_speed_all_all,
817 (void *)&cmd_config_speed_all_item1,
818 (void *)&cmd_config_speed_all_value1,
819 (void *)&cmd_config_speed_all_item2,
820 (void *)&cmd_config_speed_all_value2,
825 /* *** configure speed for specific port *** */
826 struct cmd_config_speed_specific {
827 cmdline_fixed_string_t port;
828 cmdline_fixed_string_t keyword;
830 cmdline_fixed_string_t item1;
831 cmdline_fixed_string_t item2;
832 cmdline_fixed_string_t value1;
833 cmdline_fixed_string_t value2;
837 cmd_config_speed_specific_parsed(void *parsed_result,
838 __attribute__((unused)) struct cmdline *cl,
839 __attribute__((unused)) void *data)
841 struct cmd_config_speed_specific *res = parsed_result;
842 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
843 uint16_t link_duplex = 0;
845 if (!all_ports_stopped()) {
846 printf("Please stop all ports first\n");
850 if (res->id >= nb_ports) {
851 printf("Port id %d must be less than %d\n", res->id, nb_ports);
855 if (!strcmp(res->value1, "10"))
856 link_speed = ETH_LINK_SPEED_10;
857 else if (!strcmp(res->value1, "100"))
858 link_speed = ETH_LINK_SPEED_100;
859 else if (!strcmp(res->value1, "1000"))
860 link_speed = ETH_LINK_SPEED_1000;
861 else if (!strcmp(res->value1, "10000"))
862 link_speed = ETH_LINK_SPEED_10000;
863 else if (!strcmp(res->value1, "auto"))
864 link_speed = ETH_LINK_SPEED_AUTONEG;
866 printf("Unknown parameter\n");
870 if (!strcmp(res->value2, "half"))
871 link_duplex = ETH_LINK_HALF_DUPLEX;
872 else if (!strcmp(res->value2, "full"))
873 link_duplex = ETH_LINK_FULL_DUPLEX;
874 else if (!strcmp(res->value2, "auto"))
875 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
877 printf("Unknown parameter\n");
881 ports[res->id].dev_conf.link_speed = link_speed;
882 ports[res->id].dev_conf.link_duplex = link_duplex;
884 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
888 cmdline_parse_token_string_t cmd_config_speed_specific_port =
889 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
891 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
892 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
894 cmdline_parse_token_num_t cmd_config_speed_specific_id =
895 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
896 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
897 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
899 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
900 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
901 "10#100#1000#10000#auto");
902 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
903 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
905 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
906 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
909 cmdline_parse_inst_t cmd_config_speed_specific = {
910 .f = cmd_config_speed_specific_parsed,
912 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
915 (void *)&cmd_config_speed_specific_port,
916 (void *)&cmd_config_speed_specific_keyword,
917 (void *)&cmd_config_speed_specific_id,
918 (void *)&cmd_config_speed_specific_item1,
919 (void *)&cmd_config_speed_specific_value1,
920 (void *)&cmd_config_speed_specific_item2,
921 (void *)&cmd_config_speed_specific_value2,
926 /* *** configure txq/rxq, txd/rxd *** */
927 struct cmd_config_rx_tx {
928 cmdline_fixed_string_t port;
929 cmdline_fixed_string_t keyword;
930 cmdline_fixed_string_t all;
931 cmdline_fixed_string_t name;
936 cmd_config_rx_tx_parsed(void *parsed_result,
937 __attribute__((unused)) struct cmdline *cl,
938 __attribute__((unused)) void *data)
940 struct cmd_config_rx_tx *res = parsed_result;
942 if (!all_ports_stopped()) {
943 printf("Please stop all ports first\n");
947 if (!strcmp(res->name, "rxq")) {
948 if (res->value <= 0) {
949 printf("rxq %d invalid - must be > 0\n", res->value);
954 else if (!strcmp(res->name, "txq")) {
955 if (res->value <= 0) {
956 printf("txq %d invalid - must be > 0\n", res->value);
961 else if (!strcmp(res->name, "rxd")) {
962 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
963 printf("rxd %d invalid - must be > 0 && <= %d\n",
964 res->value, RTE_TEST_RX_DESC_MAX);
968 } else if (!strcmp(res->name, "txd")) {
969 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
970 printf("txd %d invalid - must be > 0 && <= %d\n",
971 res->value, RTE_TEST_TX_DESC_MAX);
976 printf("Unknown parameter\n");
982 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
985 cmdline_parse_token_string_t cmd_config_rx_tx_port =
986 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
987 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
988 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
989 cmdline_parse_token_string_t cmd_config_rx_tx_all =
990 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
991 cmdline_parse_token_string_t cmd_config_rx_tx_name =
992 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
994 cmdline_parse_token_num_t cmd_config_rx_tx_value =
995 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
997 cmdline_parse_inst_t cmd_config_rx_tx = {
998 .f = cmd_config_rx_tx_parsed,
1000 .help_str = "port config all rxq|txq|rxd|txd value",
1002 (void *)&cmd_config_rx_tx_port,
1003 (void *)&cmd_config_rx_tx_keyword,
1004 (void *)&cmd_config_rx_tx_all,
1005 (void *)&cmd_config_rx_tx_name,
1006 (void *)&cmd_config_rx_tx_value,
1011 /* *** config max packet length *** */
1012 struct cmd_config_max_pkt_len_result {
1013 cmdline_fixed_string_t port;
1014 cmdline_fixed_string_t keyword;
1015 cmdline_fixed_string_t all;
1016 cmdline_fixed_string_t name;
1021 cmd_config_max_pkt_len_parsed(void *parsed_result,
1022 __attribute__((unused)) struct cmdline *cl,
1023 __attribute__((unused)) void *data)
1025 struct cmd_config_max_pkt_len_result *res = parsed_result;
1027 if (!all_ports_stopped()) {
1028 printf("Please stop all ports first\n");
1032 if (!strcmp(res->name, "max-pkt-len")) {
1033 if (res->value < ETHER_MIN_LEN) {
1034 printf("max-pkt-len can not be less than %d\n",
1038 if (res->value == rx_mode.max_rx_pkt_len)
1041 rx_mode.max_rx_pkt_len = res->value;
1042 if (res->value > ETHER_MAX_LEN)
1043 rx_mode.jumbo_frame = 1;
1045 rx_mode.jumbo_frame = 0;
1047 printf("Unknown parameter\n");
1053 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1056 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1057 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1059 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1060 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1062 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1063 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1065 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1066 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1068 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1069 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1072 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1073 .f = cmd_config_max_pkt_len_parsed,
1075 .help_str = "port config all max-pkt-len value",
1077 (void *)&cmd_config_max_pkt_len_port,
1078 (void *)&cmd_config_max_pkt_len_keyword,
1079 (void *)&cmd_config_max_pkt_len_all,
1080 (void *)&cmd_config_max_pkt_len_name,
1081 (void *)&cmd_config_max_pkt_len_value,
1086 /* *** configure rx mode *** */
1087 struct cmd_config_rx_mode_flag {
1088 cmdline_fixed_string_t port;
1089 cmdline_fixed_string_t keyword;
1090 cmdline_fixed_string_t all;
1091 cmdline_fixed_string_t name;
1092 cmdline_fixed_string_t value;
1096 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1097 __attribute__((unused)) struct cmdline *cl,
1098 __attribute__((unused)) void *data)
1100 struct cmd_config_rx_mode_flag *res = parsed_result;
1102 if (!all_ports_stopped()) {
1103 printf("Please stop all ports first\n");
1107 if (!strcmp(res->name, "crc-strip")) {
1108 if (!strcmp(res->value, "on"))
1109 rx_mode.hw_strip_crc = 1;
1110 else if (!strcmp(res->value, "off"))
1111 rx_mode.hw_strip_crc = 0;
1113 printf("Unknown parameter\n");
1116 } else if (!strcmp(res->name, "rx-cksum")) {
1117 if (!strcmp(res->value, "on"))
1118 rx_mode.hw_ip_checksum = 1;
1119 else if (!strcmp(res->value, "off"))
1120 rx_mode.hw_ip_checksum = 0;
1122 printf("Unknown parameter\n");
1125 } else if (!strcmp(res->name, "hw-vlan")) {
1126 if (!strcmp(res->value, "on")) {
1127 rx_mode.hw_vlan_filter = 1;
1128 rx_mode.hw_vlan_strip = 1;
1130 else if (!strcmp(res->value, "off")) {
1131 rx_mode.hw_vlan_filter = 0;
1132 rx_mode.hw_vlan_strip = 0;
1135 printf("Unknown parameter\n");
1138 } else if (!strcmp(res->name, "drop-en")) {
1139 if (!strcmp(res->value, "on"))
1141 else if (!strcmp(res->value, "off"))
1144 printf("Unknown parameter\n");
1148 printf("Unknown parameter\n");
1154 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1157 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1158 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1159 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1160 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1162 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1163 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1164 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1165 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1166 "crc-strip#rx-cksum#hw-vlan");
1167 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1168 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1171 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1172 .f = cmd_config_rx_mode_flag_parsed,
1174 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1176 (void *)&cmd_config_rx_mode_flag_port,
1177 (void *)&cmd_config_rx_mode_flag_keyword,
1178 (void *)&cmd_config_rx_mode_flag_all,
1179 (void *)&cmd_config_rx_mode_flag_name,
1180 (void *)&cmd_config_rx_mode_flag_value,
1185 /* *** configure rss *** */
1186 struct cmd_config_rss {
1187 cmdline_fixed_string_t port;
1188 cmdline_fixed_string_t keyword;
1189 cmdline_fixed_string_t all;
1190 cmdline_fixed_string_t name;
1191 cmdline_fixed_string_t value;
1195 cmd_config_rss_parsed(void *parsed_result,
1196 __attribute__((unused)) struct cmdline *cl,
1197 __attribute__((unused)) void *data)
1199 struct cmd_config_rss *res = parsed_result;
1200 struct rte_eth_rss_conf rss_conf;
1203 if (!strcmp(res->value, "ip"))
1204 rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
1205 else if (!strcmp(res->value, "udp"))
1206 rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
1207 else if (!strcmp(res->value, "none"))
1208 rss_conf.rss_hf = 0;
1210 printf("Unknown parameter\n");
1213 rss_conf.rss_key = NULL;
1214 for (i = 0; i < rte_eth_dev_count(); i++)
1215 rte_eth_dev_rss_hash_update(i, &rss_conf);
1218 cmdline_parse_token_string_t cmd_config_rss_port =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1220 cmdline_parse_token_string_t cmd_config_rss_keyword =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1222 cmdline_parse_token_string_t cmd_config_rss_all =
1223 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1224 cmdline_parse_token_string_t cmd_config_rss_name =
1225 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1226 cmdline_parse_token_string_t cmd_config_rss_value =
1227 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1229 cmdline_parse_inst_t cmd_config_rss = {
1230 .f = cmd_config_rss_parsed,
1232 .help_str = "port config all rss ip|udp|none",
1234 (void *)&cmd_config_rss_port,
1235 (void *)&cmd_config_rss_keyword,
1236 (void *)&cmd_config_rss_all,
1237 (void *)&cmd_config_rss_name,
1238 (void *)&cmd_config_rss_value,
1243 /* *** configure rss hash key *** */
1244 struct cmd_config_rss_hash_key {
1245 cmdline_fixed_string_t port;
1246 cmdline_fixed_string_t config;
1248 cmdline_fixed_string_t rss_hash_key;
1249 cmdline_fixed_string_t key;
1252 #define RSS_HASH_KEY_LENGTH 40
1254 hexa_digit_to_value(char hexa_digit)
1256 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1257 return (uint8_t) (hexa_digit - '0');
1258 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1259 return (uint8_t) ((hexa_digit - 'a') + 10);
1260 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1261 return (uint8_t) ((hexa_digit - 'A') + 10);
1262 /* Invalid hexa digit */
1267 parse_and_check_key_hexa_digit(char *key, int idx)
1271 hexa_v = hexa_digit_to_value(key[idx]);
1273 printf("invalid key: character %c at position %d is not a "
1274 "valid hexa digit\n", key[idx], idx);
1279 cmd_config_rss_hash_key_parsed(void *parsed_result,
1280 __attribute__((unused)) struct cmdline *cl,
1281 __attribute__((unused)) void *data)
1283 struct cmd_config_rss_hash_key *res = parsed_result;
1284 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1289 /* Check the length of the RSS hash key */
1290 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1291 printf("key length: %d invalid - key must be a string of %d"
1292 "hexa-decimal numbers\n", (int) strlen(res->key),
1293 RSS_HASH_KEY_LENGTH * 2);
1296 /* Translate RSS hash key into binary representation */
1297 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1298 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1301 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1304 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1306 port_rss_hash_key_update(res->port_id, hash_key);
1309 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1311 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1314 cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
1315 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1316 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1318 rss_hash_key, "rss-hash-key");
1319 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1322 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1323 .f = cmd_config_rss_hash_key_parsed,
1325 .help_str = "port config X rss-hash-key 80 hexa digits",
1327 (void *)&cmd_config_rss_hash_key_port,
1328 (void *)&cmd_config_rss_hash_key_config,
1329 (void *)&cmd_config_rss_hash_key_port_id,
1330 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1331 (void *)&cmd_config_rss_hash_key_value,
1336 /* *** Configure RSS RETA *** */
1337 struct cmd_config_rss_reta {
1338 cmdline_fixed_string_t port;
1339 cmdline_fixed_string_t keyword;
1341 cmdline_fixed_string_t name;
1342 cmdline_fixed_string_t list_name;
1343 cmdline_fixed_string_t list_of_items;
1347 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1354 const char *p, *p0 = str;
1361 unsigned long int_fld[_NUM_FLD];
1362 char *str_fld[_NUM_FLD];
1364 while ((p = strchr(p0,'(')) != NULL) {
1366 if((p0 = strchr(p,')')) == NULL)
1370 if(size >= sizeof(s))
1373 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1374 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1376 for (i = 0; i < _NUM_FLD; i++) {
1378 int_fld[i] = strtoul(str_fld[i], &end, 0);
1379 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1383 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1384 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1386 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1387 printf("Invalid RETA hash index=%d",hash_index);
1391 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1392 reta_conf->mask_lo |= (1ULL << hash_index);
1394 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1396 reta_conf->reta[hash_index] = nb_queue;
1403 cmd_set_rss_reta_parsed(void *parsed_result,
1404 __attribute__((unused)) struct cmdline *cl,
1405 __attribute__((unused)) void *data)
1408 struct rte_eth_rss_reta reta_conf;
1409 struct cmd_config_rss_reta *res = parsed_result;
1411 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1412 if (!strcmp(res->list_name, "reta")) {
1413 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1414 printf("Invalid RSS Redirection Table config entered\n");
1417 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1419 printf("Bad redirection table parameter, return code = %d \n",ret);
1423 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1425 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1427 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1428 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1429 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1431 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1433 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1436 cmdline_parse_inst_t cmd_config_rss_reta = {
1437 .f = cmd_set_rss_reta_parsed,
1439 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1441 (void *)&cmd_config_rss_reta_port,
1442 (void *)&cmd_config_rss_reta_keyword,
1443 (void *)&cmd_config_rss_reta_port_id,
1444 (void *)&cmd_config_rss_reta_name,
1445 (void *)&cmd_config_rss_reta_list_name,
1446 (void *)&cmd_config_rss_reta_list_of_items,
1451 /* *** SHOW PORT RETA INFO *** */
1452 struct cmd_showport_reta {
1453 cmdline_fixed_string_t show;
1454 cmdline_fixed_string_t port;
1456 cmdline_fixed_string_t rss;
1457 cmdline_fixed_string_t reta;
1462 static void cmd_showport_reta_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_showport_reta *res = parsed_result;
1467 struct rte_eth_rss_reta reta_conf;
1469 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1470 printf("Invalid RSS Redirection Table config entered\n");
1474 reta_conf.mask_lo = res->mask_lo;
1475 reta_conf.mask_hi = res->mask_hi;
1477 port_rss_reta_info(res->port_id,&reta_conf);
1480 cmdline_parse_token_string_t cmd_showport_reta_show =
1481 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1482 cmdline_parse_token_string_t cmd_showport_reta_port =
1483 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1484 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1485 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1486 cmdline_parse_token_string_t cmd_showport_reta_rss =
1487 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1488 cmdline_parse_token_string_t cmd_showport_reta_reta =
1489 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1490 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1491 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1492 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1493 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1495 cmdline_parse_inst_t cmd_showport_reta = {
1496 .f = cmd_showport_reta_parsed,
1498 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1499 (mask_lo and mask_hi is UINT64)",
1501 (void *)&cmd_showport_reta_show,
1502 (void *)&cmd_showport_reta_port,
1503 (void *)&cmd_showport_reta_port_id,
1504 (void *)&cmd_showport_reta_rss,
1505 (void *)&cmd_showport_reta_reta,
1506 (void *)&cmd_showport_reta_mask_lo,
1507 (void *)&cmd_showport_reta_mask_hi,
1512 /* *** Show RSS hash configuration *** */
1513 struct cmd_showport_rss_hash {
1514 cmdline_fixed_string_t show;
1515 cmdline_fixed_string_t port;
1517 cmdline_fixed_string_t rss_hash;
1518 cmdline_fixed_string_t key; /* optional argument */
1521 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1522 __attribute__((unused)) struct cmdline *cl,
1525 struct cmd_showport_rss_hash *res = parsed_result;
1527 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1530 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1531 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1532 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1533 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1534 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1535 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1536 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1537 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1539 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1540 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1542 cmdline_parse_inst_t cmd_showport_rss_hash = {
1543 .f = cmd_showport_rss_hash_parsed,
1545 .help_str = "show port X rss-hash (X = port number)\n",
1547 (void *)&cmd_showport_rss_hash_show,
1548 (void *)&cmd_showport_rss_hash_port,
1549 (void *)&cmd_showport_rss_hash_port_id,
1550 (void *)&cmd_showport_rss_hash_rss_hash,
1555 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1556 .f = cmd_showport_rss_hash_parsed,
1558 .help_str = "show port X rss-hash key (X = port number)\n",
1560 (void *)&cmd_showport_rss_hash_show,
1561 (void *)&cmd_showport_rss_hash_port,
1562 (void *)&cmd_showport_rss_hash_port_id,
1563 (void *)&cmd_showport_rss_hash_rss_hash,
1564 (void *)&cmd_showport_rss_hash_rss_key,
1569 /* *** Configure DCB *** */
1570 struct cmd_config_dcb {
1571 cmdline_fixed_string_t port;
1572 cmdline_fixed_string_t config;
1574 cmdline_fixed_string_t dcb;
1575 cmdline_fixed_string_t vt;
1576 cmdline_fixed_string_t vt_en;
1578 cmdline_fixed_string_t pfc;
1579 cmdline_fixed_string_t pfc_en;
1583 cmd_config_dcb_parsed(void *parsed_result,
1584 __attribute__((unused)) struct cmdline *cl,
1585 __attribute__((unused)) void *data)
1587 struct cmd_config_dcb *res = parsed_result;
1588 struct dcb_config dcb_conf;
1589 portid_t port_id = res->port_id;
1590 struct rte_port *port;
1592 port = &ports[port_id];
1593 /** Check if the port is not started **/
1594 if (port->port_status != RTE_PORT_STOPPED) {
1595 printf("Please stop port %d first\n",port_id);
1599 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1600 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1601 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1605 /* DCB in VT mode */
1606 if (!strncmp(res->vt_en, "on",2))
1607 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1609 dcb_conf.dcb_mode = DCB_ENABLED;
1611 if (!strncmp(res->pfc_en, "on",2)) {
1612 dcb_conf.pfc_en = 1;
1615 dcb_conf.pfc_en = 0;
1617 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1618 printf("Cannot initialize network ports\n");
1622 cmd_reconfig_device_queue(port_id, 1, 1);
1625 cmdline_parse_token_string_t cmd_config_dcb_port =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1627 cmdline_parse_token_string_t cmd_config_dcb_config =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1629 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1630 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1631 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1633 cmdline_parse_token_string_t cmd_config_dcb_vt =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1635 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1637 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1638 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1639 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1641 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1644 cmdline_parse_inst_t cmd_config_dcb = {
1645 .f = cmd_config_dcb_parsed,
1647 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1649 (void *)&cmd_config_dcb_port,
1650 (void *)&cmd_config_dcb_config,
1651 (void *)&cmd_config_dcb_port_id,
1652 (void *)&cmd_config_dcb_dcb,
1653 (void *)&cmd_config_dcb_vt,
1654 (void *)&cmd_config_dcb_vt_en,
1655 (void *)&cmd_config_dcb_num_tcs,
1656 (void *)&cmd_config_dcb_pfc,
1657 (void *)&cmd_config_dcb_pfc_en,
1662 /* *** configure number of packets per burst *** */
1663 struct cmd_config_burst {
1664 cmdline_fixed_string_t port;
1665 cmdline_fixed_string_t keyword;
1666 cmdline_fixed_string_t all;
1667 cmdline_fixed_string_t name;
1672 cmd_config_burst_parsed(void *parsed_result,
1673 __attribute__((unused)) struct cmdline *cl,
1674 __attribute__((unused)) void *data)
1676 struct cmd_config_burst *res = parsed_result;
1678 if (!all_ports_stopped()) {
1679 printf("Please stop all ports first\n");
1683 if (!strcmp(res->name, "burst")) {
1684 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1685 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1688 nb_pkt_per_burst = res->value;
1690 printf("Unknown parameter\n");
1696 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1699 cmdline_parse_token_string_t cmd_config_burst_port =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1701 cmdline_parse_token_string_t cmd_config_burst_keyword =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1703 cmdline_parse_token_string_t cmd_config_burst_all =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1705 cmdline_parse_token_string_t cmd_config_burst_name =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1707 cmdline_parse_token_num_t cmd_config_burst_value =
1708 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1710 cmdline_parse_inst_t cmd_config_burst = {
1711 .f = cmd_config_burst_parsed,
1713 .help_str = "port config all burst value",
1715 (void *)&cmd_config_burst_port,
1716 (void *)&cmd_config_burst_keyword,
1717 (void *)&cmd_config_burst_all,
1718 (void *)&cmd_config_burst_name,
1719 (void *)&cmd_config_burst_value,
1724 /* *** configure rx/tx queues *** */
1725 struct cmd_config_thresh {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t keyword;
1728 cmdline_fixed_string_t all;
1729 cmdline_fixed_string_t name;
1734 cmd_config_thresh_parsed(void *parsed_result,
1735 __attribute__((unused)) struct cmdline *cl,
1736 __attribute__((unused)) void *data)
1738 struct cmd_config_thresh *res = parsed_result;
1740 if (!all_ports_stopped()) {
1741 printf("Please stop all ports first\n");
1745 if (!strcmp(res->name, "txpt"))
1746 tx_thresh.pthresh = res->value;
1747 else if(!strcmp(res->name, "txht"))
1748 tx_thresh.hthresh = res->value;
1749 else if(!strcmp(res->name, "txwt"))
1750 tx_thresh.wthresh = res->value;
1751 else if(!strcmp(res->name, "rxpt"))
1752 rx_thresh.pthresh = res->value;
1753 else if(!strcmp(res->name, "rxht"))
1754 rx_thresh.hthresh = res->value;
1755 else if(!strcmp(res->name, "rxwt"))
1756 rx_thresh.wthresh = res->value;
1758 printf("Unknown parameter\n");
1764 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1767 cmdline_parse_token_string_t cmd_config_thresh_port =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1769 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1771 cmdline_parse_token_string_t cmd_config_thresh_all =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1773 cmdline_parse_token_string_t cmd_config_thresh_name =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1775 "txpt#txht#txwt#rxpt#rxht#rxwt");
1776 cmdline_parse_token_num_t cmd_config_thresh_value =
1777 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1779 cmdline_parse_inst_t cmd_config_thresh = {
1780 .f = cmd_config_thresh_parsed,
1782 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1784 (void *)&cmd_config_thresh_port,
1785 (void *)&cmd_config_thresh_keyword,
1786 (void *)&cmd_config_thresh_all,
1787 (void *)&cmd_config_thresh_name,
1788 (void *)&cmd_config_thresh_value,
1793 /* *** configure free/rs threshold *** */
1794 struct cmd_config_threshold {
1795 cmdline_fixed_string_t port;
1796 cmdline_fixed_string_t keyword;
1797 cmdline_fixed_string_t all;
1798 cmdline_fixed_string_t name;
1803 cmd_config_threshold_parsed(void *parsed_result,
1804 __attribute__((unused)) struct cmdline *cl,
1805 __attribute__((unused)) void *data)
1807 struct cmd_config_threshold *res = parsed_result;
1809 if (!all_ports_stopped()) {
1810 printf("Please stop all ports first\n");
1814 if (!strcmp(res->name, "txfreet"))
1815 tx_free_thresh = res->value;
1816 else if (!strcmp(res->name, "txrst"))
1817 tx_rs_thresh = res->value;
1818 else if (!strcmp(res->name, "rxfreet"))
1819 rx_free_thresh = res->value;
1821 printf("Unknown parameter\n");
1827 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1830 cmdline_parse_token_string_t cmd_config_threshold_port =
1831 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1832 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1833 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1835 cmdline_parse_token_string_t cmd_config_threshold_all =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1837 cmdline_parse_token_string_t cmd_config_threshold_name =
1838 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1839 "txfreet#txrst#rxfreet");
1840 cmdline_parse_token_num_t cmd_config_threshold_value =
1841 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1843 cmdline_parse_inst_t cmd_config_threshold = {
1844 .f = cmd_config_threshold_parsed,
1846 .help_str = "port config all txfreet|txrst|rxfreet value",
1848 (void *)&cmd_config_threshold_port,
1849 (void *)&cmd_config_threshold_keyword,
1850 (void *)&cmd_config_threshold_all,
1851 (void *)&cmd_config_threshold_name,
1852 (void *)&cmd_config_threshold_value,
1858 struct cmd_stop_result {
1859 cmdline_fixed_string_t stop;
1862 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1863 __attribute__((unused)) struct cmdline *cl,
1864 __attribute__((unused)) void *data)
1866 stop_packet_forwarding();
1869 cmdline_parse_token_string_t cmd_stop_stop =
1870 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1872 cmdline_parse_inst_t cmd_stop = {
1873 .f = cmd_stop_parsed,
1875 .help_str = "stop - stop packet forwarding",
1877 (void *)&cmd_stop_stop,
1882 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1885 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1886 unsigned int *parsed_items, int check_unique_values)
1888 unsigned int nb_item;
1896 * First parse all items in the list and store their value.
1901 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1903 if ((c >= '0') && (c <= '9')) {
1904 value = (unsigned int) (value * 10 + (c - '0'));
1909 printf("character %c is not a decimal digit\n", c);
1913 printf("No valid value before comma\n");
1916 if (nb_item < max_items) {
1917 parsed_items[nb_item] = value;
1923 if (nb_item >= max_items) {
1924 printf("Number of %s = %u > %u (maximum items)\n",
1925 item_name, nb_item + 1, max_items);
1928 parsed_items[nb_item++] = value;
1929 if (! check_unique_values)
1933 * Then, check that all values in the list are differents.
1934 * No optimization here...
1936 for (i = 0; i < nb_item; i++) {
1937 for (j = i + 1; j < nb_item; j++) {
1938 if (parsed_items[j] == parsed_items[i]) {
1939 printf("duplicated %s %u at index %u and %u\n",
1940 item_name, parsed_items[i], i, j);
1948 struct cmd_set_list_result {
1949 cmdline_fixed_string_t cmd_keyword;
1950 cmdline_fixed_string_t list_name;
1951 cmdline_fixed_string_t list_of_items;
1954 static void cmd_set_list_parsed(void *parsed_result,
1955 __attribute__((unused)) struct cmdline *cl,
1956 __attribute__((unused)) void *data)
1958 struct cmd_set_list_result *res;
1960 unsigned int lcorelist[RTE_MAX_LCORE];
1961 unsigned int portlist[RTE_MAX_ETHPORTS];
1963 unsigned int nb_item;
1965 res = parsed_result;
1966 if (!strcmp(res->list_name, "corelist")) {
1967 nb_item = parse_item_list(res->list_of_items, "core",
1969 parsed_items.lcorelist, 1);
1971 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
1974 if (!strcmp(res->list_name, "portlist")) {
1975 nb_item = parse_item_list(res->list_of_items, "port",
1977 parsed_items.portlist, 1);
1979 set_fwd_ports_list(parsed_items.portlist, nb_item);
1983 cmdline_parse_token_string_t cmd_set_list_keyword =
1984 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
1986 cmdline_parse_token_string_t cmd_set_list_name =
1987 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
1988 "corelist#portlist");
1989 cmdline_parse_token_string_t cmd_set_list_of_items =
1990 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
1993 cmdline_parse_inst_t cmd_set_fwd_list = {
1994 .f = cmd_set_list_parsed,
1996 .help_str = "set corelist|portlist x[,y]*",
1998 (void *)&cmd_set_list_keyword,
1999 (void *)&cmd_set_list_name,
2000 (void *)&cmd_set_list_of_items,
2005 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2007 struct cmd_setmask_result {
2008 cmdline_fixed_string_t set;
2009 cmdline_fixed_string_t mask;
2013 static void cmd_set_mask_parsed(void *parsed_result,
2014 __attribute__((unused)) struct cmdline *cl,
2015 __attribute__((unused)) void *data)
2017 struct cmd_setmask_result *res = parsed_result;
2019 if (!strcmp(res->mask, "coremask"))
2020 set_fwd_lcores_mask(res->hexavalue);
2021 else if (!strcmp(res->mask, "portmask"))
2022 set_fwd_ports_mask(res->hexavalue);
2025 cmdline_parse_token_string_t cmd_setmask_set =
2026 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2027 cmdline_parse_token_string_t cmd_setmask_mask =
2028 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2029 "coremask#portmask");
2030 cmdline_parse_token_num_t cmd_setmask_value =
2031 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2033 cmdline_parse_inst_t cmd_set_fwd_mask = {
2034 .f = cmd_set_mask_parsed,
2036 .help_str = "set coremask|portmask hexadecimal value",
2038 (void *)&cmd_setmask_set,
2039 (void *)&cmd_setmask_mask,
2040 (void *)&cmd_setmask_value,
2046 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2048 struct cmd_set_result {
2049 cmdline_fixed_string_t set;
2050 cmdline_fixed_string_t what;
2054 static void cmd_set_parsed(void *parsed_result,
2055 __attribute__((unused)) struct cmdline *cl,
2056 __attribute__((unused)) void *data)
2058 struct cmd_set_result *res = parsed_result;
2059 if (!strcmp(res->what, "nbport"))
2060 set_fwd_ports_number(res->value);
2061 else if (!strcmp(res->what, "nbcore"))
2062 set_fwd_lcores_number(res->value);
2063 else if (!strcmp(res->what, "burst"))
2064 set_nb_pkt_per_burst(res->value);
2065 else if (!strcmp(res->what, "verbose"))
2066 set_verbose_level(res->value);
2069 cmdline_parse_token_string_t cmd_set_set =
2070 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2071 cmdline_parse_token_string_t cmd_set_what =
2072 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2073 "nbport#nbcore#burst#verbose");
2074 cmdline_parse_token_num_t cmd_set_value =
2075 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2077 cmdline_parse_inst_t cmd_set_numbers = {
2078 .f = cmd_set_parsed,
2080 .help_str = "set nbport|nbcore|burst|verbose value",
2082 (void *)&cmd_set_set,
2083 (void *)&cmd_set_what,
2084 (void *)&cmd_set_value,
2089 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2091 struct cmd_set_txpkts_result {
2092 cmdline_fixed_string_t cmd_keyword;
2093 cmdline_fixed_string_t txpkts;
2094 cmdline_fixed_string_t seg_lengths;
2098 cmd_set_txpkts_parsed(void *parsed_result,
2099 __attribute__((unused)) struct cmdline *cl,
2100 __attribute__((unused)) void *data)
2102 struct cmd_set_txpkts_result *res;
2103 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2104 unsigned int nb_segs;
2106 res = parsed_result;
2107 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2108 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2110 set_tx_pkt_segments(seg_lengths, nb_segs);
2113 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2114 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2115 cmd_keyword, "set");
2116 cmdline_parse_token_string_t cmd_set_txpkts_name =
2117 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2119 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2120 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2123 cmdline_parse_inst_t cmd_set_txpkts = {
2124 .f = cmd_set_txpkts_parsed,
2126 .help_str = "set txpkts x[,y]*",
2128 (void *)&cmd_set_txpkts_keyword,
2129 (void *)&cmd_set_txpkts_name,
2130 (void *)&cmd_set_txpkts_lengths,
2135 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2136 struct cmd_rx_vlan_filter_all_result {
2137 cmdline_fixed_string_t rx_vlan;
2138 cmdline_fixed_string_t what;
2139 cmdline_fixed_string_t all;
2144 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2145 __attribute__((unused)) struct cmdline *cl,
2146 __attribute__((unused)) void *data)
2148 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2150 if (!strcmp(res->what, "add"))
2151 rx_vlan_all_filter_set(res->port_id, 1);
2153 rx_vlan_all_filter_set(res->port_id, 0);
2156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2158 rx_vlan, "rx_vlan");
2159 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2160 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2162 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2163 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2165 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2166 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2169 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2170 .f = cmd_rx_vlan_filter_all_parsed,
2172 .help_str = "add/remove all identifiers to/from the set of VLAN "
2173 "Identifiers filtered by a port",
2175 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2176 (void *)&cmd_rx_vlan_filter_all_what,
2177 (void *)&cmd_rx_vlan_filter_all_all,
2178 (void *)&cmd_rx_vlan_filter_all_portid,
2183 /* *** VLAN OFFLOAD SET ON A PORT *** */
2184 struct cmd_vlan_offload_result {
2185 cmdline_fixed_string_t vlan;
2186 cmdline_fixed_string_t set;
2187 cmdline_fixed_string_t what;
2188 cmdline_fixed_string_t on;
2189 cmdline_fixed_string_t port_id;
2193 cmd_vlan_offload_parsed(void *parsed_result,
2194 __attribute__((unused)) struct cmdline *cl,
2195 __attribute__((unused)) void *data)
2198 struct cmd_vlan_offload_result *res = parsed_result;
2201 portid_t port_id = 0;
2205 len = strnlen(str, STR_TOKEN_SIZE);
2207 /* Get port_id first */
2215 tmp = strtoul(str, NULL, 0);
2216 /* If port_id greater that what portid_t can represent, return */
2217 if(tmp >= RTE_MAX_ETHPORTS)
2219 port_id = (portid_t)tmp;
2221 if (!strcmp(res->on, "on"))
2226 if (!strcmp(res->what, "strip"))
2227 rx_vlan_strip_set(port_id, on);
2228 else if(!strcmp(res->what, "stripq")){
2229 uint16_t queue_id = 0;
2231 /* No queue_id, return */
2233 printf("must specify (port,queue_id)\n");
2236 tmp = strtoul(str + i + 1, NULL, 0);
2237 /* If queue_id greater that what 16-bits can represent, return */
2241 queue_id = (uint16_t)tmp;
2242 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2244 else if (!strcmp(res->what, "filter"))
2245 rx_vlan_filter_set(port_id, on);
2247 vlan_extend_set(port_id, on);
2252 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2253 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2255 cmdline_parse_token_string_t cmd_vlan_offload_set =
2256 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2258 cmdline_parse_token_string_t cmd_vlan_offload_what =
2259 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2260 what, "strip#filter#qinq#stripq");
2261 cmdline_parse_token_string_t cmd_vlan_offload_on =
2262 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2264 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2265 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2268 cmdline_parse_inst_t cmd_vlan_offload = {
2269 .f = cmd_vlan_offload_parsed,
2271 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2272 " qinq(extended) for both rx/tx sides ",
2274 (void *)&cmd_vlan_offload_vlan,
2275 (void *)&cmd_vlan_offload_set,
2276 (void *)&cmd_vlan_offload_what,
2277 (void *)&cmd_vlan_offload_on,
2278 (void *)&cmd_vlan_offload_portid,
2283 /* *** VLAN TPID SET ON A PORT *** */
2284 struct cmd_vlan_tpid_result {
2285 cmdline_fixed_string_t vlan;
2286 cmdline_fixed_string_t set;
2287 cmdline_fixed_string_t what;
2293 cmd_vlan_tpid_parsed(void *parsed_result,
2294 __attribute__((unused)) struct cmdline *cl,
2295 __attribute__((unused)) void *data)
2297 struct cmd_vlan_tpid_result *res = parsed_result;
2298 vlan_tpid_set(res->port_id, res->tp_id);
2302 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2305 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2308 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2311 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2312 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2314 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2315 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2318 cmdline_parse_inst_t cmd_vlan_tpid = {
2319 .f = cmd_vlan_tpid_parsed,
2321 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2323 (void *)&cmd_vlan_tpid_vlan,
2324 (void *)&cmd_vlan_tpid_set,
2325 (void *)&cmd_vlan_tpid_what,
2326 (void *)&cmd_vlan_tpid_tpid,
2327 (void *)&cmd_vlan_tpid_portid,
2332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2333 struct cmd_rx_vlan_filter_result {
2334 cmdline_fixed_string_t rx_vlan;
2335 cmdline_fixed_string_t what;
2341 cmd_rx_vlan_filter_parsed(void *parsed_result,
2342 __attribute__((unused)) struct cmdline *cl,
2343 __attribute__((unused)) void *data)
2345 struct cmd_rx_vlan_filter_result *res = parsed_result;
2347 if (!strcmp(res->what, "add"))
2348 rx_vft_set(res->port_id, res->vlan_id, 1);
2350 rx_vft_set(res->port_id, res->vlan_id, 0);
2353 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2354 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2355 rx_vlan, "rx_vlan");
2356 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2359 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2360 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2362 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2366 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2367 .f = cmd_rx_vlan_filter_parsed,
2369 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2370 "Identifiers filtered by a port",
2372 (void *)&cmd_rx_vlan_filter_rx_vlan,
2373 (void *)&cmd_rx_vlan_filter_what,
2374 (void *)&cmd_rx_vlan_filter_vlanid,
2375 (void *)&cmd_rx_vlan_filter_portid,
2380 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2381 struct cmd_tx_vlan_set_result {
2382 cmdline_fixed_string_t tx_vlan;
2383 cmdline_fixed_string_t set;
2389 cmd_tx_vlan_set_parsed(void *parsed_result,
2390 __attribute__((unused)) struct cmdline *cl,
2391 __attribute__((unused)) void *data)
2393 struct cmd_tx_vlan_set_result *res = parsed_result;
2394 tx_vlan_set(res->port_id, res->vlan_id);
2397 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2398 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2399 tx_vlan, "tx_vlan");
2400 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2401 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2403 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2404 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2406 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2407 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2410 cmdline_parse_inst_t cmd_tx_vlan_set = {
2411 .f = cmd_tx_vlan_set_parsed,
2413 .help_str = "enable hardware insertion of a VLAN header with a given "
2414 "TAG Identifier in packets sent on a port",
2416 (void *)&cmd_tx_vlan_set_tx_vlan,
2417 (void *)&cmd_tx_vlan_set_set,
2418 (void *)&cmd_tx_vlan_set_vlanid,
2419 (void *)&cmd_tx_vlan_set_portid,
2424 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2425 struct cmd_tx_vlan_reset_result {
2426 cmdline_fixed_string_t tx_vlan;
2427 cmdline_fixed_string_t reset;
2432 cmd_tx_vlan_reset_parsed(void *parsed_result,
2433 __attribute__((unused)) struct cmdline *cl,
2434 __attribute__((unused)) void *data)
2436 struct cmd_tx_vlan_reset_result *res = parsed_result;
2438 tx_vlan_reset(res->port_id);
2441 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2442 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2443 tx_vlan, "tx_vlan");
2444 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2445 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2447 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2448 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2451 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2452 .f = cmd_tx_vlan_reset_parsed,
2454 .help_str = "disable hardware insertion of a VLAN header in packets "
2457 (void *)&cmd_tx_vlan_reset_tx_vlan,
2458 (void *)&cmd_tx_vlan_reset_reset,
2459 (void *)&cmd_tx_vlan_reset_portid,
2465 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2466 struct cmd_tx_cksum_set_result {
2467 cmdline_fixed_string_t tx_cksum;
2468 cmdline_fixed_string_t set;
2474 cmd_tx_cksum_set_parsed(void *parsed_result,
2475 __attribute__((unused)) struct cmdline *cl,
2476 __attribute__((unused)) void *data)
2478 struct cmd_tx_cksum_set_result *res = parsed_result;
2480 tx_cksum_set(res->port_id, res->cksum_mask);
2483 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2484 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2485 tx_cksum, "tx_checksum");
2486 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2487 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2489 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2490 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2492 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2493 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2496 cmdline_parse_inst_t cmd_tx_cksum_set = {
2497 .f = cmd_tx_cksum_set_parsed,
2499 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2500 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2501 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2503 (void *)&cmd_tx_cksum_set_tx_cksum,
2504 (void *)&cmd_tx_cksum_set_set,
2505 (void *)&cmd_tx_cksum_set_cksum_mask,
2506 (void *)&cmd_tx_cksum_set_portid,
2511 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2512 struct cmd_set_flush_rx {
2513 cmdline_fixed_string_t set;
2514 cmdline_fixed_string_t flush_rx;
2515 cmdline_fixed_string_t mode;
2519 cmd_set_flush_rx_parsed(void *parsed_result,
2520 __attribute__((unused)) struct cmdline *cl,
2521 __attribute__((unused)) void *data)
2523 struct cmd_set_flush_rx *res = parsed_result;
2524 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2527 cmdline_parse_token_string_t cmd_setflushrx_set =
2528 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2530 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2531 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2532 flush_rx, "flush_rx");
2533 cmdline_parse_token_string_t cmd_setflushrx_mode =
2534 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2538 cmdline_parse_inst_t cmd_set_flush_rx = {
2539 .f = cmd_set_flush_rx_parsed,
2540 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2543 (void *)&cmd_setflushrx_set,
2544 (void *)&cmd_setflushrx_flush_rx,
2545 (void *)&cmd_setflushrx_mode,
2550 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2551 struct cmd_set_link_check {
2552 cmdline_fixed_string_t set;
2553 cmdline_fixed_string_t link_check;
2554 cmdline_fixed_string_t mode;
2558 cmd_set_link_check_parsed(void *parsed_result,
2559 __attribute__((unused)) struct cmdline *cl,
2560 __attribute__((unused)) void *data)
2562 struct cmd_set_link_check *res = parsed_result;
2563 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2566 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2567 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2569 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2570 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2571 link_check, "link_check");
2572 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2573 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2577 cmdline_parse_inst_t cmd_set_link_check = {
2578 .f = cmd_set_link_check_parsed,
2579 .help_str = "set link_check on|off: enable/disable link status check "
2580 "when starting/stopping a port",
2583 (void *)&cmd_setlinkcheck_set,
2584 (void *)&cmd_setlinkcheck_link_check,
2585 (void *)&cmd_setlinkcheck_mode,
2590 #ifdef RTE_NIC_BYPASS
2591 /* *** SET NIC BYPASS MODE *** */
2592 struct cmd_set_bypass_mode_result {
2593 cmdline_fixed_string_t set;
2594 cmdline_fixed_string_t bypass;
2595 cmdline_fixed_string_t mode;
2596 cmdline_fixed_string_t value;
2601 cmd_set_bypass_mode_parsed(void *parsed_result,
2602 __attribute__((unused)) struct cmdline *cl,
2603 __attribute__((unused)) void *data)
2605 struct cmd_set_bypass_mode_result *res = parsed_result;
2606 portid_t port_id = res->port_id;
2607 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2609 if (!bypass_is_supported(port_id))
2612 if (!strcmp(res->value, "bypass"))
2613 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2614 else if (!strcmp(res->value, "isolate"))
2615 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2617 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2619 /* Set the bypass mode for the relevant port. */
2620 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2621 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2625 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2626 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2628 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2631 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2634 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2636 value, "normal#bypass#isolate");
2637 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2638 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2641 cmdline_parse_inst_t cmd_set_bypass_mode = {
2642 .f = cmd_set_bypass_mode_parsed,
2643 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2644 "Set the NIC bypass mode for port_id",
2647 (void *)&cmd_setbypass_mode_set,
2648 (void *)&cmd_setbypass_mode_bypass,
2649 (void *)&cmd_setbypass_mode_mode,
2650 (void *)&cmd_setbypass_mode_value,
2651 (void *)&cmd_setbypass_mode_port,
2656 /* *** SET NIC BYPASS EVENT *** */
2657 struct cmd_set_bypass_event_result {
2658 cmdline_fixed_string_t set;
2659 cmdline_fixed_string_t bypass;
2660 cmdline_fixed_string_t event;
2661 cmdline_fixed_string_t event_value;
2662 cmdline_fixed_string_t mode;
2663 cmdline_fixed_string_t mode_value;
2668 cmd_set_bypass_event_parsed(void *parsed_result,
2669 __attribute__((unused)) struct cmdline *cl,
2670 __attribute__((unused)) void *data)
2673 struct cmd_set_bypass_event_result *res = parsed_result;
2674 portid_t port_id = res->port_id;
2675 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2676 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2678 if (!bypass_is_supported(port_id))
2681 if (!strcmp(res->event_value, "timeout"))
2682 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2683 else if (!strcmp(res->event_value, "os_on"))
2684 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2685 else if (!strcmp(res->event_value, "os_off"))
2686 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2687 else if (!strcmp(res->event_value, "power_on"))
2688 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2689 else if (!strcmp(res->event_value, "power_off"))
2690 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2692 bypass_event = RTE_BYPASS_EVENT_NONE;
2694 if (!strcmp(res->mode_value, "bypass"))
2695 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2696 else if (!strcmp(res->mode_value, "isolate"))
2697 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2699 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2701 /* Set the watchdog timeout. */
2702 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2705 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2706 (rc = rte_eth_dev_wd_timeout_store(port_id,
2707 bypass_timeout)) != 0) {
2708 printf("Failed to set timeout value %u "
2709 "for port %d, errto code: %d.\n",
2710 bypass_timeout, port_id, rc);
2714 /* Set the bypass event to transition to bypass mode. */
2715 if (0 != rte_eth_dev_bypass_event_store(port_id,
2716 bypass_event, bypass_mode)) {
2717 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2722 cmdline_parse_token_string_t cmd_setbypass_event_set =
2723 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2725 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2726 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2728 cmdline_parse_token_string_t cmd_setbypass_event_event =
2729 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2731 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2732 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2733 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2734 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2735 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2737 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2738 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2739 mode_value, "normal#bypass#isolate");
2740 cmdline_parse_token_num_t cmd_setbypass_event_port =
2741 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2744 cmdline_parse_inst_t cmd_set_bypass_event = {
2745 .f = cmd_set_bypass_event_parsed,
2746 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2747 "mode (normal|bypass|isolate) (port_id): "
2748 "Set the NIC bypass event mode for port_id",
2751 (void *)&cmd_setbypass_event_set,
2752 (void *)&cmd_setbypass_event_bypass,
2753 (void *)&cmd_setbypass_event_event,
2754 (void *)&cmd_setbypass_event_event_value,
2755 (void *)&cmd_setbypass_event_mode,
2756 (void *)&cmd_setbypass_event_mode_value,
2757 (void *)&cmd_setbypass_event_port,
2763 /* *** SET NIC BYPASS TIMEOUT *** */
2764 struct cmd_set_bypass_timeout_result {
2765 cmdline_fixed_string_t set;
2766 cmdline_fixed_string_t bypass;
2767 cmdline_fixed_string_t timeout;
2768 cmdline_fixed_string_t value;
2772 cmd_set_bypass_timeout_parsed(void *parsed_result,
2773 __attribute__((unused)) struct cmdline *cl,
2774 __attribute__((unused)) void *data)
2776 struct cmd_set_bypass_timeout_result *res = parsed_result;
2778 if (!strcmp(res->value, "1.5"))
2779 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2780 else if (!strcmp(res->value, "2"))
2781 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2782 else if (!strcmp(res->value, "3"))
2783 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2784 else if (!strcmp(res->value, "4"))
2785 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2786 else if (!strcmp(res->value, "8"))
2787 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2788 else if (!strcmp(res->value, "16"))
2789 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2790 else if (!strcmp(res->value, "32"))
2791 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2793 bypass_timeout = RTE_BYPASS_TMT_OFF;
2796 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2797 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2799 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2800 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2802 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2803 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2804 timeout, "timeout");
2805 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2806 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2807 value, "0#1.5#2#3#4#8#16#32");
2809 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2810 .f = cmd_set_bypass_timeout_parsed,
2811 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2812 "Set the NIC bypass watchdog timeout",
2815 (void *)&cmd_setbypass_timeout_set,
2816 (void *)&cmd_setbypass_timeout_bypass,
2817 (void *)&cmd_setbypass_timeout_timeout,
2818 (void *)&cmd_setbypass_timeout_value,
2823 /* *** SHOW NIC BYPASS MODE *** */
2824 struct cmd_show_bypass_config_result {
2825 cmdline_fixed_string_t show;
2826 cmdline_fixed_string_t bypass;
2827 cmdline_fixed_string_t config;
2832 cmd_show_bypass_config_parsed(void *parsed_result,
2833 __attribute__((unused)) struct cmdline *cl,
2834 __attribute__((unused)) void *data)
2836 struct cmd_show_bypass_config_result *res = parsed_result;
2837 uint32_t event_mode;
2838 uint32_t bypass_mode;
2839 portid_t port_id = res->port_id;
2840 uint32_t timeout = bypass_timeout;
2843 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2844 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2845 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2846 {"UNKNOWN", "normal", "bypass", "isolate"};
2847 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2854 int num_events = (sizeof events) / (sizeof events[0]);
2856 if (!bypass_is_supported(port_id))
2859 /* Display the bypass mode.*/
2860 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2861 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2865 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2866 bypass_mode = RTE_BYPASS_MODE_NONE;
2868 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2871 /* Display the bypass timeout.*/
2872 if (!RTE_BYPASS_TMT_VALID(timeout))
2873 timeout = RTE_BYPASS_TMT_OFF;
2875 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2877 /* Display the bypass events and associated modes. */
2878 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2880 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2881 printf("\tFailed to get bypass mode for event = %s\n",
2884 if (!RTE_BYPASS_MODE_VALID(event_mode))
2885 event_mode = RTE_BYPASS_MODE_NONE;
2887 printf("\tbypass event: %-16s = %s\n", events[i],
2893 cmdline_parse_token_string_t cmd_showbypass_config_show =
2894 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2896 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
2897 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2899 cmdline_parse_token_string_t cmd_showbypass_config_config =
2900 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
2902 cmdline_parse_token_num_t cmd_showbypass_config_port =
2903 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
2906 cmdline_parse_inst_t cmd_show_bypass_config = {
2907 .f = cmd_show_bypass_config_parsed,
2908 .help_str = "show bypass config (port_id): "
2909 "Show the NIC bypass config for port_id",
2912 (void *)&cmd_showbypass_config_show,
2913 (void *)&cmd_showbypass_config_bypass,
2914 (void *)&cmd_showbypass_config_config,
2915 (void *)&cmd_showbypass_config_port,
2921 /* *** SET FORWARDING MODE *** */
2922 struct cmd_set_fwd_mode_result {
2923 cmdline_fixed_string_t set;
2924 cmdline_fixed_string_t fwd;
2925 cmdline_fixed_string_t mode;
2928 static void cmd_set_fwd_mode_parsed(void *parsed_result,
2929 __attribute__((unused)) struct cmdline *cl,
2930 __attribute__((unused)) void *data)
2932 struct cmd_set_fwd_mode_result *res = parsed_result;
2934 set_pkt_forwarding_mode(res->mode);
2937 cmdline_parse_token_string_t cmd_setfwd_set =
2938 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
2939 cmdline_parse_token_string_t cmd_setfwd_fwd =
2940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
2941 cmdline_parse_token_string_t cmd_setfwd_mode =
2942 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
2943 "" /* defined at init */);
2945 cmdline_parse_inst_t cmd_set_fwd_mode = {
2946 .f = cmd_set_fwd_mode_parsed,
2948 .help_str = NULL, /* defined at init */
2950 (void *)&cmd_setfwd_set,
2951 (void *)&cmd_setfwd_fwd,
2952 (void *)&cmd_setfwd_mode,
2957 static void cmd_set_fwd_mode_init(void)
2960 static char token[128];
2961 static char help[256];
2962 cmdline_parse_token_string_t *token_struct;
2964 modes = list_pkt_forwarding_modes();
2965 rte_snprintf(help, sizeof help, "set fwd %s - "
2966 "set packet forwarding mode", modes);
2967 cmd_set_fwd_mode.help_str = help;
2969 /* string token separator is # */
2970 for (c = token; *modes != '\0'; modes++)
2975 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
2976 token_struct->string_data.str = token;
2979 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
2980 struct cmd_set_burst_tx_retry_result {
2981 cmdline_fixed_string_t set;
2982 cmdline_fixed_string_t burst;
2983 cmdline_fixed_string_t tx;
2984 cmdline_fixed_string_t delay;
2986 cmdline_fixed_string_t retry;
2990 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
2991 __attribute__((unused)) struct cmdline *cl,
2992 __attribute__((unused)) void *data)
2994 struct cmd_set_burst_tx_retry_result *res = parsed_result;
2996 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
2997 && !strcmp(res->tx, "tx")) {
2998 if (!strcmp(res->delay, "delay"))
2999 burst_tx_delay_time = res->time;
3000 if (!strcmp(res->retry, "retry"))
3001 burst_tx_retry_num = res->retry_num;
3006 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3007 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3008 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3009 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3011 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3012 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3013 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3014 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3015 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3016 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3017 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3018 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3019 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3020 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3022 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3023 .f = cmd_set_burst_tx_retry_parsed,
3024 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3026 (void *)&cmd_set_burst_tx_retry_set,
3027 (void *)&cmd_set_burst_tx_retry_burst,
3028 (void *)&cmd_set_burst_tx_retry_tx,
3029 (void *)&cmd_set_burst_tx_retry_delay,
3030 (void *)&cmd_set_burst_tx_retry_time,
3031 (void *)&cmd_set_burst_tx_retry_retry,
3032 (void *)&cmd_set_burst_tx_retry_retry_num,
3037 /* *** SET PROMISC MODE *** */
3038 struct cmd_set_promisc_mode_result {
3039 cmdline_fixed_string_t set;
3040 cmdline_fixed_string_t promisc;
3041 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3042 uint8_t port_num; /* valid if "allports" argument == 0 */
3043 cmdline_fixed_string_t mode;
3046 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3047 __attribute__((unused)) struct cmdline *cl,
3050 struct cmd_set_promisc_mode_result *res = parsed_result;
3054 if (!strcmp(res->mode, "on"))
3061 for (i = 0; i < nb_ports; i++) {
3063 rte_eth_promiscuous_enable(i);
3065 rte_eth_promiscuous_disable(i);
3070 rte_eth_promiscuous_enable(res->port_num);
3072 rte_eth_promiscuous_disable(res->port_num);
3076 cmdline_parse_token_string_t cmd_setpromisc_set =
3077 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3078 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3079 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3081 cmdline_parse_token_string_t cmd_setpromisc_portall =
3082 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3084 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3085 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3087 cmdline_parse_token_string_t cmd_setpromisc_mode =
3088 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3091 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3092 .f = cmd_set_promisc_mode_parsed,
3094 .help_str = "set promisc all on|off: set promisc mode for all ports",
3096 (void *)&cmd_setpromisc_set,
3097 (void *)&cmd_setpromisc_promisc,
3098 (void *)&cmd_setpromisc_portall,
3099 (void *)&cmd_setpromisc_mode,
3104 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3105 .f = cmd_set_promisc_mode_parsed,
3107 .help_str = "set promisc X on|off: set promisc mode on port X",
3109 (void *)&cmd_setpromisc_set,
3110 (void *)&cmd_setpromisc_promisc,
3111 (void *)&cmd_setpromisc_portnum,
3112 (void *)&cmd_setpromisc_mode,
3117 /* *** SET ALLMULTI MODE *** */
3118 struct cmd_set_allmulti_mode_result {
3119 cmdline_fixed_string_t set;
3120 cmdline_fixed_string_t allmulti;
3121 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3122 uint8_t port_num; /* valid if "allports" argument == 0 */
3123 cmdline_fixed_string_t mode;
3126 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3127 __attribute__((unused)) struct cmdline *cl,
3130 struct cmd_set_allmulti_mode_result *res = parsed_result;
3134 if (!strcmp(res->mode, "on"))
3141 for (i = 0; i < nb_ports; i++) {
3143 rte_eth_allmulticast_enable(i);
3145 rte_eth_allmulticast_disable(i);
3150 rte_eth_allmulticast_enable(res->port_num);
3152 rte_eth_allmulticast_disable(res->port_num);
3156 cmdline_parse_token_string_t cmd_setallmulti_set =
3157 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3158 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3159 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3161 cmdline_parse_token_string_t cmd_setallmulti_portall =
3162 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3164 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3165 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3167 cmdline_parse_token_string_t cmd_setallmulti_mode =
3168 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3171 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3172 .f = cmd_set_allmulti_mode_parsed,
3174 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3176 (void *)&cmd_setallmulti_set,
3177 (void *)&cmd_setallmulti_allmulti,
3178 (void *)&cmd_setallmulti_portall,
3179 (void *)&cmd_setallmulti_mode,
3184 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3185 .f = cmd_set_allmulti_mode_parsed,
3187 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3189 (void *)&cmd_setallmulti_set,
3190 (void *)&cmd_setallmulti_allmulti,
3191 (void *)&cmd_setallmulti_portnum,
3192 (void *)&cmd_setallmulti_mode,
3197 /* *** ADD/REMOVE A PKT FILTER *** */
3198 struct cmd_pkt_filter_result {
3199 cmdline_fixed_string_t pkt_filter;
3201 cmdline_fixed_string_t protocol;
3202 cmdline_fixed_string_t src;
3203 cmdline_ipaddr_t ip_src;
3205 cmdline_fixed_string_t dst;
3206 cmdline_ipaddr_t ip_dst;
3208 cmdline_fixed_string_t flexbytes;
3209 uint16_t flexbytes_value;
3210 cmdline_fixed_string_t vlan;
3212 cmdline_fixed_string_t queue;
3214 cmdline_fixed_string_t soft;
3219 cmd_pkt_filter_parsed(void *parsed_result,
3220 __attribute__((unused)) struct cmdline *cl,
3221 __attribute__((unused)) void *data)
3223 struct rte_fdir_filter fdir_filter;
3224 struct cmd_pkt_filter_result *res = parsed_result;
3226 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3228 if (res->ip_src.family == AF_INET)
3229 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3231 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3232 &(res->ip_src.addr.ipv6),
3233 sizeof(struct in6_addr));
3235 if (res->ip_dst.family == AF_INET)
3236 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3238 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3239 &(res->ip_dst.addr.ipv6),
3240 sizeof(struct in6_addr));
3242 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3243 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3245 if (!strcmp(res->protocol, "udp"))
3246 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3247 else if (!strcmp(res->protocol, "tcp"))
3248 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3249 else if (!strcmp(res->protocol, "sctp"))
3250 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3251 else /* default only IP */
3252 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3254 if (res->ip_dst.family == AF_INET6)
3255 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3257 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3259 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3260 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3262 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3263 fdir_add_signature_filter(res->port_id, res->queue_id,
3265 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3266 fdir_update_signature_filter(res->port_id, res->queue_id,
3268 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3269 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3270 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3271 fdir_add_perfect_filter(res->port_id, res->soft_id,
3273 (uint8_t) (res->queue_id < 0),
3275 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3276 fdir_update_perfect_filter(res->port_id, res->soft_id,
3278 (uint8_t) (res->queue_id < 0),
3280 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3281 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3287 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3288 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3290 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3291 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3292 protocol, "ip#tcp#udp#sctp");
3293 cmdline_parse_token_string_t cmd_pkt_filter_src =
3294 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3296 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3297 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3299 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3300 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3302 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3303 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3305 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3306 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3308 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3309 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3311 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3312 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3313 flexbytes, "flexbytes");
3314 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3315 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3316 flexbytes_value, UINT16);
3317 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3318 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3320 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3321 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3323 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3324 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3326 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3327 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3329 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3330 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3332 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3333 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3337 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3338 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3339 pkt_filter, "add_signature_filter");
3340 cmdline_parse_inst_t cmd_add_signature_filter = {
3341 .f = cmd_pkt_filter_parsed,
3343 .help_str = "add a signature filter",
3345 (void *)&cmd_pkt_filter_add_signature_filter,
3346 (void *)&cmd_pkt_filter_port_id,
3347 (void *)&cmd_pkt_filter_protocol,
3348 (void *)&cmd_pkt_filter_src,
3349 (void *)&cmd_pkt_filter_ip_src,
3350 (void *)&cmd_pkt_filter_port_src,
3351 (void *)&cmd_pkt_filter_dst,
3352 (void *)&cmd_pkt_filter_ip_dst,
3353 (void *)&cmd_pkt_filter_port_dst,
3354 (void *)&cmd_pkt_filter_flexbytes,
3355 (void *)&cmd_pkt_filter_flexbytes_value,
3356 (void *)&cmd_pkt_filter_vlan,
3357 (void *)&cmd_pkt_filter_vlan_id,
3358 (void *)&cmd_pkt_filter_queue,
3359 (void *)&cmd_pkt_filter_queue_id,
3365 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3366 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3367 pkt_filter, "upd_signature_filter");
3368 cmdline_parse_inst_t cmd_upd_signature_filter = {
3369 .f = cmd_pkt_filter_parsed,
3371 .help_str = "update a signature filter",
3373 (void *)&cmd_pkt_filter_upd_signature_filter,
3374 (void *)&cmd_pkt_filter_port_id,
3375 (void *)&cmd_pkt_filter_protocol,
3376 (void *)&cmd_pkt_filter_src,
3377 (void *)&cmd_pkt_filter_ip_src,
3378 (void *)&cmd_pkt_filter_port_src,
3379 (void *)&cmd_pkt_filter_dst,
3380 (void *)&cmd_pkt_filter_ip_dst,
3381 (void *)&cmd_pkt_filter_port_dst,
3382 (void *)&cmd_pkt_filter_flexbytes,
3383 (void *)&cmd_pkt_filter_flexbytes_value,
3384 (void *)&cmd_pkt_filter_vlan,
3385 (void *)&cmd_pkt_filter_vlan_id,
3386 (void *)&cmd_pkt_filter_queue,
3387 (void *)&cmd_pkt_filter_queue_id,
3393 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3394 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3395 pkt_filter, "rm_signature_filter");
3396 cmdline_parse_inst_t cmd_rm_signature_filter = {
3397 .f = cmd_pkt_filter_parsed,
3399 .help_str = "remove a signature filter",
3401 (void *)&cmd_pkt_filter_rm_signature_filter,
3402 (void *)&cmd_pkt_filter_port_id,
3403 (void *)&cmd_pkt_filter_protocol,
3404 (void *)&cmd_pkt_filter_src,
3405 (void *)&cmd_pkt_filter_ip_src,
3406 (void *)&cmd_pkt_filter_port_src,
3407 (void *)&cmd_pkt_filter_dst,
3408 (void *)&cmd_pkt_filter_ip_dst,
3409 (void *)&cmd_pkt_filter_port_dst,
3410 (void *)&cmd_pkt_filter_flexbytes,
3411 (void *)&cmd_pkt_filter_flexbytes_value,
3412 (void *)&cmd_pkt_filter_vlan,
3413 (void *)&cmd_pkt_filter_vlan_id,
3419 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3420 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3421 pkt_filter, "add_perfect_filter");
3422 cmdline_parse_inst_t cmd_add_perfect_filter = {
3423 .f = cmd_pkt_filter_parsed,
3425 .help_str = "add a perfect filter",
3427 (void *)&cmd_pkt_filter_add_perfect_filter,
3428 (void *)&cmd_pkt_filter_port_id,
3429 (void *)&cmd_pkt_filter_protocol,
3430 (void *)&cmd_pkt_filter_src,
3431 (void *)&cmd_pkt_filter_ip_src,
3432 (void *)&cmd_pkt_filter_port_src,
3433 (void *)&cmd_pkt_filter_dst,
3434 (void *)&cmd_pkt_filter_ip_dst,
3435 (void *)&cmd_pkt_filter_port_dst,
3436 (void *)&cmd_pkt_filter_flexbytes,
3437 (void *)&cmd_pkt_filter_flexbytes_value,
3438 (void *)&cmd_pkt_filter_vlan,
3439 (void *)&cmd_pkt_filter_vlan_id,
3440 (void *)&cmd_pkt_filter_queue,
3441 (void *)&cmd_pkt_filter_queue_id,
3442 (void *)&cmd_pkt_filter_soft,
3443 (void *)&cmd_pkt_filter_soft_id,
3449 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3450 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3451 pkt_filter, "upd_perfect_filter");
3452 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3453 .f = cmd_pkt_filter_parsed,
3455 .help_str = "update a perfect filter",
3457 (void *)&cmd_pkt_filter_upd_perfect_filter,
3458 (void *)&cmd_pkt_filter_port_id,
3459 (void *)&cmd_pkt_filter_protocol,
3460 (void *)&cmd_pkt_filter_src,
3461 (void *)&cmd_pkt_filter_ip_src,
3462 (void *)&cmd_pkt_filter_port_src,
3463 (void *)&cmd_pkt_filter_dst,
3464 (void *)&cmd_pkt_filter_ip_dst,
3465 (void *)&cmd_pkt_filter_port_dst,
3466 (void *)&cmd_pkt_filter_flexbytes,
3467 (void *)&cmd_pkt_filter_flexbytes_value,
3468 (void *)&cmd_pkt_filter_vlan,
3469 (void *)&cmd_pkt_filter_vlan_id,
3470 (void *)&cmd_pkt_filter_queue,
3471 (void *)&cmd_pkt_filter_queue_id,
3472 (void *)&cmd_pkt_filter_soft,
3473 (void *)&cmd_pkt_filter_soft_id,
3479 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3480 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3481 pkt_filter, "rm_perfect_filter");
3482 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3483 .f = cmd_pkt_filter_parsed,
3485 .help_str = "remove a perfect filter",
3487 (void *)&cmd_pkt_filter_rm_perfect_filter,
3488 (void *)&cmd_pkt_filter_port_id,
3489 (void *)&cmd_pkt_filter_protocol,
3490 (void *)&cmd_pkt_filter_src,
3491 (void *)&cmd_pkt_filter_ip_src,
3492 (void *)&cmd_pkt_filter_port_src,
3493 (void *)&cmd_pkt_filter_dst,
3494 (void *)&cmd_pkt_filter_ip_dst,
3495 (void *)&cmd_pkt_filter_port_dst,
3496 (void *)&cmd_pkt_filter_flexbytes,
3497 (void *)&cmd_pkt_filter_flexbytes_value,
3498 (void *)&cmd_pkt_filter_vlan,
3499 (void *)&cmd_pkt_filter_vlan_id,
3500 (void *)&cmd_pkt_filter_soft,
3501 (void *)&cmd_pkt_filter_soft_id,
3506 /* *** SETUP MASKS FILTER *** */
3507 struct cmd_pkt_filter_masks_result {
3508 cmdline_fixed_string_t filter_mask;
3510 cmdline_fixed_string_t src_mask;
3511 uint32_t ip_src_mask;
3512 uint16_t ipv6_src_mask;
3513 uint16_t port_src_mask;
3514 cmdline_fixed_string_t dst_mask;
3515 uint32_t ip_dst_mask;
3516 uint16_t ipv6_dst_mask;
3517 uint16_t port_dst_mask;
3518 cmdline_fixed_string_t flexbytes;
3519 uint8_t flexbytes_value;
3520 cmdline_fixed_string_t vlan_id;
3521 uint8_t vlan_id_value;
3522 cmdline_fixed_string_t vlan_prio;
3523 uint8_t vlan_prio_value;
3524 cmdline_fixed_string_t only_ip_flow;
3525 uint8_t only_ip_flow_value;
3526 cmdline_fixed_string_t comp_ipv6_dst;
3527 uint8_t comp_ipv6_dst_value;
3531 cmd_pkt_filter_masks_parsed(void *parsed_result,
3532 __attribute__((unused)) struct cmdline *cl,
3533 __attribute__((unused)) void *data)
3535 struct rte_fdir_masks fdir_masks;
3536 struct cmd_pkt_filter_masks_result *res = parsed_result;
3538 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3540 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3541 fdir_masks.vlan_id = res->vlan_id_value;
3542 fdir_masks.vlan_prio = res->vlan_prio_value;
3543 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3544 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3545 fdir_masks.src_port_mask = res->port_src_mask;
3546 fdir_masks.dst_port_mask = res->port_dst_mask;
3547 fdir_masks.flexbytes = res->flexbytes_value;
3549 fdir_set_masks(res->port_id, &fdir_masks);
3552 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3553 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3554 filter_mask, "set_masks_filter");
3555 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3556 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3558 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3559 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3560 only_ip_flow, "only_ip_flow");
3561 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3562 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3563 only_ip_flow_value, UINT8);
3564 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3565 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3566 src_mask, "src_mask");
3567 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3568 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3569 ip_src_mask, UINT32);
3570 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3571 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3572 port_src_mask, UINT16);
3573 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3574 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3575 dst_mask, "dst_mask");
3576 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3577 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3578 ip_dst_mask, UINT32);
3579 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3580 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3581 port_dst_mask, UINT16);
3582 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3583 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3584 flexbytes, "flexbytes");
3585 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3586 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3587 flexbytes_value, UINT8);
3588 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3589 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3590 vlan_id, "vlan_id");
3591 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3592 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3593 vlan_id_value, UINT8);
3594 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3595 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3596 vlan_prio, "vlan_prio");
3597 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3598 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3599 vlan_prio_value, UINT8);
3601 cmdline_parse_inst_t cmd_set_masks_filter = {
3602 .f = cmd_pkt_filter_masks_parsed,
3604 .help_str = "setup masks filter",
3606 (void *)&cmd_pkt_filter_masks_filter_mask,
3607 (void *)&cmd_pkt_filter_masks_port_id,
3608 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3609 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3610 (void *)&cmd_pkt_filter_masks_src_mask,
3611 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3612 (void *)&cmd_pkt_filter_masks_port_src_mask,
3613 (void *)&cmd_pkt_filter_masks_dst_mask,
3614 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3615 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3616 (void *)&cmd_pkt_filter_masks_flexbytes,
3617 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3618 (void *)&cmd_pkt_filter_masks_vlan_id,
3619 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3620 (void *)&cmd_pkt_filter_masks_vlan_prio,
3621 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3627 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3628 __attribute__((unused)) struct cmdline *cl,
3629 __attribute__((unused)) void *data)
3631 struct rte_fdir_masks fdir_masks;
3632 struct cmd_pkt_filter_masks_result *res = parsed_result;
3634 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3636 fdir_masks.set_ipv6_mask = 1;
3637 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3638 fdir_masks.vlan_id = res->vlan_id_value;
3639 fdir_masks.vlan_prio = res->vlan_prio_value;
3640 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3641 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3642 fdir_masks.src_port_mask = res->port_src_mask;
3643 fdir_masks.dst_port_mask = res->port_dst_mask;
3644 fdir_masks.flexbytes = res->flexbytes_value;
3645 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3647 fdir_set_masks(res->port_id, &fdir_masks);
3650 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3651 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3652 filter_mask, "set_ipv6_masks_filter");
3653 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3654 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3655 ipv6_src_mask, UINT16);
3656 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3657 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3658 ipv6_dst_mask, UINT16);
3660 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3661 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3662 comp_ipv6_dst, "compare_dst");
3663 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3664 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3665 comp_ipv6_dst_value, UINT8);
3667 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3668 .f = cmd_pkt_filter_masks_ipv6_parsed,
3670 .help_str = "setup ipv6 masks filter",
3672 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3673 (void *)&cmd_pkt_filter_masks_port_id,
3674 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3675 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3676 (void *)&cmd_pkt_filter_masks_src_mask,
3677 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3678 (void *)&cmd_pkt_filter_masks_port_src_mask,
3679 (void *)&cmd_pkt_filter_masks_dst_mask,
3680 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3681 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3682 (void *)&cmd_pkt_filter_masks_flexbytes,
3683 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3684 (void *)&cmd_pkt_filter_masks_vlan_id,
3685 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3686 (void *)&cmd_pkt_filter_masks_vlan_prio,
3687 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3688 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3689 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3694 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3695 struct cmd_link_flow_ctrl_set_result {
3696 cmdline_fixed_string_t set;
3697 cmdline_fixed_string_t flow_ctrl;
3698 cmdline_fixed_string_t rx;
3699 cmdline_fixed_string_t rx_lfc_mode;
3700 cmdline_fixed_string_t tx;
3701 cmdline_fixed_string_t tx_lfc_mode;
3702 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3703 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3704 uint32_t high_water;
3706 uint16_t pause_time;
3712 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3713 __attribute__((unused)) struct cmdline *cl,
3714 __attribute__((unused)) void *data)
3716 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3717 struct rte_eth_fc_conf fc_conf;
3718 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3722 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3723 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3724 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3725 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3727 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3728 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3731 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3732 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3733 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3735 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3736 fc_conf.high_water = res->high_water;
3737 fc_conf.low_water = res->low_water;
3738 fc_conf.pause_time = res->pause_time;
3739 fc_conf.send_xon = res->send_xon;
3740 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3742 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3744 printf("bad flow contrl parameter, return code = %d \n", ret);
3747 cmdline_parse_token_string_t cmd_lfc_set_set =
3748 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3750 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3751 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3752 flow_ctrl, "flow_ctrl");
3753 cmdline_parse_token_string_t cmd_lfc_set_rx =
3754 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3756 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3757 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3758 rx_lfc_mode, "on#off");
3759 cmdline_parse_token_string_t cmd_lfc_set_tx =
3760 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3762 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3763 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3764 tx_lfc_mode, "on#off");
3765 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3766 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3767 high_water, UINT32);
3768 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3769 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3771 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3772 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3773 pause_time, UINT16);
3774 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3775 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3777 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3779 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3780 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3782 mac_ctrl_frame_fwd_mode, "on#off");
3783 cmdline_parse_token_num_t cmd_lfc_set_portid =
3784 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3787 cmdline_parse_inst_t cmd_link_flow_control_set = {
3788 .f = cmd_link_flow_ctrl_set_parsed,
3790 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3791 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3794 (void *)&cmd_lfc_set_set,
3795 (void *)&cmd_lfc_set_flow_ctrl,
3796 (void *)&cmd_lfc_set_rx,
3797 (void *)&cmd_lfc_set_rx_mode,
3798 (void *)&cmd_lfc_set_tx,
3799 (void *)&cmd_lfc_set_tx_mode,
3800 (void *)&cmd_lfc_set_high_water,
3801 (void *)&cmd_lfc_set_low_water,
3802 (void *)&cmd_lfc_set_pause_time,
3803 (void *)&cmd_lfc_set_send_xon,
3804 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3805 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3806 (void *)&cmd_lfc_set_portid,
3811 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3812 struct cmd_priority_flow_ctrl_set_result {
3813 cmdline_fixed_string_t set;
3814 cmdline_fixed_string_t pfc_ctrl;
3815 cmdline_fixed_string_t rx;
3816 cmdline_fixed_string_t rx_pfc_mode;
3817 cmdline_fixed_string_t tx;
3818 cmdline_fixed_string_t tx_pfc_mode;
3819 uint32_t high_water;
3821 uint16_t pause_time;
3827 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3828 __attribute__((unused)) struct cmdline *cl,
3829 __attribute__((unused)) void *data)
3831 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3832 struct rte_eth_pfc_conf pfc_conf;
3833 int rx_fc_enable, tx_fc_enable;
3837 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3838 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3839 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3840 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3842 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3843 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3846 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3847 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3848 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3849 pfc_conf.fc.high_water = res->high_water;
3850 pfc_conf.fc.low_water = res->low_water;
3851 pfc_conf.fc.pause_time = res->pause_time;
3852 pfc_conf.priority = res->priority;
3854 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3856 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3859 cmdline_parse_token_string_t cmd_pfc_set_set =
3860 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3862 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3863 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3864 pfc_ctrl, "pfc_ctrl");
3865 cmdline_parse_token_string_t cmd_pfc_set_rx =
3866 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3868 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3869 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3870 rx_pfc_mode, "on#off");
3871 cmdline_parse_token_string_t cmd_pfc_set_tx =
3872 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3874 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3875 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3876 tx_pfc_mode, "on#off");
3877 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3878 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3879 high_water, UINT32);
3880 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3881 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3883 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3884 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3885 pause_time, UINT16);
3886 cmdline_parse_token_num_t cmd_pfc_set_priority =
3887 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3889 cmdline_parse_token_num_t cmd_pfc_set_portid =
3890 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3893 cmdline_parse_inst_t cmd_priority_flow_control_set = {
3894 .f = cmd_priority_flow_ctrl_set_parsed,
3896 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
3897 tx on|off high_water low_water pause_time priority port_id",
3899 (void *)&cmd_pfc_set_set,
3900 (void *)&cmd_pfc_set_flow_ctrl,
3901 (void *)&cmd_pfc_set_rx,
3902 (void *)&cmd_pfc_set_rx_mode,
3903 (void *)&cmd_pfc_set_tx,
3904 (void *)&cmd_pfc_set_tx_mode,
3905 (void *)&cmd_pfc_set_high_water,
3906 (void *)&cmd_pfc_set_low_water,
3907 (void *)&cmd_pfc_set_pause_time,
3908 (void *)&cmd_pfc_set_priority,
3909 (void *)&cmd_pfc_set_portid,
3914 /* *** RESET CONFIGURATION *** */
3915 struct cmd_reset_result {
3916 cmdline_fixed_string_t reset;
3917 cmdline_fixed_string_t def;
3920 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
3922 __attribute__((unused)) void *data)
3924 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
3925 set_def_fwd_config();
3928 cmdline_parse_token_string_t cmd_reset_set =
3929 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
3930 cmdline_parse_token_string_t cmd_reset_def =
3931 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
3934 cmdline_parse_inst_t cmd_reset = {
3935 .f = cmd_reset_parsed,
3937 .help_str = "set default: reset default forwarding configuration",
3939 (void *)&cmd_reset_set,
3940 (void *)&cmd_reset_def,
3945 /* *** START FORWARDING *** */
3946 struct cmd_start_result {
3947 cmdline_fixed_string_t start;
3950 cmdline_parse_token_string_t cmd_start_start =
3951 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
3953 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
3954 __attribute__((unused)) struct cmdline *cl,
3955 __attribute__((unused)) void *data)
3957 start_packet_forwarding(0);
3960 cmdline_parse_inst_t cmd_start = {
3961 .f = cmd_start_parsed,
3963 .help_str = "start packet forwarding",
3965 (void *)&cmd_start_start,
3970 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
3971 struct cmd_start_tx_first_result {
3972 cmdline_fixed_string_t start;
3973 cmdline_fixed_string_t tx_first;
3977 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
3978 __attribute__((unused)) struct cmdline *cl,
3979 __attribute__((unused)) void *data)
3981 start_packet_forwarding(1);
3984 cmdline_parse_token_string_t cmd_start_tx_first_start =
3985 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
3987 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
3988 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
3989 tx_first, "tx_first");
3991 cmdline_parse_inst_t cmd_start_tx_first = {
3992 .f = cmd_start_tx_first_parsed,
3994 .help_str = "start packet forwarding, after sending 1 burst of packets",
3996 (void *)&cmd_start_tx_first_start,
3997 (void *)&cmd_start_tx_first_tx_first,
4002 /* *** SET LINK UP *** */
4003 struct cmd_set_link_up_result {
4004 cmdline_fixed_string_t set;
4005 cmdline_fixed_string_t link_up;
4006 cmdline_fixed_string_t port;
4010 cmdline_parse_token_string_t cmd_set_link_up_set =
4011 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4012 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4015 cmdline_parse_token_string_t cmd_set_link_up_port =
4016 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4017 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4018 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4020 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4021 __attribute__((unused)) struct cmdline *cl,
4022 __attribute__((unused)) void *data)
4024 struct cmd_set_link_up_result *res = parsed_result;
4025 dev_set_link_up(res->port_id);
4028 cmdline_parse_inst_t cmd_set_link_up = {
4029 .f = cmd_set_link_up_parsed,
4031 .help_str = "set link-up port (port id)",
4033 (void *)&cmd_set_link_up_set,
4034 (void *)&cmd_set_link_up_link_up,
4035 (void *)&cmd_set_link_up_port,
4036 (void *)&cmd_set_link_up_port_id,
4041 /* *** SET LINK DOWN *** */
4042 struct cmd_set_link_down_result {
4043 cmdline_fixed_string_t set;
4044 cmdline_fixed_string_t link_down;
4045 cmdline_fixed_string_t port;
4049 cmdline_parse_token_string_t cmd_set_link_down_set =
4050 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4051 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4054 cmdline_parse_token_string_t cmd_set_link_down_port =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4056 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4057 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4059 static void cmd_set_link_down_parsed(
4060 __attribute__((unused)) void *parsed_result,
4061 __attribute__((unused)) struct cmdline *cl,
4062 __attribute__((unused)) void *data)
4064 struct cmd_set_link_down_result *res = parsed_result;
4065 dev_set_link_down(res->port_id);
4068 cmdline_parse_inst_t cmd_set_link_down = {
4069 .f = cmd_set_link_down_parsed,
4071 .help_str = "set link-down port (port id)",
4073 (void *)&cmd_set_link_down_set,
4074 (void *)&cmd_set_link_down_link_down,
4075 (void *)&cmd_set_link_down_port,
4076 (void *)&cmd_set_link_down_port_id,
4081 /* *** SHOW CFG *** */
4082 struct cmd_showcfg_result {
4083 cmdline_fixed_string_t show;
4084 cmdline_fixed_string_t cfg;
4085 cmdline_fixed_string_t what;
4088 static void cmd_showcfg_parsed(void *parsed_result,
4089 __attribute__((unused)) struct cmdline *cl,
4090 __attribute__((unused)) void *data)
4092 struct cmd_showcfg_result *res = parsed_result;
4093 if (!strcmp(res->what, "rxtx"))
4094 rxtx_config_display();
4095 else if (!strcmp(res->what, "cores"))
4096 fwd_lcores_config_display();
4097 else if (!strcmp(res->what, "fwd"))
4098 fwd_config_display();
4101 cmdline_parse_token_string_t cmd_showcfg_show =
4102 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4103 cmdline_parse_token_string_t cmd_showcfg_port =
4104 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4105 cmdline_parse_token_string_t cmd_showcfg_what =
4106 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4109 cmdline_parse_inst_t cmd_showcfg = {
4110 .f = cmd_showcfg_parsed,
4112 .help_str = "show config rxtx|cores|fwd",
4114 (void *)&cmd_showcfg_show,
4115 (void *)&cmd_showcfg_port,
4116 (void *)&cmd_showcfg_what,
4121 /* *** SHOW ALL PORT INFO *** */
4122 struct cmd_showportall_result {
4123 cmdline_fixed_string_t show;
4124 cmdline_fixed_string_t port;
4125 cmdline_fixed_string_t what;
4126 cmdline_fixed_string_t all;
4129 static void cmd_showportall_parsed(void *parsed_result,
4130 __attribute__((unused)) struct cmdline *cl,
4131 __attribute__((unused)) void *data)
4135 struct cmd_showportall_result *res = parsed_result;
4136 if (!strcmp(res->show, "clear")) {
4137 if (!strcmp(res->what, "stats"))
4138 for (i = 0; i < nb_ports; i++)
4140 } else if (!strcmp(res->what, "info"))
4141 for (i = 0; i < nb_ports; i++)
4142 port_infos_display(i);
4143 else if (!strcmp(res->what, "stats"))
4144 for (i = 0; i < nb_ports; i++)
4145 nic_stats_display(i);
4146 else if (!strcmp(res->what, "fdir"))
4147 for (i = 0; i < nb_ports; i++)
4149 else if (!strcmp(res->what, "stat_qmap"))
4150 for (i = 0; i < nb_ports; i++)
4151 nic_stats_mapping_display(i);
4154 cmdline_parse_token_string_t cmd_showportall_show =
4155 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4157 cmdline_parse_token_string_t cmd_showportall_port =
4158 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4159 cmdline_parse_token_string_t cmd_showportall_what =
4160 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4161 "info#stats#fdir#stat_qmap");
4162 cmdline_parse_token_string_t cmd_showportall_all =
4163 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4164 cmdline_parse_inst_t cmd_showportall = {
4165 .f = cmd_showportall_parsed,
4167 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4169 (void *)&cmd_showportall_show,
4170 (void *)&cmd_showportall_port,
4171 (void *)&cmd_showportall_what,
4172 (void *)&cmd_showportall_all,
4177 /* *** SHOW PORT INFO *** */
4178 struct cmd_showport_result {
4179 cmdline_fixed_string_t show;
4180 cmdline_fixed_string_t port;
4181 cmdline_fixed_string_t what;
4185 static void cmd_showport_parsed(void *parsed_result,
4186 __attribute__((unused)) struct cmdline *cl,
4187 __attribute__((unused)) void *data)
4189 struct cmd_showport_result *res = parsed_result;
4190 if (!strcmp(res->show, "clear")) {
4191 if (!strcmp(res->what, "stats"))
4192 nic_stats_clear(res->portnum);
4193 } else if (!strcmp(res->what, "info"))
4194 port_infos_display(res->portnum);
4195 else if (!strcmp(res->what, "stats"))
4196 nic_stats_display(res->portnum);
4197 else if (!strcmp(res->what, "fdir"))
4198 fdir_get_infos(res->portnum);
4199 else if (!strcmp(res->what, "stat_qmap"))
4200 nic_stats_mapping_display(res->portnum);
4203 cmdline_parse_token_string_t cmd_showport_show =
4204 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4206 cmdline_parse_token_string_t cmd_showport_port =
4207 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4208 cmdline_parse_token_string_t cmd_showport_what =
4209 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4210 "info#stats#fdir#stat_qmap");
4211 cmdline_parse_token_num_t cmd_showport_portnum =
4212 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4214 cmdline_parse_inst_t cmd_showport = {
4215 .f = cmd_showport_parsed,
4217 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4219 (void *)&cmd_showport_show,
4220 (void *)&cmd_showport_port,
4221 (void *)&cmd_showport_what,
4222 (void *)&cmd_showport_portnum,
4227 /* *** READ PORT REGISTER *** */
4228 struct cmd_read_reg_result {
4229 cmdline_fixed_string_t read;
4230 cmdline_fixed_string_t reg;
4236 cmd_read_reg_parsed(void *parsed_result,
4237 __attribute__((unused)) struct cmdline *cl,
4238 __attribute__((unused)) void *data)
4240 struct cmd_read_reg_result *res = parsed_result;
4241 port_reg_display(res->port_id, res->reg_off);
4244 cmdline_parse_token_string_t cmd_read_reg_read =
4245 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4246 cmdline_parse_token_string_t cmd_read_reg_reg =
4247 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4248 cmdline_parse_token_num_t cmd_read_reg_port_id =
4249 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4250 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4251 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4253 cmdline_parse_inst_t cmd_read_reg = {
4254 .f = cmd_read_reg_parsed,
4256 .help_str = "read reg port_id reg_off",
4258 (void *)&cmd_read_reg_read,
4259 (void *)&cmd_read_reg_reg,
4260 (void *)&cmd_read_reg_port_id,
4261 (void *)&cmd_read_reg_reg_off,
4266 /* *** READ PORT REGISTER BIT FIELD *** */
4267 struct cmd_read_reg_bit_field_result {
4268 cmdline_fixed_string_t read;
4269 cmdline_fixed_string_t regfield;
4277 cmd_read_reg_bit_field_parsed(void *parsed_result,
4278 __attribute__((unused)) struct cmdline *cl,
4279 __attribute__((unused)) void *data)
4281 struct cmd_read_reg_bit_field_result *res = parsed_result;
4282 port_reg_bit_field_display(res->port_id, res->reg_off,
4283 res->bit1_pos, res->bit2_pos);
4286 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4287 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4289 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4290 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4291 regfield, "regfield");
4292 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4293 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4295 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4296 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4298 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4299 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4301 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4302 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4305 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4306 .f = cmd_read_reg_bit_field_parsed,
4308 .help_str = "read regfield port_id reg_off bit_x bit_y "
4309 "(read register bit field between bit_x and bit_y included)",
4311 (void *)&cmd_read_reg_bit_field_read,
4312 (void *)&cmd_read_reg_bit_field_regfield,
4313 (void *)&cmd_read_reg_bit_field_port_id,
4314 (void *)&cmd_read_reg_bit_field_reg_off,
4315 (void *)&cmd_read_reg_bit_field_bit1_pos,
4316 (void *)&cmd_read_reg_bit_field_bit2_pos,
4321 /* *** READ PORT REGISTER BIT *** */
4322 struct cmd_read_reg_bit_result {
4323 cmdline_fixed_string_t read;
4324 cmdline_fixed_string_t regbit;
4331 cmd_read_reg_bit_parsed(void *parsed_result,
4332 __attribute__((unused)) struct cmdline *cl,
4333 __attribute__((unused)) void *data)
4335 struct cmd_read_reg_bit_result *res = parsed_result;
4336 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4339 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4340 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4341 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4342 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4344 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4345 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4346 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4347 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4348 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4349 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4351 cmdline_parse_inst_t cmd_read_reg_bit = {
4352 .f = cmd_read_reg_bit_parsed,
4354 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4356 (void *)&cmd_read_reg_bit_read,
4357 (void *)&cmd_read_reg_bit_regbit,
4358 (void *)&cmd_read_reg_bit_port_id,
4359 (void *)&cmd_read_reg_bit_reg_off,
4360 (void *)&cmd_read_reg_bit_bit_pos,
4365 /* *** WRITE PORT REGISTER *** */
4366 struct cmd_write_reg_result {
4367 cmdline_fixed_string_t write;
4368 cmdline_fixed_string_t reg;
4375 cmd_write_reg_parsed(void *parsed_result,
4376 __attribute__((unused)) struct cmdline *cl,
4377 __attribute__((unused)) void *data)
4379 struct cmd_write_reg_result *res = parsed_result;
4380 port_reg_set(res->port_id, res->reg_off, res->value);
4383 cmdline_parse_token_string_t cmd_write_reg_write =
4384 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4385 cmdline_parse_token_string_t cmd_write_reg_reg =
4386 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4387 cmdline_parse_token_num_t cmd_write_reg_port_id =
4388 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4389 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4390 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4391 cmdline_parse_token_num_t cmd_write_reg_value =
4392 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4394 cmdline_parse_inst_t cmd_write_reg = {
4395 .f = cmd_write_reg_parsed,
4397 .help_str = "write reg port_id reg_off reg_value",
4399 (void *)&cmd_write_reg_write,
4400 (void *)&cmd_write_reg_reg,
4401 (void *)&cmd_write_reg_port_id,
4402 (void *)&cmd_write_reg_reg_off,
4403 (void *)&cmd_write_reg_value,
4408 /* *** WRITE PORT REGISTER BIT FIELD *** */
4409 struct cmd_write_reg_bit_field_result {
4410 cmdline_fixed_string_t write;
4411 cmdline_fixed_string_t regfield;
4420 cmd_write_reg_bit_field_parsed(void *parsed_result,
4421 __attribute__((unused)) struct cmdline *cl,
4422 __attribute__((unused)) void *data)
4424 struct cmd_write_reg_bit_field_result *res = parsed_result;
4425 port_reg_bit_field_set(res->port_id, res->reg_off,
4426 res->bit1_pos, res->bit2_pos, res->value);
4429 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4430 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4432 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4433 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4434 regfield, "regfield");
4435 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4438 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4439 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4441 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4442 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4444 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4445 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4447 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4451 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4452 .f = cmd_write_reg_bit_field_parsed,
4454 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4455 "(set register bit field between bit_x and bit_y included)",
4457 (void *)&cmd_write_reg_bit_field_write,
4458 (void *)&cmd_write_reg_bit_field_regfield,
4459 (void *)&cmd_write_reg_bit_field_port_id,
4460 (void *)&cmd_write_reg_bit_field_reg_off,
4461 (void *)&cmd_write_reg_bit_field_bit1_pos,
4462 (void *)&cmd_write_reg_bit_field_bit2_pos,
4463 (void *)&cmd_write_reg_bit_field_value,
4468 /* *** WRITE PORT REGISTER BIT *** */
4469 struct cmd_write_reg_bit_result {
4470 cmdline_fixed_string_t write;
4471 cmdline_fixed_string_t regbit;
4479 cmd_write_reg_bit_parsed(void *parsed_result,
4480 __attribute__((unused)) struct cmdline *cl,
4481 __attribute__((unused)) void *data)
4483 struct cmd_write_reg_bit_result *res = parsed_result;
4484 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4487 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4488 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4490 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4491 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4493 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4494 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4495 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4496 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4497 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4498 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4499 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4500 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4502 cmdline_parse_inst_t cmd_write_reg_bit = {
4503 .f = cmd_write_reg_bit_parsed,
4505 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4507 (void *)&cmd_write_reg_bit_write,
4508 (void *)&cmd_write_reg_bit_regbit,
4509 (void *)&cmd_write_reg_bit_port_id,
4510 (void *)&cmd_write_reg_bit_reg_off,
4511 (void *)&cmd_write_reg_bit_bit_pos,
4512 (void *)&cmd_write_reg_bit_value,
4517 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4518 struct cmd_read_rxd_txd_result {
4519 cmdline_fixed_string_t read;
4520 cmdline_fixed_string_t rxd_txd;
4527 cmd_read_rxd_txd_parsed(void *parsed_result,
4528 __attribute__((unused)) struct cmdline *cl,
4529 __attribute__((unused)) void *data)
4531 struct cmd_read_rxd_txd_result *res = parsed_result;
4533 if (!strcmp(res->rxd_txd, "rxd"))
4534 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4535 else if (!strcmp(res->rxd_txd, "txd"))
4536 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4539 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4540 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4541 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4542 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4544 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4545 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4546 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4547 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4548 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4549 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4551 cmdline_parse_inst_t cmd_read_rxd_txd = {
4552 .f = cmd_read_rxd_txd_parsed,
4554 .help_str = "read rxd|txd port_id queue_id rxd_id",
4556 (void *)&cmd_read_rxd_txd_read,
4557 (void *)&cmd_read_rxd_txd_rxd_txd,
4558 (void *)&cmd_read_rxd_txd_port_id,
4559 (void *)&cmd_read_rxd_txd_queue_id,
4560 (void *)&cmd_read_rxd_txd_desc_id,
4566 struct cmd_quit_result {
4567 cmdline_fixed_string_t quit;
4570 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4572 __attribute__((unused)) void *data)
4578 cmdline_parse_token_string_t cmd_quit_quit =
4579 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4581 cmdline_parse_inst_t cmd_quit = {
4582 .f = cmd_quit_parsed,
4584 .help_str = "exit application",
4586 (void *)&cmd_quit_quit,
4591 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4592 struct cmd_mac_addr_result {
4593 cmdline_fixed_string_t mac_addr_cmd;
4594 cmdline_fixed_string_t what;
4596 struct ether_addr address;
4599 static void cmd_mac_addr_parsed(void *parsed_result,
4600 __attribute__((unused)) struct cmdline *cl,
4601 __attribute__((unused)) void *data)
4603 struct cmd_mac_addr_result *res = parsed_result;
4606 if (strcmp(res->what, "add") == 0)
4607 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4609 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4611 /* check the return value and print it if is < 0 */
4613 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4617 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4618 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4620 cmdline_parse_token_string_t cmd_mac_addr_what =
4621 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4623 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4624 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4625 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4628 cmdline_parse_inst_t cmd_mac_addr = {
4629 .f = cmd_mac_addr_parsed,
4631 .help_str = "mac_addr add|remove X <address>: "
4632 "add/remove MAC address on port X",
4634 (void *)&cmd_mac_addr_cmd,
4635 (void *)&cmd_mac_addr_what,
4636 (void *)&cmd_mac_addr_portnum,
4637 (void *)&cmd_mac_addr_addr,
4643 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4644 struct cmd_set_qmap_result {
4645 cmdline_fixed_string_t set;
4646 cmdline_fixed_string_t qmap;
4647 cmdline_fixed_string_t what;
4654 cmd_set_qmap_parsed(void *parsed_result,
4655 __attribute__((unused)) struct cmdline *cl,
4656 __attribute__((unused)) void *data)
4658 struct cmd_set_qmap_result *res = parsed_result;
4659 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4661 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4664 cmdline_parse_token_string_t cmd_setqmap_set =
4665 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4667 cmdline_parse_token_string_t cmd_setqmap_qmap =
4668 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4670 cmdline_parse_token_string_t cmd_setqmap_what =
4671 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4673 cmdline_parse_token_num_t cmd_setqmap_portid =
4674 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4676 cmdline_parse_token_num_t cmd_setqmap_queueid =
4677 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4679 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4680 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4683 cmdline_parse_inst_t cmd_set_qmap = {
4684 .f = cmd_set_qmap_parsed,
4686 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4688 (void *)&cmd_setqmap_set,
4689 (void *)&cmd_setqmap_qmap,
4690 (void *)&cmd_setqmap_what,
4691 (void *)&cmd_setqmap_portid,
4692 (void *)&cmd_setqmap_queueid,
4693 (void *)&cmd_setqmap_mapvalue,
4698 /* *** CONFIGURE UNICAST HASH TABLE *** */
4699 struct cmd_set_uc_hash_table {
4700 cmdline_fixed_string_t set;
4701 cmdline_fixed_string_t port;
4703 cmdline_fixed_string_t what;
4704 struct ether_addr address;
4705 cmdline_fixed_string_t mode;
4709 cmd_set_uc_hash_parsed(void *parsed_result,
4710 __attribute__((unused)) struct cmdline *cl,
4711 __attribute__((unused)) void *data)
4714 struct cmd_set_uc_hash_table *res = parsed_result;
4716 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4718 if (strcmp(res->what, "uta") == 0)
4719 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4720 &res->address,(uint8_t)is_on);
4722 printf("bad unicast hash table parameter, return code = %d \n", ret);
4726 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4727 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4729 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4730 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4732 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4733 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4735 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4736 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4738 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4739 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4741 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4742 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4745 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4746 .f = cmd_set_uc_hash_parsed,
4748 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4750 (void *)&cmd_set_uc_hash_set,
4751 (void *)&cmd_set_uc_hash_port,
4752 (void *)&cmd_set_uc_hash_portid,
4753 (void *)&cmd_set_uc_hash_what,
4754 (void *)&cmd_set_uc_hash_mac,
4755 (void *)&cmd_set_uc_hash_mode,
4760 struct cmd_set_uc_all_hash_table {
4761 cmdline_fixed_string_t set;
4762 cmdline_fixed_string_t port;
4764 cmdline_fixed_string_t what;
4765 cmdline_fixed_string_t value;
4766 cmdline_fixed_string_t mode;
4770 cmd_set_uc_all_hash_parsed(void *parsed_result,
4771 __attribute__((unused)) struct cmdline *cl,
4772 __attribute__((unused)) void *data)
4775 struct cmd_set_uc_all_hash_table *res = parsed_result;
4777 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4779 if ((strcmp(res->what, "uta") == 0) &&
4780 (strcmp(res->value, "all") == 0))
4781 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4783 printf("bad unicast hash table parameter,"
4784 "return code = %d \n", ret);
4787 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4790 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4791 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4793 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4794 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4796 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4797 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4799 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4802 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4806 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4807 .f = cmd_set_uc_all_hash_parsed,
4809 .help_str = "set port X uta all on|off (X = port number)",
4811 (void *)&cmd_set_uc_all_hash_set,
4812 (void *)&cmd_set_uc_all_hash_port,
4813 (void *)&cmd_set_uc_all_hash_portid,
4814 (void *)&cmd_set_uc_all_hash_what,
4815 (void *)&cmd_set_uc_all_hash_value,
4816 (void *)&cmd_set_uc_all_hash_mode,
4821 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4822 struct cmd_set_vf_traffic {
4823 cmdline_fixed_string_t set;
4824 cmdline_fixed_string_t port;
4826 cmdline_fixed_string_t vf;
4828 cmdline_fixed_string_t what;
4829 cmdline_fixed_string_t mode;
4833 cmd_set_vf_traffic_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4837 struct cmd_set_vf_traffic *res = parsed_result;
4838 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4839 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4841 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4844 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4847 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4850 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4851 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4853 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4856 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4857 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4859 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4862 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4866 cmdline_parse_inst_t cmd_set_vf_traffic = {
4867 .f = cmd_set_vf_traffic_parsed,
4869 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4871 (void *)&cmd_setvf_traffic_set,
4872 (void *)&cmd_setvf_traffic_port,
4873 (void *)&cmd_setvf_traffic_portid,
4874 (void *)&cmd_setvf_traffic_vf,
4875 (void *)&cmd_setvf_traffic_vfid,
4876 (void *)&cmd_setvf_traffic_what,
4877 (void *)&cmd_setvf_traffic_mode,
4882 /* *** CONFIGURE VF RECEIVE MODE *** */
4883 struct cmd_set_vf_rxmode {
4884 cmdline_fixed_string_t set;
4885 cmdline_fixed_string_t port;
4887 cmdline_fixed_string_t vf;
4889 cmdline_fixed_string_t what;
4890 cmdline_fixed_string_t mode;
4891 cmdline_fixed_string_t on;
4895 cmd_set_vf_rxmode_parsed(void *parsed_result,
4896 __attribute__((unused)) struct cmdline *cl,
4897 __attribute__((unused)) void *data)
4900 uint16_t rx_mode = 0;
4901 struct cmd_set_vf_rxmode *res = parsed_result;
4903 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
4904 if (!strcmp(res->what,"rxmode")) {
4905 if (!strcmp(res->mode, "AUPE"))
4906 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
4907 else if (!strcmp(res->mode, "ROPE"))
4908 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
4909 else if (!strcmp(res->mode, "BAM"))
4910 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
4911 else if (!strncmp(res->mode, "MPE",3))
4912 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
4915 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
4917 printf("bad VF receive mode parameter, return code = %d \n",
4921 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
4922 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4924 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
4925 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4927 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
4928 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4930 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
4931 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4933 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
4934 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
4936 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4939 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4941 mode, "AUPE#ROPE#BAM#MPE");
4942 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
4946 cmdline_parse_inst_t cmd_set_vf_rxmode = {
4947 .f = cmd_set_vf_rxmode_parsed,
4949 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
4951 (void *)&cmd_set_vf_rxmode_set,
4952 (void *)&cmd_set_vf_rxmode_port,
4953 (void *)&cmd_set_vf_rxmode_portid,
4954 (void *)&cmd_set_vf_rxmode_vf,
4955 (void *)&cmd_set_vf_rxmode_vfid,
4956 (void *)&cmd_set_vf_rxmode_what,
4957 (void *)&cmd_set_vf_rxmode_mode,
4958 (void *)&cmd_set_vf_rxmode_on,
4963 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
4964 struct cmd_vf_mac_addr_result {
4965 cmdline_fixed_string_t mac_addr_cmd;
4966 cmdline_fixed_string_t what;
4967 cmdline_fixed_string_t port;
4969 cmdline_fixed_string_t vf;
4971 struct ether_addr address;
4974 static void cmd_vf_mac_addr_parsed(void *parsed_result,
4975 __attribute__((unused)) struct cmdline *cl,
4976 __attribute__((unused)) void *data)
4978 struct cmd_vf_mac_addr_result *res = parsed_result;
4981 if (strcmp(res->what, "add") == 0)
4982 ret = rte_eth_dev_mac_addr_add(res->port_num,
4983 &res->address, res->vf_num);
4985 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
4989 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
4990 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4991 mac_addr_cmd,"mac_addr");
4992 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
4993 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4995 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
4996 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
4998 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
4999 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5001 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5002 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5004 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5005 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5007 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5008 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5011 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5012 .f = cmd_vf_mac_addr_parsed,
5014 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5015 "Y = VF number)add MAC address filtering for a VF on port X",
5017 (void *)&cmd_vf_mac_addr_cmd,
5018 (void *)&cmd_vf_mac_addr_what,
5019 (void *)&cmd_vf_mac_addr_port,
5020 (void *)&cmd_vf_mac_addr_portnum,
5021 (void *)&cmd_vf_mac_addr_vf,
5022 (void *)&cmd_vf_mac_addr_vfnum,
5023 (void *)&cmd_vf_mac_addr_addr,
5028 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5029 struct cmd_vf_rx_vlan_filter {
5030 cmdline_fixed_string_t rx_vlan;
5031 cmdline_fixed_string_t what;
5033 cmdline_fixed_string_t port;
5035 cmdline_fixed_string_t vf;
5040 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5041 __attribute__((unused)) struct cmdline *cl,
5042 __attribute__((unused)) void *data)
5044 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5046 if (!strcmp(res->what, "add"))
5047 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5049 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5052 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5054 rx_vlan, "rx_vlan");
5055 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5058 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5061 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5062 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5064 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5065 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5067 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5068 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5070 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5071 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5074 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5075 .f = cmd_vf_rx_vlan_filter_parsed,
5077 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5078 "Y = port number,Z = hexadecimal VF mask)",
5080 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5081 (void *)&cmd_vf_rx_vlan_filter_what,
5082 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5083 (void *)&cmd_vf_rx_vlan_filter_port,
5084 (void *)&cmd_vf_rx_vlan_filter_portid,
5085 (void *)&cmd_vf_rx_vlan_filter_vf,
5086 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5091 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5092 struct cmd_queue_rate_limit_result {
5093 cmdline_fixed_string_t set;
5094 cmdline_fixed_string_t port;
5096 cmdline_fixed_string_t queue;
5098 cmdline_fixed_string_t rate;
5102 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5103 __attribute__((unused)) struct cmdline *cl,
5104 __attribute__((unused)) void *data)
5106 struct cmd_queue_rate_limit_result *res = parsed_result;
5109 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5110 && (strcmp(res->queue, "queue") == 0)
5111 && (strcmp(res->rate, "rate") == 0))
5112 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5115 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5119 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5120 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5122 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5123 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5125 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5126 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5128 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5129 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5131 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5132 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5134 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5135 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5137 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5138 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5141 cmdline_parse_inst_t cmd_queue_rate_limit = {
5142 .f = cmd_queue_rate_limit_parsed,
5144 .help_str = "set port X queue Y rate Z:(X = port number,"
5145 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5147 (void *)&cmd_queue_rate_limit_set,
5148 (void *)&cmd_queue_rate_limit_port,
5149 (void *)&cmd_queue_rate_limit_portnum,
5150 (void *)&cmd_queue_rate_limit_queue,
5151 (void *)&cmd_queue_rate_limit_queuenum,
5152 (void *)&cmd_queue_rate_limit_rate,
5153 (void *)&cmd_queue_rate_limit_ratenum,
5158 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5159 struct cmd_vf_rate_limit_result {
5160 cmdline_fixed_string_t set;
5161 cmdline_fixed_string_t port;
5163 cmdline_fixed_string_t vf;
5165 cmdline_fixed_string_t rate;
5167 cmdline_fixed_string_t q_msk;
5171 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5172 __attribute__((unused)) struct cmdline *cl,
5173 __attribute__((unused)) void *data)
5175 struct cmd_vf_rate_limit_result *res = parsed_result;
5178 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5179 && (strcmp(res->vf, "vf") == 0)
5180 && (strcmp(res->rate, "rate") == 0)
5181 && (strcmp(res->q_msk, "queue_mask") == 0))
5182 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5183 res->rate_num, res->q_msk_val);
5185 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5189 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5190 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5192 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5193 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5195 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5196 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5198 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5199 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5201 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5202 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5204 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5205 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5207 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5208 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5210 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5211 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5212 q_msk, "queue_mask");
5213 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5214 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5217 cmdline_parse_inst_t cmd_vf_rate_limit = {
5218 .f = cmd_vf_rate_limit_parsed,
5220 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5221 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5222 "for queues of VF on port X",
5224 (void *)&cmd_vf_rate_limit_set,
5225 (void *)&cmd_vf_rate_limit_port,
5226 (void *)&cmd_vf_rate_limit_portnum,
5227 (void *)&cmd_vf_rate_limit_vf,
5228 (void *)&cmd_vf_rate_limit_vfnum,
5229 (void *)&cmd_vf_rate_limit_rate,
5230 (void *)&cmd_vf_rate_limit_ratenum,
5231 (void *)&cmd_vf_rate_limit_q_msk,
5232 (void *)&cmd_vf_rate_limit_q_msk_val,
5237 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5238 struct cmd_set_mirror_mask_result {
5239 cmdline_fixed_string_t set;
5240 cmdline_fixed_string_t port;
5242 cmdline_fixed_string_t mirror;
5244 cmdline_fixed_string_t what;
5245 cmdline_fixed_string_t value;
5246 cmdline_fixed_string_t dstpool;
5248 cmdline_fixed_string_t on;
5251 cmdline_parse_token_string_t cmd_mirror_mask_set =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5254 cmdline_parse_token_string_t cmd_mirror_mask_port =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5257 cmdline_parse_token_string_t cmd_mirror_mask_portid =
5258 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5260 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5262 mirror, "mirror-rule");
5263 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5264 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5266 cmdline_parse_token_string_t cmd_mirror_mask_what =
5267 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5268 what, "pool-mirror#vlan-mirror");
5269 cmdline_parse_token_string_t cmd_mirror_mask_value =
5270 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5272 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5273 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5274 dstpool, "dst-pool");
5275 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5276 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5278 cmdline_parse_token_string_t cmd_mirror_mask_on =
5279 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5283 cmd_set_mirror_mask_parsed(void *parsed_result,
5284 __attribute__((unused)) struct cmdline *cl,
5285 __attribute__((unused)) void *data)
5288 struct cmd_set_mirror_mask_result *res = parsed_result;
5289 struct rte_eth_vmdq_mirror_conf mr_conf;
5291 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5293 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5295 mr_conf.dst_pool = res->dstpool_id;
5297 if (!strcmp(res->what, "pool-mirror")) {
5298 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5299 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5300 } else if(!strcmp(res->what, "vlan-mirror")) {
5301 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5302 nb_item = parse_item_list(res->value, "core",
5303 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5307 for(i=0; i < nb_item; i++) {
5308 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5309 printf("Invalid vlan_id: must be < 4096\n");
5313 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5314 mr_conf.vlan.vlan_mask |= 1ULL << i;
5318 if(!strcmp(res->on, "on"))
5319 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5322 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5325 printf("mirror rule add error: (%s)\n", strerror(-ret));
5328 cmdline_parse_inst_t cmd_set_mirror_mask = {
5329 .f = cmd_set_mirror_mask_parsed,
5331 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5332 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5334 (void *)&cmd_mirror_mask_set,
5335 (void *)&cmd_mirror_mask_port,
5336 (void *)&cmd_mirror_mask_portid,
5337 (void *)&cmd_mirror_mask_mirror,
5338 (void *)&cmd_mirror_mask_ruleid,
5339 (void *)&cmd_mirror_mask_what,
5340 (void *)&cmd_mirror_mask_value,
5341 (void *)&cmd_mirror_mask_dstpool,
5342 (void *)&cmd_mirror_mask_poolid,
5343 (void *)&cmd_mirror_mask_on,
5348 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5349 struct cmd_set_mirror_link_result {
5350 cmdline_fixed_string_t set;
5351 cmdline_fixed_string_t port;
5353 cmdline_fixed_string_t mirror;
5355 cmdline_fixed_string_t what;
5356 cmdline_fixed_string_t dstpool;
5358 cmdline_fixed_string_t on;
5361 cmdline_parse_token_string_t cmd_mirror_link_set =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5364 cmdline_parse_token_string_t cmd_mirror_link_port =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5367 cmdline_parse_token_string_t cmd_mirror_link_portid =
5368 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5370 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5372 mirror, "mirror-rule");
5373 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5374 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5376 cmdline_parse_token_string_t cmd_mirror_link_what =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5378 what, "uplink-mirror#downlink-mirror");
5379 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5381 dstpool, "dst-pool");
5382 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5383 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5385 cmdline_parse_token_string_t cmd_mirror_link_on =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5390 cmd_set_mirror_link_parsed(void *parsed_result,
5391 __attribute__((unused)) struct cmdline *cl,
5392 __attribute__((unused)) void *data)
5395 struct cmd_set_mirror_link_result *res = parsed_result;
5396 struct rte_eth_vmdq_mirror_conf mr_conf;
5398 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5399 if(!strcmp(res->what, "uplink-mirror")) {
5400 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5401 }else if(!strcmp(res->what, "downlink-mirror"))
5402 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5404 mr_conf.dst_pool = res->dstpool_id;
5406 if(!strcmp(res->on, "on"))
5407 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5410 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5413 /* check the return value and print it if is < 0 */
5415 printf("mirror rule add error: (%s)\n", strerror(-ret));
5419 cmdline_parse_inst_t cmd_set_mirror_link = {
5420 .f = cmd_set_mirror_link_parsed,
5422 .help_str = "set port X mirror-rule Y uplink-mirror|"
5423 "downlink-mirror dst-pool Z on|off",
5425 (void *)&cmd_mirror_link_set,
5426 (void *)&cmd_mirror_link_port,
5427 (void *)&cmd_mirror_link_portid,
5428 (void *)&cmd_mirror_link_mirror,
5429 (void *)&cmd_mirror_link_ruleid,
5430 (void *)&cmd_mirror_link_what,
5431 (void *)&cmd_mirror_link_dstpool,
5432 (void *)&cmd_mirror_link_poolid,
5433 (void *)&cmd_mirror_link_on,
5438 /* *** RESET VM MIRROR RULE *** */
5439 struct cmd_rm_mirror_rule_result {
5440 cmdline_fixed_string_t reset;
5441 cmdline_fixed_string_t port;
5443 cmdline_fixed_string_t mirror;
5447 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5448 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5450 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5451 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5453 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5454 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5456 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5457 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5458 mirror, "mirror-rule");
5459 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5460 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5464 cmd_reset_mirror_rule_parsed(void *parsed_result,
5465 __attribute__((unused)) struct cmdline *cl,
5466 __attribute__((unused)) void *data)
5469 struct cmd_set_mirror_link_result *res = parsed_result;
5471 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5473 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5476 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5477 .f = cmd_reset_mirror_rule_parsed,
5479 .help_str = "reset port X mirror-rule Y",
5481 (void *)&cmd_rm_mirror_rule_reset,
5482 (void *)&cmd_rm_mirror_rule_port,
5483 (void *)&cmd_rm_mirror_rule_portid,
5484 (void *)&cmd_rm_mirror_rule_mirror,
5485 (void *)&cmd_rm_mirror_rule_ruleid,
5490 /* ******************************************************************************** */
5492 struct cmd_dump_result {
5493 cmdline_fixed_string_t dump;
5497 dump_struct_sizes(void)
5499 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5500 DUMP_SIZE(struct rte_mbuf);
5501 DUMP_SIZE(struct rte_pktmbuf);
5502 DUMP_SIZE(struct rte_ctrlmbuf);
5503 DUMP_SIZE(struct rte_mempool);
5504 DUMP_SIZE(struct rte_ring);
5508 static void cmd_dump_parsed(void *parsed_result,
5509 __attribute__((unused)) struct cmdline *cl,
5510 __attribute__((unused)) void *data)
5512 struct cmd_dump_result *res = parsed_result;
5514 if (!strcmp(res->dump, "dump_physmem"))
5515 rte_dump_physmem_layout(stdout);
5516 else if (!strcmp(res->dump, "dump_memzone"))
5517 rte_memzone_dump(stdout);
5518 else if (!strcmp(res->dump, "dump_log_history"))
5519 rte_log_dump_history(stdout);
5520 else if (!strcmp(res->dump, "dump_struct_sizes"))
5521 dump_struct_sizes();
5522 else if (!strcmp(res->dump, "dump_ring"))
5523 rte_ring_list_dump(stdout);
5524 else if (!strcmp(res->dump, "dump_mempool"))
5525 rte_mempool_list_dump(stdout);
5526 else if (!strcmp(res->dump, "dump_devargs"))
5527 rte_eal_devargs_dump(stdout);
5530 cmdline_parse_token_string_t cmd_dump_dump =
5531 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5535 "dump_struct_sizes#"
5540 cmdline_parse_inst_t cmd_dump = {
5541 .f = cmd_dump_parsed, /* function to call */
5542 .data = NULL, /* 2nd arg of func */
5543 .help_str = "dump status",
5544 .tokens = { /* token list, NULL terminated */
5545 (void *)&cmd_dump_dump,
5550 /* ******************************************************************************** */
5552 struct cmd_dump_one_result {
5553 cmdline_fixed_string_t dump;
5554 cmdline_fixed_string_t name;
5557 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5558 __attribute__((unused)) void *data)
5560 struct cmd_dump_one_result *res = parsed_result;
5562 if (!strcmp(res->dump, "dump_ring")) {
5564 r = rte_ring_lookup(res->name);
5566 cmdline_printf(cl, "Cannot find ring\n");
5569 rte_ring_dump(stdout, r);
5570 } else if (!strcmp(res->dump, "dump_mempool")) {
5571 struct rte_mempool *mp;
5572 mp = rte_mempool_lookup(res->name);
5574 cmdline_printf(cl, "Cannot find mempool\n");
5577 rte_mempool_dump(stdout, mp);
5581 cmdline_parse_token_string_t cmd_dump_one_dump =
5582 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5583 "dump_ring#dump_mempool");
5585 cmdline_parse_token_string_t cmd_dump_one_name =
5586 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5588 cmdline_parse_inst_t cmd_dump_one = {
5589 .f = cmd_dump_one_parsed, /* function to call */
5590 .data = NULL, /* 2nd arg of func */
5591 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5592 .tokens = { /* token list, NULL terminated */
5593 (void *)&cmd_dump_one_dump,
5594 (void *)&cmd_dump_one_name,
5599 /* *** ADD/REMOVE an ethertype FILTER *** */
5600 struct cmd_ethertype_filter_result {
5601 cmdline_fixed_string_t filter;
5603 cmdline_fixed_string_t ethertype;
5604 uint16_t ethertype_value;
5605 cmdline_fixed_string_t priority;
5606 cmdline_fixed_string_t priority_en;
5607 uint8_t priority_value;
5608 cmdline_fixed_string_t queue;
5610 cmdline_fixed_string_t index;
5611 uint16_t index_value;
5615 cmd_ethertype_filter_parsed(void *parsed_result,
5616 __attribute__((unused)) struct cmdline *cl,
5617 __attribute__((unused)) void *data)
5620 struct cmd_ethertype_filter_result *res = parsed_result;
5621 struct rte_ethertype_filter filter;
5623 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
5624 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
5625 filter.priority = res->priority_value;
5627 if (!strcmp(res->priority_en, "enable"))
5628 filter.priority_en = 1;
5629 if (!strcmp(res->filter, "add_ethertype_filter"))
5630 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
5632 &filter, res->queue_id);
5633 else if (!strcmp(res->filter, "remove_ethertype_filter"))
5634 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
5636 else if (!strcmp(res->filter, "get_ethertype_filter"))
5637 get_ethertype_filter(res->port_id, res->index_value);
5640 printf("ethertype filter setting error: (%s)\n",
5644 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
5645 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5647 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
5648 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5649 ethertype, "ethertype");
5650 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
5651 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5652 ethertype_value, UINT16);
5653 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
5654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5655 priority, "priority");
5656 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
5657 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5658 priority_en, "enable#disable");
5659 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
5660 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5661 priority_value, UINT8);
5662 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
5663 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5665 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
5666 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5668 cmdline_parse_token_string_t cmd_ethertype_filter_index =
5669 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5671 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
5672 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5673 index_value, UINT16);
5674 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
5675 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5676 filter, "add_ethertype_filter");
5677 cmdline_parse_inst_t cmd_add_ethertype_filter = {
5678 .f = cmd_ethertype_filter_parsed,
5680 .help_str = "add an ethertype filter",
5682 (void *)&cmd_ethertype_filter_add_filter,
5683 (void *)&cmd_ethertype_filter_port_id,
5684 (void *)&cmd_ethertype_filter_ethertype,
5685 (void *)&cmd_ethertype_filter_ethertype_value,
5686 (void *)&cmd_ethertype_filter_priority,
5687 (void *)&cmd_ethertype_filter_priority_en,
5688 (void *)&cmd_ethertype_filter_priority_value,
5689 (void *)&cmd_ethertype_filter_queue,
5690 (void *)&cmd_ethertype_filter_queue_id,
5691 (void *)&cmd_ethertype_filter_index,
5692 (void *)&cmd_ethertype_filter_index_value,
5697 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
5698 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5699 filter, "remove_ethertype_filter");
5700 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
5701 .f = cmd_ethertype_filter_parsed,
5703 .help_str = "remove an ethertype filter",
5705 (void *)&cmd_ethertype_filter_remove_filter,
5706 (void *)&cmd_ethertype_filter_port_id,
5707 (void *)&cmd_ethertype_filter_index,
5708 (void *)&cmd_ethertype_filter_index_value,
5712 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
5713 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5714 filter, "get_ethertype_filter");
5715 cmdline_parse_inst_t cmd_get_ethertype_filter = {
5716 .f = cmd_ethertype_filter_parsed,
5718 .help_str = "get an ethertype filter",
5720 (void *)&cmd_ethertype_filter_get_filter,
5721 (void *)&cmd_ethertype_filter_port_id,
5722 (void *)&cmd_ethertype_filter_index,
5723 (void *)&cmd_ethertype_filter_index_value,
5728 /* *** set SYN filter *** */
5729 struct cmd_set_syn_filter_result {
5730 cmdline_fixed_string_t filter;
5732 cmdline_fixed_string_t priority;
5733 cmdline_fixed_string_t high;
5734 cmdline_fixed_string_t queue;
5739 cmd_set_syn_filter_parsed(void *parsed_result,
5740 __attribute__((unused)) struct cmdline *cl,
5741 __attribute__((unused)) void *data)
5744 struct cmd_set_syn_filter_result *res = parsed_result;
5745 struct rte_syn_filter filter;
5747 if (!strcmp(res->filter, "add_syn_filter")) {
5748 if (!strcmp(res->high, "high"))
5752 ret = rte_eth_dev_add_syn_filter(res->port_id,
5753 &filter, res->queue_id);
5754 } else if (!strcmp(res->filter, "remove_syn_filter"))
5755 ret = rte_eth_dev_remove_syn_filter(res->port_id);
5756 else if (!strcmp(res->filter, "get_syn_filter"))
5757 get_syn_filter(res->port_id);
5759 printf("syn filter setting error: (%s)\n", strerror(-ret));
5762 cmdline_parse_token_string_t cmd_syn_filter_portid =
5763 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5765 cmdline_parse_token_string_t cmd_syn_filter_priority =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5767 priority, "priority");
5768 cmdline_parse_token_string_t cmd_syn_filter_high =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5771 cmdline_parse_token_string_t cmd_syn_filter_queue =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5774 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
5775 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5777 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5779 filter, "add_syn_filter");
5780 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5782 filter, "remove_syn_filter");
5783 cmdline_parse_inst_t cmd_add_syn_filter = {
5784 .f = cmd_set_syn_filter_parsed,
5786 .help_str = "add syn filter",
5788 (void *)&cmd_syn_filter_add_filter,
5789 (void *)&cmd_syn_filter_portid,
5790 (void *)&cmd_syn_filter_priority,
5791 (void *)&cmd_syn_filter_high,
5792 (void *)&cmd_syn_filter_queue,
5793 (void *)&cmd_syn_filter_queue_id,
5797 cmdline_parse_inst_t cmd_remove_syn_filter = {
5798 .f = cmd_set_syn_filter_parsed,
5800 .help_str = "remove syn filter",
5802 (void *)&cmd_syn_filter_remove_filter,
5803 (void *)&cmd_syn_filter_portid,
5808 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5810 filter, "get_syn_filter");
5812 cmdline_parse_inst_t cmd_get_syn_filter = {
5813 .f = cmd_set_syn_filter_parsed,
5815 .help_str = "get syn filter",
5817 (void *)&cmd_syn_filter_get_filter,
5818 (void *)&cmd_syn_filter_portid,
5823 /* *** ADD/REMOVE A 2tuple FILTER *** */
5824 struct cmd_2tuple_filter_result {
5825 cmdline_fixed_string_t filter;
5827 cmdline_fixed_string_t protocol;
5828 uint8_t protocol_value;
5829 uint8_t protocol_mask;
5830 cmdline_fixed_string_t dst_port;
5831 uint16_t dst_port_value;
5832 uint16_t dst_port_mask;
5833 cmdline_fixed_string_t flags;
5834 uint8_t flags_value;
5835 cmdline_fixed_string_t priority;
5836 uint8_t priority_value;
5837 cmdline_fixed_string_t queue;
5839 cmdline_fixed_string_t index;
5840 uint16_t index_value;
5844 cmd_2tuple_filter_parsed(void *parsed_result,
5845 __attribute__((unused)) struct cmdline *cl,
5846 __attribute__((unused)) void *data)
5849 struct rte_2tuple_filter filter;
5850 struct cmd_2tuple_filter_result *res = parsed_result;
5852 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
5854 if (!strcmp(res->filter, "add_2tuple_filter")) {
5855 /* need convert to big endian. */
5856 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
5857 filter.protocol = res->protocol_value;
5858 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
5859 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
5860 filter.priority = res->priority_value;
5861 filter.tcp_flags = res->flags_value;
5862 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
5863 res->index_value, &filter, res->queue_id);
5864 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
5865 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
5867 else if (!strcmp(res->filter, "get_2tuple_filter"))
5868 get_2tuple_filter(res->port_id, res->index_value);
5871 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
5874 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
5875 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5877 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
5878 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5879 protocol, "protocol");
5880 cmdline_parse_token_string_t cmd_2tuple_filter_protocol_value =
5881 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5882 protocol_value, UINT8);
5883 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
5884 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5885 protocol_mask, UINT8);
5886 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
5887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5888 dst_port, "dst_port");
5889 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
5890 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5891 dst_port_value, UINT16);
5892 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
5893 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5894 dst_port_mask, UINT16);
5895 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
5896 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5898 cmdline_parse_token_string_t cmd_2tuple_filter_flags_value =
5899 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5900 flags_value, UINT8);
5901 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
5902 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5903 priority, "priority");
5904 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
5905 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5906 priority_value, UINT8);
5907 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
5908 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5910 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
5911 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5913 cmdline_parse_token_string_t cmd_2tuple_filter_index =
5914 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5916 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
5917 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5918 index_value, UINT16);
5919 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
5920 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5921 filter, "add_2tuple_filter");
5922 cmdline_parse_inst_t cmd_add_2tuple_filter = {
5923 .f = cmd_2tuple_filter_parsed,
5925 .help_str = "add a 2tuple filter",
5927 (void *)&cmd_2tuple_filter_add_filter,
5928 (void *)&cmd_2tuple_filter_port_id,
5929 (void *)&cmd_2tuple_filter_protocol,
5930 (void *)&cmd_2tuple_filter_protocol_value,
5931 (void *)&cmd_2tuple_filter_protocol_mask,
5932 (void *)&cmd_2tuple_filter_dst_port,
5933 (void *)&cmd_2tuple_filter_dst_port_value,
5934 (void *)&cmd_2tuple_filter_dst_port_mask,
5935 (void *)&cmd_2tuple_filter_flags,
5936 (void *)&cmd_2tuple_filter_flags_value,
5937 (void *)&cmd_2tuple_filter_priority,
5938 (void *)&cmd_2tuple_filter_priority_value,
5939 (void *)&cmd_2tuple_filter_queue,
5940 (void *)&cmd_2tuple_filter_queue_id,
5941 (void *)&cmd_2tuple_filter_index,
5942 (void *)&cmd_2tuple_filter_index_value,
5947 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
5948 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5949 filter, "remove_2tuple_filter");
5950 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
5951 .f = cmd_2tuple_filter_parsed,
5953 .help_str = "remove a 2tuple filter",
5955 (void *)&cmd_2tuple_filter_remove_filter,
5956 (void *)&cmd_2tuple_filter_port_id,
5957 (void *)&cmd_2tuple_filter_index,
5958 (void *)&cmd_2tuple_filter_index_value,
5962 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
5963 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5964 filter, "get_2tuple_filter");
5965 cmdline_parse_inst_t cmd_get_2tuple_filter = {
5966 .f = cmd_2tuple_filter_parsed,
5968 .help_str = "get a 2tuple filter",
5970 (void *)&cmd_2tuple_filter_get_filter,
5971 (void *)&cmd_2tuple_filter_port_id,
5972 (void *)&cmd_2tuple_filter_index,
5973 (void *)&cmd_2tuple_filter_index_value,
5978 /* *** ADD/REMOVE A 5tuple FILTER *** */
5979 struct cmd_5tuple_filter_result {
5980 cmdline_fixed_string_t filter;
5982 cmdline_fixed_string_t dst_ip;
5983 cmdline_ipaddr_t dst_ip_value;
5984 cmdline_fixed_string_t src_ip;
5985 cmdline_ipaddr_t src_ip_value;
5986 cmdline_fixed_string_t dst_port;
5987 uint16_t dst_port_value;
5988 cmdline_fixed_string_t src_port;
5989 uint16_t src_port_value;
5990 cmdline_fixed_string_t protocol;
5991 uint8_t protocol_value;
5992 cmdline_fixed_string_t mask;
5994 cmdline_fixed_string_t flags;
5995 uint8_t flags_value;
5996 cmdline_fixed_string_t priority;
5997 uint8_t priority_value;
5998 cmdline_fixed_string_t queue;
6000 cmdline_fixed_string_t index;
6001 uint16_t index_value;
6005 cmd_5tuple_filter_parsed(void *parsed_result,
6006 __attribute__((unused)) struct cmdline *cl,
6007 __attribute__((unused)) void *data)
6010 struct rte_5tuple_filter filter;
6011 struct cmd_5tuple_filter_result *res = parsed_result;
6013 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6015 if (!strcmp(res->filter, "add_5tuple_filter")) {
6016 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6017 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6018 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6019 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6020 filter.protocol = res->protocol_value;
6021 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6022 filter.priority = res->priority_value;
6023 filter.tcp_flags = res->flags_value;
6025 if (res->dst_ip_value.family == AF_INET)
6026 /* no need to convert, already big endian. */
6027 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6029 if (filter.dst_ip_mask == 0) {
6030 printf("can not support ipv6 involved compare.\n");
6036 if (res->src_ip_value.family == AF_INET)
6037 /* no need to convert, already big endian. */
6038 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6040 if (filter.src_ip_mask == 0) {
6041 printf("can not support ipv6 involved compare.\n");
6046 /* need convert to big endian. */
6047 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6048 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6050 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6051 res->index_value, &filter, res->queue_id);
6052 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6053 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6055 else if (!strcmp(res->filter, "get_5tuple_filter"))
6056 get_5tuple_filter(res->port_id, res->index_value);
6058 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6062 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6063 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6065 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6068 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6069 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6071 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6074 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6075 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6077 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6078 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6079 dst_port, "dst_port");
6080 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6081 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6082 dst_port_value, UINT16);
6083 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6085 src_port, "src_port");
6086 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6087 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6088 src_port_value, UINT16);
6089 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6091 protocol, "protocol");
6092 cmdline_parse_token_string_t cmd_5tuple_filter_protocol_value =
6093 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6094 protocol_value, UINT8);
6095 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6098 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6101 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6104 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6106 flags_value, UINT8);
6107 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6109 priority, "priority");
6110 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6112 priority_value, UINT8);
6113 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6116 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6119 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6120 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6122 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
6123 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6124 index_value, UINT16);
6126 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
6127 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6128 filter, "add_5tuple_filter");
6129 cmdline_parse_inst_t cmd_add_5tuple_filter = {
6130 .f = cmd_5tuple_filter_parsed,
6132 .help_str = "add a 5tuple filter",
6134 (void *)&cmd_5tuple_filter_add_filter,
6135 (void *)&cmd_5tuple_filter_port_id,
6136 (void *)&cmd_5tuple_filter_dst_ip,
6137 (void *)&cmd_5tuple_filter_dst_ip_value,
6138 (void *)&cmd_5tuple_filter_src_ip,
6139 (void *)&cmd_5tuple_filter_src_ip_value,
6140 (void *)&cmd_5tuple_filter_dst_port,
6141 (void *)&cmd_5tuple_filter_dst_port_value,
6142 (void *)&cmd_5tuple_filter_src_port,
6143 (void *)&cmd_5tuple_filter_src_port_value,
6144 (void *)&cmd_5tuple_filter_protocol,
6145 (void *)&cmd_5tuple_filter_protocol_value,
6146 (void *)&cmd_5tuple_filter_mask,
6147 (void *)&cmd_5tuple_filter_mask_value,
6148 (void *)&cmd_5tuple_filter_flags,
6149 (void *)&cmd_5tuple_filter_flags_value,
6150 (void *)&cmd_5tuple_filter_priority,
6151 (void *)&cmd_5tuple_filter_priority_value,
6152 (void *)&cmd_5tuple_filter_queue,
6153 (void *)&cmd_5tuple_filter_queue_id,
6154 (void *)&cmd_5tuple_filter_index,
6155 (void *)&cmd_5tuple_filter_index_value,
6160 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
6161 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6162 filter, "remove_5tuple_filter");
6163 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
6164 .f = cmd_5tuple_filter_parsed,
6166 .help_str = "remove a 5tuple filter",
6168 (void *)&cmd_5tuple_filter_remove_filter,
6169 (void *)&cmd_5tuple_filter_port_id,
6170 (void *)&cmd_5tuple_filter_index,
6171 (void *)&cmd_5tuple_filter_index_value,
6176 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
6177 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6178 filter, "get_5tuple_filter");
6179 cmdline_parse_inst_t cmd_get_5tuple_filter = {
6180 .f = cmd_5tuple_filter_parsed,
6182 .help_str = "get a 5tuple filter",
6184 (void *)&cmd_5tuple_filter_get_filter,
6185 (void *)&cmd_5tuple_filter_port_id,
6186 (void *)&cmd_5tuple_filter_index,
6187 (void *)&cmd_5tuple_filter_index_value,
6192 /* *** ADD/REMOVE A flex FILTER *** */
6193 struct cmd_flex_filter_result {
6194 cmdline_fixed_string_t filter;
6196 cmdline_fixed_string_t len;
6198 cmdline_fixed_string_t bytes;
6199 cmdline_fixed_string_t bytes_value;
6200 cmdline_fixed_string_t mask;
6201 cmdline_fixed_string_t mask_value;
6202 cmdline_fixed_string_t priority;
6203 uint8_t priority_value;
6204 cmdline_fixed_string_t queue;
6206 cmdline_fixed_string_t index;
6207 uint16_t index_value;
6210 static int xdigit2val(unsigned char c)
6215 else if (isupper(c))
6223 cmd_flex_filter_parsed(void *parsed_result,
6224 __attribute__((unused)) struct cmdline *cl,
6225 __attribute__((unused)) void *data)
6228 struct rte_flex_filter filter;
6229 struct cmd_flex_filter_result *res = parsed_result;
6230 char *bytes_ptr, *mask_ptr;
6238 if (!strcmp(res->filter, "add_flex_filter")) {
6239 if (res->len_value > 128) {
6240 printf("the len exceed the max length 128\n");
6243 memset(&filter, 0, sizeof(struct rte_flex_filter));
6244 filter.len = res->len_value;
6245 filter.priority = res->priority_value;
6246 bytes_ptr = res->bytes_value;
6247 mask_ptr = res->mask_value;
6250 /* translate bytes string to uint_32 array. */
6251 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
6252 (bytes_ptr[1] == 'X')))
6254 len = strnlen(bytes_ptr, res->len_value * 2);
6255 if (len == 0 || (len % 8 != 0)) {
6256 printf("please check len and bytes input\n");
6259 for (i = 0; i < len; i++) {
6261 if (isxdigit(c) == 0) {
6262 /* invalid characters. */
6263 printf("invalid input\n");
6266 val = xdigit2val(c);
6270 dword |= byte << (4 * mod - 4);
6275 filter.dwords[j] = dword;
6276 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
6282 /* translate mask string to uint8_t array. */
6284 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
6285 (mask_ptr[1] == 'X')))
6287 len = strnlen(mask_ptr, (res->len_value+3)/4);
6289 printf("invalid input\n");
6292 for (i = 0; i < len; i++) {
6294 if (isxdigit(c) == 0) {
6295 /* invalid characters. */
6296 printf("invalid input\n");
6299 val = xdigit2val(c);
6300 hex |= (uint8_t)(val & 0x8) >> 3;
6301 hex |= (uint8_t)(val & 0x4) >> 1;
6302 hex |= (uint8_t)(val & 0x2) << 1;
6303 hex |= (uint8_t)(val & 0x1) << 3;
6306 filter.mask[j] = byte;
6307 printf("mask[%d]:%02x ", j, filter.mask[j]);
6315 printf("call function rte_eth_dev_add_flex_filter: "
6316 "index = %d, queue-id = %d, len = %d, priority = %d\n",
6317 res->index_value, res->queue_id,
6318 filter.len, filter.priority);
6319 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
6320 &filter, res->queue_id);
6322 } else if (!strcmp(res->filter, "remove_flex_filter"))
6323 ret = rte_eth_dev_remove_flex_filter(res->port_id,
6325 else if (!strcmp(res->filter, "get_flex_filter"))
6326 get_flex_filter(res->port_id, res->index_value);
6329 printf("flex filter setting error: (%s)\n", strerror(-ret));
6332 cmdline_parse_token_num_t cmd_flex_filter_port_id =
6333 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6335 cmdline_parse_token_string_t cmd_flex_filter_len =
6336 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6338 cmdline_parse_token_string_t cmd_flex_filter_len_value =
6339 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6341 cmdline_parse_token_string_t cmd_flex_filter_bytes =
6342 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6344 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
6345 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6347 cmdline_parse_token_string_t cmd_flex_filter_mask =
6348 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6350 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
6351 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6353 cmdline_parse_token_string_t cmd_flex_filter_priority =
6354 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6355 priority, "priority");
6356 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
6357 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6358 priority_value, UINT8);
6359 cmdline_parse_token_string_t cmd_flex_filter_queue =
6360 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6362 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
6363 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6365 cmdline_parse_token_string_t cmd_flex_filter_index =
6366 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6368 cmdline_parse_token_num_t cmd_flex_filter_index_value =
6369 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6370 index_value, UINT16);
6371 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
6372 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6373 filter, "add_flex_filter");
6374 cmdline_parse_inst_t cmd_add_flex_filter = {
6375 .f = cmd_flex_filter_parsed,
6377 .help_str = "add a flex filter",
6379 (void *)&cmd_flex_filter_add_filter,
6380 (void *)&cmd_flex_filter_port_id,
6381 (void *)&cmd_flex_filter_len,
6382 (void *)&cmd_flex_filter_len_value,
6383 (void *)&cmd_flex_filter_bytes,
6384 (void *)&cmd_flex_filter_bytes_value,
6385 (void *)&cmd_flex_filter_mask,
6386 (void *)&cmd_flex_filter_mask_value,
6387 (void *)&cmd_flex_filter_priority,
6388 (void *)&cmd_flex_filter_priority_value,
6389 (void *)&cmd_flex_filter_queue,
6390 (void *)&cmd_flex_filter_queue_id,
6391 (void *)&cmd_flex_filter_index,
6392 (void *)&cmd_flex_filter_index_value,
6397 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
6398 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6399 filter, "remove_flex_filter");
6400 cmdline_parse_inst_t cmd_remove_flex_filter = {
6401 .f = cmd_flex_filter_parsed,
6403 .help_str = "remove a flex filter",
6405 (void *)&cmd_flex_filter_remove_filter,
6406 (void *)&cmd_flex_filter_port_id,
6407 (void *)&cmd_flex_filter_index,
6408 (void *)&cmd_flex_filter_index_value,
6413 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
6414 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6415 filter, "get_flex_filter");
6416 cmdline_parse_inst_t cmd_get_flex_filter = {
6417 .f = cmd_flex_filter_parsed,
6419 .help_str = "get a flex filter",
6421 (void *)&cmd_flex_filter_get_filter,
6422 (void *)&cmd_flex_filter_port_id,
6423 (void *)&cmd_flex_filter_index,
6424 (void *)&cmd_flex_filter_index_value,
6429 /* ******************************************************************************** */
6431 /* list of instructions */
6432 cmdline_parse_ctx_t main_ctx[] = {
6433 (cmdline_parse_inst_t *)&cmd_help_brief,
6434 (cmdline_parse_inst_t *)&cmd_help_long,
6435 (cmdline_parse_inst_t *)&cmd_quit,
6436 (cmdline_parse_inst_t *)&cmd_showport,
6437 (cmdline_parse_inst_t *)&cmd_showportall,
6438 (cmdline_parse_inst_t *)&cmd_showcfg,
6439 (cmdline_parse_inst_t *)&cmd_start,
6440 (cmdline_parse_inst_t *)&cmd_start_tx_first,
6441 (cmdline_parse_inst_t *)&cmd_set_link_up,
6442 (cmdline_parse_inst_t *)&cmd_set_link_down,
6443 (cmdline_parse_inst_t *)&cmd_reset,
6444 (cmdline_parse_inst_t *)&cmd_set_numbers,
6445 (cmdline_parse_inst_t *)&cmd_set_txpkts,
6446 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
6447 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
6448 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
6449 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
6450 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
6451 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
6452 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
6453 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
6454 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
6455 (cmdline_parse_inst_t *)&cmd_set_link_check,
6456 #ifdef RTE_NIC_BYPASS
6457 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
6458 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
6459 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
6460 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
6462 (cmdline_parse_inst_t *)&cmd_vlan_offload,
6463 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
6464 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
6465 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
6466 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
6467 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
6468 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
6469 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
6470 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
6471 (cmdline_parse_inst_t *)&cmd_config_dcb,
6472 (cmdline_parse_inst_t *)&cmd_read_reg,
6473 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
6474 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
6475 (cmdline_parse_inst_t *)&cmd_write_reg,
6476 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
6477 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
6478 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
6479 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
6480 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
6481 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
6482 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
6483 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
6484 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
6485 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
6486 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
6487 (cmdline_parse_inst_t *)&cmd_stop,
6488 (cmdline_parse_inst_t *)&cmd_mac_addr,
6489 (cmdline_parse_inst_t *)&cmd_set_qmap,
6490 (cmdline_parse_inst_t *)&cmd_operate_port,
6491 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
6492 (cmdline_parse_inst_t *)&cmd_config_speed_all,
6493 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
6494 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
6495 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
6496 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
6497 (cmdline_parse_inst_t *)&cmd_config_rss,
6498 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
6499 (cmdline_parse_inst_t *)&cmd_showport_reta,
6500 (cmdline_parse_inst_t *)&cmd_config_burst,
6501 (cmdline_parse_inst_t *)&cmd_config_thresh,
6502 (cmdline_parse_inst_t *)&cmd_config_threshold,
6503 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
6504 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
6505 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
6506 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
6507 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
6508 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
6509 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
6510 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
6511 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
6512 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
6513 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
6514 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
6515 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
6516 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
6517 (cmdline_parse_inst_t *)&cmd_dump,
6518 (cmdline_parse_inst_t *)&cmd_dump_one,
6519 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
6520 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
6521 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
6522 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
6523 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
6524 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
6525 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
6526 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
6527 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
6528 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
6529 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
6530 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
6531 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
6532 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
6533 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
6537 /* prompt function, called from main on MASTER lcore */
6543 /* initialize non-constant commands */
6544 cmd_set_fwd_mode_init();
6546 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
6550 cmdline_interact(cl);
6551 cmdline_stdin_exit(cl);
6555 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
6557 if (id < nb_ports) {
6558 /* check if need_reconfig has been set to 1 */
6559 if (ports[id].need_reconfig == 0)
6560 ports[id].need_reconfig = dev;
6561 /* check if need_reconfig_queues has been set to 1 */
6562 if (ports[id].need_reconfig_queues == 0)
6563 ports[id].need_reconfig_queues = queue;
6567 for (pid = 0; pid < nb_ports; pid++) {
6568 /* check if need_reconfig has been set to 1 */
6569 if (ports[pid].need_reconfig == 0)
6570 ports[pid].need_reconfig = dev;
6571 /* check if need_reconfig_queues has been set to 1 */
6572 if (ports[pid].need_reconfig_queues == 0)
6573 ports[pid].need_reconfig_queues = queue;
6578 #ifdef RTE_NIC_BYPASS
6580 bypass_is_supported(portid_t port_id)
6582 struct rte_port *port;
6583 struct rte_pci_id *pci_id;
6585 if (port_id >= nb_ports) {
6586 printf("\tPort id must be less than %d.\n", nb_ports);
6590 /* Get the device id. */
6591 port = &ports[port_id];
6592 pci_id = &port->dev_info.pci_dev->id;
6594 /* Check if NIC supports bypass. */
6595 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
6599 printf("\tBypass not supported for port_id = %d.\n", port_id);