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 set pvid port_id vlan_id (on|off)\n"
290 " Set port based TX VLAN insertion.\n\n"
292 "tx_vlan reset (port_id)\n"
293 " Disable hardware insertion of a VLAN header in"
294 " packets sent on a port.\n\n"
296 "tx_checksum set mask (port_id)\n"
297 " Enable hardware insertion of checksum offload with"
298 " the 4-bit mask, 0~0xf, in packets sent on a port.\n"
299 " bit 0 - insert ip checksum offload if set\n"
300 " bit 1 - insert udp checksum offload if set\n"
301 " bit 2 - insert tcp checksum offload if set\n"
302 " bit 3 - insert sctp checksum offload if set\n"
303 " Please check the NIC datasheet for HW limits.\n\n"
306 " Set packet forwarding mode.\n\n"
308 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
309 " Add a MAC address on port_id.\n\n"
311 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
312 " Remove a MAC address from port_id.\n\n"
314 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
315 " Add a MAC address for a VF on the port.\n\n"
317 "set port (port_id) uta (mac_address|all) (on|off)\n"
318 " Add/Remove a or all unicast hash filter(s)"
321 "set promisc (port_id|all) (on|off)\n"
322 " Set the promiscuous mode on port_id, or all.\n\n"
324 "set allmulti (port_id|all) (on|off)\n"
325 " Set the allmulti mode on port_id, or all.\n\n"
327 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
328 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
329 " (on|off) (port_id)\n"
330 " Set the link flow control parameter on a port.\n\n"
332 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
333 " (low_water) (pause_time) (priority) (port_id)\n"
334 " Set the priority flow control parameter on a"
337 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
338 " Set statistics mapping (qmapping 0..15) for RX/TX"
340 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
341 " on port 0 to mapping 5.\n\n"
343 "set port (port_id) vf (vf_id) rx|tx on|off \n"
344 " Enable/Disable a VF receive/tranmit from a port\n\n"
346 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
348 " AUPE:accepts untagged VLAN;"
349 "ROPE:accept unicast hash\n\n"
350 " BAM:accepts broadcast packets;"
351 "MPE:accepts all multicast packets\n\n"
352 " Enable/Disable a VF receive mode of a port\n\n"
354 "set port (port_id) queue (queue_id) rate (rate_num)\n"
355 " Set rate limit for a queue of a port\n\n"
357 "set port (port_id) vf (vf_id) rate (rate_num) "
358 "queue_mask (queue_mask_value)\n"
359 " Set rate limit for queues in VF of a port\n\n"
361 "set port (port_id) mirror-rule (rule_id)"
362 "(pool-mirror|vlan-mirror)\n"
363 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
364 " Set pool or vlan type mirror rule on a port.\n"
365 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
366 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
369 "set port (port_id) mirror-rule (rule_id)"
370 " (uplink-mirror|downlink-mirror) dst-pool"
371 " (pool_id) (on|off)\n"
372 " Set uplink or downlink type mirror rule on a port.\n"
373 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
374 " 0 on' enable mirror income traffic to pool 0.\n\n"
376 "reset port (port_id) mirror-rule (rule_id)\n"
377 " Reset a mirror rule.\n\n"
379 "set flush_rx (on|off)\n"
380 " Flush (default) or don't flush RX streams before"
381 " forwarding. Mainly used with PCAP drivers.\n\n"
383 #ifdef RTE_NIC_BYPASS
384 "set bypass mode (normal|bypass|isolate) (port_id)\n"
385 " Set the bypass mode for the lowest port on bypass enabled"
388 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
389 "mode (normal|bypass|isolate) (port_id)\n"
390 " Set the event required to initiate specified bypass mode for"
391 " the lowest port on a bypass enabled NIC where:\n"
392 " timeout = enable bypass after watchdog timeout.\n"
393 " os_on = enable bypass when OS/board is powered on.\n"
394 " os_off = enable bypass when OS/board is powered off.\n"
395 " power_on = enable bypass when power supply is turned on.\n"
396 " power_off = enable bypass when power supply is turned off."
399 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
400 " Set the bypass watchdog timeout to 'n' seconds"
401 " where 0 = instant.\n\n"
403 "show bypass config (port_id)\n"
404 " Show the bypass configuration for a bypass enabled NIC"
405 " using the lowest port on the NIC.\n\n"
408 , list_pkt_forwarding_modes()
413 if (show_all || !strcmp(res->section, "flowdir")) {
418 "Flow director mode:\n"
419 "-------------------\n\n"
421 "add_signature_filter (port_id) (ip|udp|tcp|sctp)"
422 " src (src_ip_address) (src_port)"
423 " dst (dst_ip_address) (dst_port)"
424 " flexbytes (flexbytes_values) vlan (vlan_id)"
425 " queue (queue_id)\n"
426 " Add a signature filter.\n\n"
428 "upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
429 " src (src_ip_address) (src_port)"
430 " dst (dst_ip_address) (dst_port)"
431 " flexbytes (flexbytes_values) vlan (vlan_id)"
432 " queue (queue_id)\n"
433 " Update a signature filter.\n\n"
435 "rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
436 " src (src_ip_address) (src_port)"
437 " dst (dst_ip_address) (dst_port)"
438 " flexbytes (flexbytes_values) vlan (vlan_id)\n"
439 " Remove a signature filter.\n\n"
441 "add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
442 " src (src_ip_address) (src_port)"
443 " dst (dst_ip_address) (dst_port)"
444 " flexbytes (flexbytes_values) vlan (vlan_id)"
445 " queue (queue_id) soft (soft_id)\n"
446 " Add a perfect filter.\n\n"
448 "upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
449 " src (src_ip_address) (src_port)"
450 " dst (dst_ip_address) (dst_port)"
451 " flexbytes (flexbytes_values) vlan (vlan_id)"
452 " queue (queue_id)\n"
453 " Update a perfect filter.\n\n"
455 "rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
456 " src (src_ip_address) (src_port)"
457 " dst (dst_ip_address) (dst_port)"
458 " flexbytes (flexbytes_values) vlan (vlan_id)"
460 " Remove a perfect filter.\n\n"
462 "set_masks_filter (port_id) only_ip_flow (0|1)"
463 " src_mask (ip_src_mask) (src_port_mask)"
464 " dst_mask (ip_dst_mask) (dst_port_mask)"
465 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
466 " Set IPv4 filter masks.\n\n"
468 "set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
469 " src_mask (ip_src_mask) (src_port_mask)"
470 " dst_mask (ip_dst_mask) (dst_port_mask)"
471 " flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
472 " compare_dst (0|1)\n"
473 " Set IPv6 filter masks.\n\n"
477 if (show_all || !strcmp(res->section, "ports")) {
483 "----------------\n\n"
485 "port start (port_id|all)\n"
486 " Start all ports or port_id.\n\n"
488 "port stop (port_id|all)\n"
489 " Stop all ports or port_id.\n\n"
491 "port close (port_id|all)\n"
492 " Close all ports or port_id.\n\n"
494 "port config (port_id|all) speed (10|100|1000|10000|auto)"
495 " duplex (half|full|auto)\n"
496 " Set speed and duplex for all ports or port_id\n\n"
498 "port config all (rxq|txq|rxd|txd) (value)\n"
499 " Set number for rxq/txq/rxd/txd.\n\n"
501 "port config all max-pkt-len (value)\n"
502 " Set the max packet length.\n\n"
504 "port config all (crc-strip|rx-cksum|hw-vlan|drop-en)"
506 " Set crc-strip/rx-checksum/hardware-vlan/drop_en"
509 "port config all rss (ip|udp|none)\n"
510 " Set the RSS mode.\n\n"
512 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
513 " Set the RSS redirection table.\n\n"
515 "port config (port_id) dcb vt (on|off) (traffic_class)"
517 " Set the DCB mode.\n\n"
519 "port config all burst (value)\n"
520 " Set the number of packets per burst.\n\n"
522 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
524 " Set the ring prefetch/host/writeback threshold"
525 " for tx/rx queue.\n\n"
527 "port config all (txfreet|txrst|rxfreet) (value)\n"
528 " Set free threshold for rx/tx, or set"
529 " tx rs bit threshold.\n\n"
530 "port config mtu X value\n"
531 " Set the MTU of port X to a given value\n\n"
535 if (show_all || !strcmp(res->section, "registers")) {
543 "read reg (port_id) (address)\n"
544 " Display value of a port register.\n\n"
546 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
547 " Display a port register bit field.\n\n"
549 "read regbit (port_id) (address) (bit_x)\n"
550 " Display a single port register bit.\n\n"
552 "write reg (port_id) (address) (value)\n"
553 " Set value of a port register.\n\n"
555 "write regfield (port_id) (address) (bit_x) (bit_y)"
557 " Set bit field of a port register.\n\n"
559 "write regbit (port_id) (address) (bit_x) (value)\n"
560 " Set single bit value of a port register.\n\n"
563 if (show_all || !strcmp(res->section, "filters")) {
571 "add_ethertype_filter (port_id) ethertype (eth_value)"
572 " priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
573 " add an ethertype filter.\n\n"
575 "remove_ethertype_filter (port_id) index (idx)\n"
576 " remove an ethertype filter.\n\n"
578 "get_ethertype_filter (port_id) index (idx)\n"
579 " get info of a ethertype filter.\n\n"
581 "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
582 " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
583 " queue (queue_id) index (idx)\n"
584 " add a 2tuple filter.\n\n"
586 "remove_2tuple_filter (port_id) index (idx)\n"
587 " remove a 2tuple filter.\n\n"
589 "get_2tuple_filter (port_id) index (idx)\n"
590 " get info of a 2tuple filter.\n\n"
592 "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)"
593 " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)"
594 " mask (mask_value) flags (flags_value) priority (prio_value)"
595 " queue (queue_id) index (idx)\n"
596 " add a 5tuple filter.\n\n"
598 "remove_5tuple_filter (port_id) index (idx)\n"
599 " remove a 5tuple filter.\n\n"
601 "get_5tuple_filter (port_id) index (idx)\n"
602 " get info of a 5tuple filter.\n\n"
604 "add_syn_filter (port_id) priority (high|low) queue (queue_id)"
605 " add syn filter.\n\n"
607 "remove_syn_filter (port_id)"
608 " remove syn filter.\n\n"
610 "get_syn_filter (port_id) "
611 " get syn filter info.\n\n"
613 "add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
614 " priority (prio_value) queue (queue_id) index (idx)\n"
615 " add a flex filter.\n\n"
617 "remove_flex_filter (port_id) index (idx)\n"
618 " remove a flex filter.\n\n"
620 "get_flex_filter (port_id) index (idx)\n"
621 " get info of a flex filter.\n\n"
626 cmdline_parse_token_string_t cmd_help_long_help =
627 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
629 cmdline_parse_token_string_t cmd_help_long_section =
630 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
631 "all#control#display#config#flowdir#"
632 "ports#registers#filters");
634 cmdline_parse_inst_t cmd_help_long = {
635 .f = cmd_help_long_parsed,
637 .help_str = "show help",
639 (void *)&cmd_help_long_help,
640 (void *)&cmd_help_long_section,
646 /* *** start/stop/close all ports *** */
647 struct cmd_operate_port_result {
648 cmdline_fixed_string_t keyword;
649 cmdline_fixed_string_t name;
650 cmdline_fixed_string_t value;
653 static void cmd_operate_port_parsed(void *parsed_result,
654 __attribute__((unused)) struct cmdline *cl,
655 __attribute__((unused)) void *data)
657 struct cmd_operate_port_result *res = parsed_result;
659 if (!strcmp(res->name, "start"))
660 start_port(RTE_PORT_ALL);
661 else if (!strcmp(res->name, "stop"))
662 stop_port(RTE_PORT_ALL);
663 else if (!strcmp(res->name, "close"))
664 close_port(RTE_PORT_ALL);
666 printf("Unknown parameter\n");
669 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
670 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
672 cmdline_parse_token_string_t cmd_operate_port_all_port =
673 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
675 cmdline_parse_token_string_t cmd_operate_port_all_all =
676 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
678 cmdline_parse_inst_t cmd_operate_port = {
679 .f = cmd_operate_port_parsed,
681 .help_str = "port start|stop|close all: start/stop/close all ports",
683 (void *)&cmd_operate_port_all_cmd,
684 (void *)&cmd_operate_port_all_port,
685 (void *)&cmd_operate_port_all_all,
690 /* *** start/stop/close specific port *** */
691 struct cmd_operate_specific_port_result {
692 cmdline_fixed_string_t keyword;
693 cmdline_fixed_string_t name;
697 static void cmd_operate_specific_port_parsed(void *parsed_result,
698 __attribute__((unused)) struct cmdline *cl,
699 __attribute__((unused)) void *data)
701 struct cmd_operate_specific_port_result *res = parsed_result;
703 if (!strcmp(res->name, "start"))
704 start_port(res->value);
705 else if (!strcmp(res->name, "stop"))
706 stop_port(res->value);
707 else if (!strcmp(res->name, "close"))
708 close_port(res->value);
710 printf("Unknown parameter\n");
713 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
714 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
716 cmdline_parse_token_string_t cmd_operate_specific_port_port =
717 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
718 name, "start#stop#close");
719 cmdline_parse_token_num_t cmd_operate_specific_port_id =
720 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
723 cmdline_parse_inst_t cmd_operate_specific_port = {
724 .f = cmd_operate_specific_port_parsed,
726 .help_str = "port start|stop|close X: start/stop/close port X",
728 (void *)&cmd_operate_specific_port_cmd,
729 (void *)&cmd_operate_specific_port_port,
730 (void *)&cmd_operate_specific_port_id,
735 /* *** configure speed for all ports *** */
736 struct cmd_config_speed_all {
737 cmdline_fixed_string_t port;
738 cmdline_fixed_string_t keyword;
739 cmdline_fixed_string_t all;
740 cmdline_fixed_string_t item1;
741 cmdline_fixed_string_t item2;
742 cmdline_fixed_string_t value1;
743 cmdline_fixed_string_t value2;
747 cmd_config_speed_all_parsed(void *parsed_result,
748 __attribute__((unused)) struct cmdline *cl,
749 __attribute__((unused)) void *data)
751 struct cmd_config_speed_all *res = parsed_result;
752 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
753 uint16_t link_duplex = 0;
756 if (!all_ports_stopped()) {
757 printf("Please stop all ports first\n");
761 if (!strcmp(res->value1, "10"))
762 link_speed = ETH_LINK_SPEED_10;
763 else if (!strcmp(res->value1, "100"))
764 link_speed = ETH_LINK_SPEED_100;
765 else if (!strcmp(res->value1, "1000"))
766 link_speed = ETH_LINK_SPEED_1000;
767 else if (!strcmp(res->value1, "10000"))
768 link_speed = ETH_LINK_SPEED_10000;
769 else if (!strcmp(res->value1, "auto"))
770 link_speed = ETH_LINK_SPEED_AUTONEG;
772 printf("Unknown parameter\n");
776 if (!strcmp(res->value2, "half"))
777 link_duplex = ETH_LINK_HALF_DUPLEX;
778 else if (!strcmp(res->value2, "full"))
779 link_duplex = ETH_LINK_FULL_DUPLEX;
780 else if (!strcmp(res->value2, "auto"))
781 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
783 printf("Unknown parameter\n");
787 for (pid = 0; pid < nb_ports; pid++) {
788 ports[pid].dev_conf.link_speed = link_speed;
789 ports[pid].dev_conf.link_duplex = link_duplex;
792 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
795 cmdline_parse_token_string_t cmd_config_speed_all_port =
796 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
797 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
798 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
800 cmdline_parse_token_string_t cmd_config_speed_all_all =
801 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
802 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
803 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
804 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
805 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
806 "10#100#1000#10000#auto");
807 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
808 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
809 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
810 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
813 cmdline_parse_inst_t cmd_config_speed_all = {
814 .f = cmd_config_speed_all_parsed,
816 .help_str = "port config all speed 10|100|1000|10000|auto duplex "
819 (void *)&cmd_config_speed_all_port,
820 (void *)&cmd_config_speed_all_keyword,
821 (void *)&cmd_config_speed_all_all,
822 (void *)&cmd_config_speed_all_item1,
823 (void *)&cmd_config_speed_all_value1,
824 (void *)&cmd_config_speed_all_item2,
825 (void *)&cmd_config_speed_all_value2,
830 /* *** configure speed for specific port *** */
831 struct cmd_config_speed_specific {
832 cmdline_fixed_string_t port;
833 cmdline_fixed_string_t keyword;
835 cmdline_fixed_string_t item1;
836 cmdline_fixed_string_t item2;
837 cmdline_fixed_string_t value1;
838 cmdline_fixed_string_t value2;
842 cmd_config_speed_specific_parsed(void *parsed_result,
843 __attribute__((unused)) struct cmdline *cl,
844 __attribute__((unused)) void *data)
846 struct cmd_config_speed_specific *res = parsed_result;
847 uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
848 uint16_t link_duplex = 0;
850 if (!all_ports_stopped()) {
851 printf("Please stop all ports first\n");
855 if (res->id >= nb_ports) {
856 printf("Port id %d must be less than %d\n", res->id, nb_ports);
860 if (!strcmp(res->value1, "10"))
861 link_speed = ETH_LINK_SPEED_10;
862 else if (!strcmp(res->value1, "100"))
863 link_speed = ETH_LINK_SPEED_100;
864 else if (!strcmp(res->value1, "1000"))
865 link_speed = ETH_LINK_SPEED_1000;
866 else if (!strcmp(res->value1, "10000"))
867 link_speed = ETH_LINK_SPEED_10000;
868 else if (!strcmp(res->value1, "auto"))
869 link_speed = ETH_LINK_SPEED_AUTONEG;
871 printf("Unknown parameter\n");
875 if (!strcmp(res->value2, "half"))
876 link_duplex = ETH_LINK_HALF_DUPLEX;
877 else if (!strcmp(res->value2, "full"))
878 link_duplex = ETH_LINK_FULL_DUPLEX;
879 else if (!strcmp(res->value2, "auto"))
880 link_duplex = ETH_LINK_AUTONEG_DUPLEX;
882 printf("Unknown parameter\n");
886 ports[res->id].dev_conf.link_speed = link_speed;
887 ports[res->id].dev_conf.link_duplex = link_duplex;
889 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
893 cmdline_parse_token_string_t cmd_config_speed_specific_port =
894 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
896 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
897 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
899 cmdline_parse_token_num_t cmd_config_speed_specific_id =
900 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
901 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
902 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
904 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
905 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
906 "10#100#1000#10000#auto");
907 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
908 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
910 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
911 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
914 cmdline_parse_inst_t cmd_config_speed_specific = {
915 .f = cmd_config_speed_specific_parsed,
917 .help_str = "port config X speed 10|100|1000|10000|auto duplex "
920 (void *)&cmd_config_speed_specific_port,
921 (void *)&cmd_config_speed_specific_keyword,
922 (void *)&cmd_config_speed_specific_id,
923 (void *)&cmd_config_speed_specific_item1,
924 (void *)&cmd_config_speed_specific_value1,
925 (void *)&cmd_config_speed_specific_item2,
926 (void *)&cmd_config_speed_specific_value2,
931 /* *** configure txq/rxq, txd/rxd *** */
932 struct cmd_config_rx_tx {
933 cmdline_fixed_string_t port;
934 cmdline_fixed_string_t keyword;
935 cmdline_fixed_string_t all;
936 cmdline_fixed_string_t name;
941 cmd_config_rx_tx_parsed(void *parsed_result,
942 __attribute__((unused)) struct cmdline *cl,
943 __attribute__((unused)) void *data)
945 struct cmd_config_rx_tx *res = parsed_result;
947 if (!all_ports_stopped()) {
948 printf("Please stop all ports first\n");
952 if (!strcmp(res->name, "rxq")) {
953 if (res->value <= 0) {
954 printf("rxq %d invalid - must be > 0\n", res->value);
959 else if (!strcmp(res->name, "txq")) {
960 if (res->value <= 0) {
961 printf("txq %d invalid - must be > 0\n", res->value);
966 else if (!strcmp(res->name, "rxd")) {
967 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
968 printf("rxd %d invalid - must be > 0 && <= %d\n",
969 res->value, RTE_TEST_RX_DESC_MAX);
973 } else if (!strcmp(res->name, "txd")) {
974 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
975 printf("txd %d invalid - must be > 0 && <= %d\n",
976 res->value, RTE_TEST_TX_DESC_MAX);
981 printf("Unknown parameter\n");
987 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
990 cmdline_parse_token_string_t cmd_config_rx_tx_port =
991 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
992 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
993 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
994 cmdline_parse_token_string_t cmd_config_rx_tx_all =
995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
996 cmdline_parse_token_string_t cmd_config_rx_tx_name =
997 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
999 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1000 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1002 cmdline_parse_inst_t cmd_config_rx_tx = {
1003 .f = cmd_config_rx_tx_parsed,
1005 .help_str = "port config all rxq|txq|rxd|txd value",
1007 (void *)&cmd_config_rx_tx_port,
1008 (void *)&cmd_config_rx_tx_keyword,
1009 (void *)&cmd_config_rx_tx_all,
1010 (void *)&cmd_config_rx_tx_name,
1011 (void *)&cmd_config_rx_tx_value,
1016 /* *** config max packet length *** */
1017 struct cmd_config_max_pkt_len_result {
1018 cmdline_fixed_string_t port;
1019 cmdline_fixed_string_t keyword;
1020 cmdline_fixed_string_t all;
1021 cmdline_fixed_string_t name;
1026 cmd_config_max_pkt_len_parsed(void *parsed_result,
1027 __attribute__((unused)) struct cmdline *cl,
1028 __attribute__((unused)) void *data)
1030 struct cmd_config_max_pkt_len_result *res = parsed_result;
1032 if (!all_ports_stopped()) {
1033 printf("Please stop all ports first\n");
1037 if (!strcmp(res->name, "max-pkt-len")) {
1038 if (res->value < ETHER_MIN_LEN) {
1039 printf("max-pkt-len can not be less than %d\n",
1043 if (res->value == rx_mode.max_rx_pkt_len)
1046 rx_mode.max_rx_pkt_len = res->value;
1047 if (res->value > ETHER_MAX_LEN)
1048 rx_mode.jumbo_frame = 1;
1050 rx_mode.jumbo_frame = 0;
1052 printf("Unknown parameter\n");
1058 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1061 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1062 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1064 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1065 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1067 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1068 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1070 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1071 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1073 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1074 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1077 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1078 .f = cmd_config_max_pkt_len_parsed,
1080 .help_str = "port config all max-pkt-len value",
1082 (void *)&cmd_config_max_pkt_len_port,
1083 (void *)&cmd_config_max_pkt_len_keyword,
1084 (void *)&cmd_config_max_pkt_len_all,
1085 (void *)&cmd_config_max_pkt_len_name,
1086 (void *)&cmd_config_max_pkt_len_value,
1091 /* *** configure port MTU *** */
1092 struct cmd_config_mtu_result {
1093 cmdline_fixed_string_t port;
1094 cmdline_fixed_string_t keyword;
1095 cmdline_fixed_string_t mtu;
1101 cmd_config_mtu_parsed(void *parsed_result,
1102 __attribute__((unused)) struct cmdline *cl,
1103 __attribute__((unused)) void *data)
1105 struct cmd_config_mtu_result *res = parsed_result;
1107 if (res->value < ETHER_MIN_LEN) {
1108 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1111 port_mtu_set(res->port_id, res->value);
1114 cmdline_parse_token_string_t cmd_config_mtu_port =
1115 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1117 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1118 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1120 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1121 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1123 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1124 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
1125 cmdline_parse_token_num_t cmd_config_mtu_value =
1126 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1128 cmdline_parse_inst_t cmd_config_mtu = {
1129 .f = cmd_config_mtu_parsed,
1131 .help_str = "port config mtu value",
1133 (void *)&cmd_config_mtu_port,
1134 (void *)&cmd_config_mtu_keyword,
1135 (void *)&cmd_config_mtu_mtu,
1136 (void *)&cmd_config_mtu_port_id,
1137 (void *)&cmd_config_mtu_value,
1142 /* *** configure rx mode *** */
1143 struct cmd_config_rx_mode_flag {
1144 cmdline_fixed_string_t port;
1145 cmdline_fixed_string_t keyword;
1146 cmdline_fixed_string_t all;
1147 cmdline_fixed_string_t name;
1148 cmdline_fixed_string_t value;
1152 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1153 __attribute__((unused)) struct cmdline *cl,
1154 __attribute__((unused)) void *data)
1156 struct cmd_config_rx_mode_flag *res = parsed_result;
1158 if (!all_ports_stopped()) {
1159 printf("Please stop all ports first\n");
1163 if (!strcmp(res->name, "crc-strip")) {
1164 if (!strcmp(res->value, "on"))
1165 rx_mode.hw_strip_crc = 1;
1166 else if (!strcmp(res->value, "off"))
1167 rx_mode.hw_strip_crc = 0;
1169 printf("Unknown parameter\n");
1172 } else if (!strcmp(res->name, "rx-cksum")) {
1173 if (!strcmp(res->value, "on"))
1174 rx_mode.hw_ip_checksum = 1;
1175 else if (!strcmp(res->value, "off"))
1176 rx_mode.hw_ip_checksum = 0;
1178 printf("Unknown parameter\n");
1181 } else if (!strcmp(res->name, "hw-vlan")) {
1182 if (!strcmp(res->value, "on")) {
1183 rx_mode.hw_vlan_filter = 1;
1184 rx_mode.hw_vlan_strip = 1;
1186 else if (!strcmp(res->value, "off")) {
1187 rx_mode.hw_vlan_filter = 0;
1188 rx_mode.hw_vlan_strip = 0;
1191 printf("Unknown parameter\n");
1194 } else if (!strcmp(res->name, "drop-en")) {
1195 if (!strcmp(res->value, "on"))
1197 else if (!strcmp(res->value, "off"))
1200 printf("Unknown parameter\n");
1204 printf("Unknown parameter\n");
1210 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1213 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1215 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1216 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1218 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1219 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1220 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1221 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1222 "crc-strip#rx-cksum#hw-vlan");
1223 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1224 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1227 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1228 .f = cmd_config_rx_mode_flag_parsed,
1230 .help_str = "port config all crc-strip|rx-cksum|hw-vlan on|off",
1232 (void *)&cmd_config_rx_mode_flag_port,
1233 (void *)&cmd_config_rx_mode_flag_keyword,
1234 (void *)&cmd_config_rx_mode_flag_all,
1235 (void *)&cmd_config_rx_mode_flag_name,
1236 (void *)&cmd_config_rx_mode_flag_value,
1241 /* *** configure rss *** */
1242 struct cmd_config_rss {
1243 cmdline_fixed_string_t port;
1244 cmdline_fixed_string_t keyword;
1245 cmdline_fixed_string_t all;
1246 cmdline_fixed_string_t name;
1247 cmdline_fixed_string_t value;
1251 cmd_config_rss_parsed(void *parsed_result,
1252 __attribute__((unused)) struct cmdline *cl,
1253 __attribute__((unused)) void *data)
1255 struct cmd_config_rss *res = parsed_result;
1256 struct rte_eth_rss_conf rss_conf;
1259 if (!strcmp(res->value, "ip"))
1260 rss_conf.rss_hf = ETH_RSS_IP;
1261 else if (!strcmp(res->value, "udp"))
1262 rss_conf.rss_hf = ETH_RSS_UDP;
1263 else if (!strcmp(res->value, "none"))
1264 rss_conf.rss_hf = 0;
1266 printf("Unknown parameter\n");
1269 rss_conf.rss_key = NULL;
1270 for (i = 0; i < rte_eth_dev_count(); i++)
1271 rte_eth_dev_rss_hash_update(i, &rss_conf);
1274 cmdline_parse_token_string_t cmd_config_rss_port =
1275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1276 cmdline_parse_token_string_t cmd_config_rss_keyword =
1277 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1278 cmdline_parse_token_string_t cmd_config_rss_all =
1279 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1280 cmdline_parse_token_string_t cmd_config_rss_name =
1281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1282 cmdline_parse_token_string_t cmd_config_rss_value =
1283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, "ip#udp#none");
1285 cmdline_parse_inst_t cmd_config_rss = {
1286 .f = cmd_config_rss_parsed,
1288 .help_str = "port config all rss ip|udp|none",
1290 (void *)&cmd_config_rss_port,
1291 (void *)&cmd_config_rss_keyword,
1292 (void *)&cmd_config_rss_all,
1293 (void *)&cmd_config_rss_name,
1294 (void *)&cmd_config_rss_value,
1299 /* *** configure rss hash key *** */
1300 struct cmd_config_rss_hash_key {
1301 cmdline_fixed_string_t port;
1302 cmdline_fixed_string_t config;
1304 cmdline_fixed_string_t rss_hash_key;
1305 cmdline_fixed_string_t key;
1308 #define RSS_HASH_KEY_LENGTH 40
1310 hexa_digit_to_value(char hexa_digit)
1312 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1313 return (uint8_t) (hexa_digit - '0');
1314 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1315 return (uint8_t) ((hexa_digit - 'a') + 10);
1316 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1317 return (uint8_t) ((hexa_digit - 'A') + 10);
1318 /* Invalid hexa digit */
1323 parse_and_check_key_hexa_digit(char *key, int idx)
1327 hexa_v = hexa_digit_to_value(key[idx]);
1329 printf("invalid key: character %c at position %d is not a "
1330 "valid hexa digit\n", key[idx], idx);
1335 cmd_config_rss_hash_key_parsed(void *parsed_result,
1336 __attribute__((unused)) struct cmdline *cl,
1337 __attribute__((unused)) void *data)
1339 struct cmd_config_rss_hash_key *res = parsed_result;
1340 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1345 /* Check the length of the RSS hash key */
1346 if (strlen(res->key) != (RSS_HASH_KEY_LENGTH * 2)) {
1347 printf("key length: %d invalid - key must be a string of %d"
1348 "hexa-decimal numbers\n", (int) strlen(res->key),
1349 RSS_HASH_KEY_LENGTH * 2);
1352 /* Translate RSS hash key into binary representation */
1353 for (i = 0; i < RSS_HASH_KEY_LENGTH; i++) {
1354 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1357 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1360 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1362 port_rss_hash_key_update(res->port_id, hash_key);
1365 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1367 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1370 cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
1371 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
1372 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1374 rss_hash_key, "rss-hash-key");
1375 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1378 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1379 .f = cmd_config_rss_hash_key_parsed,
1381 .help_str = "port config X rss-hash-key 80 hexa digits",
1383 (void *)&cmd_config_rss_hash_key_port,
1384 (void *)&cmd_config_rss_hash_key_config,
1385 (void *)&cmd_config_rss_hash_key_port_id,
1386 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1387 (void *)&cmd_config_rss_hash_key_value,
1392 /* *** Configure RSS RETA *** */
1393 struct cmd_config_rss_reta {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1397 cmdline_fixed_string_t name;
1398 cmdline_fixed_string_t list_name;
1399 cmdline_fixed_string_t list_of_items;
1403 parse_reta_config(const char *str, struct rte_eth_rss_reta *reta_conf)
1410 const char *p, *p0 = str;
1417 unsigned long int_fld[_NUM_FLD];
1418 char *str_fld[_NUM_FLD];
1420 while ((p = strchr(p0,'(')) != NULL) {
1422 if((p0 = strchr(p,')')) == NULL)
1426 if(size >= sizeof(s))
1429 rte_snprintf(s, sizeof(s), "%.*s", size, p);
1430 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
1432 for (i = 0; i < _NUM_FLD; i++) {
1434 int_fld[i] = strtoul(str_fld[i], &end, 0);
1435 if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
1439 hash_index = (uint8_t)int_fld[FLD_HASH_INDEX];
1440 nb_queue = (uint8_t)int_fld[FLD_QUEUE];
1442 if (hash_index >= ETH_RSS_RETA_NUM_ENTRIES) {
1443 printf("Invalid RETA hash index=%d",hash_index);
1447 if (hash_index < ETH_RSS_RETA_NUM_ENTRIES/2)
1448 reta_conf->mask_lo |= (1ULL << hash_index);
1450 reta_conf->mask_hi |= (1ULL << (hash_index - ETH_RSS_RETA_NUM_ENTRIES/2));
1452 reta_conf->reta[hash_index] = nb_queue;
1459 cmd_set_rss_reta_parsed(void *parsed_result,
1460 __attribute__((unused)) struct cmdline *cl,
1461 __attribute__((unused)) void *data)
1464 struct rte_eth_rss_reta reta_conf;
1465 struct cmd_config_rss_reta *res = parsed_result;
1467 memset(&reta_conf,0,sizeof(struct rte_eth_rss_reta));
1468 if (!strcmp(res->list_name, "reta")) {
1469 if (parse_reta_config(res->list_of_items, &reta_conf)) {
1470 printf("Invalid RSS Redirection Table config entered\n");
1473 ret = rte_eth_dev_rss_reta_update(res->port_id, &reta_conf);
1475 printf("Bad redirection table parameter, return code = %d \n",ret);
1479 cmdline_parse_token_string_t cmd_config_rss_reta_port =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
1481 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
1483 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
1484 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT8);
1485 cmdline_parse_token_string_t cmd_config_rss_reta_name =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
1487 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
1489 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
1490 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
1492 cmdline_parse_inst_t cmd_config_rss_reta = {
1493 .f = cmd_set_rss_reta_parsed,
1495 .help_str = "port config X rss reta (hash,queue)[,(hash,queue)]",
1497 (void *)&cmd_config_rss_reta_port,
1498 (void *)&cmd_config_rss_reta_keyword,
1499 (void *)&cmd_config_rss_reta_port_id,
1500 (void *)&cmd_config_rss_reta_name,
1501 (void *)&cmd_config_rss_reta_list_name,
1502 (void *)&cmd_config_rss_reta_list_of_items,
1507 /* *** SHOW PORT RETA INFO *** */
1508 struct cmd_showport_reta {
1509 cmdline_fixed_string_t show;
1510 cmdline_fixed_string_t port;
1512 cmdline_fixed_string_t rss;
1513 cmdline_fixed_string_t reta;
1518 static void cmd_showport_reta_parsed(void *parsed_result,
1519 __attribute__((unused)) struct cmdline *cl,
1520 __attribute__((unused)) void *data)
1522 struct cmd_showport_reta *res = parsed_result;
1523 struct rte_eth_rss_reta reta_conf;
1525 if ((res->mask_lo == 0) && (res->mask_hi == 0)) {
1526 printf("Invalid RSS Redirection Table config entered\n");
1530 reta_conf.mask_lo = res->mask_lo;
1531 reta_conf.mask_hi = res->mask_hi;
1533 port_rss_reta_info(res->port_id,&reta_conf);
1536 cmdline_parse_token_string_t cmd_showport_reta_show =
1537 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
1538 cmdline_parse_token_string_t cmd_showport_reta_port =
1539 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
1540 cmdline_parse_token_num_t cmd_showport_reta_port_id =
1541 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT8);
1542 cmdline_parse_token_string_t cmd_showport_reta_rss =
1543 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
1544 cmdline_parse_token_string_t cmd_showport_reta_reta =
1545 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
1546 cmdline_parse_token_num_t cmd_showport_reta_mask_lo =
1547 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_lo,UINT64);
1548 cmdline_parse_token_num_t cmd_showport_reta_mask_hi =
1549 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta,mask_hi,UINT64);
1551 cmdline_parse_inst_t cmd_showport_reta = {
1552 .f = cmd_showport_reta_parsed,
1554 .help_str = "show port X rss reta mask_lo mask_hi (X = port number)\n\
1555 (mask_lo and mask_hi is UINT64)",
1557 (void *)&cmd_showport_reta_show,
1558 (void *)&cmd_showport_reta_port,
1559 (void *)&cmd_showport_reta_port_id,
1560 (void *)&cmd_showport_reta_rss,
1561 (void *)&cmd_showport_reta_reta,
1562 (void *)&cmd_showport_reta_mask_lo,
1563 (void *)&cmd_showport_reta_mask_hi,
1568 /* *** Show RSS hash configuration *** */
1569 struct cmd_showport_rss_hash {
1570 cmdline_fixed_string_t show;
1571 cmdline_fixed_string_t port;
1573 cmdline_fixed_string_t rss_hash;
1574 cmdline_fixed_string_t key; /* optional argument */
1577 static void cmd_showport_rss_hash_parsed(void *parsed_result,
1578 __attribute__((unused)) struct cmdline *cl,
1581 struct cmd_showport_rss_hash *res = parsed_result;
1583 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
1586 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
1587 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
1588 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
1589 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
1590 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
1591 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
1592 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
1593 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
1595 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
1596 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
1598 cmdline_parse_inst_t cmd_showport_rss_hash = {
1599 .f = cmd_showport_rss_hash_parsed,
1601 .help_str = "show port X rss-hash (X = port number)\n",
1603 (void *)&cmd_showport_rss_hash_show,
1604 (void *)&cmd_showport_rss_hash_port,
1605 (void *)&cmd_showport_rss_hash_port_id,
1606 (void *)&cmd_showport_rss_hash_rss_hash,
1611 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
1612 .f = cmd_showport_rss_hash_parsed,
1614 .help_str = "show port X rss-hash key (X = port number)\n",
1616 (void *)&cmd_showport_rss_hash_show,
1617 (void *)&cmd_showport_rss_hash_port,
1618 (void *)&cmd_showport_rss_hash_port_id,
1619 (void *)&cmd_showport_rss_hash_rss_hash,
1620 (void *)&cmd_showport_rss_hash_rss_key,
1625 /* *** Configure DCB *** */
1626 struct cmd_config_dcb {
1627 cmdline_fixed_string_t port;
1628 cmdline_fixed_string_t config;
1630 cmdline_fixed_string_t dcb;
1631 cmdline_fixed_string_t vt;
1632 cmdline_fixed_string_t vt_en;
1634 cmdline_fixed_string_t pfc;
1635 cmdline_fixed_string_t pfc_en;
1639 cmd_config_dcb_parsed(void *parsed_result,
1640 __attribute__((unused)) struct cmdline *cl,
1641 __attribute__((unused)) void *data)
1643 struct cmd_config_dcb *res = parsed_result;
1644 struct dcb_config dcb_conf;
1645 portid_t port_id = res->port_id;
1646 struct rte_port *port;
1648 port = &ports[port_id];
1649 /** Check if the port is not started **/
1650 if (port->port_status != RTE_PORT_STOPPED) {
1651 printf("Please stop port %d first\n",port_id);
1655 dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
1656 if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
1657 printf("The invalid number of traffic class,only 4 or 8 allowed\n");
1661 /* DCB in VT mode */
1662 if (!strncmp(res->vt_en, "on",2))
1663 dcb_conf.dcb_mode = DCB_VT_ENABLED;
1665 dcb_conf.dcb_mode = DCB_ENABLED;
1667 if (!strncmp(res->pfc_en, "on",2)) {
1668 dcb_conf.pfc_en = 1;
1671 dcb_conf.pfc_en = 0;
1673 if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
1674 printf("Cannot initialize network ports\n");
1678 cmd_reconfig_device_queue(port_id, 1, 1);
1681 cmdline_parse_token_string_t cmd_config_dcb_port =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
1683 cmdline_parse_token_string_t cmd_config_dcb_config =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
1685 cmdline_parse_token_num_t cmd_config_dcb_port_id =
1686 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT8);
1687 cmdline_parse_token_string_t cmd_config_dcb_dcb =
1688 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
1689 cmdline_parse_token_string_t cmd_config_dcb_vt =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
1691 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
1692 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
1693 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
1694 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
1695 cmdline_parse_token_string_t cmd_config_dcb_pfc=
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
1697 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
1700 cmdline_parse_inst_t cmd_config_dcb = {
1701 .f = cmd_config_dcb_parsed,
1703 .help_str = "port config port-id dcb vt on|off nb-tcs pfc on|off",
1705 (void *)&cmd_config_dcb_port,
1706 (void *)&cmd_config_dcb_config,
1707 (void *)&cmd_config_dcb_port_id,
1708 (void *)&cmd_config_dcb_dcb,
1709 (void *)&cmd_config_dcb_vt,
1710 (void *)&cmd_config_dcb_vt_en,
1711 (void *)&cmd_config_dcb_num_tcs,
1712 (void *)&cmd_config_dcb_pfc,
1713 (void *)&cmd_config_dcb_pfc_en,
1718 /* *** configure number of packets per burst *** */
1719 struct cmd_config_burst {
1720 cmdline_fixed_string_t port;
1721 cmdline_fixed_string_t keyword;
1722 cmdline_fixed_string_t all;
1723 cmdline_fixed_string_t name;
1728 cmd_config_burst_parsed(void *parsed_result,
1729 __attribute__((unused)) struct cmdline *cl,
1730 __attribute__((unused)) void *data)
1732 struct cmd_config_burst *res = parsed_result;
1734 if (!all_ports_stopped()) {
1735 printf("Please stop all ports first\n");
1739 if (!strcmp(res->name, "burst")) {
1740 if (res->value < 1 || res->value > MAX_PKT_BURST) {
1741 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
1744 nb_pkt_per_burst = res->value;
1746 printf("Unknown parameter\n");
1752 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1755 cmdline_parse_token_string_t cmd_config_burst_port =
1756 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
1757 cmdline_parse_token_string_t cmd_config_burst_keyword =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
1759 cmdline_parse_token_string_t cmd_config_burst_all =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
1761 cmdline_parse_token_string_t cmd_config_burst_name =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
1763 cmdline_parse_token_num_t cmd_config_burst_value =
1764 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
1766 cmdline_parse_inst_t cmd_config_burst = {
1767 .f = cmd_config_burst_parsed,
1769 .help_str = "port config all burst value",
1771 (void *)&cmd_config_burst_port,
1772 (void *)&cmd_config_burst_keyword,
1773 (void *)&cmd_config_burst_all,
1774 (void *)&cmd_config_burst_name,
1775 (void *)&cmd_config_burst_value,
1780 /* *** configure rx/tx queues *** */
1781 struct cmd_config_thresh {
1782 cmdline_fixed_string_t port;
1783 cmdline_fixed_string_t keyword;
1784 cmdline_fixed_string_t all;
1785 cmdline_fixed_string_t name;
1790 cmd_config_thresh_parsed(void *parsed_result,
1791 __attribute__((unused)) struct cmdline *cl,
1792 __attribute__((unused)) void *data)
1794 struct cmd_config_thresh *res = parsed_result;
1796 if (!all_ports_stopped()) {
1797 printf("Please stop all ports first\n");
1801 if (!strcmp(res->name, "txpt"))
1802 tx_thresh.pthresh = res->value;
1803 else if(!strcmp(res->name, "txht"))
1804 tx_thresh.hthresh = res->value;
1805 else if(!strcmp(res->name, "txwt"))
1806 tx_thresh.wthresh = res->value;
1807 else if(!strcmp(res->name, "rxpt"))
1808 rx_thresh.pthresh = res->value;
1809 else if(!strcmp(res->name, "rxht"))
1810 rx_thresh.hthresh = res->value;
1811 else if(!strcmp(res->name, "rxwt"))
1812 rx_thresh.wthresh = res->value;
1814 printf("Unknown parameter\n");
1820 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1823 cmdline_parse_token_string_t cmd_config_thresh_port =
1824 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
1825 cmdline_parse_token_string_t cmd_config_thresh_keyword =
1826 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
1827 cmdline_parse_token_string_t cmd_config_thresh_all =
1828 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
1829 cmdline_parse_token_string_t cmd_config_thresh_name =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
1831 "txpt#txht#txwt#rxpt#rxht#rxwt");
1832 cmdline_parse_token_num_t cmd_config_thresh_value =
1833 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
1835 cmdline_parse_inst_t cmd_config_thresh = {
1836 .f = cmd_config_thresh_parsed,
1838 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt value",
1840 (void *)&cmd_config_thresh_port,
1841 (void *)&cmd_config_thresh_keyword,
1842 (void *)&cmd_config_thresh_all,
1843 (void *)&cmd_config_thresh_name,
1844 (void *)&cmd_config_thresh_value,
1849 /* *** configure free/rs threshold *** */
1850 struct cmd_config_threshold {
1851 cmdline_fixed_string_t port;
1852 cmdline_fixed_string_t keyword;
1853 cmdline_fixed_string_t all;
1854 cmdline_fixed_string_t name;
1859 cmd_config_threshold_parsed(void *parsed_result,
1860 __attribute__((unused)) struct cmdline *cl,
1861 __attribute__((unused)) void *data)
1863 struct cmd_config_threshold *res = parsed_result;
1865 if (!all_ports_stopped()) {
1866 printf("Please stop all ports first\n");
1870 if (!strcmp(res->name, "txfreet"))
1871 tx_free_thresh = res->value;
1872 else if (!strcmp(res->name, "txrst"))
1873 tx_rs_thresh = res->value;
1874 else if (!strcmp(res->name, "rxfreet"))
1875 rx_free_thresh = res->value;
1877 printf("Unknown parameter\n");
1883 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1886 cmdline_parse_token_string_t cmd_config_threshold_port =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
1888 cmdline_parse_token_string_t cmd_config_threshold_keyword =
1889 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
1891 cmdline_parse_token_string_t cmd_config_threshold_all =
1892 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
1893 cmdline_parse_token_string_t cmd_config_threshold_name =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
1895 "txfreet#txrst#rxfreet");
1896 cmdline_parse_token_num_t cmd_config_threshold_value =
1897 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
1899 cmdline_parse_inst_t cmd_config_threshold = {
1900 .f = cmd_config_threshold_parsed,
1902 .help_str = "port config all txfreet|txrst|rxfreet value",
1904 (void *)&cmd_config_threshold_port,
1905 (void *)&cmd_config_threshold_keyword,
1906 (void *)&cmd_config_threshold_all,
1907 (void *)&cmd_config_threshold_name,
1908 (void *)&cmd_config_threshold_value,
1914 struct cmd_stop_result {
1915 cmdline_fixed_string_t stop;
1918 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
1919 __attribute__((unused)) struct cmdline *cl,
1920 __attribute__((unused)) void *data)
1922 stop_packet_forwarding();
1925 cmdline_parse_token_string_t cmd_stop_stop =
1926 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
1928 cmdline_parse_inst_t cmd_stop = {
1929 .f = cmd_stop_parsed,
1931 .help_str = "stop - stop packet forwarding",
1933 (void *)&cmd_stop_stop,
1938 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
1941 parse_item_list(char* str, const char* item_name, unsigned int max_items,
1942 unsigned int *parsed_items, int check_unique_values)
1944 unsigned int nb_item;
1952 * First parse all items in the list and store their value.
1957 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
1959 if ((c >= '0') && (c <= '9')) {
1960 value = (unsigned int) (value * 10 + (c - '0'));
1965 printf("character %c is not a decimal digit\n", c);
1969 printf("No valid value before comma\n");
1972 if (nb_item < max_items) {
1973 parsed_items[nb_item] = value;
1979 if (nb_item >= max_items) {
1980 printf("Number of %s = %u > %u (maximum items)\n",
1981 item_name, nb_item + 1, max_items);
1984 parsed_items[nb_item++] = value;
1985 if (! check_unique_values)
1989 * Then, check that all values in the list are differents.
1990 * No optimization here...
1992 for (i = 0; i < nb_item; i++) {
1993 for (j = i + 1; j < nb_item; j++) {
1994 if (parsed_items[j] == parsed_items[i]) {
1995 printf("duplicated %s %u at index %u and %u\n",
1996 item_name, parsed_items[i], i, j);
2004 struct cmd_set_list_result {
2005 cmdline_fixed_string_t cmd_keyword;
2006 cmdline_fixed_string_t list_name;
2007 cmdline_fixed_string_t list_of_items;
2010 static void cmd_set_list_parsed(void *parsed_result,
2011 __attribute__((unused)) struct cmdline *cl,
2012 __attribute__((unused)) void *data)
2014 struct cmd_set_list_result *res;
2016 unsigned int lcorelist[RTE_MAX_LCORE];
2017 unsigned int portlist[RTE_MAX_ETHPORTS];
2019 unsigned int nb_item;
2021 res = parsed_result;
2022 if (!strcmp(res->list_name, "corelist")) {
2023 nb_item = parse_item_list(res->list_of_items, "core",
2025 parsed_items.lcorelist, 1);
2027 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2030 if (!strcmp(res->list_name, "portlist")) {
2031 nb_item = parse_item_list(res->list_of_items, "port",
2033 parsed_items.portlist, 1);
2035 set_fwd_ports_list(parsed_items.portlist, nb_item);
2039 cmdline_parse_token_string_t cmd_set_list_keyword =
2040 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2042 cmdline_parse_token_string_t cmd_set_list_name =
2043 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2044 "corelist#portlist");
2045 cmdline_parse_token_string_t cmd_set_list_of_items =
2046 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2049 cmdline_parse_inst_t cmd_set_fwd_list = {
2050 .f = cmd_set_list_parsed,
2052 .help_str = "set corelist|portlist x[,y]*",
2054 (void *)&cmd_set_list_keyword,
2055 (void *)&cmd_set_list_name,
2056 (void *)&cmd_set_list_of_items,
2061 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2063 struct cmd_setmask_result {
2064 cmdline_fixed_string_t set;
2065 cmdline_fixed_string_t mask;
2069 static void cmd_set_mask_parsed(void *parsed_result,
2070 __attribute__((unused)) struct cmdline *cl,
2071 __attribute__((unused)) void *data)
2073 struct cmd_setmask_result *res = parsed_result;
2075 if (!strcmp(res->mask, "coremask"))
2076 set_fwd_lcores_mask(res->hexavalue);
2077 else if (!strcmp(res->mask, "portmask"))
2078 set_fwd_ports_mask(res->hexavalue);
2081 cmdline_parse_token_string_t cmd_setmask_set =
2082 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2083 cmdline_parse_token_string_t cmd_setmask_mask =
2084 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2085 "coremask#portmask");
2086 cmdline_parse_token_num_t cmd_setmask_value =
2087 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2089 cmdline_parse_inst_t cmd_set_fwd_mask = {
2090 .f = cmd_set_mask_parsed,
2092 .help_str = "set coremask|portmask hexadecimal value",
2094 (void *)&cmd_setmask_set,
2095 (void *)&cmd_setmask_mask,
2096 (void *)&cmd_setmask_value,
2102 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2104 struct cmd_set_result {
2105 cmdline_fixed_string_t set;
2106 cmdline_fixed_string_t what;
2110 static void cmd_set_parsed(void *parsed_result,
2111 __attribute__((unused)) struct cmdline *cl,
2112 __attribute__((unused)) void *data)
2114 struct cmd_set_result *res = parsed_result;
2115 if (!strcmp(res->what, "nbport"))
2116 set_fwd_ports_number(res->value);
2117 else if (!strcmp(res->what, "nbcore"))
2118 set_fwd_lcores_number(res->value);
2119 else if (!strcmp(res->what, "burst"))
2120 set_nb_pkt_per_burst(res->value);
2121 else if (!strcmp(res->what, "verbose"))
2122 set_verbose_level(res->value);
2125 cmdline_parse_token_string_t cmd_set_set =
2126 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2127 cmdline_parse_token_string_t cmd_set_what =
2128 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2129 "nbport#nbcore#burst#verbose");
2130 cmdline_parse_token_num_t cmd_set_value =
2131 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2133 cmdline_parse_inst_t cmd_set_numbers = {
2134 .f = cmd_set_parsed,
2136 .help_str = "set nbport|nbcore|burst|verbose value",
2138 (void *)&cmd_set_set,
2139 (void *)&cmd_set_what,
2140 (void *)&cmd_set_value,
2145 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2147 struct cmd_set_txpkts_result {
2148 cmdline_fixed_string_t cmd_keyword;
2149 cmdline_fixed_string_t txpkts;
2150 cmdline_fixed_string_t seg_lengths;
2154 cmd_set_txpkts_parsed(void *parsed_result,
2155 __attribute__((unused)) struct cmdline *cl,
2156 __attribute__((unused)) void *data)
2158 struct cmd_set_txpkts_result *res;
2159 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2160 unsigned int nb_segs;
2162 res = parsed_result;
2163 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2164 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2166 set_tx_pkt_segments(seg_lengths, nb_segs);
2169 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2170 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2171 cmd_keyword, "set");
2172 cmdline_parse_token_string_t cmd_set_txpkts_name =
2173 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2175 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2176 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2179 cmdline_parse_inst_t cmd_set_txpkts = {
2180 .f = cmd_set_txpkts_parsed,
2182 .help_str = "set txpkts x[,y]*",
2184 (void *)&cmd_set_txpkts_keyword,
2185 (void *)&cmd_set_txpkts_name,
2186 (void *)&cmd_set_txpkts_lengths,
2191 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
2192 struct cmd_rx_vlan_filter_all_result {
2193 cmdline_fixed_string_t rx_vlan;
2194 cmdline_fixed_string_t what;
2195 cmdline_fixed_string_t all;
2200 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
2201 __attribute__((unused)) struct cmdline *cl,
2202 __attribute__((unused)) void *data)
2204 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
2206 if (!strcmp(res->what, "add"))
2207 rx_vlan_all_filter_set(res->port_id, 1);
2209 rx_vlan_all_filter_set(res->port_id, 0);
2212 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
2213 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2214 rx_vlan, "rx_vlan");
2215 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
2216 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2218 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
2219 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2221 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
2222 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
2225 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
2226 .f = cmd_rx_vlan_filter_all_parsed,
2228 .help_str = "add/remove all identifiers to/from the set of VLAN "
2229 "Identifiers filtered by a port",
2231 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
2232 (void *)&cmd_rx_vlan_filter_all_what,
2233 (void *)&cmd_rx_vlan_filter_all_all,
2234 (void *)&cmd_rx_vlan_filter_all_portid,
2239 /* *** VLAN OFFLOAD SET ON A PORT *** */
2240 struct cmd_vlan_offload_result {
2241 cmdline_fixed_string_t vlan;
2242 cmdline_fixed_string_t set;
2243 cmdline_fixed_string_t what;
2244 cmdline_fixed_string_t on;
2245 cmdline_fixed_string_t port_id;
2249 cmd_vlan_offload_parsed(void *parsed_result,
2250 __attribute__((unused)) struct cmdline *cl,
2251 __attribute__((unused)) void *data)
2254 struct cmd_vlan_offload_result *res = parsed_result;
2257 portid_t port_id = 0;
2261 len = strnlen(str, STR_TOKEN_SIZE);
2263 /* Get port_id first */
2271 tmp = strtoul(str, NULL, 0);
2272 /* If port_id greater that what portid_t can represent, return */
2273 if(tmp >= RTE_MAX_ETHPORTS)
2275 port_id = (portid_t)tmp;
2277 if (!strcmp(res->on, "on"))
2282 if (!strcmp(res->what, "strip"))
2283 rx_vlan_strip_set(port_id, on);
2284 else if(!strcmp(res->what, "stripq")){
2285 uint16_t queue_id = 0;
2287 /* No queue_id, return */
2289 printf("must specify (port,queue_id)\n");
2292 tmp = strtoul(str + i + 1, NULL, 0);
2293 /* If queue_id greater that what 16-bits can represent, return */
2297 queue_id = (uint16_t)tmp;
2298 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
2300 else if (!strcmp(res->what, "filter"))
2301 rx_vlan_filter_set(port_id, on);
2303 vlan_extend_set(port_id, on);
2308 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
2309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2311 cmdline_parse_token_string_t cmd_vlan_offload_set =
2312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2314 cmdline_parse_token_string_t cmd_vlan_offload_what =
2315 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2316 what, "strip#filter#qinq#stripq");
2317 cmdline_parse_token_string_t cmd_vlan_offload_on =
2318 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2320 cmdline_parse_token_string_t cmd_vlan_offload_portid =
2321 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
2324 cmdline_parse_inst_t cmd_vlan_offload = {
2325 .f = cmd_vlan_offload_parsed,
2327 .help_str = "set strip|filter|qinq|stripq on|off port_id[,queue_id], filter/strip for rx side"
2328 " qinq(extended) for both rx/tx sides ",
2330 (void *)&cmd_vlan_offload_vlan,
2331 (void *)&cmd_vlan_offload_set,
2332 (void *)&cmd_vlan_offload_what,
2333 (void *)&cmd_vlan_offload_on,
2334 (void *)&cmd_vlan_offload_portid,
2339 /* *** VLAN TPID SET ON A PORT *** */
2340 struct cmd_vlan_tpid_result {
2341 cmdline_fixed_string_t vlan;
2342 cmdline_fixed_string_t set;
2343 cmdline_fixed_string_t what;
2349 cmd_vlan_tpid_parsed(void *parsed_result,
2350 __attribute__((unused)) struct cmdline *cl,
2351 __attribute__((unused)) void *data)
2353 struct cmd_vlan_tpid_result *res = parsed_result;
2354 vlan_tpid_set(res->port_id, res->tp_id);
2358 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
2359 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2361 cmdline_parse_token_string_t cmd_vlan_tpid_set =
2362 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2364 cmdline_parse_token_string_t cmd_vlan_tpid_what =
2365 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
2367 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
2368 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2370 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
2371 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
2374 cmdline_parse_inst_t cmd_vlan_tpid = {
2375 .f = cmd_vlan_tpid_parsed,
2377 .help_str = "set tpid tp_id port_id, set the Outer VLAN Ether type",
2379 (void *)&cmd_vlan_tpid_vlan,
2380 (void *)&cmd_vlan_tpid_set,
2381 (void *)&cmd_vlan_tpid_what,
2382 (void *)&cmd_vlan_tpid_tpid,
2383 (void *)&cmd_vlan_tpid_portid,
2388 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
2389 struct cmd_rx_vlan_filter_result {
2390 cmdline_fixed_string_t rx_vlan;
2391 cmdline_fixed_string_t what;
2397 cmd_rx_vlan_filter_parsed(void *parsed_result,
2398 __attribute__((unused)) struct cmdline *cl,
2399 __attribute__((unused)) void *data)
2401 struct cmd_rx_vlan_filter_result *res = parsed_result;
2403 if (!strcmp(res->what, "add"))
2404 rx_vft_set(res->port_id, res->vlan_id, 1);
2406 rx_vft_set(res->port_id, res->vlan_id, 0);
2409 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
2410 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2411 rx_vlan, "rx_vlan");
2412 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
2413 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
2415 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
2416 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2418 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
2419 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
2422 cmdline_parse_inst_t cmd_rx_vlan_filter = {
2423 .f = cmd_rx_vlan_filter_parsed,
2425 .help_str = "add/remove a VLAN identifier to/from the set of VLAN "
2426 "Identifiers filtered by a port",
2428 (void *)&cmd_rx_vlan_filter_rx_vlan,
2429 (void *)&cmd_rx_vlan_filter_what,
2430 (void *)&cmd_rx_vlan_filter_vlanid,
2431 (void *)&cmd_rx_vlan_filter_portid,
2436 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2437 struct cmd_tx_vlan_set_result {
2438 cmdline_fixed_string_t tx_vlan;
2439 cmdline_fixed_string_t set;
2445 cmd_tx_vlan_set_parsed(void *parsed_result,
2446 __attribute__((unused)) struct cmdline *cl,
2447 __attribute__((unused)) void *data)
2449 struct cmd_tx_vlan_set_result *res = parsed_result;
2450 tx_vlan_set(res->port_id, res->vlan_id);
2453 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
2454 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2455 tx_vlan, "tx_vlan");
2456 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
2457 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
2459 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
2460 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2462 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
2463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
2466 cmdline_parse_inst_t cmd_tx_vlan_set = {
2467 .f = cmd_tx_vlan_set_parsed,
2469 .help_str = "enable hardware insertion of a VLAN header with a given "
2470 "TAG Identifier in packets sent on a port",
2472 (void *)&cmd_tx_vlan_set_tx_vlan,
2473 (void *)&cmd_tx_vlan_set_set,
2474 (void *)&cmd_tx_vlan_set_vlanid,
2475 (void *)&cmd_tx_vlan_set_portid,
2480 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
2481 struct cmd_tx_vlan_set_pvid_result {
2482 cmdline_fixed_string_t tx_vlan;
2483 cmdline_fixed_string_t set;
2484 cmdline_fixed_string_t pvid;
2487 cmdline_fixed_string_t mode;
2491 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
2492 __attribute__((unused)) struct cmdline *cl,
2493 __attribute__((unused)) void *data)
2495 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
2497 if (strcmp(res->mode, "on") == 0)
2498 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
2500 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
2503 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
2504 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2505 tx_vlan, "tx_vlan");
2506 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
2507 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2509 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
2510 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2512 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
2513 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2515 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
2516 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2518 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
2519 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
2522 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
2523 .f = cmd_tx_vlan_set_pvid_parsed,
2525 .help_str = "tx_vlan set pvid port_id vlan_id (on|off)",
2527 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
2528 (void *)&cmd_tx_vlan_set_pvid_set,
2529 (void *)&cmd_tx_vlan_set_pvid_pvid,
2530 (void *)&cmd_tx_vlan_set_pvid_port_id,
2531 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
2532 (void *)&cmd_tx_vlan_set_pvid_mode,
2537 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
2538 struct cmd_tx_vlan_reset_result {
2539 cmdline_fixed_string_t tx_vlan;
2540 cmdline_fixed_string_t reset;
2545 cmd_tx_vlan_reset_parsed(void *parsed_result,
2546 __attribute__((unused)) struct cmdline *cl,
2547 __attribute__((unused)) void *data)
2549 struct cmd_tx_vlan_reset_result *res = parsed_result;
2551 tx_vlan_reset(res->port_id);
2554 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
2555 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2556 tx_vlan, "tx_vlan");
2557 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
2558 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
2560 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
2561 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
2564 cmdline_parse_inst_t cmd_tx_vlan_reset = {
2565 .f = cmd_tx_vlan_reset_parsed,
2567 .help_str = "disable hardware insertion of a VLAN header in packets "
2570 (void *)&cmd_tx_vlan_reset_tx_vlan,
2571 (void *)&cmd_tx_vlan_reset_reset,
2572 (void *)&cmd_tx_vlan_reset_portid,
2578 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
2579 struct cmd_tx_cksum_set_result {
2580 cmdline_fixed_string_t tx_cksum;
2581 cmdline_fixed_string_t set;
2587 cmd_tx_cksum_set_parsed(void *parsed_result,
2588 __attribute__((unused)) struct cmdline *cl,
2589 __attribute__((unused)) void *data)
2591 struct cmd_tx_cksum_set_result *res = parsed_result;
2593 tx_cksum_set(res->port_id, res->cksum_mask);
2596 cmdline_parse_token_string_t cmd_tx_cksum_set_tx_cksum =
2597 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2598 tx_cksum, "tx_checksum");
2599 cmdline_parse_token_string_t cmd_tx_cksum_set_set =
2600 TOKEN_STRING_INITIALIZER(struct cmd_tx_cksum_set_result,
2602 cmdline_parse_token_num_t cmd_tx_cksum_set_cksum_mask =
2603 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2605 cmdline_parse_token_num_t cmd_tx_cksum_set_portid =
2606 TOKEN_NUM_INITIALIZER(struct cmd_tx_cksum_set_result,
2609 cmdline_parse_inst_t cmd_tx_cksum_set = {
2610 .f = cmd_tx_cksum_set_parsed,
2612 .help_str = "enable hardware insertion of L3/L4checksum with a given "
2613 "mask in packets sent on a port, the bit mapping is given as, Bit 0 for ip"
2614 "Bit 1 for UDP, Bit 2 for TCP, Bit 3 for SCTP",
2616 (void *)&cmd_tx_cksum_set_tx_cksum,
2617 (void *)&cmd_tx_cksum_set_set,
2618 (void *)&cmd_tx_cksum_set_cksum_mask,
2619 (void *)&cmd_tx_cksum_set_portid,
2624 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
2625 struct cmd_set_flush_rx {
2626 cmdline_fixed_string_t set;
2627 cmdline_fixed_string_t flush_rx;
2628 cmdline_fixed_string_t mode;
2632 cmd_set_flush_rx_parsed(void *parsed_result,
2633 __attribute__((unused)) struct cmdline *cl,
2634 __attribute__((unused)) void *data)
2636 struct cmd_set_flush_rx *res = parsed_result;
2637 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2640 cmdline_parse_token_string_t cmd_setflushrx_set =
2641 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2643 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
2644 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2645 flush_rx, "flush_rx");
2646 cmdline_parse_token_string_t cmd_setflushrx_mode =
2647 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
2651 cmdline_parse_inst_t cmd_set_flush_rx = {
2652 .f = cmd_set_flush_rx_parsed,
2653 .help_str = "set flush_rx on|off: enable/disable flush on rx streams",
2656 (void *)&cmd_setflushrx_set,
2657 (void *)&cmd_setflushrx_flush_rx,
2658 (void *)&cmd_setflushrx_mode,
2663 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
2664 struct cmd_set_link_check {
2665 cmdline_fixed_string_t set;
2666 cmdline_fixed_string_t link_check;
2667 cmdline_fixed_string_t mode;
2671 cmd_set_link_check_parsed(void *parsed_result,
2672 __attribute__((unused)) struct cmdline *cl,
2673 __attribute__((unused)) void *data)
2675 struct cmd_set_link_check *res = parsed_result;
2676 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
2679 cmdline_parse_token_string_t cmd_setlinkcheck_set =
2680 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2682 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
2683 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2684 link_check, "link_check");
2685 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
2686 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
2690 cmdline_parse_inst_t cmd_set_link_check = {
2691 .f = cmd_set_link_check_parsed,
2692 .help_str = "set link_check on|off: enable/disable link status check "
2693 "when starting/stopping a port",
2696 (void *)&cmd_setlinkcheck_set,
2697 (void *)&cmd_setlinkcheck_link_check,
2698 (void *)&cmd_setlinkcheck_mode,
2703 #ifdef RTE_NIC_BYPASS
2704 /* *** SET NIC BYPASS MODE *** */
2705 struct cmd_set_bypass_mode_result {
2706 cmdline_fixed_string_t set;
2707 cmdline_fixed_string_t bypass;
2708 cmdline_fixed_string_t mode;
2709 cmdline_fixed_string_t value;
2714 cmd_set_bypass_mode_parsed(void *parsed_result,
2715 __attribute__((unused)) struct cmdline *cl,
2716 __attribute__((unused)) void *data)
2718 struct cmd_set_bypass_mode_result *res = parsed_result;
2719 portid_t port_id = res->port_id;
2720 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2722 if (!bypass_is_supported(port_id))
2725 if (!strcmp(res->value, "bypass"))
2726 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2727 else if (!strcmp(res->value, "isolate"))
2728 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2730 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2732 /* Set the bypass mode for the relevant port. */
2733 if (0 != rte_eth_dev_bypass_state_set(port_id, &bypass_mode)) {
2734 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
2738 cmdline_parse_token_string_t cmd_setbypass_mode_set =
2739 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2741 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
2742 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2744 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
2745 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2747 cmdline_parse_token_string_t cmd_setbypass_mode_value =
2748 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
2749 value, "normal#bypass#isolate");
2750 cmdline_parse_token_num_t cmd_setbypass_mode_port =
2751 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
2754 cmdline_parse_inst_t cmd_set_bypass_mode = {
2755 .f = cmd_set_bypass_mode_parsed,
2756 .help_str = "set bypass mode (normal|bypass|isolate) (port_id): "
2757 "Set the NIC bypass mode for port_id",
2760 (void *)&cmd_setbypass_mode_set,
2761 (void *)&cmd_setbypass_mode_bypass,
2762 (void *)&cmd_setbypass_mode_mode,
2763 (void *)&cmd_setbypass_mode_value,
2764 (void *)&cmd_setbypass_mode_port,
2769 /* *** SET NIC BYPASS EVENT *** */
2770 struct cmd_set_bypass_event_result {
2771 cmdline_fixed_string_t set;
2772 cmdline_fixed_string_t bypass;
2773 cmdline_fixed_string_t event;
2774 cmdline_fixed_string_t event_value;
2775 cmdline_fixed_string_t mode;
2776 cmdline_fixed_string_t mode_value;
2781 cmd_set_bypass_event_parsed(void *parsed_result,
2782 __attribute__((unused)) struct cmdline *cl,
2783 __attribute__((unused)) void *data)
2786 struct cmd_set_bypass_event_result *res = parsed_result;
2787 portid_t port_id = res->port_id;
2788 uint32_t bypass_event = RTE_BYPASS_EVENT_NONE;
2789 uint32_t bypass_mode = RTE_BYPASS_MODE_NORMAL;
2791 if (!bypass_is_supported(port_id))
2794 if (!strcmp(res->event_value, "timeout"))
2795 bypass_event = RTE_BYPASS_EVENT_TIMEOUT;
2796 else if (!strcmp(res->event_value, "os_on"))
2797 bypass_event = RTE_BYPASS_EVENT_OS_ON;
2798 else if (!strcmp(res->event_value, "os_off"))
2799 bypass_event = RTE_BYPASS_EVENT_OS_OFF;
2800 else if (!strcmp(res->event_value, "power_on"))
2801 bypass_event = RTE_BYPASS_EVENT_POWER_ON;
2802 else if (!strcmp(res->event_value, "power_off"))
2803 bypass_event = RTE_BYPASS_EVENT_POWER_OFF;
2805 bypass_event = RTE_BYPASS_EVENT_NONE;
2807 if (!strcmp(res->mode_value, "bypass"))
2808 bypass_mode = RTE_BYPASS_MODE_BYPASS;
2809 else if (!strcmp(res->mode_value, "isolate"))
2810 bypass_mode = RTE_BYPASS_MODE_ISOLATE;
2812 bypass_mode = RTE_BYPASS_MODE_NORMAL;
2814 /* Set the watchdog timeout. */
2815 if (bypass_event == RTE_BYPASS_EVENT_TIMEOUT) {
2818 if (!RTE_BYPASS_TMT_VALID(bypass_timeout) ||
2819 (rc = rte_eth_dev_wd_timeout_store(port_id,
2820 bypass_timeout)) != 0) {
2821 printf("Failed to set timeout value %u "
2822 "for port %d, errto code: %d.\n",
2823 bypass_timeout, port_id, rc);
2827 /* Set the bypass event to transition to bypass mode. */
2828 if (0 != rte_eth_dev_bypass_event_store(port_id,
2829 bypass_event, bypass_mode)) {
2830 printf("\t Failed to set bypass event for port = %d.\n", port_id);
2835 cmdline_parse_token_string_t cmd_setbypass_event_set =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2838 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2841 cmdline_parse_token_string_t cmd_setbypass_event_event =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2844 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
2845 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2846 event_value, "none#timeout#os_off#os_on#power_on#power_off");
2847 cmdline_parse_token_string_t cmd_setbypass_event_mode =
2848 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2850 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
2851 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
2852 mode_value, "normal#bypass#isolate");
2853 cmdline_parse_token_num_t cmd_setbypass_event_port =
2854 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
2857 cmdline_parse_inst_t cmd_set_bypass_event = {
2858 .f = cmd_set_bypass_event_parsed,
2859 .help_str = "set bypass event (timeout|os_on|os_off|power_on|power_off) "
2860 "mode (normal|bypass|isolate) (port_id): "
2861 "Set the NIC bypass event mode for port_id",
2864 (void *)&cmd_setbypass_event_set,
2865 (void *)&cmd_setbypass_event_bypass,
2866 (void *)&cmd_setbypass_event_event,
2867 (void *)&cmd_setbypass_event_event_value,
2868 (void *)&cmd_setbypass_event_mode,
2869 (void *)&cmd_setbypass_event_mode_value,
2870 (void *)&cmd_setbypass_event_port,
2876 /* *** SET NIC BYPASS TIMEOUT *** */
2877 struct cmd_set_bypass_timeout_result {
2878 cmdline_fixed_string_t set;
2879 cmdline_fixed_string_t bypass;
2880 cmdline_fixed_string_t timeout;
2881 cmdline_fixed_string_t value;
2885 cmd_set_bypass_timeout_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_set_bypass_timeout_result *res = parsed_result;
2891 if (!strcmp(res->value, "1.5"))
2892 bypass_timeout = RTE_BYPASS_TMT_1_5_SEC;
2893 else if (!strcmp(res->value, "2"))
2894 bypass_timeout = RTE_BYPASS_TMT_2_SEC;
2895 else if (!strcmp(res->value, "3"))
2896 bypass_timeout = RTE_BYPASS_TMT_3_SEC;
2897 else if (!strcmp(res->value, "4"))
2898 bypass_timeout = RTE_BYPASS_TMT_4_SEC;
2899 else if (!strcmp(res->value, "8"))
2900 bypass_timeout = RTE_BYPASS_TMT_8_SEC;
2901 else if (!strcmp(res->value, "16"))
2902 bypass_timeout = RTE_BYPASS_TMT_16_SEC;
2903 else if (!strcmp(res->value, "32"))
2904 bypass_timeout = RTE_BYPASS_TMT_32_SEC;
2906 bypass_timeout = RTE_BYPASS_TMT_OFF;
2909 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
2910 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2912 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
2913 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2915 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
2916 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2917 timeout, "timeout");
2918 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
2919 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
2920 value, "0#1.5#2#3#4#8#16#32");
2922 cmdline_parse_inst_t cmd_set_bypass_timeout = {
2923 .f = cmd_set_bypass_timeout_parsed,
2924 .help_str = "set bypass timeout (0|1.5|2|3|4|8|16|32) seconds: "
2925 "Set the NIC bypass watchdog timeout",
2928 (void *)&cmd_setbypass_timeout_set,
2929 (void *)&cmd_setbypass_timeout_bypass,
2930 (void *)&cmd_setbypass_timeout_timeout,
2931 (void *)&cmd_setbypass_timeout_value,
2936 /* *** SHOW NIC BYPASS MODE *** */
2937 struct cmd_show_bypass_config_result {
2938 cmdline_fixed_string_t show;
2939 cmdline_fixed_string_t bypass;
2940 cmdline_fixed_string_t config;
2945 cmd_show_bypass_config_parsed(void *parsed_result,
2946 __attribute__((unused)) struct cmdline *cl,
2947 __attribute__((unused)) void *data)
2949 struct cmd_show_bypass_config_result *res = parsed_result;
2950 uint32_t event_mode;
2951 uint32_t bypass_mode;
2952 portid_t port_id = res->port_id;
2953 uint32_t timeout = bypass_timeout;
2956 static const char * const timeouts[RTE_BYPASS_TMT_NUM] =
2957 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
2958 static const char * const modes[RTE_BYPASS_MODE_NUM] =
2959 {"UNKNOWN", "normal", "bypass", "isolate"};
2960 static const char * const events[RTE_BYPASS_EVENT_NUM] = {
2967 int num_events = (sizeof events) / (sizeof events[0]);
2969 if (!bypass_is_supported(port_id))
2972 /* Display the bypass mode.*/
2973 if (0 != rte_eth_dev_bypass_state_show(port_id, &bypass_mode)) {
2974 printf("\tFailed to get bypass mode for port = %d\n", port_id);
2978 if (!RTE_BYPASS_MODE_VALID(bypass_mode))
2979 bypass_mode = RTE_BYPASS_MODE_NONE;
2981 printf("\tbypass mode = %s\n", modes[bypass_mode]);
2984 /* Display the bypass timeout.*/
2985 if (!RTE_BYPASS_TMT_VALID(timeout))
2986 timeout = RTE_BYPASS_TMT_OFF;
2988 printf("\tbypass timeout = %s\n", timeouts[timeout]);
2990 /* Display the bypass events and associated modes. */
2991 for (i = RTE_BYPASS_EVENT_START; i < num_events; i++) {
2993 if (0 != rte_eth_dev_bypass_event_show(port_id, i, &event_mode)) {
2994 printf("\tFailed to get bypass mode for event = %s\n",
2997 if (!RTE_BYPASS_MODE_VALID(event_mode))
2998 event_mode = RTE_BYPASS_MODE_NONE;
3000 printf("\tbypass event: %-16s = %s\n", events[i],
3006 cmdline_parse_token_string_t cmd_showbypass_config_show =
3007 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3009 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
3010 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3012 cmdline_parse_token_string_t cmd_showbypass_config_config =
3013 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
3015 cmdline_parse_token_num_t cmd_showbypass_config_port =
3016 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
3019 cmdline_parse_inst_t cmd_show_bypass_config = {
3020 .f = cmd_show_bypass_config_parsed,
3021 .help_str = "show bypass config (port_id): "
3022 "Show the NIC bypass config for port_id",
3025 (void *)&cmd_showbypass_config_show,
3026 (void *)&cmd_showbypass_config_bypass,
3027 (void *)&cmd_showbypass_config_config,
3028 (void *)&cmd_showbypass_config_port,
3034 /* *** SET FORWARDING MODE *** */
3035 struct cmd_set_fwd_mode_result {
3036 cmdline_fixed_string_t set;
3037 cmdline_fixed_string_t fwd;
3038 cmdline_fixed_string_t mode;
3041 static void cmd_set_fwd_mode_parsed(void *parsed_result,
3042 __attribute__((unused)) struct cmdline *cl,
3043 __attribute__((unused)) void *data)
3045 struct cmd_set_fwd_mode_result *res = parsed_result;
3047 set_pkt_forwarding_mode(res->mode);
3050 cmdline_parse_token_string_t cmd_setfwd_set =
3051 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
3052 cmdline_parse_token_string_t cmd_setfwd_fwd =
3053 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
3054 cmdline_parse_token_string_t cmd_setfwd_mode =
3055 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
3056 "" /* defined at init */);
3058 cmdline_parse_inst_t cmd_set_fwd_mode = {
3059 .f = cmd_set_fwd_mode_parsed,
3061 .help_str = NULL, /* defined at init */
3063 (void *)&cmd_setfwd_set,
3064 (void *)&cmd_setfwd_fwd,
3065 (void *)&cmd_setfwd_mode,
3070 static void cmd_set_fwd_mode_init(void)
3073 static char token[128];
3074 static char help[256];
3075 cmdline_parse_token_string_t *token_struct;
3077 modes = list_pkt_forwarding_modes();
3078 rte_snprintf(help, sizeof help, "set fwd %s - "
3079 "set packet forwarding mode", modes);
3080 cmd_set_fwd_mode.help_str = help;
3082 /* string token separator is # */
3083 for (c = token; *modes != '\0'; modes++)
3088 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
3089 token_struct->string_data.str = token;
3092 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
3093 struct cmd_set_burst_tx_retry_result {
3094 cmdline_fixed_string_t set;
3095 cmdline_fixed_string_t burst;
3096 cmdline_fixed_string_t tx;
3097 cmdline_fixed_string_t delay;
3099 cmdline_fixed_string_t retry;
3103 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
3104 __attribute__((unused)) struct cmdline *cl,
3105 __attribute__((unused)) void *data)
3107 struct cmd_set_burst_tx_retry_result *res = parsed_result;
3109 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
3110 && !strcmp(res->tx, "tx")) {
3111 if (!strcmp(res->delay, "delay"))
3112 burst_tx_delay_time = res->time;
3113 if (!strcmp(res->retry, "retry"))
3114 burst_tx_retry_num = res->retry_num;
3119 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
3120 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
3121 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
3122 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
3124 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
3125 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
3126 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
3127 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
3128 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
3129 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
3130 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
3131 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
3132 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
3133 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
3135 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
3136 .f = cmd_set_burst_tx_retry_parsed,
3137 .help_str = "set burst tx delay (time_by_useconds) retry (retry_num)",
3139 (void *)&cmd_set_burst_tx_retry_set,
3140 (void *)&cmd_set_burst_tx_retry_burst,
3141 (void *)&cmd_set_burst_tx_retry_tx,
3142 (void *)&cmd_set_burst_tx_retry_delay,
3143 (void *)&cmd_set_burst_tx_retry_time,
3144 (void *)&cmd_set_burst_tx_retry_retry,
3145 (void *)&cmd_set_burst_tx_retry_retry_num,
3150 /* *** SET PROMISC MODE *** */
3151 struct cmd_set_promisc_mode_result {
3152 cmdline_fixed_string_t set;
3153 cmdline_fixed_string_t promisc;
3154 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3155 uint8_t port_num; /* valid if "allports" argument == 0 */
3156 cmdline_fixed_string_t mode;
3159 static void cmd_set_promisc_mode_parsed(void *parsed_result,
3160 __attribute__((unused)) struct cmdline *cl,
3163 struct cmd_set_promisc_mode_result *res = parsed_result;
3167 if (!strcmp(res->mode, "on"))
3174 for (i = 0; i < nb_ports; i++) {
3176 rte_eth_promiscuous_enable(i);
3178 rte_eth_promiscuous_disable(i);
3183 rte_eth_promiscuous_enable(res->port_num);
3185 rte_eth_promiscuous_disable(res->port_num);
3189 cmdline_parse_token_string_t cmd_setpromisc_set =
3190 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
3191 cmdline_parse_token_string_t cmd_setpromisc_promisc =
3192 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
3194 cmdline_parse_token_string_t cmd_setpromisc_portall =
3195 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
3197 cmdline_parse_token_num_t cmd_setpromisc_portnum =
3198 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
3200 cmdline_parse_token_string_t cmd_setpromisc_mode =
3201 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
3204 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
3205 .f = cmd_set_promisc_mode_parsed,
3207 .help_str = "set promisc all on|off: set promisc mode for all ports",
3209 (void *)&cmd_setpromisc_set,
3210 (void *)&cmd_setpromisc_promisc,
3211 (void *)&cmd_setpromisc_portall,
3212 (void *)&cmd_setpromisc_mode,
3217 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
3218 .f = cmd_set_promisc_mode_parsed,
3220 .help_str = "set promisc X on|off: set promisc mode on port X",
3222 (void *)&cmd_setpromisc_set,
3223 (void *)&cmd_setpromisc_promisc,
3224 (void *)&cmd_setpromisc_portnum,
3225 (void *)&cmd_setpromisc_mode,
3230 /* *** SET ALLMULTI MODE *** */
3231 struct cmd_set_allmulti_mode_result {
3232 cmdline_fixed_string_t set;
3233 cmdline_fixed_string_t allmulti;
3234 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
3235 uint8_t port_num; /* valid if "allports" argument == 0 */
3236 cmdline_fixed_string_t mode;
3239 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
3240 __attribute__((unused)) struct cmdline *cl,
3243 struct cmd_set_allmulti_mode_result *res = parsed_result;
3247 if (!strcmp(res->mode, "on"))
3254 for (i = 0; i < nb_ports; i++) {
3256 rte_eth_allmulticast_enable(i);
3258 rte_eth_allmulticast_disable(i);
3263 rte_eth_allmulticast_enable(res->port_num);
3265 rte_eth_allmulticast_disable(res->port_num);
3269 cmdline_parse_token_string_t cmd_setallmulti_set =
3270 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
3271 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
3272 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
3274 cmdline_parse_token_string_t cmd_setallmulti_portall =
3275 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
3277 cmdline_parse_token_num_t cmd_setallmulti_portnum =
3278 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
3280 cmdline_parse_token_string_t cmd_setallmulti_mode =
3281 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
3284 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
3285 .f = cmd_set_allmulti_mode_parsed,
3287 .help_str = "set allmulti all on|off: set allmulti mode for all ports",
3289 (void *)&cmd_setallmulti_set,
3290 (void *)&cmd_setallmulti_allmulti,
3291 (void *)&cmd_setallmulti_portall,
3292 (void *)&cmd_setallmulti_mode,
3297 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
3298 .f = cmd_set_allmulti_mode_parsed,
3300 .help_str = "set allmulti X on|off: set allmulti mode on port X",
3302 (void *)&cmd_setallmulti_set,
3303 (void *)&cmd_setallmulti_allmulti,
3304 (void *)&cmd_setallmulti_portnum,
3305 (void *)&cmd_setallmulti_mode,
3310 /* *** ADD/REMOVE A PKT FILTER *** */
3311 struct cmd_pkt_filter_result {
3312 cmdline_fixed_string_t pkt_filter;
3314 cmdline_fixed_string_t protocol;
3315 cmdline_fixed_string_t src;
3316 cmdline_ipaddr_t ip_src;
3318 cmdline_fixed_string_t dst;
3319 cmdline_ipaddr_t ip_dst;
3321 cmdline_fixed_string_t flexbytes;
3322 uint16_t flexbytes_value;
3323 cmdline_fixed_string_t vlan;
3325 cmdline_fixed_string_t queue;
3327 cmdline_fixed_string_t soft;
3332 cmd_pkt_filter_parsed(void *parsed_result,
3333 __attribute__((unused)) struct cmdline *cl,
3334 __attribute__((unused)) void *data)
3336 struct rte_fdir_filter fdir_filter;
3337 struct cmd_pkt_filter_result *res = parsed_result;
3339 memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
3341 if (res->ip_src.family == AF_INET)
3342 fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
3344 memcpy(&(fdir_filter.ip_src.ipv6_addr),
3345 &(res->ip_src.addr.ipv6),
3346 sizeof(struct in6_addr));
3348 if (res->ip_dst.family == AF_INET)
3349 fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
3351 memcpy(&(fdir_filter.ip_dst.ipv6_addr),
3352 &(res->ip_dst.addr.ipv6),
3353 sizeof(struct in6_addr));
3355 fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
3356 fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
3358 if (!strcmp(res->protocol, "udp"))
3359 fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
3360 else if (!strcmp(res->protocol, "tcp"))
3361 fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
3362 else if (!strcmp(res->protocol, "sctp"))
3363 fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
3364 else /* default only IP */
3365 fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
3367 if (res->ip_dst.family == AF_INET6)
3368 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
3370 fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
3372 fdir_filter.vlan_id = rte_cpu_to_be_16(res->vlan_id);
3373 fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
3375 if (!strcmp(res->pkt_filter, "add_signature_filter"))
3376 fdir_add_signature_filter(res->port_id, res->queue_id,
3378 else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
3379 fdir_update_signature_filter(res->port_id, res->queue_id,
3381 else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
3382 fdir_remove_signature_filter(res->port_id, &fdir_filter);
3383 else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
3384 fdir_add_perfect_filter(res->port_id, res->soft_id,
3386 (uint8_t) (res->queue_id < 0),
3388 else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
3389 fdir_update_perfect_filter(res->port_id, res->soft_id,
3391 (uint8_t) (res->queue_id < 0),
3393 else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
3394 fdir_remove_perfect_filter(res->port_id, res->soft_id,
3400 cmdline_parse_token_num_t cmd_pkt_filter_port_id =
3401 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3403 cmdline_parse_token_string_t cmd_pkt_filter_protocol =
3404 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3405 protocol, "ip#tcp#udp#sctp");
3406 cmdline_parse_token_string_t cmd_pkt_filter_src =
3407 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3409 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
3410 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3412 cmdline_parse_token_num_t cmd_pkt_filter_port_src =
3413 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3415 cmdline_parse_token_string_t cmd_pkt_filter_dst =
3416 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3418 cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
3419 TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
3421 cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
3422 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3424 cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
3425 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3426 flexbytes, "flexbytes");
3427 cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
3428 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3429 flexbytes_value, UINT16);
3430 cmdline_parse_token_string_t cmd_pkt_filter_vlan =
3431 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3433 cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
3434 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3436 cmdline_parse_token_string_t cmd_pkt_filter_queue =
3437 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3439 cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
3440 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3442 cmdline_parse_token_string_t cmd_pkt_filter_soft =
3443 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3445 cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
3446 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
3450 cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
3451 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3452 pkt_filter, "add_signature_filter");
3453 cmdline_parse_inst_t cmd_add_signature_filter = {
3454 .f = cmd_pkt_filter_parsed,
3456 .help_str = "add a signature filter",
3458 (void *)&cmd_pkt_filter_add_signature_filter,
3459 (void *)&cmd_pkt_filter_port_id,
3460 (void *)&cmd_pkt_filter_protocol,
3461 (void *)&cmd_pkt_filter_src,
3462 (void *)&cmd_pkt_filter_ip_src,
3463 (void *)&cmd_pkt_filter_port_src,
3464 (void *)&cmd_pkt_filter_dst,
3465 (void *)&cmd_pkt_filter_ip_dst,
3466 (void *)&cmd_pkt_filter_port_dst,
3467 (void *)&cmd_pkt_filter_flexbytes,
3468 (void *)&cmd_pkt_filter_flexbytes_value,
3469 (void *)&cmd_pkt_filter_vlan,
3470 (void *)&cmd_pkt_filter_vlan_id,
3471 (void *)&cmd_pkt_filter_queue,
3472 (void *)&cmd_pkt_filter_queue_id,
3478 cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
3479 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3480 pkt_filter, "upd_signature_filter");
3481 cmdline_parse_inst_t cmd_upd_signature_filter = {
3482 .f = cmd_pkt_filter_parsed,
3484 .help_str = "update a signature filter",
3486 (void *)&cmd_pkt_filter_upd_signature_filter,
3487 (void *)&cmd_pkt_filter_port_id,
3488 (void *)&cmd_pkt_filter_protocol,
3489 (void *)&cmd_pkt_filter_src,
3490 (void *)&cmd_pkt_filter_ip_src,
3491 (void *)&cmd_pkt_filter_port_src,
3492 (void *)&cmd_pkt_filter_dst,
3493 (void *)&cmd_pkt_filter_ip_dst,
3494 (void *)&cmd_pkt_filter_port_dst,
3495 (void *)&cmd_pkt_filter_flexbytes,
3496 (void *)&cmd_pkt_filter_flexbytes_value,
3497 (void *)&cmd_pkt_filter_vlan,
3498 (void *)&cmd_pkt_filter_vlan_id,
3499 (void *)&cmd_pkt_filter_queue,
3500 (void *)&cmd_pkt_filter_queue_id,
3506 cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
3507 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3508 pkt_filter, "rm_signature_filter");
3509 cmdline_parse_inst_t cmd_rm_signature_filter = {
3510 .f = cmd_pkt_filter_parsed,
3512 .help_str = "remove a signature filter",
3514 (void *)&cmd_pkt_filter_rm_signature_filter,
3515 (void *)&cmd_pkt_filter_port_id,
3516 (void *)&cmd_pkt_filter_protocol,
3517 (void *)&cmd_pkt_filter_src,
3518 (void *)&cmd_pkt_filter_ip_src,
3519 (void *)&cmd_pkt_filter_port_src,
3520 (void *)&cmd_pkt_filter_dst,
3521 (void *)&cmd_pkt_filter_ip_dst,
3522 (void *)&cmd_pkt_filter_port_dst,
3523 (void *)&cmd_pkt_filter_flexbytes,
3524 (void *)&cmd_pkt_filter_flexbytes_value,
3525 (void *)&cmd_pkt_filter_vlan,
3526 (void *)&cmd_pkt_filter_vlan_id,
3532 cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
3533 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3534 pkt_filter, "add_perfect_filter");
3535 cmdline_parse_inst_t cmd_add_perfect_filter = {
3536 .f = cmd_pkt_filter_parsed,
3538 .help_str = "add a perfect filter",
3540 (void *)&cmd_pkt_filter_add_perfect_filter,
3541 (void *)&cmd_pkt_filter_port_id,
3542 (void *)&cmd_pkt_filter_protocol,
3543 (void *)&cmd_pkt_filter_src,
3544 (void *)&cmd_pkt_filter_ip_src,
3545 (void *)&cmd_pkt_filter_port_src,
3546 (void *)&cmd_pkt_filter_dst,
3547 (void *)&cmd_pkt_filter_ip_dst,
3548 (void *)&cmd_pkt_filter_port_dst,
3549 (void *)&cmd_pkt_filter_flexbytes,
3550 (void *)&cmd_pkt_filter_flexbytes_value,
3551 (void *)&cmd_pkt_filter_vlan,
3552 (void *)&cmd_pkt_filter_vlan_id,
3553 (void *)&cmd_pkt_filter_queue,
3554 (void *)&cmd_pkt_filter_queue_id,
3555 (void *)&cmd_pkt_filter_soft,
3556 (void *)&cmd_pkt_filter_soft_id,
3562 cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
3563 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3564 pkt_filter, "upd_perfect_filter");
3565 cmdline_parse_inst_t cmd_upd_perfect_filter = {
3566 .f = cmd_pkt_filter_parsed,
3568 .help_str = "update a perfect filter",
3570 (void *)&cmd_pkt_filter_upd_perfect_filter,
3571 (void *)&cmd_pkt_filter_port_id,
3572 (void *)&cmd_pkt_filter_protocol,
3573 (void *)&cmd_pkt_filter_src,
3574 (void *)&cmd_pkt_filter_ip_src,
3575 (void *)&cmd_pkt_filter_port_src,
3576 (void *)&cmd_pkt_filter_dst,
3577 (void *)&cmd_pkt_filter_ip_dst,
3578 (void *)&cmd_pkt_filter_port_dst,
3579 (void *)&cmd_pkt_filter_flexbytes,
3580 (void *)&cmd_pkt_filter_flexbytes_value,
3581 (void *)&cmd_pkt_filter_vlan,
3582 (void *)&cmd_pkt_filter_vlan_id,
3583 (void *)&cmd_pkt_filter_queue,
3584 (void *)&cmd_pkt_filter_queue_id,
3585 (void *)&cmd_pkt_filter_soft,
3586 (void *)&cmd_pkt_filter_soft_id,
3592 cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
3593 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
3594 pkt_filter, "rm_perfect_filter");
3595 cmdline_parse_inst_t cmd_rm_perfect_filter = {
3596 .f = cmd_pkt_filter_parsed,
3598 .help_str = "remove a perfect filter",
3600 (void *)&cmd_pkt_filter_rm_perfect_filter,
3601 (void *)&cmd_pkt_filter_port_id,
3602 (void *)&cmd_pkt_filter_protocol,
3603 (void *)&cmd_pkt_filter_src,
3604 (void *)&cmd_pkt_filter_ip_src,
3605 (void *)&cmd_pkt_filter_port_src,
3606 (void *)&cmd_pkt_filter_dst,
3607 (void *)&cmd_pkt_filter_ip_dst,
3608 (void *)&cmd_pkt_filter_port_dst,
3609 (void *)&cmd_pkt_filter_flexbytes,
3610 (void *)&cmd_pkt_filter_flexbytes_value,
3611 (void *)&cmd_pkt_filter_vlan,
3612 (void *)&cmd_pkt_filter_vlan_id,
3613 (void *)&cmd_pkt_filter_soft,
3614 (void *)&cmd_pkt_filter_soft_id,
3619 /* *** SETUP MASKS FILTER *** */
3620 struct cmd_pkt_filter_masks_result {
3621 cmdline_fixed_string_t filter_mask;
3623 cmdline_fixed_string_t src_mask;
3624 uint32_t ip_src_mask;
3625 uint16_t ipv6_src_mask;
3626 uint16_t port_src_mask;
3627 cmdline_fixed_string_t dst_mask;
3628 uint32_t ip_dst_mask;
3629 uint16_t ipv6_dst_mask;
3630 uint16_t port_dst_mask;
3631 cmdline_fixed_string_t flexbytes;
3632 uint8_t flexbytes_value;
3633 cmdline_fixed_string_t vlan_id;
3634 uint8_t vlan_id_value;
3635 cmdline_fixed_string_t vlan_prio;
3636 uint8_t vlan_prio_value;
3637 cmdline_fixed_string_t only_ip_flow;
3638 uint8_t only_ip_flow_value;
3639 cmdline_fixed_string_t comp_ipv6_dst;
3640 uint8_t comp_ipv6_dst_value;
3644 cmd_pkt_filter_masks_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3648 struct rte_fdir_masks fdir_masks;
3649 struct cmd_pkt_filter_masks_result *res = parsed_result;
3651 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3653 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3654 fdir_masks.vlan_id = res->vlan_id_value;
3655 fdir_masks.vlan_prio = res->vlan_prio_value;
3656 fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
3657 fdir_masks.src_ipv4_mask = res->ip_src_mask;
3658 fdir_masks.src_port_mask = res->port_src_mask;
3659 fdir_masks.dst_port_mask = res->port_dst_mask;
3660 fdir_masks.flexbytes = res->flexbytes_value;
3662 fdir_set_masks(res->port_id, &fdir_masks);
3665 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
3666 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3667 filter_mask, "set_masks_filter");
3668 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
3669 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3671 cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
3672 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3673 only_ip_flow, "only_ip_flow");
3674 cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
3675 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3676 only_ip_flow_value, UINT8);
3677 cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
3678 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3679 src_mask, "src_mask");
3680 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
3681 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3682 ip_src_mask, UINT32);
3683 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
3684 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3685 port_src_mask, UINT16);
3686 cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
3687 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3688 dst_mask, "dst_mask");
3689 cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
3690 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3691 ip_dst_mask, UINT32);
3692 cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
3693 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3694 port_dst_mask, UINT16);
3695 cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
3696 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3697 flexbytes, "flexbytes");
3698 cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
3699 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3700 flexbytes_value, UINT8);
3701 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
3702 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3703 vlan_id, "vlan_id");
3704 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
3705 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3706 vlan_id_value, UINT8);
3707 cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
3708 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3709 vlan_prio, "vlan_prio");
3710 cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
3711 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3712 vlan_prio_value, UINT8);
3714 cmdline_parse_inst_t cmd_set_masks_filter = {
3715 .f = cmd_pkt_filter_masks_parsed,
3717 .help_str = "setup masks filter",
3719 (void *)&cmd_pkt_filter_masks_filter_mask,
3720 (void *)&cmd_pkt_filter_masks_port_id,
3721 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3722 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3723 (void *)&cmd_pkt_filter_masks_src_mask,
3724 (void *)&cmd_pkt_filter_masks_ip_src_mask,
3725 (void *)&cmd_pkt_filter_masks_port_src_mask,
3726 (void *)&cmd_pkt_filter_masks_dst_mask,
3727 (void *)&cmd_pkt_filter_masks_ip_dst_mask,
3728 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3729 (void *)&cmd_pkt_filter_masks_flexbytes,
3730 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3731 (void *)&cmd_pkt_filter_masks_vlan_id,
3732 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3733 (void *)&cmd_pkt_filter_masks_vlan_prio,
3734 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3740 cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
3741 __attribute__((unused)) struct cmdline *cl,
3742 __attribute__((unused)) void *data)
3744 struct rte_fdir_masks fdir_masks;
3745 struct cmd_pkt_filter_masks_result *res = parsed_result;
3747 memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
3749 fdir_masks.set_ipv6_mask = 1;
3750 fdir_masks.only_ip_flow = res->only_ip_flow_value;
3751 fdir_masks.vlan_id = res->vlan_id_value;
3752 fdir_masks.vlan_prio = res->vlan_prio_value;
3753 fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
3754 fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
3755 fdir_masks.src_port_mask = res->port_src_mask;
3756 fdir_masks.dst_port_mask = res->port_dst_mask;
3757 fdir_masks.flexbytes = res->flexbytes_value;
3758 fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
3760 fdir_set_masks(res->port_id, &fdir_masks);
3763 cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
3764 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3765 filter_mask, "set_ipv6_masks_filter");
3766 cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
3767 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3768 ipv6_src_mask, UINT16);
3769 cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
3770 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3771 ipv6_dst_mask, UINT16);
3773 cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
3774 TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
3775 comp_ipv6_dst, "compare_dst");
3776 cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
3777 TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
3778 comp_ipv6_dst_value, UINT8);
3780 cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
3781 .f = cmd_pkt_filter_masks_ipv6_parsed,
3783 .help_str = "setup ipv6 masks filter",
3785 (void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
3786 (void *)&cmd_pkt_filter_masks_port_id,
3787 (void *)&cmd_pkt_filter_masks_only_ip_flow,
3788 (void *)&cmd_pkt_filter_masks_only_ip_flow_value,
3789 (void *)&cmd_pkt_filter_masks_src_mask,
3790 (void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
3791 (void *)&cmd_pkt_filter_masks_port_src_mask,
3792 (void *)&cmd_pkt_filter_masks_dst_mask,
3793 (void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
3794 (void *)&cmd_pkt_filter_masks_port_dst_mask,
3795 (void *)&cmd_pkt_filter_masks_flexbytes,
3796 (void *)&cmd_pkt_filter_masks_flexbytes_value,
3797 (void *)&cmd_pkt_filter_masks_vlan_id,
3798 (void *)&cmd_pkt_filter_masks_vlan_id_value,
3799 (void *)&cmd_pkt_filter_masks_vlan_prio,
3800 (void *)&cmd_pkt_filter_masks_vlan_prio_value,
3801 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
3802 (void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
3807 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
3808 struct cmd_link_flow_ctrl_set_result {
3809 cmdline_fixed_string_t set;
3810 cmdline_fixed_string_t flow_ctrl;
3811 cmdline_fixed_string_t rx;
3812 cmdline_fixed_string_t rx_lfc_mode;
3813 cmdline_fixed_string_t tx;
3814 cmdline_fixed_string_t tx_lfc_mode;
3815 cmdline_fixed_string_t mac_ctrl_frame_fwd;
3816 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
3817 uint32_t high_water;
3819 uint16_t pause_time;
3825 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3826 __attribute__((unused)) struct cmdline *cl,
3827 __attribute__((unused)) void *data)
3829 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3830 struct rte_eth_fc_conf fc_conf;
3831 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3835 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3836 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3837 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3838 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3840 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3841 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3844 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3845 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3846 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3848 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3849 fc_conf.high_water = res->high_water;
3850 fc_conf.low_water = res->low_water;
3851 fc_conf.pause_time = res->pause_time;
3852 fc_conf.send_xon = res->send_xon;
3853 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3855 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3857 printf("bad flow contrl parameter, return code = %d \n", ret);
3860 cmdline_parse_token_string_t cmd_lfc_set_set =
3861 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3863 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3864 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3865 flow_ctrl, "flow_ctrl");
3866 cmdline_parse_token_string_t cmd_lfc_set_rx =
3867 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3869 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3870 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3871 rx_lfc_mode, "on#off");
3872 cmdline_parse_token_string_t cmd_lfc_set_tx =
3873 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3875 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3876 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3877 tx_lfc_mode, "on#off");
3878 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3879 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3880 high_water, UINT32);
3881 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3882 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3884 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3885 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3886 pause_time, UINT16);
3887 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3888 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3890 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3891 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3892 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3893 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3895 mac_ctrl_frame_fwd_mode, "on#off");
3896 cmdline_parse_token_num_t cmd_lfc_set_portid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3900 cmdline_parse_inst_t cmd_link_flow_control_set = {
3901 .f = cmd_link_flow_ctrl_set_parsed,
3903 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3904 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3907 (void *)&cmd_lfc_set_set,
3908 (void *)&cmd_lfc_set_flow_ctrl,
3909 (void *)&cmd_lfc_set_rx,
3910 (void *)&cmd_lfc_set_rx_mode,
3911 (void *)&cmd_lfc_set_tx,
3912 (void *)&cmd_lfc_set_tx_mode,
3913 (void *)&cmd_lfc_set_high_water,
3914 (void *)&cmd_lfc_set_low_water,
3915 (void *)&cmd_lfc_set_pause_time,
3916 (void *)&cmd_lfc_set_send_xon,
3917 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3918 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3919 (void *)&cmd_lfc_set_portid,
3924 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3925 struct cmd_priority_flow_ctrl_set_result {
3926 cmdline_fixed_string_t set;
3927 cmdline_fixed_string_t pfc_ctrl;
3928 cmdline_fixed_string_t rx;
3929 cmdline_fixed_string_t rx_pfc_mode;
3930 cmdline_fixed_string_t tx;
3931 cmdline_fixed_string_t tx_pfc_mode;
3932 uint32_t high_water;
3934 uint16_t pause_time;
3940 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3941 __attribute__((unused)) struct cmdline *cl,
3942 __attribute__((unused)) void *data)
3944 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3945 struct rte_eth_pfc_conf pfc_conf;
3946 int rx_fc_enable, tx_fc_enable;
3950 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3951 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3952 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3953 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3955 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3956 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3959 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3960 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3961 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3962 pfc_conf.fc.high_water = res->high_water;
3963 pfc_conf.fc.low_water = res->low_water;
3964 pfc_conf.fc.pause_time = res->pause_time;
3965 pfc_conf.priority = res->priority;
3967 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3969 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3972 cmdline_parse_token_string_t cmd_pfc_set_set =
3973 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3975 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3976 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3977 pfc_ctrl, "pfc_ctrl");
3978 cmdline_parse_token_string_t cmd_pfc_set_rx =
3979 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3981 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3982 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3983 rx_pfc_mode, "on#off");
3984 cmdline_parse_token_string_t cmd_pfc_set_tx =
3985 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3987 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3988 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3989 tx_pfc_mode, "on#off");
3990 cmdline_parse_token_num_t cmd_pfc_set_high_water =
3991 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3992 high_water, UINT32);
3993 cmdline_parse_token_num_t cmd_pfc_set_low_water =
3994 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3996 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
3997 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3998 pause_time, UINT16);
3999 cmdline_parse_token_num_t cmd_pfc_set_priority =
4000 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4002 cmdline_parse_token_num_t cmd_pfc_set_portid =
4003 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4006 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4007 .f = cmd_priority_flow_ctrl_set_parsed,
4009 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4010 tx on|off high_water low_water pause_time priority port_id",
4012 (void *)&cmd_pfc_set_set,
4013 (void *)&cmd_pfc_set_flow_ctrl,
4014 (void *)&cmd_pfc_set_rx,
4015 (void *)&cmd_pfc_set_rx_mode,
4016 (void *)&cmd_pfc_set_tx,
4017 (void *)&cmd_pfc_set_tx_mode,
4018 (void *)&cmd_pfc_set_high_water,
4019 (void *)&cmd_pfc_set_low_water,
4020 (void *)&cmd_pfc_set_pause_time,
4021 (void *)&cmd_pfc_set_priority,
4022 (void *)&cmd_pfc_set_portid,
4027 /* *** RESET CONFIGURATION *** */
4028 struct cmd_reset_result {
4029 cmdline_fixed_string_t reset;
4030 cmdline_fixed_string_t def;
4033 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4035 __attribute__((unused)) void *data)
4037 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4038 set_def_fwd_config();
4041 cmdline_parse_token_string_t cmd_reset_set =
4042 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4043 cmdline_parse_token_string_t cmd_reset_def =
4044 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4047 cmdline_parse_inst_t cmd_reset = {
4048 .f = cmd_reset_parsed,
4050 .help_str = "set default: reset default forwarding configuration",
4052 (void *)&cmd_reset_set,
4053 (void *)&cmd_reset_def,
4058 /* *** START FORWARDING *** */
4059 struct cmd_start_result {
4060 cmdline_fixed_string_t start;
4063 cmdline_parse_token_string_t cmd_start_start =
4064 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4066 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4067 __attribute__((unused)) struct cmdline *cl,
4068 __attribute__((unused)) void *data)
4070 start_packet_forwarding(0);
4073 cmdline_parse_inst_t cmd_start = {
4074 .f = cmd_start_parsed,
4076 .help_str = "start packet forwarding",
4078 (void *)&cmd_start_start,
4083 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4084 struct cmd_start_tx_first_result {
4085 cmdline_fixed_string_t start;
4086 cmdline_fixed_string_t tx_first;
4090 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 start_packet_forwarding(1);
4097 cmdline_parse_token_string_t cmd_start_tx_first_start =
4098 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4100 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4101 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4102 tx_first, "tx_first");
4104 cmdline_parse_inst_t cmd_start_tx_first = {
4105 .f = cmd_start_tx_first_parsed,
4107 .help_str = "start packet forwarding, after sending 1 burst of packets",
4109 (void *)&cmd_start_tx_first_start,
4110 (void *)&cmd_start_tx_first_tx_first,
4115 /* *** SET LINK UP *** */
4116 struct cmd_set_link_up_result {
4117 cmdline_fixed_string_t set;
4118 cmdline_fixed_string_t link_up;
4119 cmdline_fixed_string_t port;
4123 cmdline_parse_token_string_t cmd_set_link_up_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4125 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4126 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4128 cmdline_parse_token_string_t cmd_set_link_up_port =
4129 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4130 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4131 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4133 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4134 __attribute__((unused)) struct cmdline *cl,
4135 __attribute__((unused)) void *data)
4137 struct cmd_set_link_up_result *res = parsed_result;
4138 dev_set_link_up(res->port_id);
4141 cmdline_parse_inst_t cmd_set_link_up = {
4142 .f = cmd_set_link_up_parsed,
4144 .help_str = "set link-up port (port id)",
4146 (void *)&cmd_set_link_up_set,
4147 (void *)&cmd_set_link_up_link_up,
4148 (void *)&cmd_set_link_up_port,
4149 (void *)&cmd_set_link_up_port_id,
4154 /* *** SET LINK DOWN *** */
4155 struct cmd_set_link_down_result {
4156 cmdline_fixed_string_t set;
4157 cmdline_fixed_string_t link_down;
4158 cmdline_fixed_string_t port;
4162 cmdline_parse_token_string_t cmd_set_link_down_set =
4163 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4164 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4165 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4167 cmdline_parse_token_string_t cmd_set_link_down_port =
4168 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4169 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4170 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4172 static void cmd_set_link_down_parsed(
4173 __attribute__((unused)) void *parsed_result,
4174 __attribute__((unused)) struct cmdline *cl,
4175 __attribute__((unused)) void *data)
4177 struct cmd_set_link_down_result *res = parsed_result;
4178 dev_set_link_down(res->port_id);
4181 cmdline_parse_inst_t cmd_set_link_down = {
4182 .f = cmd_set_link_down_parsed,
4184 .help_str = "set link-down port (port id)",
4186 (void *)&cmd_set_link_down_set,
4187 (void *)&cmd_set_link_down_link_down,
4188 (void *)&cmd_set_link_down_port,
4189 (void *)&cmd_set_link_down_port_id,
4194 /* *** SHOW CFG *** */
4195 struct cmd_showcfg_result {
4196 cmdline_fixed_string_t show;
4197 cmdline_fixed_string_t cfg;
4198 cmdline_fixed_string_t what;
4201 static void cmd_showcfg_parsed(void *parsed_result,
4202 __attribute__((unused)) struct cmdline *cl,
4203 __attribute__((unused)) void *data)
4205 struct cmd_showcfg_result *res = parsed_result;
4206 if (!strcmp(res->what, "rxtx"))
4207 rxtx_config_display();
4208 else if (!strcmp(res->what, "cores"))
4209 fwd_lcores_config_display();
4210 else if (!strcmp(res->what, "fwd"))
4211 fwd_config_display();
4214 cmdline_parse_token_string_t cmd_showcfg_show =
4215 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4216 cmdline_parse_token_string_t cmd_showcfg_port =
4217 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4218 cmdline_parse_token_string_t cmd_showcfg_what =
4219 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4222 cmdline_parse_inst_t cmd_showcfg = {
4223 .f = cmd_showcfg_parsed,
4225 .help_str = "show config rxtx|cores|fwd",
4227 (void *)&cmd_showcfg_show,
4228 (void *)&cmd_showcfg_port,
4229 (void *)&cmd_showcfg_what,
4234 /* *** SHOW ALL PORT INFO *** */
4235 struct cmd_showportall_result {
4236 cmdline_fixed_string_t show;
4237 cmdline_fixed_string_t port;
4238 cmdline_fixed_string_t what;
4239 cmdline_fixed_string_t all;
4242 static void cmd_showportall_parsed(void *parsed_result,
4243 __attribute__((unused)) struct cmdline *cl,
4244 __attribute__((unused)) void *data)
4248 struct cmd_showportall_result *res = parsed_result;
4249 if (!strcmp(res->show, "clear")) {
4250 if (!strcmp(res->what, "stats"))
4251 for (i = 0; i < nb_ports; i++)
4253 } else if (!strcmp(res->what, "info"))
4254 for (i = 0; i < nb_ports; i++)
4255 port_infos_display(i);
4256 else if (!strcmp(res->what, "stats"))
4257 for (i = 0; i < nb_ports; i++)
4258 nic_stats_display(i);
4259 else if (!strcmp(res->what, "fdir"))
4260 for (i = 0; i < nb_ports; i++)
4262 else if (!strcmp(res->what, "stat_qmap"))
4263 for (i = 0; i < nb_ports; i++)
4264 nic_stats_mapping_display(i);
4267 cmdline_parse_token_string_t cmd_showportall_show =
4268 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4270 cmdline_parse_token_string_t cmd_showportall_port =
4271 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4272 cmdline_parse_token_string_t cmd_showportall_what =
4273 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4274 "info#stats#fdir#stat_qmap");
4275 cmdline_parse_token_string_t cmd_showportall_all =
4276 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4277 cmdline_parse_inst_t cmd_showportall = {
4278 .f = cmd_showportall_parsed,
4280 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4282 (void *)&cmd_showportall_show,
4283 (void *)&cmd_showportall_port,
4284 (void *)&cmd_showportall_what,
4285 (void *)&cmd_showportall_all,
4290 /* *** SHOW PORT INFO *** */
4291 struct cmd_showport_result {
4292 cmdline_fixed_string_t show;
4293 cmdline_fixed_string_t port;
4294 cmdline_fixed_string_t what;
4298 static void cmd_showport_parsed(void *parsed_result,
4299 __attribute__((unused)) struct cmdline *cl,
4300 __attribute__((unused)) void *data)
4302 struct cmd_showport_result *res = parsed_result;
4303 if (!strcmp(res->show, "clear")) {
4304 if (!strcmp(res->what, "stats"))
4305 nic_stats_clear(res->portnum);
4306 } else if (!strcmp(res->what, "info"))
4307 port_infos_display(res->portnum);
4308 else if (!strcmp(res->what, "stats"))
4309 nic_stats_display(res->portnum);
4310 else if (!strcmp(res->what, "fdir"))
4311 fdir_get_infos(res->portnum);
4312 else if (!strcmp(res->what, "stat_qmap"))
4313 nic_stats_mapping_display(res->portnum);
4316 cmdline_parse_token_string_t cmd_showport_show =
4317 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4319 cmdline_parse_token_string_t cmd_showport_port =
4320 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4321 cmdline_parse_token_string_t cmd_showport_what =
4322 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4323 "info#stats#fdir#stat_qmap");
4324 cmdline_parse_token_num_t cmd_showport_portnum =
4325 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4327 cmdline_parse_inst_t cmd_showport = {
4328 .f = cmd_showport_parsed,
4330 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4332 (void *)&cmd_showport_show,
4333 (void *)&cmd_showport_port,
4334 (void *)&cmd_showport_what,
4335 (void *)&cmd_showport_portnum,
4340 /* *** READ PORT REGISTER *** */
4341 struct cmd_read_reg_result {
4342 cmdline_fixed_string_t read;
4343 cmdline_fixed_string_t reg;
4349 cmd_read_reg_parsed(void *parsed_result,
4350 __attribute__((unused)) struct cmdline *cl,
4351 __attribute__((unused)) void *data)
4353 struct cmd_read_reg_result *res = parsed_result;
4354 port_reg_display(res->port_id, res->reg_off);
4357 cmdline_parse_token_string_t cmd_read_reg_read =
4358 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4359 cmdline_parse_token_string_t cmd_read_reg_reg =
4360 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4361 cmdline_parse_token_num_t cmd_read_reg_port_id =
4362 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4363 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4364 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4366 cmdline_parse_inst_t cmd_read_reg = {
4367 .f = cmd_read_reg_parsed,
4369 .help_str = "read reg port_id reg_off",
4371 (void *)&cmd_read_reg_read,
4372 (void *)&cmd_read_reg_reg,
4373 (void *)&cmd_read_reg_port_id,
4374 (void *)&cmd_read_reg_reg_off,
4379 /* *** READ PORT REGISTER BIT FIELD *** */
4380 struct cmd_read_reg_bit_field_result {
4381 cmdline_fixed_string_t read;
4382 cmdline_fixed_string_t regfield;
4390 cmd_read_reg_bit_field_parsed(void *parsed_result,
4391 __attribute__((unused)) struct cmdline *cl,
4392 __attribute__((unused)) void *data)
4394 struct cmd_read_reg_bit_field_result *res = parsed_result;
4395 port_reg_bit_field_display(res->port_id, res->reg_off,
4396 res->bit1_pos, res->bit2_pos);
4399 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4400 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4402 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4404 regfield, "regfield");
4405 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4406 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4408 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4409 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4411 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4412 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4414 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4418 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4419 .f = cmd_read_reg_bit_field_parsed,
4421 .help_str = "read regfield port_id reg_off bit_x bit_y "
4422 "(read register bit field between bit_x and bit_y included)",
4424 (void *)&cmd_read_reg_bit_field_read,
4425 (void *)&cmd_read_reg_bit_field_regfield,
4426 (void *)&cmd_read_reg_bit_field_port_id,
4427 (void *)&cmd_read_reg_bit_field_reg_off,
4428 (void *)&cmd_read_reg_bit_field_bit1_pos,
4429 (void *)&cmd_read_reg_bit_field_bit2_pos,
4434 /* *** READ PORT REGISTER BIT *** */
4435 struct cmd_read_reg_bit_result {
4436 cmdline_fixed_string_t read;
4437 cmdline_fixed_string_t regbit;
4444 cmd_read_reg_bit_parsed(void *parsed_result,
4445 __attribute__((unused)) struct cmdline *cl,
4446 __attribute__((unused)) void *data)
4448 struct cmd_read_reg_bit_result *res = parsed_result;
4449 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4452 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4453 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4454 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4455 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4457 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4459 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4461 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4462 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4464 cmdline_parse_inst_t cmd_read_reg_bit = {
4465 .f = cmd_read_reg_bit_parsed,
4467 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4469 (void *)&cmd_read_reg_bit_read,
4470 (void *)&cmd_read_reg_bit_regbit,
4471 (void *)&cmd_read_reg_bit_port_id,
4472 (void *)&cmd_read_reg_bit_reg_off,
4473 (void *)&cmd_read_reg_bit_bit_pos,
4478 /* *** WRITE PORT REGISTER *** */
4479 struct cmd_write_reg_result {
4480 cmdline_fixed_string_t write;
4481 cmdline_fixed_string_t reg;
4488 cmd_write_reg_parsed(void *parsed_result,
4489 __attribute__((unused)) struct cmdline *cl,
4490 __attribute__((unused)) void *data)
4492 struct cmd_write_reg_result *res = parsed_result;
4493 port_reg_set(res->port_id, res->reg_off, res->value);
4496 cmdline_parse_token_string_t cmd_write_reg_write =
4497 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4498 cmdline_parse_token_string_t cmd_write_reg_reg =
4499 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4500 cmdline_parse_token_num_t cmd_write_reg_port_id =
4501 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4502 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4503 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4504 cmdline_parse_token_num_t cmd_write_reg_value =
4505 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4507 cmdline_parse_inst_t cmd_write_reg = {
4508 .f = cmd_write_reg_parsed,
4510 .help_str = "write reg port_id reg_off reg_value",
4512 (void *)&cmd_write_reg_write,
4513 (void *)&cmd_write_reg_reg,
4514 (void *)&cmd_write_reg_port_id,
4515 (void *)&cmd_write_reg_reg_off,
4516 (void *)&cmd_write_reg_value,
4521 /* *** WRITE PORT REGISTER BIT FIELD *** */
4522 struct cmd_write_reg_bit_field_result {
4523 cmdline_fixed_string_t write;
4524 cmdline_fixed_string_t regfield;
4533 cmd_write_reg_bit_field_parsed(void *parsed_result,
4534 __attribute__((unused)) struct cmdline *cl,
4535 __attribute__((unused)) void *data)
4537 struct cmd_write_reg_bit_field_result *res = parsed_result;
4538 port_reg_bit_field_set(res->port_id, res->reg_off,
4539 res->bit1_pos, res->bit2_pos, res->value);
4542 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4543 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4545 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4546 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4547 regfield, "regfield");
4548 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4549 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4551 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4552 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4554 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4555 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4557 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4558 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4560 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4561 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4564 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4565 .f = cmd_write_reg_bit_field_parsed,
4567 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4568 "(set register bit field between bit_x and bit_y included)",
4570 (void *)&cmd_write_reg_bit_field_write,
4571 (void *)&cmd_write_reg_bit_field_regfield,
4572 (void *)&cmd_write_reg_bit_field_port_id,
4573 (void *)&cmd_write_reg_bit_field_reg_off,
4574 (void *)&cmd_write_reg_bit_field_bit1_pos,
4575 (void *)&cmd_write_reg_bit_field_bit2_pos,
4576 (void *)&cmd_write_reg_bit_field_value,
4581 /* *** WRITE PORT REGISTER BIT *** */
4582 struct cmd_write_reg_bit_result {
4583 cmdline_fixed_string_t write;
4584 cmdline_fixed_string_t regbit;
4592 cmd_write_reg_bit_parsed(void *parsed_result,
4593 __attribute__((unused)) struct cmdline *cl,
4594 __attribute__((unused)) void *data)
4596 struct cmd_write_reg_bit_result *res = parsed_result;
4597 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4600 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4601 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4603 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4604 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4606 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4607 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4608 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4610 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4611 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4612 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4613 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4615 cmdline_parse_inst_t cmd_write_reg_bit = {
4616 .f = cmd_write_reg_bit_parsed,
4618 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4620 (void *)&cmd_write_reg_bit_write,
4621 (void *)&cmd_write_reg_bit_regbit,
4622 (void *)&cmd_write_reg_bit_port_id,
4623 (void *)&cmd_write_reg_bit_reg_off,
4624 (void *)&cmd_write_reg_bit_bit_pos,
4625 (void *)&cmd_write_reg_bit_value,
4630 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4631 struct cmd_read_rxd_txd_result {
4632 cmdline_fixed_string_t read;
4633 cmdline_fixed_string_t rxd_txd;
4640 cmd_read_rxd_txd_parsed(void *parsed_result,
4641 __attribute__((unused)) struct cmdline *cl,
4642 __attribute__((unused)) void *data)
4644 struct cmd_read_rxd_txd_result *res = parsed_result;
4646 if (!strcmp(res->rxd_txd, "rxd"))
4647 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4648 else if (!strcmp(res->rxd_txd, "txd"))
4649 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4652 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4653 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4654 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4655 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4657 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4658 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4659 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4660 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4661 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4662 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4664 cmdline_parse_inst_t cmd_read_rxd_txd = {
4665 .f = cmd_read_rxd_txd_parsed,
4667 .help_str = "read rxd|txd port_id queue_id rxd_id",
4669 (void *)&cmd_read_rxd_txd_read,
4670 (void *)&cmd_read_rxd_txd_rxd_txd,
4671 (void *)&cmd_read_rxd_txd_port_id,
4672 (void *)&cmd_read_rxd_txd_queue_id,
4673 (void *)&cmd_read_rxd_txd_desc_id,
4679 struct cmd_quit_result {
4680 cmdline_fixed_string_t quit;
4683 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4685 __attribute__((unused)) void *data)
4691 cmdline_parse_token_string_t cmd_quit_quit =
4692 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4694 cmdline_parse_inst_t cmd_quit = {
4695 .f = cmd_quit_parsed,
4697 .help_str = "exit application",
4699 (void *)&cmd_quit_quit,
4704 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4705 struct cmd_mac_addr_result {
4706 cmdline_fixed_string_t mac_addr_cmd;
4707 cmdline_fixed_string_t what;
4709 struct ether_addr address;
4712 static void cmd_mac_addr_parsed(void *parsed_result,
4713 __attribute__((unused)) struct cmdline *cl,
4714 __attribute__((unused)) void *data)
4716 struct cmd_mac_addr_result *res = parsed_result;
4719 if (strcmp(res->what, "add") == 0)
4720 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4722 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4724 /* check the return value and print it if is < 0 */
4726 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4730 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4731 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4733 cmdline_parse_token_string_t cmd_mac_addr_what =
4734 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4736 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4737 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4738 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4739 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4741 cmdline_parse_inst_t cmd_mac_addr = {
4742 .f = cmd_mac_addr_parsed,
4744 .help_str = "mac_addr add|remove X <address>: "
4745 "add/remove MAC address on port X",
4747 (void *)&cmd_mac_addr_cmd,
4748 (void *)&cmd_mac_addr_what,
4749 (void *)&cmd_mac_addr_portnum,
4750 (void *)&cmd_mac_addr_addr,
4756 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4757 struct cmd_set_qmap_result {
4758 cmdline_fixed_string_t set;
4759 cmdline_fixed_string_t qmap;
4760 cmdline_fixed_string_t what;
4767 cmd_set_qmap_parsed(void *parsed_result,
4768 __attribute__((unused)) struct cmdline *cl,
4769 __attribute__((unused)) void *data)
4771 struct cmd_set_qmap_result *res = parsed_result;
4772 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4774 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4777 cmdline_parse_token_string_t cmd_setqmap_set =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4780 cmdline_parse_token_string_t cmd_setqmap_qmap =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4783 cmdline_parse_token_string_t cmd_setqmap_what =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4786 cmdline_parse_token_num_t cmd_setqmap_portid =
4787 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4789 cmdline_parse_token_num_t cmd_setqmap_queueid =
4790 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4792 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4793 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4796 cmdline_parse_inst_t cmd_set_qmap = {
4797 .f = cmd_set_qmap_parsed,
4799 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4801 (void *)&cmd_setqmap_set,
4802 (void *)&cmd_setqmap_qmap,
4803 (void *)&cmd_setqmap_what,
4804 (void *)&cmd_setqmap_portid,
4805 (void *)&cmd_setqmap_queueid,
4806 (void *)&cmd_setqmap_mapvalue,
4811 /* *** CONFIGURE UNICAST HASH TABLE *** */
4812 struct cmd_set_uc_hash_table {
4813 cmdline_fixed_string_t set;
4814 cmdline_fixed_string_t port;
4816 cmdline_fixed_string_t what;
4817 struct ether_addr address;
4818 cmdline_fixed_string_t mode;
4822 cmd_set_uc_hash_parsed(void *parsed_result,
4823 __attribute__((unused)) struct cmdline *cl,
4824 __attribute__((unused)) void *data)
4827 struct cmd_set_uc_hash_table *res = parsed_result;
4829 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4831 if (strcmp(res->what, "uta") == 0)
4832 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4833 &res->address,(uint8_t)is_on);
4835 printf("bad unicast hash table parameter, return code = %d \n", ret);
4839 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4842 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4845 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4846 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4848 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4851 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4852 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4854 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4858 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4859 .f = cmd_set_uc_hash_parsed,
4861 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4863 (void *)&cmd_set_uc_hash_set,
4864 (void *)&cmd_set_uc_hash_port,
4865 (void *)&cmd_set_uc_hash_portid,
4866 (void *)&cmd_set_uc_hash_what,
4867 (void *)&cmd_set_uc_hash_mac,
4868 (void *)&cmd_set_uc_hash_mode,
4873 struct cmd_set_uc_all_hash_table {
4874 cmdline_fixed_string_t set;
4875 cmdline_fixed_string_t port;
4877 cmdline_fixed_string_t what;
4878 cmdline_fixed_string_t value;
4879 cmdline_fixed_string_t mode;
4883 cmd_set_uc_all_hash_parsed(void *parsed_result,
4884 __attribute__((unused)) struct cmdline *cl,
4885 __attribute__((unused)) void *data)
4888 struct cmd_set_uc_all_hash_table *res = parsed_result;
4890 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4892 if ((strcmp(res->what, "uta") == 0) &&
4893 (strcmp(res->value, "all") == 0))
4894 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4896 printf("bad unicast hash table parameter,"
4897 "return code = %d \n", ret);
4900 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4903 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4904 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4906 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4907 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4909 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4910 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4912 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4913 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4915 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4916 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4919 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4920 .f = cmd_set_uc_all_hash_parsed,
4922 .help_str = "set port X uta all on|off (X = port number)",
4924 (void *)&cmd_set_uc_all_hash_set,
4925 (void *)&cmd_set_uc_all_hash_port,
4926 (void *)&cmd_set_uc_all_hash_portid,
4927 (void *)&cmd_set_uc_all_hash_what,
4928 (void *)&cmd_set_uc_all_hash_value,
4929 (void *)&cmd_set_uc_all_hash_mode,
4934 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4935 struct cmd_set_vf_traffic {
4936 cmdline_fixed_string_t set;
4937 cmdline_fixed_string_t port;
4939 cmdline_fixed_string_t vf;
4941 cmdline_fixed_string_t what;
4942 cmdline_fixed_string_t mode;
4946 cmd_set_vf_traffic_parsed(void *parsed_result,
4947 __attribute__((unused)) struct cmdline *cl,
4948 __attribute__((unused)) void *data)
4950 struct cmd_set_vf_traffic *res = parsed_result;
4951 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4952 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4954 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4957 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4958 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4960 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4961 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4963 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4964 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4966 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4967 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4969 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4970 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4972 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4973 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4975 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4976 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4979 cmdline_parse_inst_t cmd_set_vf_traffic = {
4980 .f = cmd_set_vf_traffic_parsed,
4982 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4984 (void *)&cmd_setvf_traffic_set,
4985 (void *)&cmd_setvf_traffic_port,
4986 (void *)&cmd_setvf_traffic_portid,
4987 (void *)&cmd_setvf_traffic_vf,
4988 (void *)&cmd_setvf_traffic_vfid,
4989 (void *)&cmd_setvf_traffic_what,
4990 (void *)&cmd_setvf_traffic_mode,
4995 /* *** CONFIGURE VF RECEIVE MODE *** */
4996 struct cmd_set_vf_rxmode {
4997 cmdline_fixed_string_t set;
4998 cmdline_fixed_string_t port;
5000 cmdline_fixed_string_t vf;
5002 cmdline_fixed_string_t what;
5003 cmdline_fixed_string_t mode;
5004 cmdline_fixed_string_t on;
5008 cmd_set_vf_rxmode_parsed(void *parsed_result,
5009 __attribute__((unused)) struct cmdline *cl,
5010 __attribute__((unused)) void *data)
5013 uint16_t rx_mode = 0;
5014 struct cmd_set_vf_rxmode *res = parsed_result;
5016 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5017 if (!strcmp(res->what,"rxmode")) {
5018 if (!strcmp(res->mode, "AUPE"))
5019 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5020 else if (!strcmp(res->mode, "ROPE"))
5021 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5022 else if (!strcmp(res->mode, "BAM"))
5023 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5024 else if (!strncmp(res->mode, "MPE",3))
5025 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5028 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5030 printf("bad VF receive mode parameter, return code = %d \n",
5034 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5035 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5037 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5038 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5040 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5041 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5043 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5044 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5046 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5047 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5049 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5052 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5054 mode, "AUPE#ROPE#BAM#MPE");
5055 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5059 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5060 .f = cmd_set_vf_rxmode_parsed,
5062 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5064 (void *)&cmd_set_vf_rxmode_set,
5065 (void *)&cmd_set_vf_rxmode_port,
5066 (void *)&cmd_set_vf_rxmode_portid,
5067 (void *)&cmd_set_vf_rxmode_vf,
5068 (void *)&cmd_set_vf_rxmode_vfid,
5069 (void *)&cmd_set_vf_rxmode_what,
5070 (void *)&cmd_set_vf_rxmode_mode,
5071 (void *)&cmd_set_vf_rxmode_on,
5076 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5077 struct cmd_vf_mac_addr_result {
5078 cmdline_fixed_string_t mac_addr_cmd;
5079 cmdline_fixed_string_t what;
5080 cmdline_fixed_string_t port;
5082 cmdline_fixed_string_t vf;
5084 struct ether_addr address;
5087 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5088 __attribute__((unused)) struct cmdline *cl,
5089 __attribute__((unused)) void *data)
5091 struct cmd_vf_mac_addr_result *res = parsed_result;
5094 if (strcmp(res->what, "add") == 0)
5095 ret = rte_eth_dev_mac_addr_add(res->port_num,
5096 &res->address, res->vf_num);
5098 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5102 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5103 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5104 mac_addr_cmd,"mac_addr");
5105 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5106 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5108 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5109 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5111 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5112 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5114 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5115 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5117 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5118 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5120 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5121 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5124 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5125 .f = cmd_vf_mac_addr_parsed,
5127 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5128 "Y = VF number)add MAC address filtering for a VF on port X",
5130 (void *)&cmd_vf_mac_addr_cmd,
5131 (void *)&cmd_vf_mac_addr_what,
5132 (void *)&cmd_vf_mac_addr_port,
5133 (void *)&cmd_vf_mac_addr_portnum,
5134 (void *)&cmd_vf_mac_addr_vf,
5135 (void *)&cmd_vf_mac_addr_vfnum,
5136 (void *)&cmd_vf_mac_addr_addr,
5141 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5142 struct cmd_vf_rx_vlan_filter {
5143 cmdline_fixed_string_t rx_vlan;
5144 cmdline_fixed_string_t what;
5146 cmdline_fixed_string_t port;
5148 cmdline_fixed_string_t vf;
5153 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5154 __attribute__((unused)) struct cmdline *cl,
5155 __attribute__((unused)) void *data)
5157 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5159 if (!strcmp(res->what, "add"))
5160 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5162 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5165 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5166 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5167 rx_vlan, "rx_vlan");
5168 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5169 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5171 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5172 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5174 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5175 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5177 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5178 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5180 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5183 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5184 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5187 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5188 .f = cmd_vf_rx_vlan_filter_parsed,
5190 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5191 "Y = port number,Z = hexadecimal VF mask)",
5193 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5194 (void *)&cmd_vf_rx_vlan_filter_what,
5195 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5196 (void *)&cmd_vf_rx_vlan_filter_port,
5197 (void *)&cmd_vf_rx_vlan_filter_portid,
5198 (void *)&cmd_vf_rx_vlan_filter_vf,
5199 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5204 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5205 struct cmd_queue_rate_limit_result {
5206 cmdline_fixed_string_t set;
5207 cmdline_fixed_string_t port;
5209 cmdline_fixed_string_t queue;
5211 cmdline_fixed_string_t rate;
5215 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5216 __attribute__((unused)) struct cmdline *cl,
5217 __attribute__((unused)) void *data)
5219 struct cmd_queue_rate_limit_result *res = parsed_result;
5222 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5223 && (strcmp(res->queue, "queue") == 0)
5224 && (strcmp(res->rate, "rate") == 0))
5225 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5228 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5232 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5233 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5235 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5236 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5238 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5239 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5241 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5242 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5244 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5245 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5247 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5248 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5250 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5251 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5254 cmdline_parse_inst_t cmd_queue_rate_limit = {
5255 .f = cmd_queue_rate_limit_parsed,
5257 .help_str = "set port X queue Y rate Z:(X = port number,"
5258 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5260 (void *)&cmd_queue_rate_limit_set,
5261 (void *)&cmd_queue_rate_limit_port,
5262 (void *)&cmd_queue_rate_limit_portnum,
5263 (void *)&cmd_queue_rate_limit_queue,
5264 (void *)&cmd_queue_rate_limit_queuenum,
5265 (void *)&cmd_queue_rate_limit_rate,
5266 (void *)&cmd_queue_rate_limit_ratenum,
5271 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5272 struct cmd_vf_rate_limit_result {
5273 cmdline_fixed_string_t set;
5274 cmdline_fixed_string_t port;
5276 cmdline_fixed_string_t vf;
5278 cmdline_fixed_string_t rate;
5280 cmdline_fixed_string_t q_msk;
5284 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5285 __attribute__((unused)) struct cmdline *cl,
5286 __attribute__((unused)) void *data)
5288 struct cmd_vf_rate_limit_result *res = parsed_result;
5291 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5292 && (strcmp(res->vf, "vf") == 0)
5293 && (strcmp(res->rate, "rate") == 0)
5294 && (strcmp(res->q_msk, "queue_mask") == 0))
5295 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5296 res->rate_num, res->q_msk_val);
5298 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5302 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5303 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5305 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5306 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5308 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5309 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5311 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5312 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5314 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5315 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5317 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5318 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5320 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5321 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5323 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5324 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5325 q_msk, "queue_mask");
5326 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5327 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5330 cmdline_parse_inst_t cmd_vf_rate_limit = {
5331 .f = cmd_vf_rate_limit_parsed,
5333 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5334 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5335 "for queues of VF on port X",
5337 (void *)&cmd_vf_rate_limit_set,
5338 (void *)&cmd_vf_rate_limit_port,
5339 (void *)&cmd_vf_rate_limit_portnum,
5340 (void *)&cmd_vf_rate_limit_vf,
5341 (void *)&cmd_vf_rate_limit_vfnum,
5342 (void *)&cmd_vf_rate_limit_rate,
5343 (void *)&cmd_vf_rate_limit_ratenum,
5344 (void *)&cmd_vf_rate_limit_q_msk,
5345 (void *)&cmd_vf_rate_limit_q_msk_val,
5350 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5351 struct cmd_set_mirror_mask_result {
5352 cmdline_fixed_string_t set;
5353 cmdline_fixed_string_t port;
5355 cmdline_fixed_string_t mirror;
5357 cmdline_fixed_string_t what;
5358 cmdline_fixed_string_t value;
5359 cmdline_fixed_string_t dstpool;
5361 cmdline_fixed_string_t on;
5364 cmdline_parse_token_string_t cmd_mirror_mask_set =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5367 cmdline_parse_token_string_t cmd_mirror_mask_port =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5370 cmdline_parse_token_string_t cmd_mirror_mask_portid =
5371 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5373 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5375 mirror, "mirror-rule");
5376 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5379 cmdline_parse_token_string_t cmd_mirror_mask_what =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5381 what, "pool-mirror#vlan-mirror");
5382 cmdline_parse_token_string_t cmd_mirror_mask_value =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5385 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5387 dstpool, "dst-pool");
5388 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5389 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5391 cmdline_parse_token_string_t cmd_mirror_mask_on =
5392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5396 cmd_set_mirror_mask_parsed(void *parsed_result,
5397 __attribute__((unused)) struct cmdline *cl,
5398 __attribute__((unused)) void *data)
5401 struct cmd_set_mirror_mask_result *res = parsed_result;
5402 struct rte_eth_vmdq_mirror_conf mr_conf;
5404 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5406 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5408 mr_conf.dst_pool = res->dstpool_id;
5410 if (!strcmp(res->what, "pool-mirror")) {
5411 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5412 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5413 } else if(!strcmp(res->what, "vlan-mirror")) {
5414 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5415 nb_item = parse_item_list(res->value, "core",
5416 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5420 for(i=0; i < nb_item; i++) {
5421 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5422 printf("Invalid vlan_id: must be < 4096\n");
5426 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5427 mr_conf.vlan.vlan_mask |= 1ULL << i;
5431 if(!strcmp(res->on, "on"))
5432 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5435 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5438 printf("mirror rule add error: (%s)\n", strerror(-ret));
5441 cmdline_parse_inst_t cmd_set_mirror_mask = {
5442 .f = cmd_set_mirror_mask_parsed,
5444 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5445 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5447 (void *)&cmd_mirror_mask_set,
5448 (void *)&cmd_mirror_mask_port,
5449 (void *)&cmd_mirror_mask_portid,
5450 (void *)&cmd_mirror_mask_mirror,
5451 (void *)&cmd_mirror_mask_ruleid,
5452 (void *)&cmd_mirror_mask_what,
5453 (void *)&cmd_mirror_mask_value,
5454 (void *)&cmd_mirror_mask_dstpool,
5455 (void *)&cmd_mirror_mask_poolid,
5456 (void *)&cmd_mirror_mask_on,
5461 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5462 struct cmd_set_mirror_link_result {
5463 cmdline_fixed_string_t set;
5464 cmdline_fixed_string_t port;
5466 cmdline_fixed_string_t mirror;
5468 cmdline_fixed_string_t what;
5469 cmdline_fixed_string_t dstpool;
5471 cmdline_fixed_string_t on;
5474 cmdline_parse_token_string_t cmd_mirror_link_set =
5475 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5477 cmdline_parse_token_string_t cmd_mirror_link_port =
5478 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5480 cmdline_parse_token_string_t cmd_mirror_link_portid =
5481 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5483 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5485 mirror, "mirror-rule");
5486 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5487 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5489 cmdline_parse_token_string_t cmd_mirror_link_what =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5491 what, "uplink-mirror#downlink-mirror");
5492 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5494 dstpool, "dst-pool");
5495 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5496 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5498 cmdline_parse_token_string_t cmd_mirror_link_on =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5503 cmd_set_mirror_link_parsed(void *parsed_result,
5504 __attribute__((unused)) struct cmdline *cl,
5505 __attribute__((unused)) void *data)
5508 struct cmd_set_mirror_link_result *res = parsed_result;
5509 struct rte_eth_vmdq_mirror_conf mr_conf;
5511 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5512 if(!strcmp(res->what, "uplink-mirror")) {
5513 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5514 }else if(!strcmp(res->what, "downlink-mirror"))
5515 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5517 mr_conf.dst_pool = res->dstpool_id;
5519 if(!strcmp(res->on, "on"))
5520 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5523 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5526 /* check the return value and print it if is < 0 */
5528 printf("mirror rule add error: (%s)\n", strerror(-ret));
5532 cmdline_parse_inst_t cmd_set_mirror_link = {
5533 .f = cmd_set_mirror_link_parsed,
5535 .help_str = "set port X mirror-rule Y uplink-mirror|"
5536 "downlink-mirror dst-pool Z on|off",
5538 (void *)&cmd_mirror_link_set,
5539 (void *)&cmd_mirror_link_port,
5540 (void *)&cmd_mirror_link_portid,
5541 (void *)&cmd_mirror_link_mirror,
5542 (void *)&cmd_mirror_link_ruleid,
5543 (void *)&cmd_mirror_link_what,
5544 (void *)&cmd_mirror_link_dstpool,
5545 (void *)&cmd_mirror_link_poolid,
5546 (void *)&cmd_mirror_link_on,
5551 /* *** RESET VM MIRROR RULE *** */
5552 struct cmd_rm_mirror_rule_result {
5553 cmdline_fixed_string_t reset;
5554 cmdline_fixed_string_t port;
5556 cmdline_fixed_string_t mirror;
5560 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5561 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5563 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5564 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5566 cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
5567 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5569 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5570 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5571 mirror, "mirror-rule");
5572 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5573 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5577 cmd_reset_mirror_rule_parsed(void *parsed_result,
5578 __attribute__((unused)) struct cmdline *cl,
5579 __attribute__((unused)) void *data)
5582 struct cmd_set_mirror_link_result *res = parsed_result;
5584 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5586 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5589 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5590 .f = cmd_reset_mirror_rule_parsed,
5592 .help_str = "reset port X mirror-rule Y",
5594 (void *)&cmd_rm_mirror_rule_reset,
5595 (void *)&cmd_rm_mirror_rule_port,
5596 (void *)&cmd_rm_mirror_rule_portid,
5597 (void *)&cmd_rm_mirror_rule_mirror,
5598 (void *)&cmd_rm_mirror_rule_ruleid,
5603 /* ******************************************************************************** */
5605 struct cmd_dump_result {
5606 cmdline_fixed_string_t dump;
5610 dump_struct_sizes(void)
5612 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5613 DUMP_SIZE(struct rte_mbuf);
5614 DUMP_SIZE(struct rte_pktmbuf);
5615 DUMP_SIZE(struct rte_ctrlmbuf);
5616 DUMP_SIZE(struct rte_mempool);
5617 DUMP_SIZE(struct rte_ring);
5621 static void cmd_dump_parsed(void *parsed_result,
5622 __attribute__((unused)) struct cmdline *cl,
5623 __attribute__((unused)) void *data)
5625 struct cmd_dump_result *res = parsed_result;
5627 if (!strcmp(res->dump, "dump_physmem"))
5628 rte_dump_physmem_layout(stdout);
5629 else if (!strcmp(res->dump, "dump_memzone"))
5630 rte_memzone_dump(stdout);
5631 else if (!strcmp(res->dump, "dump_log_history"))
5632 rte_log_dump_history(stdout);
5633 else if (!strcmp(res->dump, "dump_struct_sizes"))
5634 dump_struct_sizes();
5635 else if (!strcmp(res->dump, "dump_ring"))
5636 rte_ring_list_dump(stdout);
5637 else if (!strcmp(res->dump, "dump_mempool"))
5638 rte_mempool_list_dump(stdout);
5639 else if (!strcmp(res->dump, "dump_devargs"))
5640 rte_eal_devargs_dump(stdout);
5643 cmdline_parse_token_string_t cmd_dump_dump =
5644 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5648 "dump_struct_sizes#"
5653 cmdline_parse_inst_t cmd_dump = {
5654 .f = cmd_dump_parsed, /* function to call */
5655 .data = NULL, /* 2nd arg of func */
5656 .help_str = "dump status",
5657 .tokens = { /* token list, NULL terminated */
5658 (void *)&cmd_dump_dump,
5663 /* ******************************************************************************** */
5665 struct cmd_dump_one_result {
5666 cmdline_fixed_string_t dump;
5667 cmdline_fixed_string_t name;
5670 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5671 __attribute__((unused)) void *data)
5673 struct cmd_dump_one_result *res = parsed_result;
5675 if (!strcmp(res->dump, "dump_ring")) {
5677 r = rte_ring_lookup(res->name);
5679 cmdline_printf(cl, "Cannot find ring\n");
5682 rte_ring_dump(stdout, r);
5683 } else if (!strcmp(res->dump, "dump_mempool")) {
5684 struct rte_mempool *mp;
5685 mp = rte_mempool_lookup(res->name);
5687 cmdline_printf(cl, "Cannot find mempool\n");
5690 rte_mempool_dump(stdout, mp);
5694 cmdline_parse_token_string_t cmd_dump_one_dump =
5695 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5696 "dump_ring#dump_mempool");
5698 cmdline_parse_token_string_t cmd_dump_one_name =
5699 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5701 cmdline_parse_inst_t cmd_dump_one = {
5702 .f = cmd_dump_one_parsed, /* function to call */
5703 .data = NULL, /* 2nd arg of func */
5704 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5705 .tokens = { /* token list, NULL terminated */
5706 (void *)&cmd_dump_one_dump,
5707 (void *)&cmd_dump_one_name,
5712 /* *** ADD/REMOVE an ethertype FILTER *** */
5713 struct cmd_ethertype_filter_result {
5714 cmdline_fixed_string_t filter;
5716 cmdline_fixed_string_t ethertype;
5717 uint16_t ethertype_value;
5718 cmdline_fixed_string_t priority;
5719 cmdline_fixed_string_t priority_en;
5720 uint8_t priority_value;
5721 cmdline_fixed_string_t queue;
5723 cmdline_fixed_string_t index;
5724 uint16_t index_value;
5728 cmd_ethertype_filter_parsed(void *parsed_result,
5729 __attribute__((unused)) struct cmdline *cl,
5730 __attribute__((unused)) void *data)
5733 struct cmd_ethertype_filter_result *res = parsed_result;
5734 struct rte_ethertype_filter filter;
5736 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
5737 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
5738 filter.priority = res->priority_value;
5740 if (!strcmp(res->priority_en, "enable"))
5741 filter.priority_en = 1;
5742 if (!strcmp(res->filter, "add_ethertype_filter"))
5743 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
5745 &filter, res->queue_id);
5746 else if (!strcmp(res->filter, "remove_ethertype_filter"))
5747 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
5749 else if (!strcmp(res->filter, "get_ethertype_filter"))
5750 get_ethertype_filter(res->port_id, res->index_value);
5753 printf("ethertype filter setting error: (%s)\n",
5757 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
5758 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5760 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
5761 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5762 ethertype, "ethertype");
5763 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
5764 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5765 ethertype_value, UINT16);
5766 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
5767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5768 priority, "priority");
5769 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
5770 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5771 priority_en, "enable#disable");
5772 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
5773 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5774 priority_value, UINT8);
5775 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
5776 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5778 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
5779 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5781 cmdline_parse_token_string_t cmd_ethertype_filter_index =
5782 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5784 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
5785 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5786 index_value, UINT16);
5787 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
5788 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5789 filter, "add_ethertype_filter");
5790 cmdline_parse_inst_t cmd_add_ethertype_filter = {
5791 .f = cmd_ethertype_filter_parsed,
5793 .help_str = "add an ethertype filter",
5795 (void *)&cmd_ethertype_filter_add_filter,
5796 (void *)&cmd_ethertype_filter_port_id,
5797 (void *)&cmd_ethertype_filter_ethertype,
5798 (void *)&cmd_ethertype_filter_ethertype_value,
5799 (void *)&cmd_ethertype_filter_priority,
5800 (void *)&cmd_ethertype_filter_priority_en,
5801 (void *)&cmd_ethertype_filter_priority_value,
5802 (void *)&cmd_ethertype_filter_queue,
5803 (void *)&cmd_ethertype_filter_queue_id,
5804 (void *)&cmd_ethertype_filter_index,
5805 (void *)&cmd_ethertype_filter_index_value,
5810 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
5811 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5812 filter, "remove_ethertype_filter");
5813 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
5814 .f = cmd_ethertype_filter_parsed,
5816 .help_str = "remove an ethertype filter",
5818 (void *)&cmd_ethertype_filter_remove_filter,
5819 (void *)&cmd_ethertype_filter_port_id,
5820 (void *)&cmd_ethertype_filter_index,
5821 (void *)&cmd_ethertype_filter_index_value,
5825 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
5826 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5827 filter, "get_ethertype_filter");
5828 cmdline_parse_inst_t cmd_get_ethertype_filter = {
5829 .f = cmd_ethertype_filter_parsed,
5831 .help_str = "get an ethertype filter",
5833 (void *)&cmd_ethertype_filter_get_filter,
5834 (void *)&cmd_ethertype_filter_port_id,
5835 (void *)&cmd_ethertype_filter_index,
5836 (void *)&cmd_ethertype_filter_index_value,
5841 /* *** set SYN filter *** */
5842 struct cmd_set_syn_filter_result {
5843 cmdline_fixed_string_t filter;
5845 cmdline_fixed_string_t priority;
5846 cmdline_fixed_string_t high;
5847 cmdline_fixed_string_t queue;
5852 cmd_set_syn_filter_parsed(void *parsed_result,
5853 __attribute__((unused)) struct cmdline *cl,
5854 __attribute__((unused)) void *data)
5857 struct cmd_set_syn_filter_result *res = parsed_result;
5858 struct rte_syn_filter filter;
5860 if (!strcmp(res->filter, "add_syn_filter")) {
5861 if (!strcmp(res->high, "high"))
5865 ret = rte_eth_dev_add_syn_filter(res->port_id,
5866 &filter, res->queue_id);
5867 } else if (!strcmp(res->filter, "remove_syn_filter"))
5868 ret = rte_eth_dev_remove_syn_filter(res->port_id);
5869 else if (!strcmp(res->filter, "get_syn_filter"))
5870 get_syn_filter(res->port_id);
5872 printf("syn filter setting error: (%s)\n", strerror(-ret));
5875 cmdline_parse_token_string_t cmd_syn_filter_portid =
5876 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5878 cmdline_parse_token_string_t cmd_syn_filter_priority =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5880 priority, "priority");
5881 cmdline_parse_token_string_t cmd_syn_filter_high =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5884 cmdline_parse_token_string_t cmd_syn_filter_queue =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5887 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
5888 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5890 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5892 filter, "add_syn_filter");
5893 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5895 filter, "remove_syn_filter");
5896 cmdline_parse_inst_t cmd_add_syn_filter = {
5897 .f = cmd_set_syn_filter_parsed,
5899 .help_str = "add syn filter",
5901 (void *)&cmd_syn_filter_add_filter,
5902 (void *)&cmd_syn_filter_portid,
5903 (void *)&cmd_syn_filter_priority,
5904 (void *)&cmd_syn_filter_high,
5905 (void *)&cmd_syn_filter_queue,
5906 (void *)&cmd_syn_filter_queue_id,
5910 cmdline_parse_inst_t cmd_remove_syn_filter = {
5911 .f = cmd_set_syn_filter_parsed,
5913 .help_str = "remove syn filter",
5915 (void *)&cmd_syn_filter_remove_filter,
5916 (void *)&cmd_syn_filter_portid,
5921 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5923 filter, "get_syn_filter");
5925 cmdline_parse_inst_t cmd_get_syn_filter = {
5926 .f = cmd_set_syn_filter_parsed,
5928 .help_str = "get syn filter",
5930 (void *)&cmd_syn_filter_get_filter,
5931 (void *)&cmd_syn_filter_portid,
5936 /* *** ADD/REMOVE A 2tuple FILTER *** */
5937 struct cmd_2tuple_filter_result {
5938 cmdline_fixed_string_t filter;
5940 cmdline_fixed_string_t protocol;
5941 uint8_t protocol_value;
5942 uint8_t protocol_mask;
5943 cmdline_fixed_string_t dst_port;
5944 uint16_t dst_port_value;
5945 uint16_t dst_port_mask;
5946 cmdline_fixed_string_t flags;
5947 uint8_t flags_value;
5948 cmdline_fixed_string_t priority;
5949 uint8_t priority_value;
5950 cmdline_fixed_string_t queue;
5952 cmdline_fixed_string_t index;
5953 uint16_t index_value;
5957 cmd_2tuple_filter_parsed(void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5962 struct rte_2tuple_filter filter;
5963 struct cmd_2tuple_filter_result *res = parsed_result;
5965 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
5967 if (!strcmp(res->filter, "add_2tuple_filter")) {
5968 /* need convert to big endian. */
5969 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
5970 filter.protocol = res->protocol_value;
5971 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
5972 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
5973 filter.priority = res->priority_value;
5974 filter.tcp_flags = res->flags_value;
5975 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
5976 res->index_value, &filter, res->queue_id);
5977 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
5978 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
5980 else if (!strcmp(res->filter, "get_2tuple_filter"))
5981 get_2tuple_filter(res->port_id, res->index_value);
5984 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
5987 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
5988 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5990 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
5991 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
5992 protocol, "protocol");
5993 cmdline_parse_token_string_t cmd_2tuple_filter_protocol_value =
5994 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5995 protocol_value, UINT8);
5996 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
5997 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
5998 protocol_mask, UINT8);
5999 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6000 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6001 dst_port, "dst_port");
6002 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6003 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6004 dst_port_value, UINT16);
6005 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6006 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6007 dst_port_mask, UINT16);
6008 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6009 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6011 cmdline_parse_token_string_t cmd_2tuple_filter_flags_value =
6012 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6013 flags_value, UINT8);
6014 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6015 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6016 priority, "priority");
6017 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6018 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6019 priority_value, UINT8);
6020 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6021 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6023 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6024 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6026 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6027 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6029 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6030 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6031 index_value, UINT16);
6032 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6033 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6034 filter, "add_2tuple_filter");
6035 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6036 .f = cmd_2tuple_filter_parsed,
6038 .help_str = "add a 2tuple filter",
6040 (void *)&cmd_2tuple_filter_add_filter,
6041 (void *)&cmd_2tuple_filter_port_id,
6042 (void *)&cmd_2tuple_filter_protocol,
6043 (void *)&cmd_2tuple_filter_protocol_value,
6044 (void *)&cmd_2tuple_filter_protocol_mask,
6045 (void *)&cmd_2tuple_filter_dst_port,
6046 (void *)&cmd_2tuple_filter_dst_port_value,
6047 (void *)&cmd_2tuple_filter_dst_port_mask,
6048 (void *)&cmd_2tuple_filter_flags,
6049 (void *)&cmd_2tuple_filter_flags_value,
6050 (void *)&cmd_2tuple_filter_priority,
6051 (void *)&cmd_2tuple_filter_priority_value,
6052 (void *)&cmd_2tuple_filter_queue,
6053 (void *)&cmd_2tuple_filter_queue_id,
6054 (void *)&cmd_2tuple_filter_index,
6055 (void *)&cmd_2tuple_filter_index_value,
6060 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6061 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6062 filter, "remove_2tuple_filter");
6063 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6064 .f = cmd_2tuple_filter_parsed,
6066 .help_str = "remove a 2tuple filter",
6068 (void *)&cmd_2tuple_filter_remove_filter,
6069 (void *)&cmd_2tuple_filter_port_id,
6070 (void *)&cmd_2tuple_filter_index,
6071 (void *)&cmd_2tuple_filter_index_value,
6075 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6076 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6077 filter, "get_2tuple_filter");
6078 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6079 .f = cmd_2tuple_filter_parsed,
6081 .help_str = "get a 2tuple filter",
6083 (void *)&cmd_2tuple_filter_get_filter,
6084 (void *)&cmd_2tuple_filter_port_id,
6085 (void *)&cmd_2tuple_filter_index,
6086 (void *)&cmd_2tuple_filter_index_value,
6091 /* *** ADD/REMOVE A 5tuple FILTER *** */
6092 struct cmd_5tuple_filter_result {
6093 cmdline_fixed_string_t filter;
6095 cmdline_fixed_string_t dst_ip;
6096 cmdline_ipaddr_t dst_ip_value;
6097 cmdline_fixed_string_t src_ip;
6098 cmdline_ipaddr_t src_ip_value;
6099 cmdline_fixed_string_t dst_port;
6100 uint16_t dst_port_value;
6101 cmdline_fixed_string_t src_port;
6102 uint16_t src_port_value;
6103 cmdline_fixed_string_t protocol;
6104 uint8_t protocol_value;
6105 cmdline_fixed_string_t mask;
6107 cmdline_fixed_string_t flags;
6108 uint8_t flags_value;
6109 cmdline_fixed_string_t priority;
6110 uint8_t priority_value;
6111 cmdline_fixed_string_t queue;
6113 cmdline_fixed_string_t index;
6114 uint16_t index_value;
6118 cmd_5tuple_filter_parsed(void *parsed_result,
6119 __attribute__((unused)) struct cmdline *cl,
6120 __attribute__((unused)) void *data)
6123 struct rte_5tuple_filter filter;
6124 struct cmd_5tuple_filter_result *res = parsed_result;
6126 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6128 if (!strcmp(res->filter, "add_5tuple_filter")) {
6129 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6130 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6131 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6132 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6133 filter.protocol = res->protocol_value;
6134 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6135 filter.priority = res->priority_value;
6136 filter.tcp_flags = res->flags_value;
6138 if (res->dst_ip_value.family == AF_INET)
6139 /* no need to convert, already big endian. */
6140 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6142 if (filter.dst_ip_mask == 0) {
6143 printf("can not support ipv6 involved compare.\n");
6149 if (res->src_ip_value.family == AF_INET)
6150 /* no need to convert, already big endian. */
6151 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6153 if (filter.src_ip_mask == 0) {
6154 printf("can not support ipv6 involved compare.\n");
6159 /* need convert to big endian. */
6160 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6161 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6163 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6164 res->index_value, &filter, res->queue_id);
6165 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6166 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6168 else if (!strcmp(res->filter, "get_5tuple_filter"))
6169 get_5tuple_filter(res->port_id, res->index_value);
6171 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6175 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6176 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6178 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6179 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6181 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6182 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6184 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6185 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6187 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6188 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6190 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6191 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6192 dst_port, "dst_port");
6193 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6194 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6195 dst_port_value, UINT16);
6196 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6197 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6198 src_port, "src_port");
6199 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6200 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6201 src_port_value, UINT16);
6202 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6203 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6204 protocol, "protocol");
6205 cmdline_parse_token_string_t cmd_5tuple_filter_protocol_value =
6206 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6207 protocol_value, UINT8);
6208 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6209 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6211 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6212 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6214 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6215 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6217 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6218 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6219 flags_value, UINT8);
6220 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6221 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6222 priority, "priority");
6223 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6224 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6225 priority_value, UINT8);
6226 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6227 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6229 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6230 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6232 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6233 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6235 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
6236 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6237 index_value, UINT16);
6239 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
6240 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6241 filter, "add_5tuple_filter");
6242 cmdline_parse_inst_t cmd_add_5tuple_filter = {
6243 .f = cmd_5tuple_filter_parsed,
6245 .help_str = "add a 5tuple filter",
6247 (void *)&cmd_5tuple_filter_add_filter,
6248 (void *)&cmd_5tuple_filter_port_id,
6249 (void *)&cmd_5tuple_filter_dst_ip,
6250 (void *)&cmd_5tuple_filter_dst_ip_value,
6251 (void *)&cmd_5tuple_filter_src_ip,
6252 (void *)&cmd_5tuple_filter_src_ip_value,
6253 (void *)&cmd_5tuple_filter_dst_port,
6254 (void *)&cmd_5tuple_filter_dst_port_value,
6255 (void *)&cmd_5tuple_filter_src_port,
6256 (void *)&cmd_5tuple_filter_src_port_value,
6257 (void *)&cmd_5tuple_filter_protocol,
6258 (void *)&cmd_5tuple_filter_protocol_value,
6259 (void *)&cmd_5tuple_filter_mask,
6260 (void *)&cmd_5tuple_filter_mask_value,
6261 (void *)&cmd_5tuple_filter_flags,
6262 (void *)&cmd_5tuple_filter_flags_value,
6263 (void *)&cmd_5tuple_filter_priority,
6264 (void *)&cmd_5tuple_filter_priority_value,
6265 (void *)&cmd_5tuple_filter_queue,
6266 (void *)&cmd_5tuple_filter_queue_id,
6267 (void *)&cmd_5tuple_filter_index,
6268 (void *)&cmd_5tuple_filter_index_value,
6273 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
6274 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6275 filter, "remove_5tuple_filter");
6276 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
6277 .f = cmd_5tuple_filter_parsed,
6279 .help_str = "remove a 5tuple filter",
6281 (void *)&cmd_5tuple_filter_remove_filter,
6282 (void *)&cmd_5tuple_filter_port_id,
6283 (void *)&cmd_5tuple_filter_index,
6284 (void *)&cmd_5tuple_filter_index_value,
6289 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
6290 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6291 filter, "get_5tuple_filter");
6292 cmdline_parse_inst_t cmd_get_5tuple_filter = {
6293 .f = cmd_5tuple_filter_parsed,
6295 .help_str = "get a 5tuple filter",
6297 (void *)&cmd_5tuple_filter_get_filter,
6298 (void *)&cmd_5tuple_filter_port_id,
6299 (void *)&cmd_5tuple_filter_index,
6300 (void *)&cmd_5tuple_filter_index_value,
6305 /* *** ADD/REMOVE A flex FILTER *** */
6306 struct cmd_flex_filter_result {
6307 cmdline_fixed_string_t filter;
6309 cmdline_fixed_string_t len;
6311 cmdline_fixed_string_t bytes;
6312 cmdline_fixed_string_t bytes_value;
6313 cmdline_fixed_string_t mask;
6314 cmdline_fixed_string_t mask_value;
6315 cmdline_fixed_string_t priority;
6316 uint8_t priority_value;
6317 cmdline_fixed_string_t queue;
6319 cmdline_fixed_string_t index;
6320 uint16_t index_value;
6323 static int xdigit2val(unsigned char c)
6328 else if (isupper(c))
6336 cmd_flex_filter_parsed(void *parsed_result,
6337 __attribute__((unused)) struct cmdline *cl,
6338 __attribute__((unused)) void *data)
6341 struct rte_flex_filter filter;
6342 struct cmd_flex_filter_result *res = parsed_result;
6343 char *bytes_ptr, *mask_ptr;
6351 if (!strcmp(res->filter, "add_flex_filter")) {
6352 if (res->len_value > 128) {
6353 printf("the len exceed the max length 128\n");
6356 memset(&filter, 0, sizeof(struct rte_flex_filter));
6357 filter.len = res->len_value;
6358 filter.priority = res->priority_value;
6359 bytes_ptr = res->bytes_value;
6360 mask_ptr = res->mask_value;
6363 /* translate bytes string to uint_32 array. */
6364 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
6365 (bytes_ptr[1] == 'X')))
6367 len = strnlen(bytes_ptr, res->len_value * 2);
6368 if (len == 0 || (len % 8 != 0)) {
6369 printf("please check len and bytes input\n");
6372 for (i = 0; i < len; i++) {
6374 if (isxdigit(c) == 0) {
6375 /* invalid characters. */
6376 printf("invalid input\n");
6379 val = xdigit2val(c);
6383 dword |= byte << (4 * mod - 4);
6388 filter.dwords[j] = dword;
6389 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
6395 /* translate mask string to uint8_t array. */
6397 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
6398 (mask_ptr[1] == 'X')))
6400 len = strnlen(mask_ptr, (res->len_value+3)/4);
6402 printf("invalid input\n");
6405 for (i = 0; i < len; i++) {
6407 if (isxdigit(c) == 0) {
6408 /* invalid characters. */
6409 printf("invalid input\n");
6412 val = xdigit2val(c);
6413 hex |= (uint8_t)(val & 0x8) >> 3;
6414 hex |= (uint8_t)(val & 0x4) >> 1;
6415 hex |= (uint8_t)(val & 0x2) << 1;
6416 hex |= (uint8_t)(val & 0x1) << 3;
6419 filter.mask[j] = byte;
6420 printf("mask[%d]:%02x ", j, filter.mask[j]);
6428 printf("call function rte_eth_dev_add_flex_filter: "
6429 "index = %d, queue-id = %d, len = %d, priority = %d\n",
6430 res->index_value, res->queue_id,
6431 filter.len, filter.priority);
6432 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
6433 &filter, res->queue_id);
6435 } else if (!strcmp(res->filter, "remove_flex_filter"))
6436 ret = rte_eth_dev_remove_flex_filter(res->port_id,
6438 else if (!strcmp(res->filter, "get_flex_filter"))
6439 get_flex_filter(res->port_id, res->index_value);
6442 printf("flex filter setting error: (%s)\n", strerror(-ret));
6445 cmdline_parse_token_num_t cmd_flex_filter_port_id =
6446 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6448 cmdline_parse_token_string_t cmd_flex_filter_len =
6449 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6451 cmdline_parse_token_string_t cmd_flex_filter_len_value =
6452 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6454 cmdline_parse_token_string_t cmd_flex_filter_bytes =
6455 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6457 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
6458 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6460 cmdline_parse_token_string_t cmd_flex_filter_mask =
6461 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6463 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
6464 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6466 cmdline_parse_token_string_t cmd_flex_filter_priority =
6467 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6468 priority, "priority");
6469 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
6470 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6471 priority_value, UINT8);
6472 cmdline_parse_token_string_t cmd_flex_filter_queue =
6473 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6475 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
6476 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6478 cmdline_parse_token_string_t cmd_flex_filter_index =
6479 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6481 cmdline_parse_token_num_t cmd_flex_filter_index_value =
6482 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6483 index_value, UINT16);
6484 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
6485 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6486 filter, "add_flex_filter");
6487 cmdline_parse_inst_t cmd_add_flex_filter = {
6488 .f = cmd_flex_filter_parsed,
6490 .help_str = "add a flex filter",
6492 (void *)&cmd_flex_filter_add_filter,
6493 (void *)&cmd_flex_filter_port_id,
6494 (void *)&cmd_flex_filter_len,
6495 (void *)&cmd_flex_filter_len_value,
6496 (void *)&cmd_flex_filter_bytes,
6497 (void *)&cmd_flex_filter_bytes_value,
6498 (void *)&cmd_flex_filter_mask,
6499 (void *)&cmd_flex_filter_mask_value,
6500 (void *)&cmd_flex_filter_priority,
6501 (void *)&cmd_flex_filter_priority_value,
6502 (void *)&cmd_flex_filter_queue,
6503 (void *)&cmd_flex_filter_queue_id,
6504 (void *)&cmd_flex_filter_index,
6505 (void *)&cmd_flex_filter_index_value,
6510 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
6511 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6512 filter, "remove_flex_filter");
6513 cmdline_parse_inst_t cmd_remove_flex_filter = {
6514 .f = cmd_flex_filter_parsed,
6516 .help_str = "remove a flex filter",
6518 (void *)&cmd_flex_filter_remove_filter,
6519 (void *)&cmd_flex_filter_port_id,
6520 (void *)&cmd_flex_filter_index,
6521 (void *)&cmd_flex_filter_index_value,
6526 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
6527 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6528 filter, "get_flex_filter");
6529 cmdline_parse_inst_t cmd_get_flex_filter = {
6530 .f = cmd_flex_filter_parsed,
6532 .help_str = "get a flex filter",
6534 (void *)&cmd_flex_filter_get_filter,
6535 (void *)&cmd_flex_filter_port_id,
6536 (void *)&cmd_flex_filter_index,
6537 (void *)&cmd_flex_filter_index_value,
6542 /* ******************************************************************************** */
6544 /* list of instructions */
6545 cmdline_parse_ctx_t main_ctx[] = {
6546 (cmdline_parse_inst_t *)&cmd_help_brief,
6547 (cmdline_parse_inst_t *)&cmd_help_long,
6548 (cmdline_parse_inst_t *)&cmd_quit,
6549 (cmdline_parse_inst_t *)&cmd_showport,
6550 (cmdline_parse_inst_t *)&cmd_showportall,
6551 (cmdline_parse_inst_t *)&cmd_showcfg,
6552 (cmdline_parse_inst_t *)&cmd_start,
6553 (cmdline_parse_inst_t *)&cmd_start_tx_first,
6554 (cmdline_parse_inst_t *)&cmd_set_link_up,
6555 (cmdline_parse_inst_t *)&cmd_set_link_down,
6556 (cmdline_parse_inst_t *)&cmd_reset,
6557 (cmdline_parse_inst_t *)&cmd_set_numbers,
6558 (cmdline_parse_inst_t *)&cmd_set_txpkts,
6559 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
6560 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
6561 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
6562 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
6563 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
6564 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
6565 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
6566 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
6567 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
6568 (cmdline_parse_inst_t *)&cmd_set_link_check,
6569 #ifdef RTE_NIC_BYPASS
6570 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
6571 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
6572 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
6573 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
6575 (cmdline_parse_inst_t *)&cmd_vlan_offload,
6576 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
6577 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
6578 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
6579 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
6580 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
6581 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
6582 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
6583 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
6584 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
6585 (cmdline_parse_inst_t *)&cmd_config_dcb,
6586 (cmdline_parse_inst_t *)&cmd_read_reg,
6587 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
6588 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
6589 (cmdline_parse_inst_t *)&cmd_write_reg,
6590 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
6591 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
6592 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
6593 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
6594 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
6595 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
6596 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
6597 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
6598 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
6599 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
6600 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
6601 (cmdline_parse_inst_t *)&cmd_stop,
6602 (cmdline_parse_inst_t *)&cmd_mac_addr,
6603 (cmdline_parse_inst_t *)&cmd_set_qmap,
6604 (cmdline_parse_inst_t *)&cmd_operate_port,
6605 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
6606 (cmdline_parse_inst_t *)&cmd_config_speed_all,
6607 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
6608 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
6609 (cmdline_parse_inst_t *)&cmd_config_mtu,
6610 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
6611 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
6612 (cmdline_parse_inst_t *)&cmd_config_rss,
6613 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
6614 (cmdline_parse_inst_t *)&cmd_showport_reta,
6615 (cmdline_parse_inst_t *)&cmd_config_burst,
6616 (cmdline_parse_inst_t *)&cmd_config_thresh,
6617 (cmdline_parse_inst_t *)&cmd_config_threshold,
6618 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
6619 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
6620 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
6621 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
6622 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
6623 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
6624 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
6625 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
6626 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
6627 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
6628 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
6629 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
6630 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
6631 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
6632 (cmdline_parse_inst_t *)&cmd_dump,
6633 (cmdline_parse_inst_t *)&cmd_dump_one,
6634 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
6635 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
6636 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
6637 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
6638 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
6639 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
6640 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
6641 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
6642 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
6643 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
6644 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
6645 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
6646 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
6647 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
6648 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
6652 /* prompt function, called from main on MASTER lcore */
6658 /* initialize non-constant commands */
6659 cmd_set_fwd_mode_init();
6661 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
6665 cmdline_interact(cl);
6666 cmdline_stdin_exit(cl);
6670 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
6672 if (id < nb_ports) {
6673 /* check if need_reconfig has been set to 1 */
6674 if (ports[id].need_reconfig == 0)
6675 ports[id].need_reconfig = dev;
6676 /* check if need_reconfig_queues has been set to 1 */
6677 if (ports[id].need_reconfig_queues == 0)
6678 ports[id].need_reconfig_queues = queue;
6682 for (pid = 0; pid < nb_ports; pid++) {
6683 /* check if need_reconfig has been set to 1 */
6684 if (ports[pid].need_reconfig == 0)
6685 ports[pid].need_reconfig = dev;
6686 /* check if need_reconfig_queues has been set to 1 */
6687 if (ports[pid].need_reconfig_queues == 0)
6688 ports[pid].need_reconfig_queues = queue;
6693 #ifdef RTE_NIC_BYPASS
6695 bypass_is_supported(portid_t port_id)
6697 struct rte_port *port;
6698 struct rte_pci_id *pci_id;
6700 if (port_id >= nb_ports) {
6701 printf("\tPort id must be less than %d.\n", nb_ports);
6705 /* Get the device id. */
6706 port = &ports[port_id];
6707 pci_id = &port->dev_info.pci_dev->id;
6709 /* Check if NIC supports bypass. */
6710 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
6714 printf("\tBypass not supported for port_id = %d.\n", port_id);