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) autoneg (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_num_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 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 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 cmdline_fixed_string_t autoneg_str;
3818 cmdline_fixed_string_t autoneg;
3819 uint32_t high_water;
3821 uint16_t pause_time;
3827 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
3828 __attribute__((unused)) struct cmdline *cl,
3829 __attribute__((unused)) void *data)
3831 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
3832 struct rte_eth_fc_conf fc_conf;
3833 int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
3837 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3838 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3839 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3840 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3842 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
3843 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
3846 rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
3847 tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
3848 mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
3850 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
3851 fc_conf.high_water = res->high_water;
3852 fc_conf.low_water = res->low_water;
3853 fc_conf.pause_time = res->pause_time;
3854 fc_conf.send_xon = res->send_xon;
3855 fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
3856 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
3858 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
3860 printf("bad flow contrl parameter, return code = %d \n", ret);
3863 cmdline_parse_token_string_t cmd_lfc_set_set =
3864 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3866 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
3867 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3868 flow_ctrl, "flow_ctrl");
3869 cmdline_parse_token_string_t cmd_lfc_set_rx =
3870 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3872 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
3873 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3874 rx_lfc_mode, "on#off");
3875 cmdline_parse_token_string_t cmd_lfc_set_tx =
3876 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3878 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
3879 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3880 tx_lfc_mode, "on#off");
3881 cmdline_parse_token_num_t cmd_lfc_set_high_water =
3882 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3883 high_water, UINT32);
3884 cmdline_parse_token_num_t cmd_lfc_set_low_water =
3885 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3887 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
3888 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3889 pause_time, UINT16);
3890 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
3891 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3893 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
3894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3895 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
3896 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
3897 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3898 mac_ctrl_frame_fwd_mode, "on#off");
3899 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
3900 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3901 autoneg_str, "autoneg");
3902 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
3903 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3905 cmdline_parse_token_num_t cmd_lfc_set_portid =
3906 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
3909 cmdline_parse_inst_t cmd_link_flow_control_set = {
3910 .f = cmd_link_flow_ctrl_set_parsed,
3912 .help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
3913 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
3914 autoneg on|off port_id",
3916 (void *)&cmd_lfc_set_set,
3917 (void *)&cmd_lfc_set_flow_ctrl,
3918 (void *)&cmd_lfc_set_rx,
3919 (void *)&cmd_lfc_set_rx_mode,
3920 (void *)&cmd_lfc_set_tx,
3921 (void *)&cmd_lfc_set_tx_mode,
3922 (void *)&cmd_lfc_set_high_water,
3923 (void *)&cmd_lfc_set_low_water,
3924 (void *)&cmd_lfc_set_pause_time,
3925 (void *)&cmd_lfc_set_send_xon,
3926 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
3927 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
3928 (void *)&cmd_lfc_set_autoneg_str,
3929 (void *)&cmd_lfc_set_autoneg,
3930 (void *)&cmd_lfc_set_portid,
3935 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
3936 struct cmd_priority_flow_ctrl_set_result {
3937 cmdline_fixed_string_t set;
3938 cmdline_fixed_string_t pfc_ctrl;
3939 cmdline_fixed_string_t rx;
3940 cmdline_fixed_string_t rx_pfc_mode;
3941 cmdline_fixed_string_t tx;
3942 cmdline_fixed_string_t tx_pfc_mode;
3943 uint32_t high_water;
3945 uint16_t pause_time;
3951 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
3952 __attribute__((unused)) struct cmdline *cl,
3953 __attribute__((unused)) void *data)
3955 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
3956 struct rte_eth_pfc_conf pfc_conf;
3957 int rx_fc_enable, tx_fc_enable;
3961 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
3962 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
3963 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
3964 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
3966 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
3967 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
3970 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
3971 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
3972 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
3973 pfc_conf.fc.high_water = res->high_water;
3974 pfc_conf.fc.low_water = res->low_water;
3975 pfc_conf.fc.pause_time = res->pause_time;
3976 pfc_conf.priority = res->priority;
3978 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
3980 printf("bad priority flow contrl parameter, return code = %d \n", ret);
3983 cmdline_parse_token_string_t cmd_pfc_set_set =
3984 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3986 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
3987 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3988 pfc_ctrl, "pfc_ctrl");
3989 cmdline_parse_token_string_t cmd_pfc_set_rx =
3990 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3992 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
3993 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3994 rx_pfc_mode, "on#off");
3995 cmdline_parse_token_string_t cmd_pfc_set_tx =
3996 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
3998 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
3999 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4000 tx_pfc_mode, "on#off");
4001 cmdline_parse_token_num_t cmd_pfc_set_high_water =
4002 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4003 high_water, UINT32);
4004 cmdline_parse_token_num_t cmd_pfc_set_low_water =
4005 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4007 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
4008 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4009 pause_time, UINT16);
4010 cmdline_parse_token_num_t cmd_pfc_set_priority =
4011 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4013 cmdline_parse_token_num_t cmd_pfc_set_portid =
4014 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
4017 cmdline_parse_inst_t cmd_priority_flow_control_set = {
4018 .f = cmd_priority_flow_ctrl_set_parsed,
4020 .help_str = "Configure the Ethernet priority flow control: set pfc_ctrl rx on|off\n\
4021 tx on|off high_water low_water pause_time priority port_id",
4023 (void *)&cmd_pfc_set_set,
4024 (void *)&cmd_pfc_set_flow_ctrl,
4025 (void *)&cmd_pfc_set_rx,
4026 (void *)&cmd_pfc_set_rx_mode,
4027 (void *)&cmd_pfc_set_tx,
4028 (void *)&cmd_pfc_set_tx_mode,
4029 (void *)&cmd_pfc_set_high_water,
4030 (void *)&cmd_pfc_set_low_water,
4031 (void *)&cmd_pfc_set_pause_time,
4032 (void *)&cmd_pfc_set_priority,
4033 (void *)&cmd_pfc_set_portid,
4038 /* *** RESET CONFIGURATION *** */
4039 struct cmd_reset_result {
4040 cmdline_fixed_string_t reset;
4041 cmdline_fixed_string_t def;
4044 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
4046 __attribute__((unused)) void *data)
4048 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
4049 set_def_fwd_config();
4052 cmdline_parse_token_string_t cmd_reset_set =
4053 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
4054 cmdline_parse_token_string_t cmd_reset_def =
4055 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
4058 cmdline_parse_inst_t cmd_reset = {
4059 .f = cmd_reset_parsed,
4061 .help_str = "set default: reset default forwarding configuration",
4063 (void *)&cmd_reset_set,
4064 (void *)&cmd_reset_def,
4069 /* *** START FORWARDING *** */
4070 struct cmd_start_result {
4071 cmdline_fixed_string_t start;
4074 cmdline_parse_token_string_t cmd_start_start =
4075 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
4077 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
4078 __attribute__((unused)) struct cmdline *cl,
4079 __attribute__((unused)) void *data)
4081 start_packet_forwarding(0);
4084 cmdline_parse_inst_t cmd_start = {
4085 .f = cmd_start_parsed,
4087 .help_str = "start packet forwarding",
4089 (void *)&cmd_start_start,
4094 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
4095 struct cmd_start_tx_first_result {
4096 cmdline_fixed_string_t start;
4097 cmdline_fixed_string_t tx_first;
4101 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
4102 __attribute__((unused)) struct cmdline *cl,
4103 __attribute__((unused)) void *data)
4105 start_packet_forwarding(1);
4108 cmdline_parse_token_string_t cmd_start_tx_first_start =
4109 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
4111 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
4112 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
4113 tx_first, "tx_first");
4115 cmdline_parse_inst_t cmd_start_tx_first = {
4116 .f = cmd_start_tx_first_parsed,
4118 .help_str = "start packet forwarding, after sending 1 burst of packets",
4120 (void *)&cmd_start_tx_first_start,
4121 (void *)&cmd_start_tx_first_tx_first,
4126 /* *** SET LINK UP *** */
4127 struct cmd_set_link_up_result {
4128 cmdline_fixed_string_t set;
4129 cmdline_fixed_string_t link_up;
4130 cmdline_fixed_string_t port;
4134 cmdline_parse_token_string_t cmd_set_link_up_set =
4135 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
4136 cmdline_parse_token_string_t cmd_set_link_up_link_up =
4137 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
4139 cmdline_parse_token_string_t cmd_set_link_up_port =
4140 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
4141 cmdline_parse_token_num_t cmd_set_link_up_port_id =
4142 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
4144 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
4145 __attribute__((unused)) struct cmdline *cl,
4146 __attribute__((unused)) void *data)
4148 struct cmd_set_link_up_result *res = parsed_result;
4149 dev_set_link_up(res->port_id);
4152 cmdline_parse_inst_t cmd_set_link_up = {
4153 .f = cmd_set_link_up_parsed,
4155 .help_str = "set link-up port (port id)",
4157 (void *)&cmd_set_link_up_set,
4158 (void *)&cmd_set_link_up_link_up,
4159 (void *)&cmd_set_link_up_port,
4160 (void *)&cmd_set_link_up_port_id,
4165 /* *** SET LINK DOWN *** */
4166 struct cmd_set_link_down_result {
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t link_down;
4169 cmdline_fixed_string_t port;
4173 cmdline_parse_token_string_t cmd_set_link_down_set =
4174 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
4175 cmdline_parse_token_string_t cmd_set_link_down_link_down =
4176 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
4178 cmdline_parse_token_string_t cmd_set_link_down_port =
4179 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
4180 cmdline_parse_token_num_t cmd_set_link_down_port_id =
4181 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
4183 static void cmd_set_link_down_parsed(
4184 __attribute__((unused)) void *parsed_result,
4185 __attribute__((unused)) struct cmdline *cl,
4186 __attribute__((unused)) void *data)
4188 struct cmd_set_link_down_result *res = parsed_result;
4189 dev_set_link_down(res->port_id);
4192 cmdline_parse_inst_t cmd_set_link_down = {
4193 .f = cmd_set_link_down_parsed,
4195 .help_str = "set link-down port (port id)",
4197 (void *)&cmd_set_link_down_set,
4198 (void *)&cmd_set_link_down_link_down,
4199 (void *)&cmd_set_link_down_port,
4200 (void *)&cmd_set_link_down_port_id,
4205 /* *** SHOW CFG *** */
4206 struct cmd_showcfg_result {
4207 cmdline_fixed_string_t show;
4208 cmdline_fixed_string_t cfg;
4209 cmdline_fixed_string_t what;
4212 static void cmd_showcfg_parsed(void *parsed_result,
4213 __attribute__((unused)) struct cmdline *cl,
4214 __attribute__((unused)) void *data)
4216 struct cmd_showcfg_result *res = parsed_result;
4217 if (!strcmp(res->what, "rxtx"))
4218 rxtx_config_display();
4219 else if (!strcmp(res->what, "cores"))
4220 fwd_lcores_config_display();
4221 else if (!strcmp(res->what, "fwd"))
4222 fwd_config_display();
4225 cmdline_parse_token_string_t cmd_showcfg_show =
4226 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
4227 cmdline_parse_token_string_t cmd_showcfg_port =
4228 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
4229 cmdline_parse_token_string_t cmd_showcfg_what =
4230 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
4233 cmdline_parse_inst_t cmd_showcfg = {
4234 .f = cmd_showcfg_parsed,
4236 .help_str = "show config rxtx|cores|fwd",
4238 (void *)&cmd_showcfg_show,
4239 (void *)&cmd_showcfg_port,
4240 (void *)&cmd_showcfg_what,
4245 /* *** SHOW ALL PORT INFO *** */
4246 struct cmd_showportall_result {
4247 cmdline_fixed_string_t show;
4248 cmdline_fixed_string_t port;
4249 cmdline_fixed_string_t what;
4250 cmdline_fixed_string_t all;
4253 static void cmd_showportall_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4259 struct cmd_showportall_result *res = parsed_result;
4260 if (!strcmp(res->show, "clear")) {
4261 if (!strcmp(res->what, "stats"))
4262 for (i = 0; i < nb_ports; i++)
4264 } else if (!strcmp(res->what, "info"))
4265 for (i = 0; i < nb_ports; i++)
4266 port_infos_display(i);
4267 else if (!strcmp(res->what, "stats"))
4268 for (i = 0; i < nb_ports; i++)
4269 nic_stats_display(i);
4270 else if (!strcmp(res->what, "fdir"))
4271 for (i = 0; i < nb_ports; i++)
4273 else if (!strcmp(res->what, "stat_qmap"))
4274 for (i = 0; i < nb_ports; i++)
4275 nic_stats_mapping_display(i);
4278 cmdline_parse_token_string_t cmd_showportall_show =
4279 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
4281 cmdline_parse_token_string_t cmd_showportall_port =
4282 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
4283 cmdline_parse_token_string_t cmd_showportall_what =
4284 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
4285 "info#stats#fdir#stat_qmap");
4286 cmdline_parse_token_string_t cmd_showportall_all =
4287 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
4288 cmdline_parse_inst_t cmd_showportall = {
4289 .f = cmd_showportall_parsed,
4291 .help_str = "show|clear port info|stats|fdir|stat_qmap all",
4293 (void *)&cmd_showportall_show,
4294 (void *)&cmd_showportall_port,
4295 (void *)&cmd_showportall_what,
4296 (void *)&cmd_showportall_all,
4301 /* *** SHOW PORT INFO *** */
4302 struct cmd_showport_result {
4303 cmdline_fixed_string_t show;
4304 cmdline_fixed_string_t port;
4305 cmdline_fixed_string_t what;
4309 static void cmd_showport_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4311 __attribute__((unused)) void *data)
4313 struct cmd_showport_result *res = parsed_result;
4314 if (!strcmp(res->show, "clear")) {
4315 if (!strcmp(res->what, "stats"))
4316 nic_stats_clear(res->portnum);
4317 } else if (!strcmp(res->what, "info"))
4318 port_infos_display(res->portnum);
4319 else if (!strcmp(res->what, "stats"))
4320 nic_stats_display(res->portnum);
4321 else if (!strcmp(res->what, "fdir"))
4322 fdir_get_infos(res->portnum);
4323 else if (!strcmp(res->what, "stat_qmap"))
4324 nic_stats_mapping_display(res->portnum);
4327 cmdline_parse_token_string_t cmd_showport_show =
4328 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
4330 cmdline_parse_token_string_t cmd_showport_port =
4331 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
4332 cmdline_parse_token_string_t cmd_showport_what =
4333 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
4334 "info#stats#fdir#stat_qmap");
4335 cmdline_parse_token_num_t cmd_showport_portnum =
4336 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
4338 cmdline_parse_inst_t cmd_showport = {
4339 .f = cmd_showport_parsed,
4341 .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
4343 (void *)&cmd_showport_show,
4344 (void *)&cmd_showport_port,
4345 (void *)&cmd_showport_what,
4346 (void *)&cmd_showport_portnum,
4351 /* *** READ PORT REGISTER *** */
4352 struct cmd_read_reg_result {
4353 cmdline_fixed_string_t read;
4354 cmdline_fixed_string_t reg;
4360 cmd_read_reg_parsed(void *parsed_result,
4361 __attribute__((unused)) struct cmdline *cl,
4362 __attribute__((unused)) void *data)
4364 struct cmd_read_reg_result *res = parsed_result;
4365 port_reg_display(res->port_id, res->reg_off);
4368 cmdline_parse_token_string_t cmd_read_reg_read =
4369 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
4370 cmdline_parse_token_string_t cmd_read_reg_reg =
4371 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
4372 cmdline_parse_token_num_t cmd_read_reg_port_id =
4373 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT8);
4374 cmdline_parse_token_num_t cmd_read_reg_reg_off =
4375 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
4377 cmdline_parse_inst_t cmd_read_reg = {
4378 .f = cmd_read_reg_parsed,
4380 .help_str = "read reg port_id reg_off",
4382 (void *)&cmd_read_reg_read,
4383 (void *)&cmd_read_reg_reg,
4384 (void *)&cmd_read_reg_port_id,
4385 (void *)&cmd_read_reg_reg_off,
4390 /* *** READ PORT REGISTER BIT FIELD *** */
4391 struct cmd_read_reg_bit_field_result {
4392 cmdline_fixed_string_t read;
4393 cmdline_fixed_string_t regfield;
4401 cmd_read_reg_bit_field_parsed(void *parsed_result,
4402 __attribute__((unused)) struct cmdline *cl,
4403 __attribute__((unused)) void *data)
4405 struct cmd_read_reg_bit_field_result *res = parsed_result;
4406 port_reg_bit_field_display(res->port_id, res->reg_off,
4407 res->bit1_pos, res->bit2_pos);
4410 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
4411 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
4413 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
4414 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
4415 regfield, "regfield");
4416 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
4417 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
4419 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
4420 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
4422 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
4423 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
4425 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
4426 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
4429 cmdline_parse_inst_t cmd_read_reg_bit_field = {
4430 .f = cmd_read_reg_bit_field_parsed,
4432 .help_str = "read regfield port_id reg_off bit_x bit_y "
4433 "(read register bit field between bit_x and bit_y included)",
4435 (void *)&cmd_read_reg_bit_field_read,
4436 (void *)&cmd_read_reg_bit_field_regfield,
4437 (void *)&cmd_read_reg_bit_field_port_id,
4438 (void *)&cmd_read_reg_bit_field_reg_off,
4439 (void *)&cmd_read_reg_bit_field_bit1_pos,
4440 (void *)&cmd_read_reg_bit_field_bit2_pos,
4445 /* *** READ PORT REGISTER BIT *** */
4446 struct cmd_read_reg_bit_result {
4447 cmdline_fixed_string_t read;
4448 cmdline_fixed_string_t regbit;
4455 cmd_read_reg_bit_parsed(void *parsed_result,
4456 __attribute__((unused)) struct cmdline *cl,
4457 __attribute__((unused)) void *data)
4459 struct cmd_read_reg_bit_result *res = parsed_result;
4460 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
4463 cmdline_parse_token_string_t cmd_read_reg_bit_read =
4464 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
4465 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
4466 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
4468 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
4469 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT8);
4470 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
4471 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
4472 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
4473 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
4475 cmdline_parse_inst_t cmd_read_reg_bit = {
4476 .f = cmd_read_reg_bit_parsed,
4478 .help_str = "read regbit port_id reg_off bit_x (0 <= bit_x <= 31)",
4480 (void *)&cmd_read_reg_bit_read,
4481 (void *)&cmd_read_reg_bit_regbit,
4482 (void *)&cmd_read_reg_bit_port_id,
4483 (void *)&cmd_read_reg_bit_reg_off,
4484 (void *)&cmd_read_reg_bit_bit_pos,
4489 /* *** WRITE PORT REGISTER *** */
4490 struct cmd_write_reg_result {
4491 cmdline_fixed_string_t write;
4492 cmdline_fixed_string_t reg;
4499 cmd_write_reg_parsed(void *parsed_result,
4500 __attribute__((unused)) struct cmdline *cl,
4501 __attribute__((unused)) void *data)
4503 struct cmd_write_reg_result *res = parsed_result;
4504 port_reg_set(res->port_id, res->reg_off, res->value);
4507 cmdline_parse_token_string_t cmd_write_reg_write =
4508 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
4509 cmdline_parse_token_string_t cmd_write_reg_reg =
4510 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
4511 cmdline_parse_token_num_t cmd_write_reg_port_id =
4512 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT8);
4513 cmdline_parse_token_num_t cmd_write_reg_reg_off =
4514 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
4515 cmdline_parse_token_num_t cmd_write_reg_value =
4516 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
4518 cmdline_parse_inst_t cmd_write_reg = {
4519 .f = cmd_write_reg_parsed,
4521 .help_str = "write reg port_id reg_off reg_value",
4523 (void *)&cmd_write_reg_write,
4524 (void *)&cmd_write_reg_reg,
4525 (void *)&cmd_write_reg_port_id,
4526 (void *)&cmd_write_reg_reg_off,
4527 (void *)&cmd_write_reg_value,
4532 /* *** WRITE PORT REGISTER BIT FIELD *** */
4533 struct cmd_write_reg_bit_field_result {
4534 cmdline_fixed_string_t write;
4535 cmdline_fixed_string_t regfield;
4544 cmd_write_reg_bit_field_parsed(void *parsed_result,
4545 __attribute__((unused)) struct cmdline *cl,
4546 __attribute__((unused)) void *data)
4548 struct cmd_write_reg_bit_field_result *res = parsed_result;
4549 port_reg_bit_field_set(res->port_id, res->reg_off,
4550 res->bit1_pos, res->bit2_pos, res->value);
4553 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
4554 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
4556 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
4557 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
4558 regfield, "regfield");
4559 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
4560 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
4562 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
4563 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
4565 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
4566 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
4568 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
4569 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
4571 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
4572 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
4575 cmdline_parse_inst_t cmd_write_reg_bit_field = {
4576 .f = cmd_write_reg_bit_field_parsed,
4578 .help_str = "write regfield port_id reg_off bit_x bit_y reg_value"
4579 "(set register bit field between bit_x and bit_y included)",
4581 (void *)&cmd_write_reg_bit_field_write,
4582 (void *)&cmd_write_reg_bit_field_regfield,
4583 (void *)&cmd_write_reg_bit_field_port_id,
4584 (void *)&cmd_write_reg_bit_field_reg_off,
4585 (void *)&cmd_write_reg_bit_field_bit1_pos,
4586 (void *)&cmd_write_reg_bit_field_bit2_pos,
4587 (void *)&cmd_write_reg_bit_field_value,
4592 /* *** WRITE PORT REGISTER BIT *** */
4593 struct cmd_write_reg_bit_result {
4594 cmdline_fixed_string_t write;
4595 cmdline_fixed_string_t regbit;
4603 cmd_write_reg_bit_parsed(void *parsed_result,
4604 __attribute__((unused)) struct cmdline *cl,
4605 __attribute__((unused)) void *data)
4607 struct cmd_write_reg_bit_result *res = parsed_result;
4608 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
4611 cmdline_parse_token_string_t cmd_write_reg_bit_write =
4612 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
4614 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
4615 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
4617 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
4618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT8);
4619 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
4620 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
4621 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
4622 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
4623 cmdline_parse_token_num_t cmd_write_reg_bit_value =
4624 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
4626 cmdline_parse_inst_t cmd_write_reg_bit = {
4627 .f = cmd_write_reg_bit_parsed,
4629 .help_str = "write regbit port_id reg_off bit_x 0/1 (0 <= bit_x <= 31)",
4631 (void *)&cmd_write_reg_bit_write,
4632 (void *)&cmd_write_reg_bit_regbit,
4633 (void *)&cmd_write_reg_bit_port_id,
4634 (void *)&cmd_write_reg_bit_reg_off,
4635 (void *)&cmd_write_reg_bit_bit_pos,
4636 (void *)&cmd_write_reg_bit_value,
4641 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
4642 struct cmd_read_rxd_txd_result {
4643 cmdline_fixed_string_t read;
4644 cmdline_fixed_string_t rxd_txd;
4651 cmd_read_rxd_txd_parsed(void *parsed_result,
4652 __attribute__((unused)) struct cmdline *cl,
4653 __attribute__((unused)) void *data)
4655 struct cmd_read_rxd_txd_result *res = parsed_result;
4657 if (!strcmp(res->rxd_txd, "rxd"))
4658 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4659 else if (!strcmp(res->rxd_txd, "txd"))
4660 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
4663 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
4664 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
4665 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
4666 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
4668 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
4669 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT8);
4670 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
4671 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
4672 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
4673 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
4675 cmdline_parse_inst_t cmd_read_rxd_txd = {
4676 .f = cmd_read_rxd_txd_parsed,
4678 .help_str = "read rxd|txd port_id queue_id rxd_id",
4680 (void *)&cmd_read_rxd_txd_read,
4681 (void *)&cmd_read_rxd_txd_rxd_txd,
4682 (void *)&cmd_read_rxd_txd_port_id,
4683 (void *)&cmd_read_rxd_txd_queue_id,
4684 (void *)&cmd_read_rxd_txd_desc_id,
4690 struct cmd_quit_result {
4691 cmdline_fixed_string_t quit;
4694 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
4696 __attribute__((unused)) void *data)
4702 cmdline_parse_token_string_t cmd_quit_quit =
4703 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
4705 cmdline_parse_inst_t cmd_quit = {
4706 .f = cmd_quit_parsed,
4708 .help_str = "exit application",
4710 (void *)&cmd_quit_quit,
4715 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
4716 struct cmd_mac_addr_result {
4717 cmdline_fixed_string_t mac_addr_cmd;
4718 cmdline_fixed_string_t what;
4720 struct ether_addr address;
4723 static void cmd_mac_addr_parsed(void *parsed_result,
4724 __attribute__((unused)) struct cmdline *cl,
4725 __attribute__((unused)) void *data)
4727 struct cmd_mac_addr_result *res = parsed_result;
4730 if (strcmp(res->what, "add") == 0)
4731 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
4733 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
4735 /* check the return value and print it if is < 0 */
4737 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
4741 cmdline_parse_token_string_t cmd_mac_addr_cmd =
4742 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
4744 cmdline_parse_token_string_t cmd_mac_addr_what =
4745 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
4747 cmdline_parse_token_num_t cmd_mac_addr_portnum =
4748 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, UINT8);
4749 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
4750 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
4752 cmdline_parse_inst_t cmd_mac_addr = {
4753 .f = cmd_mac_addr_parsed,
4755 .help_str = "mac_addr add|remove X <address>: "
4756 "add/remove MAC address on port X",
4758 (void *)&cmd_mac_addr_cmd,
4759 (void *)&cmd_mac_addr_what,
4760 (void *)&cmd_mac_addr_portnum,
4761 (void *)&cmd_mac_addr_addr,
4767 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
4768 struct cmd_set_qmap_result {
4769 cmdline_fixed_string_t set;
4770 cmdline_fixed_string_t qmap;
4771 cmdline_fixed_string_t what;
4778 cmd_set_qmap_parsed(void *parsed_result,
4779 __attribute__((unused)) struct cmdline *cl,
4780 __attribute__((unused)) void *data)
4782 struct cmd_set_qmap_result *res = parsed_result;
4783 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
4785 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
4788 cmdline_parse_token_string_t cmd_setqmap_set =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4791 cmdline_parse_token_string_t cmd_setqmap_qmap =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4794 cmdline_parse_token_string_t cmd_setqmap_what =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
4797 cmdline_parse_token_num_t cmd_setqmap_portid =
4798 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4800 cmdline_parse_token_num_t cmd_setqmap_queueid =
4801 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4803 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
4804 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
4807 cmdline_parse_inst_t cmd_set_qmap = {
4808 .f = cmd_set_qmap_parsed,
4810 .help_str = "Set statistics mapping value on tx|rx queue_id of port_id",
4812 (void *)&cmd_setqmap_set,
4813 (void *)&cmd_setqmap_qmap,
4814 (void *)&cmd_setqmap_what,
4815 (void *)&cmd_setqmap_portid,
4816 (void *)&cmd_setqmap_queueid,
4817 (void *)&cmd_setqmap_mapvalue,
4822 /* *** CONFIGURE UNICAST HASH TABLE *** */
4823 struct cmd_set_uc_hash_table {
4824 cmdline_fixed_string_t set;
4825 cmdline_fixed_string_t port;
4827 cmdline_fixed_string_t what;
4828 struct ether_addr address;
4829 cmdline_fixed_string_t mode;
4833 cmd_set_uc_hash_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4838 struct cmd_set_uc_hash_table *res = parsed_result;
4840 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4842 if (strcmp(res->what, "uta") == 0)
4843 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
4844 &res->address,(uint8_t)is_on);
4846 printf("bad unicast hash table parameter, return code = %d \n", ret);
4850 cmdline_parse_token_string_t cmd_set_uc_hash_set =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4853 cmdline_parse_token_string_t cmd_set_uc_hash_port =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4856 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
4857 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
4859 cmdline_parse_token_string_t cmd_set_uc_hash_what =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4862 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
4863 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
4865 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
4869 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
4870 .f = cmd_set_uc_hash_parsed,
4872 .help_str = "set port X uta Y on|off(X = port number,Y = MAC address)",
4874 (void *)&cmd_set_uc_hash_set,
4875 (void *)&cmd_set_uc_hash_port,
4876 (void *)&cmd_set_uc_hash_portid,
4877 (void *)&cmd_set_uc_hash_what,
4878 (void *)&cmd_set_uc_hash_mac,
4879 (void *)&cmd_set_uc_hash_mode,
4884 struct cmd_set_uc_all_hash_table {
4885 cmdline_fixed_string_t set;
4886 cmdline_fixed_string_t port;
4888 cmdline_fixed_string_t what;
4889 cmdline_fixed_string_t value;
4890 cmdline_fixed_string_t mode;
4894 cmd_set_uc_all_hash_parsed(void *parsed_result,
4895 __attribute__((unused)) struct cmdline *cl,
4896 __attribute__((unused)) void *data)
4899 struct cmd_set_uc_all_hash_table *res = parsed_result;
4901 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4903 if ((strcmp(res->what, "uta") == 0) &&
4904 (strcmp(res->value, "all") == 0))
4905 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
4907 printf("bad unicast hash table parameter,"
4908 "return code = %d \n", ret);
4911 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4914 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4917 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
4918 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
4920 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
4921 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4923 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4926 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
4927 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
4930 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
4931 .f = cmd_set_uc_all_hash_parsed,
4933 .help_str = "set port X uta all on|off (X = port number)",
4935 (void *)&cmd_set_uc_all_hash_set,
4936 (void *)&cmd_set_uc_all_hash_port,
4937 (void *)&cmd_set_uc_all_hash_portid,
4938 (void *)&cmd_set_uc_all_hash_what,
4939 (void *)&cmd_set_uc_all_hash_value,
4940 (void *)&cmd_set_uc_all_hash_mode,
4945 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
4946 struct cmd_set_vf_traffic {
4947 cmdline_fixed_string_t set;
4948 cmdline_fixed_string_t port;
4950 cmdline_fixed_string_t vf;
4952 cmdline_fixed_string_t what;
4953 cmdline_fixed_string_t mode;
4957 cmd_set_vf_traffic_parsed(void *parsed_result,
4958 __attribute__((unused)) struct cmdline *cl,
4959 __attribute__((unused)) void *data)
4961 struct cmd_set_vf_traffic *res = parsed_result;
4962 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
4963 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
4965 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
4968 cmdline_parse_token_string_t cmd_setvf_traffic_set =
4969 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4971 cmdline_parse_token_string_t cmd_setvf_traffic_port =
4972 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4974 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
4975 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4977 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4980 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
4981 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
4983 cmdline_parse_token_string_t cmd_setvf_traffic_what =
4984 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4986 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
4987 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
4990 cmdline_parse_inst_t cmd_set_vf_traffic = {
4991 .f = cmd_set_vf_traffic_parsed,
4993 .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)",
4995 (void *)&cmd_setvf_traffic_set,
4996 (void *)&cmd_setvf_traffic_port,
4997 (void *)&cmd_setvf_traffic_portid,
4998 (void *)&cmd_setvf_traffic_vf,
4999 (void *)&cmd_setvf_traffic_vfid,
5000 (void *)&cmd_setvf_traffic_what,
5001 (void *)&cmd_setvf_traffic_mode,
5006 /* *** CONFIGURE VF RECEIVE MODE *** */
5007 struct cmd_set_vf_rxmode {
5008 cmdline_fixed_string_t set;
5009 cmdline_fixed_string_t port;
5011 cmdline_fixed_string_t vf;
5013 cmdline_fixed_string_t what;
5014 cmdline_fixed_string_t mode;
5015 cmdline_fixed_string_t on;
5019 cmd_set_vf_rxmode_parsed(void *parsed_result,
5020 __attribute__((unused)) struct cmdline *cl,
5021 __attribute__((unused)) void *data)
5024 uint16_t rx_mode = 0;
5025 struct cmd_set_vf_rxmode *res = parsed_result;
5027 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
5028 if (!strcmp(res->what,"rxmode")) {
5029 if (!strcmp(res->mode, "AUPE"))
5030 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
5031 else if (!strcmp(res->mode, "ROPE"))
5032 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
5033 else if (!strcmp(res->mode, "BAM"))
5034 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
5035 else if (!strncmp(res->mode, "MPE",3))
5036 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
5039 ret = rte_eth_dev_set_vf_rxmode(res->port_id,res->vf_id,rx_mode,(uint8_t)is_on);
5041 printf("bad VF receive mode parameter, return code = %d \n",
5045 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
5046 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5048 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
5049 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5051 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
5052 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5054 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
5055 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5057 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
5058 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
5060 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
5061 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5063 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
5064 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5065 mode, "AUPE#ROPE#BAM#MPE");
5066 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
5067 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
5070 cmdline_parse_inst_t cmd_set_vf_rxmode = {
5071 .f = cmd_set_vf_rxmode_parsed,
5073 .help_str = "set port X vf Y rxmode AUPE|ROPE|BAM|MPE on|off",
5075 (void *)&cmd_set_vf_rxmode_set,
5076 (void *)&cmd_set_vf_rxmode_port,
5077 (void *)&cmd_set_vf_rxmode_portid,
5078 (void *)&cmd_set_vf_rxmode_vf,
5079 (void *)&cmd_set_vf_rxmode_vfid,
5080 (void *)&cmd_set_vf_rxmode_what,
5081 (void *)&cmd_set_vf_rxmode_mode,
5082 (void *)&cmd_set_vf_rxmode_on,
5087 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
5088 struct cmd_vf_mac_addr_result {
5089 cmdline_fixed_string_t mac_addr_cmd;
5090 cmdline_fixed_string_t what;
5091 cmdline_fixed_string_t port;
5093 cmdline_fixed_string_t vf;
5095 struct ether_addr address;
5098 static void cmd_vf_mac_addr_parsed(void *parsed_result,
5099 __attribute__((unused)) struct cmdline *cl,
5100 __attribute__((unused)) void *data)
5102 struct cmd_vf_mac_addr_result *res = parsed_result;
5105 if (strcmp(res->what, "add") == 0)
5106 ret = rte_eth_dev_mac_addr_add(res->port_num,
5107 &res->address, res->vf_num);
5109 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
5113 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
5114 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5115 mac_addr_cmd,"mac_addr");
5116 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
5117 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5119 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
5120 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5122 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
5123 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5125 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
5126 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
5128 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
5129 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
5131 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
5132 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
5135 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
5136 .f = cmd_vf_mac_addr_parsed,
5138 .help_str = "mac_addr add port X vf Y ethaddr:(X = port number,"
5139 "Y = VF number)add MAC address filtering for a VF on port X",
5141 (void *)&cmd_vf_mac_addr_cmd,
5142 (void *)&cmd_vf_mac_addr_what,
5143 (void *)&cmd_vf_mac_addr_port,
5144 (void *)&cmd_vf_mac_addr_portnum,
5145 (void *)&cmd_vf_mac_addr_vf,
5146 (void *)&cmd_vf_mac_addr_vfnum,
5147 (void *)&cmd_vf_mac_addr_addr,
5152 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
5153 struct cmd_vf_rx_vlan_filter {
5154 cmdline_fixed_string_t rx_vlan;
5155 cmdline_fixed_string_t what;
5157 cmdline_fixed_string_t port;
5159 cmdline_fixed_string_t vf;
5164 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
5165 __attribute__((unused)) struct cmdline *cl,
5166 __attribute__((unused)) void *data)
5168 struct cmd_vf_rx_vlan_filter *res = parsed_result;
5170 if (!strcmp(res->what, "add"))
5171 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 1);
5173 set_vf_rx_vlan(res->port_id, res->vlan_id,res->vf_mask, 0);
5176 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
5177 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5178 rx_vlan, "rx_vlan");
5179 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
5180 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5182 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
5183 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5185 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
5186 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5188 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
5189 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5191 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
5192 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5194 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
5195 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
5198 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
5199 .f = cmd_vf_rx_vlan_filter_parsed,
5201 .help_str = "rx_vlan add|rm X port Y vf Z (X = VLAN ID,"
5202 "Y = port number,Z = hexadecimal VF mask)",
5204 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
5205 (void *)&cmd_vf_rx_vlan_filter_what,
5206 (void *)&cmd_vf_rx_vlan_filter_vlanid,
5207 (void *)&cmd_vf_rx_vlan_filter_port,
5208 (void *)&cmd_vf_rx_vlan_filter_portid,
5209 (void *)&cmd_vf_rx_vlan_filter_vf,
5210 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
5215 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
5216 struct cmd_queue_rate_limit_result {
5217 cmdline_fixed_string_t set;
5218 cmdline_fixed_string_t port;
5220 cmdline_fixed_string_t queue;
5222 cmdline_fixed_string_t rate;
5226 static void cmd_queue_rate_limit_parsed(void *parsed_result,
5227 __attribute__((unused)) struct cmdline *cl,
5228 __attribute__((unused)) void *data)
5230 struct cmd_queue_rate_limit_result *res = parsed_result;
5233 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5234 && (strcmp(res->queue, "queue") == 0)
5235 && (strcmp(res->rate, "rate") == 0))
5236 ret = set_queue_rate_limit(res->port_num, res->queue_num,
5239 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
5243 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
5244 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5246 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
5247 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5249 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
5250 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5252 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
5253 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5255 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
5256 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5258 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
5259 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
5261 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
5262 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
5265 cmdline_parse_inst_t cmd_queue_rate_limit = {
5266 .f = cmd_queue_rate_limit_parsed,
5268 .help_str = "set port X queue Y rate Z:(X = port number,"
5269 "Y = queue number,Z = rate number)set rate limit for a queue on port X",
5271 (void *)&cmd_queue_rate_limit_set,
5272 (void *)&cmd_queue_rate_limit_port,
5273 (void *)&cmd_queue_rate_limit_portnum,
5274 (void *)&cmd_queue_rate_limit_queue,
5275 (void *)&cmd_queue_rate_limit_queuenum,
5276 (void *)&cmd_queue_rate_limit_rate,
5277 (void *)&cmd_queue_rate_limit_ratenum,
5282 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
5283 struct cmd_vf_rate_limit_result {
5284 cmdline_fixed_string_t set;
5285 cmdline_fixed_string_t port;
5287 cmdline_fixed_string_t vf;
5289 cmdline_fixed_string_t rate;
5291 cmdline_fixed_string_t q_msk;
5295 static void cmd_vf_rate_limit_parsed(void *parsed_result,
5296 __attribute__((unused)) struct cmdline *cl,
5297 __attribute__((unused)) void *data)
5299 struct cmd_vf_rate_limit_result *res = parsed_result;
5302 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
5303 && (strcmp(res->vf, "vf") == 0)
5304 && (strcmp(res->rate, "rate") == 0)
5305 && (strcmp(res->q_msk, "queue_mask") == 0))
5306 ret = set_vf_rate_limit(res->port_num, res->vf_num,
5307 res->rate_num, res->q_msk_val);
5309 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
5313 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
5314 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5316 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
5317 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5319 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
5320 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5322 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
5323 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5325 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
5326 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5328 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
5329 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5331 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
5332 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5334 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
5335 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
5336 q_msk, "queue_mask");
5337 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
5338 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
5341 cmdline_parse_inst_t cmd_vf_rate_limit = {
5342 .f = cmd_vf_rate_limit_parsed,
5344 .help_str = "set port X vf Y rate Z queue_mask V:(X = port number,"
5345 "Y = VF number,Z = rate number, V = queue mask value)set rate limit "
5346 "for queues of VF on port X",
5348 (void *)&cmd_vf_rate_limit_set,
5349 (void *)&cmd_vf_rate_limit_port,
5350 (void *)&cmd_vf_rate_limit_portnum,
5351 (void *)&cmd_vf_rate_limit_vf,
5352 (void *)&cmd_vf_rate_limit_vfnum,
5353 (void *)&cmd_vf_rate_limit_rate,
5354 (void *)&cmd_vf_rate_limit_ratenum,
5355 (void *)&cmd_vf_rate_limit_q_msk,
5356 (void *)&cmd_vf_rate_limit_q_msk_val,
5361 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
5362 struct cmd_set_mirror_mask_result {
5363 cmdline_fixed_string_t set;
5364 cmdline_fixed_string_t port;
5366 cmdline_fixed_string_t mirror;
5368 cmdline_fixed_string_t what;
5369 cmdline_fixed_string_t value;
5370 cmdline_fixed_string_t dstpool;
5372 cmdline_fixed_string_t on;
5375 cmdline_parse_token_string_t cmd_mirror_mask_set =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5378 cmdline_parse_token_string_t cmd_mirror_mask_port =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5381 cmdline_parse_token_num_t cmd_mirror_mask_portid =
5382 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5384 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
5385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5386 mirror, "mirror-rule");
5387 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
5388 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5390 cmdline_parse_token_string_t cmd_mirror_mask_what =
5391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5392 what, "pool-mirror#vlan-mirror");
5393 cmdline_parse_token_string_t cmd_mirror_mask_value =
5394 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5396 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
5397 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5398 dstpool, "dst-pool");
5399 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
5400 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
5402 cmdline_parse_token_string_t cmd_mirror_mask_on =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
5407 cmd_set_mirror_mask_parsed(void *parsed_result,
5408 __attribute__((unused)) struct cmdline *cl,
5409 __attribute__((unused)) void *data)
5412 struct cmd_set_mirror_mask_result *res = parsed_result;
5413 struct rte_eth_vmdq_mirror_conf mr_conf;
5415 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5417 unsigned int vlan_list[ETH_VMDQ_MAX_VLAN_FILTERS];
5419 mr_conf.dst_pool = res->dstpool_id;
5421 if (!strcmp(res->what, "pool-mirror")) {
5422 mr_conf.pool_mask = strtoull(res->value,NULL,16);
5423 mr_conf.rule_type_mask = ETH_VMDQ_POOL_MIRROR;
5424 } else if(!strcmp(res->what, "vlan-mirror")) {
5425 mr_conf.rule_type_mask = ETH_VMDQ_VLAN_MIRROR;
5426 nb_item = parse_item_list(res->value, "core",
5427 ETH_VMDQ_MAX_VLAN_FILTERS,vlan_list,1);
5431 for(i=0; i < nb_item; i++) {
5432 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
5433 printf("Invalid vlan_id: must be < 4096\n");
5437 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
5438 mr_conf.vlan.vlan_mask |= 1ULL << i;
5442 if(!strcmp(res->on, "on"))
5443 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5446 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5449 printf("mirror rule add error: (%s)\n", strerror(-ret));
5452 cmdline_parse_inst_t cmd_set_mirror_mask = {
5453 .f = cmd_set_mirror_mask_parsed,
5455 .help_str = "set port X mirror-rule Y pool-mirror|vlan-mirror "
5456 "pool_mask|vlan_id[,vlan_id]* dst-pool Z on|off",
5458 (void *)&cmd_mirror_mask_set,
5459 (void *)&cmd_mirror_mask_port,
5460 (void *)&cmd_mirror_mask_portid,
5461 (void *)&cmd_mirror_mask_mirror,
5462 (void *)&cmd_mirror_mask_ruleid,
5463 (void *)&cmd_mirror_mask_what,
5464 (void *)&cmd_mirror_mask_value,
5465 (void *)&cmd_mirror_mask_dstpool,
5466 (void *)&cmd_mirror_mask_poolid,
5467 (void *)&cmd_mirror_mask_on,
5472 /* *** CONFIGURE VM MIRROR UDLINK/DOWNLINK RULE *** */
5473 struct cmd_set_mirror_link_result {
5474 cmdline_fixed_string_t set;
5475 cmdline_fixed_string_t port;
5477 cmdline_fixed_string_t mirror;
5479 cmdline_fixed_string_t what;
5480 cmdline_fixed_string_t dstpool;
5482 cmdline_fixed_string_t on;
5485 cmdline_parse_token_string_t cmd_mirror_link_set =
5486 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5488 cmdline_parse_token_string_t cmd_mirror_link_port =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5491 cmdline_parse_token_num_t cmd_mirror_link_portid =
5492 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5494 cmdline_parse_token_string_t cmd_mirror_link_mirror =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5496 mirror, "mirror-rule");
5497 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
5498 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5500 cmdline_parse_token_string_t cmd_mirror_link_what =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5502 what, "uplink-mirror#downlink-mirror");
5503 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5505 dstpool, "dst-pool");
5506 cmdline_parse_token_num_t cmd_mirror_link_poolid =
5507 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
5509 cmdline_parse_token_string_t cmd_mirror_link_on =
5510 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
5514 cmd_set_mirror_link_parsed(void *parsed_result,
5515 __attribute__((unused)) struct cmdline *cl,
5516 __attribute__((unused)) void *data)
5519 struct cmd_set_mirror_link_result *res = parsed_result;
5520 struct rte_eth_vmdq_mirror_conf mr_conf;
5522 memset(&mr_conf,0,sizeof(struct rte_eth_vmdq_mirror_conf));
5523 if(!strcmp(res->what, "uplink-mirror")) {
5524 mr_conf.rule_type_mask = ETH_VMDQ_UPLINK_MIRROR;
5525 }else if(!strcmp(res->what, "downlink-mirror"))
5526 mr_conf.rule_type_mask = ETH_VMDQ_DOWNLIN_MIRROR;
5528 mr_conf.dst_pool = res->dstpool_id;
5530 if(!strcmp(res->on, "on"))
5531 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5534 ret = rte_eth_mirror_rule_set(res->port_id,&mr_conf,
5537 /* check the return value and print it if is < 0 */
5539 printf("mirror rule add error: (%s)\n", strerror(-ret));
5543 cmdline_parse_inst_t cmd_set_mirror_link = {
5544 .f = cmd_set_mirror_link_parsed,
5546 .help_str = "set port X mirror-rule Y uplink-mirror|"
5547 "downlink-mirror dst-pool Z on|off",
5549 (void *)&cmd_mirror_link_set,
5550 (void *)&cmd_mirror_link_port,
5551 (void *)&cmd_mirror_link_portid,
5552 (void *)&cmd_mirror_link_mirror,
5553 (void *)&cmd_mirror_link_ruleid,
5554 (void *)&cmd_mirror_link_what,
5555 (void *)&cmd_mirror_link_dstpool,
5556 (void *)&cmd_mirror_link_poolid,
5557 (void *)&cmd_mirror_link_on,
5562 /* *** RESET VM MIRROR RULE *** */
5563 struct cmd_rm_mirror_rule_result {
5564 cmdline_fixed_string_t reset;
5565 cmdline_fixed_string_t port;
5567 cmdline_fixed_string_t mirror;
5571 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
5572 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5574 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
5575 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5577 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
5578 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5580 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
5581 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
5582 mirror, "mirror-rule");
5583 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
5584 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
5588 cmd_reset_mirror_rule_parsed(void *parsed_result,
5589 __attribute__((unused)) struct cmdline *cl,
5590 __attribute__((unused)) void *data)
5593 struct cmd_set_mirror_link_result *res = parsed_result;
5595 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
5597 printf("mirror rule remove error: (%s)\n", strerror(-ret));
5600 cmdline_parse_inst_t cmd_reset_mirror_rule = {
5601 .f = cmd_reset_mirror_rule_parsed,
5603 .help_str = "reset port X mirror-rule Y",
5605 (void *)&cmd_rm_mirror_rule_reset,
5606 (void *)&cmd_rm_mirror_rule_port,
5607 (void *)&cmd_rm_mirror_rule_portid,
5608 (void *)&cmd_rm_mirror_rule_mirror,
5609 (void *)&cmd_rm_mirror_rule_ruleid,
5614 /* ******************************************************************************** */
5616 struct cmd_dump_result {
5617 cmdline_fixed_string_t dump;
5621 dump_struct_sizes(void)
5623 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
5624 DUMP_SIZE(struct rte_mbuf);
5625 DUMP_SIZE(struct rte_pktmbuf);
5626 DUMP_SIZE(struct rte_ctrlmbuf);
5627 DUMP_SIZE(struct rte_mempool);
5628 DUMP_SIZE(struct rte_ring);
5632 static void cmd_dump_parsed(void *parsed_result,
5633 __attribute__((unused)) struct cmdline *cl,
5634 __attribute__((unused)) void *data)
5636 struct cmd_dump_result *res = parsed_result;
5638 if (!strcmp(res->dump, "dump_physmem"))
5639 rte_dump_physmem_layout(stdout);
5640 else if (!strcmp(res->dump, "dump_memzone"))
5641 rte_memzone_dump(stdout);
5642 else if (!strcmp(res->dump, "dump_log_history"))
5643 rte_log_dump_history(stdout);
5644 else if (!strcmp(res->dump, "dump_struct_sizes"))
5645 dump_struct_sizes();
5646 else if (!strcmp(res->dump, "dump_ring"))
5647 rte_ring_list_dump(stdout);
5648 else if (!strcmp(res->dump, "dump_mempool"))
5649 rte_mempool_list_dump(stdout);
5650 else if (!strcmp(res->dump, "dump_devargs"))
5651 rte_eal_devargs_dump(stdout);
5654 cmdline_parse_token_string_t cmd_dump_dump =
5655 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
5659 "dump_struct_sizes#"
5664 cmdline_parse_inst_t cmd_dump = {
5665 .f = cmd_dump_parsed, /* function to call */
5666 .data = NULL, /* 2nd arg of func */
5667 .help_str = "dump status",
5668 .tokens = { /* token list, NULL terminated */
5669 (void *)&cmd_dump_dump,
5674 /* ******************************************************************************** */
5676 struct cmd_dump_one_result {
5677 cmdline_fixed_string_t dump;
5678 cmdline_fixed_string_t name;
5681 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
5682 __attribute__((unused)) void *data)
5684 struct cmd_dump_one_result *res = parsed_result;
5686 if (!strcmp(res->dump, "dump_ring")) {
5688 r = rte_ring_lookup(res->name);
5690 cmdline_printf(cl, "Cannot find ring\n");
5693 rte_ring_dump(stdout, r);
5694 } else if (!strcmp(res->dump, "dump_mempool")) {
5695 struct rte_mempool *mp;
5696 mp = rte_mempool_lookup(res->name);
5698 cmdline_printf(cl, "Cannot find mempool\n");
5701 rte_mempool_dump(stdout, mp);
5705 cmdline_parse_token_string_t cmd_dump_one_dump =
5706 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
5707 "dump_ring#dump_mempool");
5709 cmdline_parse_token_string_t cmd_dump_one_name =
5710 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
5712 cmdline_parse_inst_t cmd_dump_one = {
5713 .f = cmd_dump_one_parsed, /* function to call */
5714 .data = NULL, /* 2nd arg of func */
5715 .help_str = "dump one ring/mempool: dump_ring|dump_mempool <name>",
5716 .tokens = { /* token list, NULL terminated */
5717 (void *)&cmd_dump_one_dump,
5718 (void *)&cmd_dump_one_name,
5723 /* *** ADD/REMOVE an ethertype FILTER *** */
5724 struct cmd_ethertype_filter_result {
5725 cmdline_fixed_string_t filter;
5727 cmdline_fixed_string_t ethertype;
5728 uint16_t ethertype_value;
5729 cmdline_fixed_string_t priority;
5730 cmdline_fixed_string_t priority_en;
5731 uint8_t priority_value;
5732 cmdline_fixed_string_t queue;
5734 cmdline_fixed_string_t index;
5735 uint16_t index_value;
5739 cmd_ethertype_filter_parsed(void *parsed_result,
5740 __attribute__((unused)) struct cmdline *cl,
5741 __attribute__((unused)) void *data)
5744 struct cmd_ethertype_filter_result *res = parsed_result;
5745 struct rte_ethertype_filter filter;
5747 memset(&filter, 0, sizeof(struct rte_ethertype_filter));
5748 filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
5749 filter.priority = res->priority_value;
5751 if (!strcmp(res->priority_en, "enable"))
5752 filter.priority_en = 1;
5753 if (!strcmp(res->filter, "add_ethertype_filter"))
5754 ret = rte_eth_dev_add_ethertype_filter(res->port_id,
5756 &filter, res->queue_id);
5757 else if (!strcmp(res->filter, "remove_ethertype_filter"))
5758 ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
5760 else if (!strcmp(res->filter, "get_ethertype_filter"))
5761 get_ethertype_filter(res->port_id, res->index_value);
5764 printf("ethertype filter setting error: (%s)\n",
5768 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
5769 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5771 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
5772 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5773 ethertype, "ethertype");
5774 cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
5775 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5776 ethertype_value, UINT16);
5777 cmdline_parse_token_string_t cmd_ethertype_filter_priority =
5778 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5779 priority, "priority");
5780 cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
5781 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5782 priority_en, "enable#disable");
5783 cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
5784 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5785 priority_value, UINT8);
5786 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
5787 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5789 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
5790 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5792 cmdline_parse_token_string_t cmd_ethertype_filter_index =
5793 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5795 cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
5796 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
5797 index_value, UINT16);
5798 cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
5799 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5800 filter, "add_ethertype_filter");
5801 cmdline_parse_inst_t cmd_add_ethertype_filter = {
5802 .f = cmd_ethertype_filter_parsed,
5804 .help_str = "add an ethertype filter",
5806 (void *)&cmd_ethertype_filter_add_filter,
5807 (void *)&cmd_ethertype_filter_port_id,
5808 (void *)&cmd_ethertype_filter_ethertype,
5809 (void *)&cmd_ethertype_filter_ethertype_value,
5810 (void *)&cmd_ethertype_filter_priority,
5811 (void *)&cmd_ethertype_filter_priority_en,
5812 (void *)&cmd_ethertype_filter_priority_value,
5813 (void *)&cmd_ethertype_filter_queue,
5814 (void *)&cmd_ethertype_filter_queue_id,
5815 (void *)&cmd_ethertype_filter_index,
5816 (void *)&cmd_ethertype_filter_index_value,
5821 cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
5822 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5823 filter, "remove_ethertype_filter");
5824 cmdline_parse_inst_t cmd_remove_ethertype_filter = {
5825 .f = cmd_ethertype_filter_parsed,
5827 .help_str = "remove an ethertype filter",
5829 (void *)&cmd_ethertype_filter_remove_filter,
5830 (void *)&cmd_ethertype_filter_port_id,
5831 (void *)&cmd_ethertype_filter_index,
5832 (void *)&cmd_ethertype_filter_index_value,
5836 cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
5837 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
5838 filter, "get_ethertype_filter");
5839 cmdline_parse_inst_t cmd_get_ethertype_filter = {
5840 .f = cmd_ethertype_filter_parsed,
5842 .help_str = "get an ethertype filter",
5844 (void *)&cmd_ethertype_filter_get_filter,
5845 (void *)&cmd_ethertype_filter_port_id,
5846 (void *)&cmd_ethertype_filter_index,
5847 (void *)&cmd_ethertype_filter_index_value,
5852 /* *** set SYN filter *** */
5853 struct cmd_set_syn_filter_result {
5854 cmdline_fixed_string_t filter;
5856 cmdline_fixed_string_t priority;
5857 cmdline_fixed_string_t high;
5858 cmdline_fixed_string_t queue;
5863 cmd_set_syn_filter_parsed(void *parsed_result,
5864 __attribute__((unused)) struct cmdline *cl,
5865 __attribute__((unused)) void *data)
5868 struct cmd_set_syn_filter_result *res = parsed_result;
5869 struct rte_syn_filter filter;
5871 if (!strcmp(res->filter, "add_syn_filter")) {
5872 if (!strcmp(res->high, "high"))
5876 ret = rte_eth_dev_add_syn_filter(res->port_id,
5877 &filter, res->queue_id);
5878 } else if (!strcmp(res->filter, "remove_syn_filter"))
5879 ret = rte_eth_dev_remove_syn_filter(res->port_id);
5880 else if (!strcmp(res->filter, "get_syn_filter"))
5881 get_syn_filter(res->port_id);
5883 printf("syn filter setting error: (%s)\n", strerror(-ret));
5886 cmdline_parse_token_num_t cmd_syn_filter_portid =
5887 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5889 cmdline_parse_token_string_t cmd_syn_filter_priority =
5890 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5891 priority, "priority");
5892 cmdline_parse_token_string_t cmd_syn_filter_high =
5893 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5895 cmdline_parse_token_string_t cmd_syn_filter_queue =
5896 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5898 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
5899 TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
5901 cmdline_parse_token_string_t cmd_syn_filter_add_filter =
5902 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5903 filter, "add_syn_filter");
5904 cmdline_parse_token_string_t cmd_syn_filter_remove_filter =
5905 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5906 filter, "remove_syn_filter");
5907 cmdline_parse_inst_t cmd_add_syn_filter = {
5908 .f = cmd_set_syn_filter_parsed,
5910 .help_str = "add syn filter",
5912 (void *)&cmd_syn_filter_add_filter,
5913 (void *)&cmd_syn_filter_portid,
5914 (void *)&cmd_syn_filter_priority,
5915 (void *)&cmd_syn_filter_high,
5916 (void *)&cmd_syn_filter_queue,
5917 (void *)&cmd_syn_filter_queue_id,
5921 cmdline_parse_inst_t cmd_remove_syn_filter = {
5922 .f = cmd_set_syn_filter_parsed,
5924 .help_str = "remove syn filter",
5926 (void *)&cmd_syn_filter_remove_filter,
5927 (void *)&cmd_syn_filter_portid,
5932 cmdline_parse_token_string_t cmd_syn_filter_get_filter =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result,
5934 filter, "get_syn_filter");
5936 cmdline_parse_inst_t cmd_get_syn_filter = {
5937 .f = cmd_set_syn_filter_parsed,
5939 .help_str = "get syn filter",
5941 (void *)&cmd_syn_filter_get_filter,
5942 (void *)&cmd_syn_filter_portid,
5947 /* *** ADD/REMOVE A 2tuple FILTER *** */
5948 struct cmd_2tuple_filter_result {
5949 cmdline_fixed_string_t filter;
5951 cmdline_fixed_string_t protocol;
5952 uint8_t protocol_value;
5953 uint8_t protocol_mask;
5954 cmdline_fixed_string_t dst_port;
5955 uint16_t dst_port_value;
5956 uint16_t dst_port_mask;
5957 cmdline_fixed_string_t flags;
5958 uint8_t flags_value;
5959 cmdline_fixed_string_t priority;
5960 uint8_t priority_value;
5961 cmdline_fixed_string_t queue;
5963 cmdline_fixed_string_t index;
5964 uint16_t index_value;
5968 cmd_2tuple_filter_parsed(void *parsed_result,
5969 __attribute__((unused)) struct cmdline *cl,
5970 __attribute__((unused)) void *data)
5973 struct rte_2tuple_filter filter;
5974 struct cmd_2tuple_filter_result *res = parsed_result;
5976 memset(&filter, 0, sizeof(struct rte_2tuple_filter));
5978 if (!strcmp(res->filter, "add_2tuple_filter")) {
5979 /* need convert to big endian. */
5980 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
5981 filter.protocol = res->protocol_value;
5982 filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1;
5983 filter.protocol_mask = (res->protocol_mask) ? 0 : 1;
5984 filter.priority = res->priority_value;
5985 filter.tcp_flags = res->flags_value;
5986 ret = rte_eth_dev_add_2tuple_filter(res->port_id,
5987 res->index_value, &filter, res->queue_id);
5988 } else if (!strcmp(res->filter, "remove_2tuple_filter"))
5989 ret = rte_eth_dev_remove_2tuple_filter(res->port_id,
5991 else if (!strcmp(res->filter, "get_2tuple_filter"))
5992 get_2tuple_filter(res->port_id, res->index_value);
5995 printf("2tuple filter setting error: (%s)\n", strerror(-ret));
5998 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
5999 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6001 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
6002 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6003 protocol, "protocol");
6004 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
6005 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6006 protocol_value, UINT8);
6007 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
6008 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6009 protocol_mask, UINT8);
6010 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
6011 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6012 dst_port, "dst_port");
6013 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
6014 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6015 dst_port_value, UINT16);
6016 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
6017 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6018 dst_port_mask, UINT16);
6019 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
6020 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6022 cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
6023 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6024 flags_value, UINT8);
6025 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
6026 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6027 priority, "priority");
6028 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
6029 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6030 priority_value, UINT8);
6031 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
6032 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6034 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
6035 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6037 cmdline_parse_token_string_t cmd_2tuple_filter_index =
6038 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6040 cmdline_parse_token_num_t cmd_2tuple_filter_index_value =
6041 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
6042 index_value, UINT16);
6043 cmdline_parse_token_string_t cmd_2tuple_filter_add_filter =
6044 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6045 filter, "add_2tuple_filter");
6046 cmdline_parse_inst_t cmd_add_2tuple_filter = {
6047 .f = cmd_2tuple_filter_parsed,
6049 .help_str = "add a 2tuple filter",
6051 (void *)&cmd_2tuple_filter_add_filter,
6052 (void *)&cmd_2tuple_filter_port_id,
6053 (void *)&cmd_2tuple_filter_protocol,
6054 (void *)&cmd_2tuple_filter_protocol_value,
6055 (void *)&cmd_2tuple_filter_protocol_mask,
6056 (void *)&cmd_2tuple_filter_dst_port,
6057 (void *)&cmd_2tuple_filter_dst_port_value,
6058 (void *)&cmd_2tuple_filter_dst_port_mask,
6059 (void *)&cmd_2tuple_filter_flags,
6060 (void *)&cmd_2tuple_filter_flags_value,
6061 (void *)&cmd_2tuple_filter_priority,
6062 (void *)&cmd_2tuple_filter_priority_value,
6063 (void *)&cmd_2tuple_filter_queue,
6064 (void *)&cmd_2tuple_filter_queue_id,
6065 (void *)&cmd_2tuple_filter_index,
6066 (void *)&cmd_2tuple_filter_index_value,
6071 cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter =
6072 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6073 filter, "remove_2tuple_filter");
6074 cmdline_parse_inst_t cmd_remove_2tuple_filter = {
6075 .f = cmd_2tuple_filter_parsed,
6077 .help_str = "remove a 2tuple filter",
6079 (void *)&cmd_2tuple_filter_remove_filter,
6080 (void *)&cmd_2tuple_filter_port_id,
6081 (void *)&cmd_2tuple_filter_index,
6082 (void *)&cmd_2tuple_filter_index_value,
6086 cmdline_parse_token_string_t cmd_2tuple_filter_get_filter =
6087 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
6088 filter, "get_2tuple_filter");
6089 cmdline_parse_inst_t cmd_get_2tuple_filter = {
6090 .f = cmd_2tuple_filter_parsed,
6092 .help_str = "get a 2tuple filter",
6094 (void *)&cmd_2tuple_filter_get_filter,
6095 (void *)&cmd_2tuple_filter_port_id,
6096 (void *)&cmd_2tuple_filter_index,
6097 (void *)&cmd_2tuple_filter_index_value,
6102 /* *** ADD/REMOVE A 5tuple FILTER *** */
6103 struct cmd_5tuple_filter_result {
6104 cmdline_fixed_string_t filter;
6106 cmdline_fixed_string_t dst_ip;
6107 cmdline_ipaddr_t dst_ip_value;
6108 cmdline_fixed_string_t src_ip;
6109 cmdline_ipaddr_t src_ip_value;
6110 cmdline_fixed_string_t dst_port;
6111 uint16_t dst_port_value;
6112 cmdline_fixed_string_t src_port;
6113 uint16_t src_port_value;
6114 cmdline_fixed_string_t protocol;
6115 uint8_t protocol_value;
6116 cmdline_fixed_string_t mask;
6118 cmdline_fixed_string_t flags;
6119 uint8_t flags_value;
6120 cmdline_fixed_string_t priority;
6121 uint8_t priority_value;
6122 cmdline_fixed_string_t queue;
6124 cmdline_fixed_string_t index;
6125 uint16_t index_value;
6129 cmd_5tuple_filter_parsed(void *parsed_result,
6130 __attribute__((unused)) struct cmdline *cl,
6131 __attribute__((unused)) void *data)
6134 struct rte_5tuple_filter filter;
6135 struct cmd_5tuple_filter_result *res = parsed_result;
6137 memset(&filter, 0, sizeof(struct rte_5tuple_filter));
6139 if (!strcmp(res->filter, "add_5tuple_filter")) {
6140 filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1;
6141 filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1;
6142 filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1;
6143 filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1;
6144 filter.protocol = res->protocol_value;
6145 filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1;
6146 filter.priority = res->priority_value;
6147 filter.tcp_flags = res->flags_value;
6149 if (res->dst_ip_value.family == AF_INET)
6150 /* no need to convert, already big endian. */
6151 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
6153 if (filter.dst_ip_mask == 0) {
6154 printf("can not support ipv6 involved compare.\n");
6160 if (res->src_ip_value.family == AF_INET)
6161 /* no need to convert, already big endian. */
6162 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
6164 if (filter.src_ip_mask == 0) {
6165 printf("can not support ipv6 involved compare.\n");
6170 /* need convert to big endian. */
6171 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
6172 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
6174 ret = rte_eth_dev_add_5tuple_filter(res->port_id,
6175 res->index_value, &filter, res->queue_id);
6176 } else if (!strcmp(res->filter, "remove_5tuple_filter"))
6177 ret = rte_eth_dev_remove_5tuple_filter(res->port_id,
6179 else if (!strcmp(res->filter, "get_5tuple_filter"))
6180 get_5tuple_filter(res->port_id, res->index_value);
6182 printf("5tuple filter setting error: (%s)\n", strerror(-ret));
6186 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
6187 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6189 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
6190 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6192 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
6193 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6195 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
6196 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6198 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
6199 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
6201 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
6202 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6203 dst_port, "dst_port");
6204 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
6205 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6206 dst_port_value, UINT16);
6207 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
6208 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6209 src_port, "src_port");
6210 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
6211 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6212 src_port_value, UINT16);
6213 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
6214 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6215 protocol, "protocol");
6216 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
6217 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6218 protocol_value, UINT8);
6219 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
6220 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6222 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
6223 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6225 cmdline_parse_token_string_t cmd_5tuple_filter_flags =
6226 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6228 cmdline_parse_token_num_t cmd_5tuple_filter_flags_value =
6229 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6230 flags_value, UINT8);
6231 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
6232 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6233 priority, "priority");
6234 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
6235 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6236 priority_value, UINT8);
6237 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
6238 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6240 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
6241 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6243 cmdline_parse_token_string_t cmd_5tuple_filter_index =
6244 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6246 cmdline_parse_token_num_t cmd_5tuple_filter_index_value =
6247 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
6248 index_value, UINT16);
6250 cmdline_parse_token_string_t cmd_5tuple_filter_add_filter =
6251 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6252 filter, "add_5tuple_filter");
6253 cmdline_parse_inst_t cmd_add_5tuple_filter = {
6254 .f = cmd_5tuple_filter_parsed,
6256 .help_str = "add a 5tuple filter",
6258 (void *)&cmd_5tuple_filter_add_filter,
6259 (void *)&cmd_5tuple_filter_port_id,
6260 (void *)&cmd_5tuple_filter_dst_ip,
6261 (void *)&cmd_5tuple_filter_dst_ip_value,
6262 (void *)&cmd_5tuple_filter_src_ip,
6263 (void *)&cmd_5tuple_filter_src_ip_value,
6264 (void *)&cmd_5tuple_filter_dst_port,
6265 (void *)&cmd_5tuple_filter_dst_port_value,
6266 (void *)&cmd_5tuple_filter_src_port,
6267 (void *)&cmd_5tuple_filter_src_port_value,
6268 (void *)&cmd_5tuple_filter_protocol,
6269 (void *)&cmd_5tuple_filter_protocol_value,
6270 (void *)&cmd_5tuple_filter_mask,
6271 (void *)&cmd_5tuple_filter_mask_value,
6272 (void *)&cmd_5tuple_filter_flags,
6273 (void *)&cmd_5tuple_filter_flags_value,
6274 (void *)&cmd_5tuple_filter_priority,
6275 (void *)&cmd_5tuple_filter_priority_value,
6276 (void *)&cmd_5tuple_filter_queue,
6277 (void *)&cmd_5tuple_filter_queue_id,
6278 (void *)&cmd_5tuple_filter_index,
6279 (void *)&cmd_5tuple_filter_index_value,
6284 cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter =
6285 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6286 filter, "remove_5tuple_filter");
6287 cmdline_parse_inst_t cmd_remove_5tuple_filter = {
6288 .f = cmd_5tuple_filter_parsed,
6290 .help_str = "remove a 5tuple filter",
6292 (void *)&cmd_5tuple_filter_remove_filter,
6293 (void *)&cmd_5tuple_filter_port_id,
6294 (void *)&cmd_5tuple_filter_index,
6295 (void *)&cmd_5tuple_filter_index_value,
6300 cmdline_parse_token_string_t cmd_5tuple_filter_get_filter =
6301 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
6302 filter, "get_5tuple_filter");
6303 cmdline_parse_inst_t cmd_get_5tuple_filter = {
6304 .f = cmd_5tuple_filter_parsed,
6306 .help_str = "get a 5tuple filter",
6308 (void *)&cmd_5tuple_filter_get_filter,
6309 (void *)&cmd_5tuple_filter_port_id,
6310 (void *)&cmd_5tuple_filter_index,
6311 (void *)&cmd_5tuple_filter_index_value,
6316 /* *** ADD/REMOVE A flex FILTER *** */
6317 struct cmd_flex_filter_result {
6318 cmdline_fixed_string_t filter;
6320 cmdline_fixed_string_t len;
6322 cmdline_fixed_string_t bytes;
6323 cmdline_fixed_string_t bytes_value;
6324 cmdline_fixed_string_t mask;
6325 cmdline_fixed_string_t mask_value;
6326 cmdline_fixed_string_t priority;
6327 uint8_t priority_value;
6328 cmdline_fixed_string_t queue;
6330 cmdline_fixed_string_t index;
6331 uint16_t index_value;
6334 static int xdigit2val(unsigned char c)
6339 else if (isupper(c))
6347 cmd_flex_filter_parsed(void *parsed_result,
6348 __attribute__((unused)) struct cmdline *cl,
6349 __attribute__((unused)) void *data)
6352 struct rte_flex_filter filter;
6353 struct cmd_flex_filter_result *res = parsed_result;
6354 char *bytes_ptr, *mask_ptr;
6362 if (!strcmp(res->filter, "add_flex_filter")) {
6363 if (res->len_value > 128) {
6364 printf("the len exceed the max length 128\n");
6367 memset(&filter, 0, sizeof(struct rte_flex_filter));
6368 filter.len = res->len_value;
6369 filter.priority = res->priority_value;
6370 bytes_ptr = res->bytes_value;
6371 mask_ptr = res->mask_value;
6374 /* translate bytes string to uint_32 array. */
6375 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
6376 (bytes_ptr[1] == 'X')))
6378 len = strnlen(bytes_ptr, res->len_value * 2);
6379 if (len == 0 || (len % 8 != 0)) {
6380 printf("please check len and bytes input\n");
6383 for (i = 0; i < len; i++) {
6385 if (isxdigit(c) == 0) {
6386 /* invalid characters. */
6387 printf("invalid input\n");
6390 val = xdigit2val(c);
6394 dword |= byte << (4 * mod - 4);
6399 filter.dwords[j] = dword;
6400 printf("dwords[%d]:%08x ", j, filter.dwords[j]);
6406 /* translate mask string to uint8_t array. */
6408 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
6409 (mask_ptr[1] == 'X')))
6411 len = strnlen(mask_ptr, (res->len_value+3)/4);
6413 printf("invalid input\n");
6416 for (i = 0; i < len; i++) {
6418 if (isxdigit(c) == 0) {
6419 /* invalid characters. */
6420 printf("invalid input\n");
6423 val = xdigit2val(c);
6424 hex |= (uint8_t)(val & 0x8) >> 3;
6425 hex |= (uint8_t)(val & 0x4) >> 1;
6426 hex |= (uint8_t)(val & 0x2) << 1;
6427 hex |= (uint8_t)(val & 0x1) << 3;
6430 filter.mask[j] = byte;
6431 printf("mask[%d]:%02x ", j, filter.mask[j]);
6439 printf("call function rte_eth_dev_add_flex_filter: "
6440 "index = %d, queue-id = %d, len = %d, priority = %d\n",
6441 res->index_value, res->queue_id,
6442 filter.len, filter.priority);
6443 ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
6444 &filter, res->queue_id);
6446 } else if (!strcmp(res->filter, "remove_flex_filter"))
6447 ret = rte_eth_dev_remove_flex_filter(res->port_id,
6449 else if (!strcmp(res->filter, "get_flex_filter"))
6450 get_flex_filter(res->port_id, res->index_value);
6453 printf("flex filter setting error: (%s)\n", strerror(-ret));
6456 cmdline_parse_token_num_t cmd_flex_filter_port_id =
6457 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6459 cmdline_parse_token_string_t cmd_flex_filter_len =
6460 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6462 cmdline_parse_token_num_t cmd_flex_filter_len_value =
6463 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6465 cmdline_parse_token_string_t cmd_flex_filter_bytes =
6466 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6468 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
6469 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6471 cmdline_parse_token_string_t cmd_flex_filter_mask =
6472 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6474 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
6475 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6477 cmdline_parse_token_string_t cmd_flex_filter_priority =
6478 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6479 priority, "priority");
6480 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
6481 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6482 priority_value, UINT8);
6483 cmdline_parse_token_string_t cmd_flex_filter_queue =
6484 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6486 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
6487 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6489 cmdline_parse_token_string_t cmd_flex_filter_index =
6490 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6492 cmdline_parse_token_num_t cmd_flex_filter_index_value =
6493 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
6494 index_value, UINT16);
6495 cmdline_parse_token_string_t cmd_flex_filter_add_filter =
6496 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6497 filter, "add_flex_filter");
6498 cmdline_parse_inst_t cmd_add_flex_filter = {
6499 .f = cmd_flex_filter_parsed,
6501 .help_str = "add a flex filter",
6503 (void *)&cmd_flex_filter_add_filter,
6504 (void *)&cmd_flex_filter_port_id,
6505 (void *)&cmd_flex_filter_len,
6506 (void *)&cmd_flex_filter_len_value,
6507 (void *)&cmd_flex_filter_bytes,
6508 (void *)&cmd_flex_filter_bytes_value,
6509 (void *)&cmd_flex_filter_mask,
6510 (void *)&cmd_flex_filter_mask_value,
6511 (void *)&cmd_flex_filter_priority,
6512 (void *)&cmd_flex_filter_priority_value,
6513 (void *)&cmd_flex_filter_queue,
6514 (void *)&cmd_flex_filter_queue_id,
6515 (void *)&cmd_flex_filter_index,
6516 (void *)&cmd_flex_filter_index_value,
6521 cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
6522 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6523 filter, "remove_flex_filter");
6524 cmdline_parse_inst_t cmd_remove_flex_filter = {
6525 .f = cmd_flex_filter_parsed,
6527 .help_str = "remove a flex filter",
6529 (void *)&cmd_flex_filter_remove_filter,
6530 (void *)&cmd_flex_filter_port_id,
6531 (void *)&cmd_flex_filter_index,
6532 (void *)&cmd_flex_filter_index_value,
6537 cmdline_parse_token_string_t cmd_flex_filter_get_filter =
6538 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
6539 filter, "get_flex_filter");
6540 cmdline_parse_inst_t cmd_get_flex_filter = {
6541 .f = cmd_flex_filter_parsed,
6543 .help_str = "get a flex filter",
6545 (void *)&cmd_flex_filter_get_filter,
6546 (void *)&cmd_flex_filter_port_id,
6547 (void *)&cmd_flex_filter_index,
6548 (void *)&cmd_flex_filter_index_value,
6553 /* ******************************************************************************** */
6555 /* list of instructions */
6556 cmdline_parse_ctx_t main_ctx[] = {
6557 (cmdline_parse_inst_t *)&cmd_help_brief,
6558 (cmdline_parse_inst_t *)&cmd_help_long,
6559 (cmdline_parse_inst_t *)&cmd_quit,
6560 (cmdline_parse_inst_t *)&cmd_showport,
6561 (cmdline_parse_inst_t *)&cmd_showportall,
6562 (cmdline_parse_inst_t *)&cmd_showcfg,
6563 (cmdline_parse_inst_t *)&cmd_start,
6564 (cmdline_parse_inst_t *)&cmd_start_tx_first,
6565 (cmdline_parse_inst_t *)&cmd_set_link_up,
6566 (cmdline_parse_inst_t *)&cmd_set_link_down,
6567 (cmdline_parse_inst_t *)&cmd_reset,
6568 (cmdline_parse_inst_t *)&cmd_set_numbers,
6569 (cmdline_parse_inst_t *)&cmd_set_txpkts,
6570 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
6571 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
6572 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
6573 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
6574 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
6575 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
6576 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
6577 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
6578 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
6579 (cmdline_parse_inst_t *)&cmd_set_link_check,
6580 #ifdef RTE_NIC_BYPASS
6581 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
6582 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
6583 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
6584 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
6586 (cmdline_parse_inst_t *)&cmd_vlan_offload,
6587 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
6588 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
6589 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
6590 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
6591 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
6592 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
6593 (cmdline_parse_inst_t *)&cmd_tx_cksum_set,
6594 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
6595 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
6596 (cmdline_parse_inst_t *)&cmd_config_dcb,
6597 (cmdline_parse_inst_t *)&cmd_read_reg,
6598 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
6599 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
6600 (cmdline_parse_inst_t *)&cmd_write_reg,
6601 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
6602 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
6603 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
6604 (cmdline_parse_inst_t *)&cmd_add_signature_filter,
6605 (cmdline_parse_inst_t *)&cmd_upd_signature_filter,
6606 (cmdline_parse_inst_t *)&cmd_rm_signature_filter,
6607 (cmdline_parse_inst_t *)&cmd_add_perfect_filter,
6608 (cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
6609 (cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
6610 (cmdline_parse_inst_t *)&cmd_set_masks_filter,
6611 (cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
6612 (cmdline_parse_inst_t *)&cmd_stop,
6613 (cmdline_parse_inst_t *)&cmd_mac_addr,
6614 (cmdline_parse_inst_t *)&cmd_set_qmap,
6615 (cmdline_parse_inst_t *)&cmd_operate_port,
6616 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
6617 (cmdline_parse_inst_t *)&cmd_config_speed_all,
6618 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
6619 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
6620 (cmdline_parse_inst_t *)&cmd_config_mtu,
6621 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
6622 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
6623 (cmdline_parse_inst_t *)&cmd_config_rss,
6624 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
6625 (cmdline_parse_inst_t *)&cmd_showport_reta,
6626 (cmdline_parse_inst_t *)&cmd_config_burst,
6627 (cmdline_parse_inst_t *)&cmd_config_thresh,
6628 (cmdline_parse_inst_t *)&cmd_config_threshold,
6629 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
6630 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
6631 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
6632 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter ,
6633 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
6634 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
6635 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
6636 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
6637 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
6638 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
6639 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
6640 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
6641 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
6642 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
6643 (cmdline_parse_inst_t *)&cmd_dump,
6644 (cmdline_parse_inst_t *)&cmd_dump_one,
6645 (cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
6646 (cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
6647 (cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
6648 (cmdline_parse_inst_t *)&cmd_add_syn_filter,
6649 (cmdline_parse_inst_t *)&cmd_remove_syn_filter,
6650 (cmdline_parse_inst_t *)&cmd_get_syn_filter,
6651 (cmdline_parse_inst_t *)&cmd_add_2tuple_filter,
6652 (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter,
6653 (cmdline_parse_inst_t *)&cmd_get_2tuple_filter,
6654 (cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
6655 (cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
6656 (cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
6657 (cmdline_parse_inst_t *)&cmd_add_flex_filter,
6658 (cmdline_parse_inst_t *)&cmd_remove_flex_filter,
6659 (cmdline_parse_inst_t *)&cmd_get_flex_filter,
6663 /* prompt function, called from main on MASTER lcore */
6669 /* initialize non-constant commands */
6670 cmd_set_fwd_mode_init();
6672 cl = cmdline_stdin_new(main_ctx, "testpmd> ");
6676 cmdline_interact(cl);
6677 cmdline_stdin_exit(cl);
6681 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
6683 if (id < nb_ports) {
6684 /* check if need_reconfig has been set to 1 */
6685 if (ports[id].need_reconfig == 0)
6686 ports[id].need_reconfig = dev;
6687 /* check if need_reconfig_queues has been set to 1 */
6688 if (ports[id].need_reconfig_queues == 0)
6689 ports[id].need_reconfig_queues = queue;
6693 for (pid = 0; pid < nb_ports; pid++) {
6694 /* check if need_reconfig has been set to 1 */
6695 if (ports[pid].need_reconfig == 0)
6696 ports[pid].need_reconfig = dev;
6697 /* check if need_reconfig_queues has been set to 1 */
6698 if (ports[pid].need_reconfig_queues == 0)
6699 ports[pid].need_reconfig_queues = queue;
6704 #ifdef RTE_NIC_BYPASS
6706 bypass_is_supported(portid_t port_id)
6708 struct rte_port *port;
6709 struct rte_pci_id *pci_id;
6711 if (port_id >= nb_ports) {
6712 printf("\tPort id must be less than %d.\n", nb_ports);
6716 /* Get the device id. */
6717 port = &ports[port_id];
6718 pci_id = &port->dev_info.pci_dev->id;
6720 /* Check if NIC supports bypass. */
6721 if (pci_id->device_id == IXGBE_DEV_ID_82599_BYPASS) {
6725 printf("\tBypass not supported for port_id = %d.\n", port_id);