4 * Copyright(c) 2010-2016 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.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set port (port_id) uta (mac_address|all) (on|off)\n"
490 " Add/Remove a or all unicast hash filter(s)"
493 "set promisc (port_id|all) (on|off)\n"
494 " Set the promiscuous mode on port_id, or all.\n\n"
496 "set allmulti (port_id|all) (on|off)\n"
497 " Set the allmulti mode on port_id, or all.\n\n"
499 "set vf promisc (port_id) (vf_id) (on|off)\n"
500 " Set unicast promiscuous mode for a VF from the PF.\n\n"
502 "set vf allmulti (port_id) (vf_id) (on|off)\n"
503 " Set multicast promiscuous mode for a VF from the PF.\n\n"
505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
507 " (on|off) autoneg (on|off) (port_id)\n"
508 "set flow_ctrl rx (on|off) (portid)\n"
509 "set flow_ctrl tx (on|off) (portid)\n"
510 "set flow_ctrl high_water (high_water) (portid)\n"
511 "set flow_ctrl low_water (low_water) (portid)\n"
512 "set flow_ctrl pause_time (pause_time) (portid)\n"
513 "set flow_ctrl send_xon (send_xon) (portid)\n"
514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
515 "set flow_ctrl autoneg (on|off) (port_id)\n"
516 " Set the link flow control parameter on a port.\n\n"
518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (priority) (port_id)\n"
520 " Set the priority flow control parameter on a"
523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
524 " Set statistics mapping (qmapping 0..15) for RX/TX"
526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
527 " on port 0 to mapping 5.\n\n"
529 "set xstats-hide-zero on|off\n"
530 " Set the option to hide the zero values"
531 " for xstats display.\n"
533 "set port (port_id) vf (vf_id) rx|tx on|off\n"
534 " Enable/Disable a VF receive/tranmit from a port\n\n"
536 "set port (port_id) vf (vf_id) (mac_addr)"
537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
538 " Add/Remove unicast or multicast MAC addr filter"
541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
543 " AUPE:accepts untagged VLAN;"
544 "ROPE:accept unicast hash\n\n"
545 " BAM:accepts broadcast packets;"
546 "MPE:accepts all multicast packets\n\n"
547 " Enable/Disable a VF receive mode of a port\n\n"
549 "set port (port_id) queue (queue_id) rate (rate_num)\n"
550 " Set rate limit for a queue of a port\n\n"
552 "set port (port_id) vf (vf_id) rate (rate_num) "
553 "queue_mask (queue_mask_value)\n"
554 " Set rate limit for queues in VF of a port\n\n"
556 "set port (port_id) mirror-rule (rule_id)"
557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
559 " Set pool or vlan type mirror rule on a port.\n"
560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
561 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (uplink-mirror|downlink-mirror) dst-pool"
566 " (pool_id) (on|off)\n"
567 " Set uplink or downlink type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
569 " 0 on' enable mirror income traffic to pool 0.\n\n"
571 "reset port (port_id) mirror-rule (rule_id)\n"
572 " Reset a mirror rule.\n\n"
574 "set flush_rx (on|off)\n"
575 " Flush (default) or don't flush RX streams before"
576 " forwarding. Mainly used with PCAP drivers.\n\n"
578 "set bypass mode (normal|bypass|isolate) (port_id)\n"
579 " Set the bypass mode for the lowest port on bypass enabled"
582 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
583 "mode (normal|bypass|isolate) (port_id)\n"
584 " Set the event required to initiate specified bypass mode for"
585 " the lowest port on a bypass enabled NIC where:\n"
586 " timeout = enable bypass after watchdog timeout.\n"
587 " os_on = enable bypass when OS/board is powered on.\n"
588 " os_off = enable bypass when OS/board is powered off.\n"
589 " power_on = enable bypass when power supply is turned on.\n"
590 " power_off = enable bypass when power supply is turned off."
593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
594 " Set the bypass watchdog timeout to 'n' seconds"
595 " where 0 = instant.\n\n"
597 "show bypass config (port_id)\n"
598 " Show the bypass configuration for a bypass enabled NIC"
599 " using the lowest port on the NIC.\n\n"
601 #ifdef RTE_LIBRTE_PMD_BOND
602 "create bonded device (mode) (socket)\n"
603 " Create a new bonded device with specific bonding mode and socket.\n\n"
605 "add bonding slave (slave_id) (port_id)\n"
606 " Add a slave device to a bonded device.\n\n"
608 "remove bonding slave (slave_id) (port_id)\n"
609 " Remove a slave device from a bonded device.\n\n"
611 "set bonding mode (value) (port_id)\n"
612 " Set the bonding mode on a bonded device.\n\n"
614 "set bonding primary (slave_id) (port_id)\n"
615 " Set the primary slave for a bonded device.\n\n"
617 "show bonding config (port_id)\n"
618 " Show the bonding config for port_id.\n\n"
620 "set bonding mac_addr (port_id) (address)\n"
621 " Set the MAC address of a bonded device.\n\n"
623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
624 " Set Aggregation mode for IEEE802.3AD (mode 4)"
626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
627 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
629 "set bonding mon_period (port_id) (value)\n"
630 " Set the bonding link status monitoring polling period in ms.\n\n"
632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
633 " Enable/disable dedicated queues for LACP control traffic.\n\n"
636 "set link-up port (port_id)\n"
637 " Set link up for a port.\n\n"
639 "set link-down port (port_id)\n"
640 " Set link down for a port.\n\n"
642 "E-tag set insertion on port-tag-id (value)"
643 " port (port_id) vf (vf_id)\n"
644 " Enable E-tag insertion for a VF on a port\n\n"
646 "E-tag set insertion off port (port_id) vf (vf_id)\n"
647 " Disable E-tag insertion for a VF on a port\n\n"
649 "E-tag set stripping (on|off) port (port_id)\n"
650 " Enable/disable E-tag stripping on a port\n\n"
652 "E-tag set forwarding (on|off) port (port_id)\n"
653 " Enable/disable E-tag based forwarding"
656 "E-tag set filter add e-tag-id (value) dst-pool"
657 " (pool_id) port (port_id)\n"
658 " Add an E-tag forwarding filter on a port\n\n"
660 "E-tag set filter del e-tag-id (value) port (port_id)\n"
661 " Delete an E-tag forwarding filter on a port\n\n"
663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
664 "set port tm hierarchy default (port_id)\n"
665 " Set default traffic Management hierarchy on a port\n\n"
668 "ddp add (port_id) (profile_path[,output_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
687 "queue_start_index (value) queue_num (value)\n"
688 " Set a queue region on a port\n\n"
690 "set port (port_id) queue-region region_id (value) "
692 " Set a flowtype region index on a port\n\n"
694 "set port (port_id) queue-region UP (value) region_id (value)\n"
695 " Set the mapping of User Priority to "
696 "queue region on a port\n\n"
698 "set port (port_id) queue-region flush (on|off)\n"
699 " flush all queue region related configuration\n\n"
701 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (color_aware)\n"
702 " meter profile add - srtcm rfc 2697\n\n"
704 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
705 " meter profile add - trtcm rfc 2698\n\n"
707 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
708 " meter profile add - trtcm rfc 4115\n\n"
710 "del port meter profile (port_id) (profile_id)\n"
711 " meter profile delete\n\n"
713 "set port meter (port_id) (mtr_id) (profile_id) (g_action) (y_action) (r_action) (stats_mask) (shared)\n"
716 "del port meter (port_id) (mtr_id)\n"
719 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 " meter update meter profile\n\n"
722 "set port meter policer action (port_id) (mtr_id) (color) (action)\n"
723 " meter update policer action\n\n"
725 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
726 " meter update stats\n\n"
728 "show port (port_id) queue-region\n"
729 " show all queue region related configuration info\n\n"
731 "add port tm node shaper profile (port_id) (shaper_profile_id)"
732 " (tb_rate) (tb_size) (packet_length_adjust)\n"
733 " Add port tm node private shaper profile.\n\n"
735 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
736 " Delete port tm node private shaper profile.\n\n"
738 "add port tm node shared shaper (port_id) (shared_shaper_id)"
739 " (shaper_profile_id)\n"
740 " Add/update port tm node shared shaper.\n\n"
742 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
743 " Delete port tm node shared shaper.\n\n"
745 "set port tm node shaper profile (port_id) (node_id)"
746 " (shaper_profile_id)\n"
747 " Set port tm node shaper profile.\n\n"
749 "add port tm node wred profile (port_id) (wred_profile_id)"
750 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
751 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
752 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
753 " Add port tm node wred profile.\n\n"
755 "del port tm node wred profile (port_id) (wred_profile_id)\n"
756 " Delete port tm node wred profile.\n\n"
758 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
759 " (priority) (weight) (level_id) (shaper_profile_id)"
760 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
761 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
762 " Add port tm nonleaf node.\n\n"
764 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
765 " (priority) (weight) (level_id) (shaper_profile_id)"
766 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
767 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
768 " Add port tm leaf node.\n\n"
770 "del port tm node (port_id) (node_id)\n"
771 " Delete port tm node.\n\n"
773 "set port tm node parent (port_id) (node_id) (parent_node_id)"
774 " (priority) (weight)\n"
775 " Set port tm node parent.\n\n"
777 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
778 " Commit tm hierarchy.\n\n"
780 , list_pkt_forwarding_modes()
784 if (show_all || !strcmp(res->section, "ports")) {
790 "----------------\n\n"
792 "port start (port_id|all)\n"
793 " Start all ports or port_id.\n\n"
795 "port stop (port_id|all)\n"
796 " Stop all ports or port_id.\n\n"
798 "port close (port_id|all)\n"
799 " Close all ports or port_id.\n\n"
801 "port attach (ident)\n"
802 " Attach physical or virtual dev by pci address or virtual device name\n\n"
804 "port detach (port_id)\n"
805 " Detach physical or virtual dev by port_id\n\n"
807 "port config (port_id|all)"
808 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
809 " duplex (half|full|auto)\n"
810 " Set speed and duplex for all ports or port_id\n\n"
812 "port config all (rxq|txq|rxd|txd) (value)\n"
813 " Set number for rxq/txq/rxd/txd.\n\n"
815 "port config all max-pkt-len (value)\n"
816 " Set the max packet length.\n\n"
818 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 "hw-vlan-strip|hw-vlan-extend|drop-en)"
821 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
824 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
825 "geneve|nvgre|none|<flowtype_id>)\n"
826 " Set the RSS mode.\n\n"
828 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 " Set the RSS redirection table.\n\n"
831 "port config (port_id) dcb vt (on|off) (traffic_class)"
833 " Set the DCB mode.\n\n"
835 "port config all burst (value)\n"
836 " Set the number of packets per burst.\n\n"
838 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
840 " Set the ring prefetch/host/writeback threshold"
841 " for tx/rx queue.\n\n"
843 "port config all (txfreet|txrst|rxfreet) (value)\n"
844 " Set free threshold for rx/tx, or set"
845 " tx rs bit threshold.\n\n"
846 "port config mtu X value\n"
847 " Set the MTU of port X to a given value\n\n"
849 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
850 " Start/stop a rx/tx queue of port X. Only take effect"
851 " when port X is started\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
870 if (show_all || !strcmp(res->section, "registers")) {
878 "read reg (port_id) (address)\n"
879 " Display value of a port register.\n\n"
881 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
882 " Display a port register bit field.\n\n"
884 "read regbit (port_id) (address) (bit_x)\n"
885 " Display a single port register bit.\n\n"
887 "write reg (port_id) (address) (value)\n"
888 " Set value of a port register.\n\n"
890 "write regfield (port_id) (address) (bit_x) (bit_y)"
892 " Set bit field of a port register.\n\n"
894 "write regbit (port_id) (address) (bit_x) (value)\n"
895 " Set single bit value of a port register.\n\n"
898 if (show_all || !strcmp(res->section, "filters")) {
906 "ethertype_filter (port_id) (add|del)"
907 " (mac_addr|mac_ignr) (mac_address) ethertype"
908 " (ether_type) (drop|fwd) queue (queue_id)\n"
909 " Add/Del an ethertype filter.\n\n"
911 "2tuple_filter (port_id) (add|del)"
912 " dst_port (dst_port_value) protocol (protocol_value)"
913 " mask (mask_value) tcp_flags (tcp_flags_value)"
914 " priority (prio_value) queue (queue_id)\n"
915 " Add/Del a 2tuple filter.\n\n"
917 "5tuple_filter (port_id) (add|del)"
918 " dst_ip (dst_address) src_ip (src_address)"
919 " dst_port (dst_port_value) src_port (src_port_value)"
920 " protocol (protocol_value)"
921 " mask (mask_value) tcp_flags (tcp_flags_value)"
922 " priority (prio_value) queue (queue_id)\n"
923 " Add/Del a 5tuple filter.\n\n"
925 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
926 " Add/Del syn filter.\n\n"
928 "flex_filter (port_id) (add|del) len (len_value)"
929 " bytes (bytes_value) mask (mask_value)"
930 " priority (prio_value) queue (queue_id)\n"
931 " Add/Del a flex filter.\n\n"
933 "flow_director_filter (port_id) mode IP (add|del|update)"
934 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
935 " src (src_ip_address) dst (dst_ip_address)"
936 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
937 " vlan (vlan_value) flexbytes (flexbytes_value)"
938 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
939 " fd_id (fd_id_value)\n"
940 " Add/Del an IP type flow director filter.\n\n"
942 "flow_director_filter (port_id) mode IP (add|del|update)"
943 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
944 " src (src_ip_address) (src_port)"
945 " dst (dst_ip_address) (dst_port)"
946 " tos (tos_value) ttl (ttl_value)"
947 " vlan (vlan_value) flexbytes (flexbytes_value)"
948 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
949 " fd_id (fd_id_value)\n"
950 " Add/Del an UDP/TCP type flow director filter.\n\n"
952 "flow_director_filter (port_id) mode IP (add|del|update)"
953 " flow (ipv4-sctp|ipv6-sctp)"
954 " src (src_ip_address) (src_port)"
955 " dst (dst_ip_address) (dst_port)"
956 " tag (verification_tag) "
957 " tos (tos_value) ttl (ttl_value)"
959 " flexbytes (flexbytes_value) (drop|fwd)"
960 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
961 " Add/Del a SCTP type flow director filter.\n\n"
963 "flow_director_filter (port_id) mode IP (add|del|update)"
964 " flow l2_payload ether (ethertype)"
965 " flexbytes (flexbytes_value) (drop|fwd)"
966 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
967 " Add/Del a l2 payload type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
970 " mac (mac_address) vlan (vlan_value)"
971 " flexbytes (flexbytes_value) (drop|fwd)"
972 " queue (queue_id) fd_id (fd_id_value)\n"
973 " Add/Del a MAC-VLAN flow director filter.\n\n"
975 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
976 " mac (mac_address) vlan (vlan_value)"
977 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
978 " flexbytes (flexbytes_value) (drop|fwd)"
979 " queue (queue_id) fd_id (fd_id_value)\n"
980 " Add/Del a Tunnel flow director filter.\n\n"
982 "flush_flow_director (port_id)\n"
983 " Flush all flow director entries of a device.\n\n"
985 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
986 " src_mask (ipv4_src) (ipv6_src) (src_port)"
987 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
988 " Set flow director IP mask.\n\n"
990 "flow_director_mask (port_id) mode MAC-VLAN"
991 " vlan (vlan_value)\n"
992 " Set flow director MAC-VLAN mask.\n\n"
994 "flow_director_mask (port_id) mode Tunnel"
995 " vlan (vlan_value) mac (mac_value)"
996 " tunnel-type (tunnel_type_value)"
997 " tunnel-id (tunnel_id_value)\n"
998 " Set flow director Tunnel mask.\n\n"
1000 "flow_director_flex_mask (port_id)"
1001 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1002 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1004 " Configure mask of flex payload.\n\n"
1006 "flow_director_flex_payload (port_id)"
1007 " (raw|l2|l3|l4) (config)\n"
1008 " Configure flex payload selection.\n\n"
1010 "get_sym_hash_ena_per_port (port_id)\n"
1011 " get symmetric hash enable configuration per port.\n\n"
1013 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1014 " set symmetric hash enable configuration per port"
1015 " to enable or disable.\n\n"
1017 "get_hash_global_config (port_id)\n"
1018 " Get the global configurations of hash filters.\n\n"
1020 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1021 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1022 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1023 " (enable|disable)\n"
1024 " Set the global configurations of hash filters.\n\n"
1026 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1027 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1028 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1029 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1030 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1031 "ipv6-next-header|udp-src-port|udp-dst-port|"
1032 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1033 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1034 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1035 "fld-8th|none) (select|add)\n"
1036 " Set the input set for hash.\n\n"
1038 "set_fdir_input_set (port_id) "
1039 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1040 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1041 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1042 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1043 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1044 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1045 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1047 " Set the input set for FDir.\n\n"
1049 "flow validate {port_id}"
1050 " [group {group_id}] [priority {level}]"
1051 " [ingress] [egress]"
1052 " pattern {item} [/ {item} [...]] / end"
1053 " actions {action} [/ {action} [...]] / end\n"
1054 " Check whether a flow rule can be created.\n\n"
1056 "flow create {port_id}"
1057 " [group {group_id}] [priority {level}]"
1058 " [ingress] [egress]"
1059 " pattern {item} [/ {item} [...]] / end"
1060 " actions {action} [/ {action} [...]] / end\n"
1061 " Create a flow rule.\n\n"
1063 "flow destroy {port_id} rule {rule_id} [...]\n"
1064 " Destroy specific flow rules.\n\n"
1066 "flow flush {port_id}\n"
1067 " Destroy all flow rules.\n\n"
1069 "flow query {port_id} {rule_id} {action}\n"
1070 " Query an existing flow rule.\n\n"
1072 "flow list {port_id} [group {group_id}] [...]\n"
1073 " List existing flow rules sorted by priority,"
1074 " filtered by group identifiers.\n\n"
1076 "flow isolate {port_id} {boolean}\n"
1077 " Restrict ingress traffic to the defined"
1083 cmdline_parse_token_string_t cmd_help_long_help =
1084 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1086 cmdline_parse_token_string_t cmd_help_long_section =
1087 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1088 "all#control#display#config#"
1089 "ports#registers#filters");
1091 cmdline_parse_inst_t cmd_help_long = {
1092 .f = cmd_help_long_parsed,
1094 .help_str = "help all|control|display|config|ports|register|filters: "
1097 (void *)&cmd_help_long_help,
1098 (void *)&cmd_help_long_section,
1104 /* *** start/stop/close all ports *** */
1105 struct cmd_operate_port_result {
1106 cmdline_fixed_string_t keyword;
1107 cmdline_fixed_string_t name;
1108 cmdline_fixed_string_t value;
1111 static void cmd_operate_port_parsed(void *parsed_result,
1112 __attribute__((unused)) struct cmdline *cl,
1113 __attribute__((unused)) void *data)
1115 struct cmd_operate_port_result *res = parsed_result;
1117 if (!strcmp(res->name, "start"))
1118 start_port(RTE_PORT_ALL);
1119 else if (!strcmp(res->name, "stop"))
1120 stop_port(RTE_PORT_ALL);
1121 else if (!strcmp(res->name, "close"))
1122 close_port(RTE_PORT_ALL);
1123 else if (!strcmp(res->name, "reset"))
1124 reset_port(RTE_PORT_ALL);
1126 printf("Unknown parameter\n");
1129 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1130 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1132 cmdline_parse_token_string_t cmd_operate_port_all_port =
1133 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1134 "start#stop#close#reset");
1135 cmdline_parse_token_string_t cmd_operate_port_all_all =
1136 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1138 cmdline_parse_inst_t cmd_operate_port = {
1139 .f = cmd_operate_port_parsed,
1141 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1143 (void *)&cmd_operate_port_all_cmd,
1144 (void *)&cmd_operate_port_all_port,
1145 (void *)&cmd_operate_port_all_all,
1150 /* *** start/stop/close specific port *** */
1151 struct cmd_operate_specific_port_result {
1152 cmdline_fixed_string_t keyword;
1153 cmdline_fixed_string_t name;
1157 static void cmd_operate_specific_port_parsed(void *parsed_result,
1158 __attribute__((unused)) struct cmdline *cl,
1159 __attribute__((unused)) void *data)
1161 struct cmd_operate_specific_port_result *res = parsed_result;
1163 if (!strcmp(res->name, "start"))
1164 start_port(res->value);
1165 else if (!strcmp(res->name, "stop"))
1166 stop_port(res->value);
1167 else if (!strcmp(res->name, "close"))
1168 close_port(res->value);
1169 else if (!strcmp(res->name, "reset"))
1170 reset_port(res->value);
1172 printf("Unknown parameter\n");
1175 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1176 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1178 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1179 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1180 name, "start#stop#close#reset");
1181 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1182 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1185 cmdline_parse_inst_t cmd_operate_specific_port = {
1186 .f = cmd_operate_specific_port_parsed,
1188 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1190 (void *)&cmd_operate_specific_port_cmd,
1191 (void *)&cmd_operate_specific_port_port,
1192 (void *)&cmd_operate_specific_port_id,
1197 /* *** attach a specified port *** */
1198 struct cmd_operate_attach_port_result {
1199 cmdline_fixed_string_t port;
1200 cmdline_fixed_string_t keyword;
1201 cmdline_fixed_string_t identifier;
1204 static void cmd_operate_attach_port_parsed(void *parsed_result,
1205 __attribute__((unused)) struct cmdline *cl,
1206 __attribute__((unused)) void *data)
1208 struct cmd_operate_attach_port_result *res = parsed_result;
1210 if (!strcmp(res->keyword, "attach"))
1211 attach_port(res->identifier);
1213 printf("Unknown parameter\n");
1216 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1219 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1222 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1226 cmdline_parse_inst_t cmd_operate_attach_port = {
1227 .f = cmd_operate_attach_port_parsed,
1229 .help_str = "port attach <identifier>: "
1230 "(identifier: pci address or virtual dev name)",
1232 (void *)&cmd_operate_attach_port_port,
1233 (void *)&cmd_operate_attach_port_keyword,
1234 (void *)&cmd_operate_attach_port_identifier,
1239 /* *** detach a specified port *** */
1240 struct cmd_operate_detach_port_result {
1241 cmdline_fixed_string_t port;
1242 cmdline_fixed_string_t keyword;
1246 static void cmd_operate_detach_port_parsed(void *parsed_result,
1247 __attribute__((unused)) struct cmdline *cl,
1248 __attribute__((unused)) void *data)
1250 struct cmd_operate_detach_port_result *res = parsed_result;
1252 if (!strcmp(res->keyword, "detach"))
1253 detach_port(res->port_id);
1255 printf("Unknown parameter\n");
1258 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1259 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1261 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1262 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1264 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1265 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1268 cmdline_parse_inst_t cmd_operate_detach_port = {
1269 .f = cmd_operate_detach_port_parsed,
1271 .help_str = "port detach <port_id>",
1273 (void *)&cmd_operate_detach_port_port,
1274 (void *)&cmd_operate_detach_port_keyword,
1275 (void *)&cmd_operate_detach_port_port_id,
1280 /* *** configure speed for all ports *** */
1281 struct cmd_config_speed_all {
1282 cmdline_fixed_string_t port;
1283 cmdline_fixed_string_t keyword;
1284 cmdline_fixed_string_t all;
1285 cmdline_fixed_string_t item1;
1286 cmdline_fixed_string_t item2;
1287 cmdline_fixed_string_t value1;
1288 cmdline_fixed_string_t value2;
1292 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1297 if (!strcmp(duplexstr, "half")) {
1298 duplex = ETH_LINK_HALF_DUPLEX;
1299 } else if (!strcmp(duplexstr, "full")) {
1300 duplex = ETH_LINK_FULL_DUPLEX;
1301 } else if (!strcmp(duplexstr, "auto")) {
1302 duplex = ETH_LINK_FULL_DUPLEX;
1304 printf("Unknown duplex parameter\n");
1308 if (!strcmp(speedstr, "10")) {
1309 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1310 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1311 } else if (!strcmp(speedstr, "100")) {
1312 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1313 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1315 if (duplex != ETH_LINK_FULL_DUPLEX) {
1316 printf("Invalid speed/duplex parameters\n");
1319 if (!strcmp(speedstr, "1000")) {
1320 *speed = ETH_LINK_SPEED_1G;
1321 } else if (!strcmp(speedstr, "10000")) {
1322 *speed = ETH_LINK_SPEED_10G;
1323 } else if (!strcmp(speedstr, "25000")) {
1324 *speed = ETH_LINK_SPEED_25G;
1325 } else if (!strcmp(speedstr, "40000")) {
1326 *speed = ETH_LINK_SPEED_40G;
1327 } else if (!strcmp(speedstr, "50000")) {
1328 *speed = ETH_LINK_SPEED_50G;
1329 } else if (!strcmp(speedstr, "100000")) {
1330 *speed = ETH_LINK_SPEED_100G;
1331 } else if (!strcmp(speedstr, "auto")) {
1332 *speed = ETH_LINK_SPEED_AUTONEG;
1334 printf("Unknown speed parameter\n");
1343 cmd_config_speed_all_parsed(void *parsed_result,
1344 __attribute__((unused)) struct cmdline *cl,
1345 __attribute__((unused)) void *data)
1347 struct cmd_config_speed_all *res = parsed_result;
1348 uint32_t link_speed;
1351 if (!all_ports_stopped()) {
1352 printf("Please stop all ports first\n");
1356 if (parse_and_check_speed_duplex(res->value1, res->value2,
1360 RTE_ETH_FOREACH_DEV(pid) {
1361 ports[pid].dev_conf.link_speeds = link_speed;
1364 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1367 cmdline_parse_token_string_t cmd_config_speed_all_port =
1368 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1369 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1370 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1372 cmdline_parse_token_string_t cmd_config_speed_all_all =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1374 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1375 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1376 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1377 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1378 "10#100#1000#10000#25000#40000#50000#100000#auto");
1379 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1380 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1381 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1382 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1385 cmdline_parse_inst_t cmd_config_speed_all = {
1386 .f = cmd_config_speed_all_parsed,
1388 .help_str = "port config all speed "
1389 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1392 (void *)&cmd_config_speed_all_port,
1393 (void *)&cmd_config_speed_all_keyword,
1394 (void *)&cmd_config_speed_all_all,
1395 (void *)&cmd_config_speed_all_item1,
1396 (void *)&cmd_config_speed_all_value1,
1397 (void *)&cmd_config_speed_all_item2,
1398 (void *)&cmd_config_speed_all_value2,
1403 /* *** configure speed for specific port *** */
1404 struct cmd_config_speed_specific {
1405 cmdline_fixed_string_t port;
1406 cmdline_fixed_string_t keyword;
1408 cmdline_fixed_string_t item1;
1409 cmdline_fixed_string_t item2;
1410 cmdline_fixed_string_t value1;
1411 cmdline_fixed_string_t value2;
1415 cmd_config_speed_specific_parsed(void *parsed_result,
1416 __attribute__((unused)) struct cmdline *cl,
1417 __attribute__((unused)) void *data)
1419 struct cmd_config_speed_specific *res = parsed_result;
1420 uint32_t link_speed;
1422 if (!all_ports_stopped()) {
1423 printf("Please stop all ports first\n");
1427 if (port_id_is_invalid(res->id, ENABLED_WARN))
1430 if (parse_and_check_speed_duplex(res->value1, res->value2,
1434 ports[res->id].dev_conf.link_speeds = link_speed;
1436 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1440 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1441 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1443 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1444 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1446 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1447 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1448 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1449 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1451 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1452 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1453 "10#100#1000#10000#25000#40000#50000#100000#auto");
1454 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1455 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1457 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1461 cmdline_parse_inst_t cmd_config_speed_specific = {
1462 .f = cmd_config_speed_specific_parsed,
1464 .help_str = "port config <port_id> speed "
1465 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1468 (void *)&cmd_config_speed_specific_port,
1469 (void *)&cmd_config_speed_specific_keyword,
1470 (void *)&cmd_config_speed_specific_id,
1471 (void *)&cmd_config_speed_specific_item1,
1472 (void *)&cmd_config_speed_specific_value1,
1473 (void *)&cmd_config_speed_specific_item2,
1474 (void *)&cmd_config_speed_specific_value2,
1479 /* *** configure txq/rxq, txd/rxd *** */
1480 struct cmd_config_rx_tx {
1481 cmdline_fixed_string_t port;
1482 cmdline_fixed_string_t keyword;
1483 cmdline_fixed_string_t all;
1484 cmdline_fixed_string_t name;
1489 cmd_config_rx_tx_parsed(void *parsed_result,
1490 __attribute__((unused)) struct cmdline *cl,
1491 __attribute__((unused)) void *data)
1493 struct cmd_config_rx_tx *res = parsed_result;
1495 if (!all_ports_stopped()) {
1496 printf("Please stop all ports first\n");
1499 if (!strcmp(res->name, "rxq")) {
1500 if (!res->value && !nb_txq) {
1501 printf("Warning: Either rx or tx queues should be non zero\n");
1504 nb_rxq = res->value;
1506 else if (!strcmp(res->name, "txq")) {
1507 if (!res->value && !nb_rxq) {
1508 printf("Warning: Either rx or tx queues should be non zero\n");
1511 nb_txq = res->value;
1513 else if (!strcmp(res->name, "rxd")) {
1514 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1515 printf("rxd %d invalid - must be > 0 && <= %d\n",
1516 res->value, RTE_TEST_RX_DESC_MAX);
1519 nb_rxd = res->value;
1520 } else if (!strcmp(res->name, "txd")) {
1521 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1522 printf("txd %d invalid - must be > 0 && <= %d\n",
1523 res->value, RTE_TEST_TX_DESC_MAX);
1526 nb_txd = res->value;
1528 printf("Unknown parameter\n");
1536 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1539 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1541 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1543 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1545 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1548 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1549 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1551 cmdline_parse_inst_t cmd_config_rx_tx = {
1552 .f = cmd_config_rx_tx_parsed,
1554 .help_str = "port config all rxq|txq|rxd|txd <value>",
1556 (void *)&cmd_config_rx_tx_port,
1557 (void *)&cmd_config_rx_tx_keyword,
1558 (void *)&cmd_config_rx_tx_all,
1559 (void *)&cmd_config_rx_tx_name,
1560 (void *)&cmd_config_rx_tx_value,
1565 /* *** config max packet length *** */
1566 struct cmd_config_max_pkt_len_result {
1567 cmdline_fixed_string_t port;
1568 cmdline_fixed_string_t keyword;
1569 cmdline_fixed_string_t all;
1570 cmdline_fixed_string_t name;
1575 cmd_config_max_pkt_len_parsed(void *parsed_result,
1576 __attribute__((unused)) struct cmdline *cl,
1577 __attribute__((unused)) void *data)
1579 struct cmd_config_max_pkt_len_result *res = parsed_result;
1581 if (!all_ports_stopped()) {
1582 printf("Please stop all ports first\n");
1586 if (!strcmp(res->name, "max-pkt-len")) {
1587 if (res->value < ETHER_MIN_LEN) {
1588 printf("max-pkt-len can not be less than %d\n",
1592 if (res->value == rx_mode.max_rx_pkt_len)
1595 rx_mode.max_rx_pkt_len = res->value;
1596 if (res->value > ETHER_MAX_LEN)
1597 rx_mode.jumbo_frame = 1;
1599 rx_mode.jumbo_frame = 0;
1601 printf("Unknown parameter\n");
1607 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1610 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1613 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1614 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1616 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1619 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1622 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1623 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1626 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1627 .f = cmd_config_max_pkt_len_parsed,
1629 .help_str = "port config all max-pkt-len <value>",
1631 (void *)&cmd_config_max_pkt_len_port,
1632 (void *)&cmd_config_max_pkt_len_keyword,
1633 (void *)&cmd_config_max_pkt_len_all,
1634 (void *)&cmd_config_max_pkt_len_name,
1635 (void *)&cmd_config_max_pkt_len_value,
1640 /* *** configure port MTU *** */
1641 struct cmd_config_mtu_result {
1642 cmdline_fixed_string_t port;
1643 cmdline_fixed_string_t keyword;
1644 cmdline_fixed_string_t mtu;
1650 cmd_config_mtu_parsed(void *parsed_result,
1651 __attribute__((unused)) struct cmdline *cl,
1652 __attribute__((unused)) void *data)
1654 struct cmd_config_mtu_result *res = parsed_result;
1656 if (res->value < ETHER_MIN_LEN) {
1657 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1660 port_mtu_set(res->port_id, res->value);
1663 cmdline_parse_token_string_t cmd_config_mtu_port =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1666 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1669 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1670 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1672 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1673 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1674 cmdline_parse_token_num_t cmd_config_mtu_value =
1675 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1677 cmdline_parse_inst_t cmd_config_mtu = {
1678 .f = cmd_config_mtu_parsed,
1680 .help_str = "port config mtu <port_id> <value>",
1682 (void *)&cmd_config_mtu_port,
1683 (void *)&cmd_config_mtu_keyword,
1684 (void *)&cmd_config_mtu_mtu,
1685 (void *)&cmd_config_mtu_port_id,
1686 (void *)&cmd_config_mtu_value,
1691 /* *** configure rx mode *** */
1692 struct cmd_config_rx_mode_flag {
1693 cmdline_fixed_string_t port;
1694 cmdline_fixed_string_t keyword;
1695 cmdline_fixed_string_t all;
1696 cmdline_fixed_string_t name;
1697 cmdline_fixed_string_t value;
1701 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1702 __attribute__((unused)) struct cmdline *cl,
1703 __attribute__((unused)) void *data)
1705 struct cmd_config_rx_mode_flag *res = parsed_result;
1707 if (!all_ports_stopped()) {
1708 printf("Please stop all ports first\n");
1712 if (!strcmp(res->name, "crc-strip")) {
1713 if (!strcmp(res->value, "on"))
1714 rx_mode.hw_strip_crc = 1;
1715 else if (!strcmp(res->value, "off"))
1716 rx_mode.hw_strip_crc = 0;
1718 printf("Unknown parameter\n");
1721 } else if (!strcmp(res->name, "scatter")) {
1722 if (!strcmp(res->value, "on"))
1723 rx_mode.enable_scatter = 1;
1724 else if (!strcmp(res->value, "off"))
1725 rx_mode.enable_scatter = 0;
1727 printf("Unknown parameter\n");
1730 } else if (!strcmp(res->name, "rx-cksum")) {
1731 if (!strcmp(res->value, "on"))
1732 rx_mode.hw_ip_checksum = 1;
1733 else if (!strcmp(res->value, "off"))
1734 rx_mode.hw_ip_checksum = 0;
1736 printf("Unknown parameter\n");
1739 } else if (!strcmp(res->name, "rx-timestamp")) {
1740 if (!strcmp(res->value, "on"))
1741 rx_mode.hw_timestamp = 1;
1742 else if (!strcmp(res->value, "off"))
1743 rx_mode.hw_timestamp = 0;
1745 printf("Unknown parameter\n");
1748 } else if (!strcmp(res->name, "hw-vlan")) {
1749 if (!strcmp(res->value, "on")) {
1750 rx_mode.hw_vlan_filter = 1;
1751 rx_mode.hw_vlan_strip = 1;
1753 else if (!strcmp(res->value, "off")) {
1754 rx_mode.hw_vlan_filter = 0;
1755 rx_mode.hw_vlan_strip = 0;
1758 printf("Unknown parameter\n");
1761 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1762 if (!strcmp(res->value, "on"))
1763 rx_mode.hw_vlan_filter = 1;
1764 else if (!strcmp(res->value, "off"))
1765 rx_mode.hw_vlan_filter = 0;
1767 printf("Unknown parameter\n");
1770 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1771 if (!strcmp(res->value, "on"))
1772 rx_mode.hw_vlan_strip = 1;
1773 else if (!strcmp(res->value, "off"))
1774 rx_mode.hw_vlan_strip = 0;
1776 printf("Unknown parameter\n");
1779 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1780 if (!strcmp(res->value, "on"))
1781 rx_mode.hw_vlan_extend = 1;
1782 else if (!strcmp(res->value, "off"))
1783 rx_mode.hw_vlan_extend = 0;
1785 printf("Unknown parameter\n");
1788 } else if (!strcmp(res->name, "drop-en")) {
1789 if (!strcmp(res->value, "on"))
1791 else if (!strcmp(res->value, "off"))
1794 printf("Unknown parameter\n");
1798 printf("Unknown parameter\n");
1804 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1807 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1808 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1809 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1810 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1812 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1813 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1814 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1816 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1817 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1818 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1822 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1823 .f = cmd_config_rx_mode_flag_parsed,
1825 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1826 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1828 (void *)&cmd_config_rx_mode_flag_port,
1829 (void *)&cmd_config_rx_mode_flag_keyword,
1830 (void *)&cmd_config_rx_mode_flag_all,
1831 (void *)&cmd_config_rx_mode_flag_name,
1832 (void *)&cmd_config_rx_mode_flag_value,
1837 /* *** configure rss *** */
1838 struct cmd_config_rss {
1839 cmdline_fixed_string_t port;
1840 cmdline_fixed_string_t keyword;
1841 cmdline_fixed_string_t all;
1842 cmdline_fixed_string_t name;
1843 cmdline_fixed_string_t value;
1847 cmd_config_rss_parsed(void *parsed_result,
1848 __attribute__((unused)) struct cmdline *cl,
1849 __attribute__((unused)) void *data)
1851 struct cmd_config_rss *res = parsed_result;
1852 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1856 if (!strcmp(res->value, "all"))
1857 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1858 ETH_RSS_UDP | ETH_RSS_SCTP |
1860 else if (!strcmp(res->value, "ip"))
1861 rss_conf.rss_hf = ETH_RSS_IP;
1862 else if (!strcmp(res->value, "udp"))
1863 rss_conf.rss_hf = ETH_RSS_UDP;
1864 else if (!strcmp(res->value, "tcp"))
1865 rss_conf.rss_hf = ETH_RSS_TCP;
1866 else if (!strcmp(res->value, "sctp"))
1867 rss_conf.rss_hf = ETH_RSS_SCTP;
1868 else if (!strcmp(res->value, "ether"))
1869 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1870 else if (!strcmp(res->value, "port"))
1871 rss_conf.rss_hf = ETH_RSS_PORT;
1872 else if (!strcmp(res->value, "vxlan"))
1873 rss_conf.rss_hf = ETH_RSS_VXLAN;
1874 else if (!strcmp(res->value, "geneve"))
1875 rss_conf.rss_hf = ETH_RSS_GENEVE;
1876 else if (!strcmp(res->value, "nvgre"))
1877 rss_conf.rss_hf = ETH_RSS_NVGRE;
1878 else if (!strcmp(res->value, "none"))
1879 rss_conf.rss_hf = 0;
1880 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1881 atoi(res->value) < 64)
1882 rss_conf.rss_hf = 1ULL << atoi(res->value);
1884 printf("Unknown parameter\n");
1887 rss_conf.rss_key = NULL;
1888 for (i = 0; i < rte_eth_dev_count(); i++) {
1889 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1891 printf("Configuration of RSS hash at ethernet port %d "
1892 "failed with error (%d): %s.\n",
1893 i, -diag, strerror(-diag));
1897 cmdline_parse_token_string_t cmd_config_rss_port =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1899 cmdline_parse_token_string_t cmd_config_rss_keyword =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1901 cmdline_parse_token_string_t cmd_config_rss_all =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1903 cmdline_parse_token_string_t cmd_config_rss_name =
1904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1905 cmdline_parse_token_string_t cmd_config_rss_value =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1908 cmdline_parse_inst_t cmd_config_rss = {
1909 .f = cmd_config_rss_parsed,
1911 .help_str = "port config all rss "
1912 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1914 (void *)&cmd_config_rss_port,
1915 (void *)&cmd_config_rss_keyword,
1916 (void *)&cmd_config_rss_all,
1917 (void *)&cmd_config_rss_name,
1918 (void *)&cmd_config_rss_value,
1923 /* *** configure rss hash key *** */
1924 struct cmd_config_rss_hash_key {
1925 cmdline_fixed_string_t port;
1926 cmdline_fixed_string_t config;
1928 cmdline_fixed_string_t rss_hash_key;
1929 cmdline_fixed_string_t rss_type;
1930 cmdline_fixed_string_t key;
1934 hexa_digit_to_value(char hexa_digit)
1936 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1937 return (uint8_t) (hexa_digit - '0');
1938 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1939 return (uint8_t) ((hexa_digit - 'a') + 10);
1940 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1941 return (uint8_t) ((hexa_digit - 'A') + 10);
1942 /* Invalid hexa digit */
1947 parse_and_check_key_hexa_digit(char *key, int idx)
1951 hexa_v = hexa_digit_to_value(key[idx]);
1953 printf("invalid key: character %c at position %d is not a "
1954 "valid hexa digit\n", key[idx], idx);
1959 cmd_config_rss_hash_key_parsed(void *parsed_result,
1960 __attribute__((unused)) struct cmdline *cl,
1961 __attribute__((unused)) void *data)
1963 struct cmd_config_rss_hash_key *res = parsed_result;
1964 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1968 struct rte_eth_dev_info dev_info;
1969 uint8_t hash_key_size;
1972 memset(&dev_info, 0, sizeof(dev_info));
1973 rte_eth_dev_info_get(res->port_id, &dev_info);
1974 if (dev_info.hash_key_size > 0 &&
1975 dev_info.hash_key_size <= sizeof(hash_key))
1976 hash_key_size = dev_info.hash_key_size;
1978 printf("dev_info did not provide a valid hash key size\n");
1981 /* Check the length of the RSS hash key */
1982 key_len = strlen(res->key);
1983 if (key_len != (hash_key_size * 2)) {
1984 printf("key length: %d invalid - key must be a string of %d"
1985 " hexa-decimal numbers\n",
1986 (int) key_len, hash_key_size * 2);
1989 /* Translate RSS hash key into binary representation */
1990 for (i = 0; i < hash_key_size; i++) {
1991 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1994 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1997 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1999 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2003 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2005 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2008 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2009 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2010 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2012 rss_hash_key, "rss-hash-key");
2013 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2015 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2016 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2017 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2018 "ipv6-tcp-ex#ipv6-udp-ex");
2019 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2022 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2023 .f = cmd_config_rss_hash_key_parsed,
2025 .help_str = "port config <port_id> rss-hash-key "
2026 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2027 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2028 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2029 "<string of hex digits (variable length, NIC dependent)>",
2031 (void *)&cmd_config_rss_hash_key_port,
2032 (void *)&cmd_config_rss_hash_key_config,
2033 (void *)&cmd_config_rss_hash_key_port_id,
2034 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2035 (void *)&cmd_config_rss_hash_key_rss_type,
2036 (void *)&cmd_config_rss_hash_key_value,
2041 /* *** configure port rxq/txq start/stop *** */
2042 struct cmd_config_rxtx_queue {
2043 cmdline_fixed_string_t port;
2045 cmdline_fixed_string_t rxtxq;
2047 cmdline_fixed_string_t opname;
2051 cmd_config_rxtx_queue_parsed(void *parsed_result,
2052 __attribute__((unused)) struct cmdline *cl,
2053 __attribute__((unused)) void *data)
2055 struct cmd_config_rxtx_queue *res = parsed_result;
2060 if (test_done == 0) {
2061 printf("Please stop forwarding first\n");
2065 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2068 if (port_is_started(res->portid) != 1) {
2069 printf("Please start port %u first\n", res->portid);
2073 if (!strcmp(res->rxtxq, "rxq"))
2075 else if (!strcmp(res->rxtxq, "txq"))
2078 printf("Unknown parameter\n");
2082 if (isrx && rx_queue_id_is_invalid(res->qid))
2084 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2087 if (!strcmp(res->opname, "start"))
2089 else if (!strcmp(res->opname, "stop"))
2092 printf("Unknown parameter\n");
2096 if (isstart && isrx)
2097 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2098 else if (!isstart && isrx)
2099 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2100 else if (isstart && !isrx)
2101 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2103 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2105 if (ret == -ENOTSUP)
2106 printf("Function not supported in PMD driver\n");
2109 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2111 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2112 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2113 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2115 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2116 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2117 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2121 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2122 .f = cmd_config_rxtx_queue_parsed,
2124 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2126 (void *)&cmd_config_speed_all_port,
2127 (void *)&cmd_config_rxtx_queue_portid,
2128 (void *)&cmd_config_rxtx_queue_rxtxq,
2129 (void *)&cmd_config_rxtx_queue_qid,
2130 (void *)&cmd_config_rxtx_queue_opname,
2135 /* *** Configure RSS RETA *** */
2136 struct cmd_config_rss_reta {
2137 cmdline_fixed_string_t port;
2138 cmdline_fixed_string_t keyword;
2140 cmdline_fixed_string_t name;
2141 cmdline_fixed_string_t list_name;
2142 cmdline_fixed_string_t list_of_items;
2146 parse_reta_config(const char *str,
2147 struct rte_eth_rss_reta_entry64 *reta_conf,
2148 uint16_t nb_entries)
2152 uint16_t hash_index, idx, shift;
2155 const char *p, *p0 = str;
2162 unsigned long int_fld[_NUM_FLD];
2163 char *str_fld[_NUM_FLD];
2165 while ((p = strchr(p0,'(')) != NULL) {
2167 if((p0 = strchr(p,')')) == NULL)
2171 if(size >= sizeof(s))
2174 snprintf(s, sizeof(s), "%.*s", size, p);
2175 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2177 for (i = 0; i < _NUM_FLD; i++) {
2179 int_fld[i] = strtoul(str_fld[i], &end, 0);
2180 if (errno != 0 || end == str_fld[i] ||
2185 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2186 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2188 if (hash_index >= nb_entries) {
2189 printf("Invalid RETA hash index=%d\n", hash_index);
2193 idx = hash_index / RTE_RETA_GROUP_SIZE;
2194 shift = hash_index % RTE_RETA_GROUP_SIZE;
2195 reta_conf[idx].mask |= (1ULL << shift);
2196 reta_conf[idx].reta[shift] = nb_queue;
2203 cmd_set_rss_reta_parsed(void *parsed_result,
2204 __attribute__((unused)) struct cmdline *cl,
2205 __attribute__((unused)) void *data)
2208 struct rte_eth_dev_info dev_info;
2209 struct rte_eth_rss_reta_entry64 reta_conf[8];
2210 struct cmd_config_rss_reta *res = parsed_result;
2212 memset(&dev_info, 0, sizeof(dev_info));
2213 rte_eth_dev_info_get(res->port_id, &dev_info);
2214 if (dev_info.reta_size == 0) {
2215 printf("Redirection table size is 0 which is "
2216 "invalid for RSS\n");
2219 printf("The reta size of port %d is %u\n",
2220 res->port_id, dev_info.reta_size);
2221 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2222 printf("Currently do not support more than %u entries of "
2223 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2227 memset(reta_conf, 0, sizeof(reta_conf));
2228 if (!strcmp(res->list_name, "reta")) {
2229 if (parse_reta_config(res->list_of_items, reta_conf,
2230 dev_info.reta_size)) {
2231 printf("Invalid RSS Redirection Table "
2232 "config entered\n");
2235 ret = rte_eth_dev_rss_reta_update(res->port_id,
2236 reta_conf, dev_info.reta_size);
2238 printf("Bad redirection table parameter, "
2239 "return code = %d \n", ret);
2243 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2244 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2245 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2247 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2248 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2249 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2251 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2253 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2256 cmdline_parse_inst_t cmd_config_rss_reta = {
2257 .f = cmd_set_rss_reta_parsed,
2259 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2261 (void *)&cmd_config_rss_reta_port,
2262 (void *)&cmd_config_rss_reta_keyword,
2263 (void *)&cmd_config_rss_reta_port_id,
2264 (void *)&cmd_config_rss_reta_name,
2265 (void *)&cmd_config_rss_reta_list_name,
2266 (void *)&cmd_config_rss_reta_list_of_items,
2271 /* *** SHOW PORT RETA INFO *** */
2272 struct cmd_showport_reta {
2273 cmdline_fixed_string_t show;
2274 cmdline_fixed_string_t port;
2276 cmdline_fixed_string_t rss;
2277 cmdline_fixed_string_t reta;
2279 cmdline_fixed_string_t list_of_items;
2283 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2284 uint16_t nb_entries,
2288 const char *p, *p0 = str;
2293 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2294 RTE_RETA_GROUP_SIZE;
2297 p = strchr(p0, '(');
2301 p0 = strchr(p, ')');
2305 if (size >= sizeof(s)) {
2306 printf("The string size exceeds the internal buffer size\n");
2309 snprintf(s, sizeof(s), "%.*s", size, p);
2310 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2311 if (ret <= 0 || ret != num) {
2312 printf("The bits of masks do not match the number of "
2313 "reta entries: %u\n", num);
2316 for (i = 0; i < ret; i++)
2317 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2323 cmd_showport_reta_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_showport_reta *res = parsed_result;
2328 struct rte_eth_rss_reta_entry64 reta_conf[8];
2329 struct rte_eth_dev_info dev_info;
2330 uint16_t max_reta_size;
2332 memset(&dev_info, 0, sizeof(dev_info));
2333 rte_eth_dev_info_get(res->port_id, &dev_info);
2334 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2335 if (res->size == 0 || res->size > max_reta_size) {
2336 printf("Invalid redirection table size: %u (1-%u)\n",
2337 res->size, max_reta_size);
2341 memset(reta_conf, 0, sizeof(reta_conf));
2342 if (showport_parse_reta_config(reta_conf, res->size,
2343 res->list_of_items) < 0) {
2344 printf("Invalid string: %s for reta masks\n",
2345 res->list_of_items);
2348 port_rss_reta_info(res->port_id, reta_conf, res->size);
2351 cmdline_parse_token_string_t cmd_showport_reta_show =
2352 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2353 cmdline_parse_token_string_t cmd_showport_reta_port =
2354 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2355 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2356 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2357 cmdline_parse_token_string_t cmd_showport_reta_rss =
2358 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2359 cmdline_parse_token_string_t cmd_showport_reta_reta =
2360 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2361 cmdline_parse_token_num_t cmd_showport_reta_size =
2362 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2363 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2364 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2365 list_of_items, NULL);
2367 cmdline_parse_inst_t cmd_showport_reta = {
2368 .f = cmd_showport_reta_parsed,
2370 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2372 (void *)&cmd_showport_reta_show,
2373 (void *)&cmd_showport_reta_port,
2374 (void *)&cmd_showport_reta_port_id,
2375 (void *)&cmd_showport_reta_rss,
2376 (void *)&cmd_showport_reta_reta,
2377 (void *)&cmd_showport_reta_size,
2378 (void *)&cmd_showport_reta_list_of_items,
2383 /* *** Show RSS hash configuration *** */
2384 struct cmd_showport_rss_hash {
2385 cmdline_fixed_string_t show;
2386 cmdline_fixed_string_t port;
2388 cmdline_fixed_string_t rss_hash;
2389 cmdline_fixed_string_t rss_type;
2390 cmdline_fixed_string_t key; /* optional argument */
2393 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2394 __attribute__((unused)) struct cmdline *cl,
2397 struct cmd_showport_rss_hash *res = parsed_result;
2399 port_rss_hash_conf_show(res->port_id, res->rss_type,
2400 show_rss_key != NULL);
2403 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2404 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2405 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2406 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2407 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2408 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2409 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2410 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2412 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2413 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2414 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2415 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2416 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2417 "ipv6-tcp-ex#ipv6-udp-ex");
2418 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2419 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2421 cmdline_parse_inst_t cmd_showport_rss_hash = {
2422 .f = cmd_showport_rss_hash_parsed,
2424 .help_str = "show port <port_id> rss-hash "
2425 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2426 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2427 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2429 (void *)&cmd_showport_rss_hash_show,
2430 (void *)&cmd_showport_rss_hash_port,
2431 (void *)&cmd_showport_rss_hash_port_id,
2432 (void *)&cmd_showport_rss_hash_rss_hash,
2433 (void *)&cmd_showport_rss_hash_rss_hash_info,
2438 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2439 .f = cmd_showport_rss_hash_parsed,
2441 .help_str = "show port <port_id> rss-hash "
2442 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2443 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2444 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2446 (void *)&cmd_showport_rss_hash_show,
2447 (void *)&cmd_showport_rss_hash_port,
2448 (void *)&cmd_showport_rss_hash_port_id,
2449 (void *)&cmd_showport_rss_hash_rss_hash,
2450 (void *)&cmd_showport_rss_hash_rss_hash_info,
2451 (void *)&cmd_showport_rss_hash_rss_key,
2456 /* *** Configure DCB *** */
2457 struct cmd_config_dcb {
2458 cmdline_fixed_string_t port;
2459 cmdline_fixed_string_t config;
2461 cmdline_fixed_string_t dcb;
2462 cmdline_fixed_string_t vt;
2463 cmdline_fixed_string_t vt_en;
2465 cmdline_fixed_string_t pfc;
2466 cmdline_fixed_string_t pfc_en;
2470 cmd_config_dcb_parsed(void *parsed_result,
2471 __attribute__((unused)) struct cmdline *cl,
2472 __attribute__((unused)) void *data)
2474 struct cmd_config_dcb *res = parsed_result;
2475 portid_t port_id = res->port_id;
2476 struct rte_port *port;
2480 port = &ports[port_id];
2481 /** Check if the port is not started **/
2482 if (port->port_status != RTE_PORT_STOPPED) {
2483 printf("Please stop port %d first\n", port_id);
2487 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2488 printf("The invalid number of traffic class,"
2489 " only 4 or 8 allowed.\n");
2493 if (nb_fwd_lcores < res->num_tcs) {
2494 printf("nb_cores shouldn't be less than number of TCs.\n");
2497 if (!strncmp(res->pfc_en, "on", 2))
2502 /* DCB in VT mode */
2503 if (!strncmp(res->vt_en, "on", 2))
2504 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2505 (enum rte_eth_nb_tcs)res->num_tcs,
2508 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2509 (enum rte_eth_nb_tcs)res->num_tcs,
2514 printf("Cannot initialize network ports.\n");
2518 cmd_reconfig_device_queue(port_id, 1, 1);
2521 cmdline_parse_token_string_t cmd_config_dcb_port =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2523 cmdline_parse_token_string_t cmd_config_dcb_config =
2524 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2525 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2526 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2527 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2529 cmdline_parse_token_string_t cmd_config_dcb_vt =
2530 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2531 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2532 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2533 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2534 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2535 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2536 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2537 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2538 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2540 cmdline_parse_inst_t cmd_config_dcb = {
2541 .f = cmd_config_dcb_parsed,
2543 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2545 (void *)&cmd_config_dcb_port,
2546 (void *)&cmd_config_dcb_config,
2547 (void *)&cmd_config_dcb_port_id,
2548 (void *)&cmd_config_dcb_dcb,
2549 (void *)&cmd_config_dcb_vt,
2550 (void *)&cmd_config_dcb_vt_en,
2551 (void *)&cmd_config_dcb_num_tcs,
2552 (void *)&cmd_config_dcb_pfc,
2553 (void *)&cmd_config_dcb_pfc_en,
2558 /* *** configure number of packets per burst *** */
2559 struct cmd_config_burst {
2560 cmdline_fixed_string_t port;
2561 cmdline_fixed_string_t keyword;
2562 cmdline_fixed_string_t all;
2563 cmdline_fixed_string_t name;
2568 cmd_config_burst_parsed(void *parsed_result,
2569 __attribute__((unused)) struct cmdline *cl,
2570 __attribute__((unused)) void *data)
2572 struct cmd_config_burst *res = parsed_result;
2574 if (!all_ports_stopped()) {
2575 printf("Please stop all ports first\n");
2579 if (!strcmp(res->name, "burst")) {
2580 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2581 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2584 nb_pkt_per_burst = res->value;
2586 printf("Unknown parameter\n");
2592 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2595 cmdline_parse_token_string_t cmd_config_burst_port =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2597 cmdline_parse_token_string_t cmd_config_burst_keyword =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2599 cmdline_parse_token_string_t cmd_config_burst_all =
2600 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2601 cmdline_parse_token_string_t cmd_config_burst_name =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2603 cmdline_parse_token_num_t cmd_config_burst_value =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2606 cmdline_parse_inst_t cmd_config_burst = {
2607 .f = cmd_config_burst_parsed,
2609 .help_str = "port config all burst <value>",
2611 (void *)&cmd_config_burst_port,
2612 (void *)&cmd_config_burst_keyword,
2613 (void *)&cmd_config_burst_all,
2614 (void *)&cmd_config_burst_name,
2615 (void *)&cmd_config_burst_value,
2620 /* *** configure rx/tx queues *** */
2621 struct cmd_config_thresh {
2622 cmdline_fixed_string_t port;
2623 cmdline_fixed_string_t keyword;
2624 cmdline_fixed_string_t all;
2625 cmdline_fixed_string_t name;
2630 cmd_config_thresh_parsed(void *parsed_result,
2631 __attribute__((unused)) struct cmdline *cl,
2632 __attribute__((unused)) void *data)
2634 struct cmd_config_thresh *res = parsed_result;
2636 if (!all_ports_stopped()) {
2637 printf("Please stop all ports first\n");
2641 if (!strcmp(res->name, "txpt"))
2642 tx_pthresh = res->value;
2643 else if(!strcmp(res->name, "txht"))
2644 tx_hthresh = res->value;
2645 else if(!strcmp(res->name, "txwt"))
2646 tx_wthresh = res->value;
2647 else if(!strcmp(res->name, "rxpt"))
2648 rx_pthresh = res->value;
2649 else if(!strcmp(res->name, "rxht"))
2650 rx_hthresh = res->value;
2651 else if(!strcmp(res->name, "rxwt"))
2652 rx_wthresh = res->value;
2654 printf("Unknown parameter\n");
2660 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2663 cmdline_parse_token_string_t cmd_config_thresh_port =
2664 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2665 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2666 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2667 cmdline_parse_token_string_t cmd_config_thresh_all =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2669 cmdline_parse_token_string_t cmd_config_thresh_name =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2671 "txpt#txht#txwt#rxpt#rxht#rxwt");
2672 cmdline_parse_token_num_t cmd_config_thresh_value =
2673 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2675 cmdline_parse_inst_t cmd_config_thresh = {
2676 .f = cmd_config_thresh_parsed,
2678 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2680 (void *)&cmd_config_thresh_port,
2681 (void *)&cmd_config_thresh_keyword,
2682 (void *)&cmd_config_thresh_all,
2683 (void *)&cmd_config_thresh_name,
2684 (void *)&cmd_config_thresh_value,
2689 /* *** configure free/rs threshold *** */
2690 struct cmd_config_threshold {
2691 cmdline_fixed_string_t port;
2692 cmdline_fixed_string_t keyword;
2693 cmdline_fixed_string_t all;
2694 cmdline_fixed_string_t name;
2699 cmd_config_threshold_parsed(void *parsed_result,
2700 __attribute__((unused)) struct cmdline *cl,
2701 __attribute__((unused)) void *data)
2703 struct cmd_config_threshold *res = parsed_result;
2705 if (!all_ports_stopped()) {
2706 printf("Please stop all ports first\n");
2710 if (!strcmp(res->name, "txfreet"))
2711 tx_free_thresh = res->value;
2712 else if (!strcmp(res->name, "txrst"))
2713 tx_rs_thresh = res->value;
2714 else if (!strcmp(res->name, "rxfreet"))
2715 rx_free_thresh = res->value;
2717 printf("Unknown parameter\n");
2723 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2726 cmdline_parse_token_string_t cmd_config_threshold_port =
2727 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2728 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2729 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2731 cmdline_parse_token_string_t cmd_config_threshold_all =
2732 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2733 cmdline_parse_token_string_t cmd_config_threshold_name =
2734 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2735 "txfreet#txrst#rxfreet");
2736 cmdline_parse_token_num_t cmd_config_threshold_value =
2737 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2739 cmdline_parse_inst_t cmd_config_threshold = {
2740 .f = cmd_config_threshold_parsed,
2742 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2744 (void *)&cmd_config_threshold_port,
2745 (void *)&cmd_config_threshold_keyword,
2746 (void *)&cmd_config_threshold_all,
2747 (void *)&cmd_config_threshold_name,
2748 (void *)&cmd_config_threshold_value,
2754 struct cmd_stop_result {
2755 cmdline_fixed_string_t stop;
2758 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2759 __attribute__((unused)) struct cmdline *cl,
2760 __attribute__((unused)) void *data)
2762 stop_packet_forwarding();
2765 cmdline_parse_token_string_t cmd_stop_stop =
2766 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2768 cmdline_parse_inst_t cmd_stop = {
2769 .f = cmd_stop_parsed,
2771 .help_str = "stop: Stop packet forwarding",
2773 (void *)&cmd_stop_stop,
2778 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2781 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2782 unsigned int *parsed_items, int check_unique_values)
2784 unsigned int nb_item;
2792 * First parse all items in the list and store their value.
2797 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2799 if ((c >= '0') && (c <= '9')) {
2800 value = (unsigned int) (value * 10 + (c - '0'));
2805 printf("character %c is not a decimal digit\n", c);
2809 printf("No valid value before comma\n");
2812 if (nb_item < max_items) {
2813 parsed_items[nb_item] = value;
2819 if (nb_item >= max_items) {
2820 printf("Number of %s = %u > %u (maximum items)\n",
2821 item_name, nb_item + 1, max_items);
2824 parsed_items[nb_item++] = value;
2825 if (! check_unique_values)
2829 * Then, check that all values in the list are differents.
2830 * No optimization here...
2832 for (i = 0; i < nb_item; i++) {
2833 for (j = i + 1; j < nb_item; j++) {
2834 if (parsed_items[j] == parsed_items[i]) {
2835 printf("duplicated %s %u at index %u and %u\n",
2836 item_name, parsed_items[i], i, j);
2844 struct cmd_set_list_result {
2845 cmdline_fixed_string_t cmd_keyword;
2846 cmdline_fixed_string_t list_name;
2847 cmdline_fixed_string_t list_of_items;
2850 static void cmd_set_list_parsed(void *parsed_result,
2851 __attribute__((unused)) struct cmdline *cl,
2852 __attribute__((unused)) void *data)
2854 struct cmd_set_list_result *res;
2856 unsigned int lcorelist[RTE_MAX_LCORE];
2857 unsigned int portlist[RTE_MAX_ETHPORTS];
2859 unsigned int nb_item;
2861 if (test_done == 0) {
2862 printf("Please stop forwarding first\n");
2866 res = parsed_result;
2867 if (!strcmp(res->list_name, "corelist")) {
2868 nb_item = parse_item_list(res->list_of_items, "core",
2870 parsed_items.lcorelist, 1);
2872 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2877 if (!strcmp(res->list_name, "portlist")) {
2878 nb_item = parse_item_list(res->list_of_items, "port",
2880 parsed_items.portlist, 1);
2882 set_fwd_ports_list(parsed_items.portlist, nb_item);
2888 cmdline_parse_token_string_t cmd_set_list_keyword =
2889 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2891 cmdline_parse_token_string_t cmd_set_list_name =
2892 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2893 "corelist#portlist");
2894 cmdline_parse_token_string_t cmd_set_list_of_items =
2895 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2898 cmdline_parse_inst_t cmd_set_fwd_list = {
2899 .f = cmd_set_list_parsed,
2901 .help_str = "set corelist|portlist <list0[,list1]*>",
2903 (void *)&cmd_set_list_keyword,
2904 (void *)&cmd_set_list_name,
2905 (void *)&cmd_set_list_of_items,
2910 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2912 struct cmd_setmask_result {
2913 cmdline_fixed_string_t set;
2914 cmdline_fixed_string_t mask;
2918 static void cmd_set_mask_parsed(void *parsed_result,
2919 __attribute__((unused)) struct cmdline *cl,
2920 __attribute__((unused)) void *data)
2922 struct cmd_setmask_result *res = parsed_result;
2924 if (test_done == 0) {
2925 printf("Please stop forwarding first\n");
2928 if (!strcmp(res->mask, "coremask")) {
2929 set_fwd_lcores_mask(res->hexavalue);
2931 } else if (!strcmp(res->mask, "portmask")) {
2932 set_fwd_ports_mask(res->hexavalue);
2937 cmdline_parse_token_string_t cmd_setmask_set =
2938 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2939 cmdline_parse_token_string_t cmd_setmask_mask =
2940 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2941 "coremask#portmask");
2942 cmdline_parse_token_num_t cmd_setmask_value =
2943 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2945 cmdline_parse_inst_t cmd_set_fwd_mask = {
2946 .f = cmd_set_mask_parsed,
2948 .help_str = "set coremask|portmask <hexadecimal value>",
2950 (void *)&cmd_setmask_set,
2951 (void *)&cmd_setmask_mask,
2952 (void *)&cmd_setmask_value,
2958 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2960 struct cmd_set_result {
2961 cmdline_fixed_string_t set;
2962 cmdline_fixed_string_t what;
2966 static void cmd_set_parsed(void *parsed_result,
2967 __attribute__((unused)) struct cmdline *cl,
2968 __attribute__((unused)) void *data)
2970 struct cmd_set_result *res = parsed_result;
2971 if (!strcmp(res->what, "nbport")) {
2972 set_fwd_ports_number(res->value);
2974 } else if (!strcmp(res->what, "nbcore")) {
2975 set_fwd_lcores_number(res->value);
2977 } else if (!strcmp(res->what, "burst"))
2978 set_nb_pkt_per_burst(res->value);
2979 else if (!strcmp(res->what, "verbose"))
2980 set_verbose_level(res->value);
2983 cmdline_parse_token_string_t cmd_set_set =
2984 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2985 cmdline_parse_token_string_t cmd_set_what =
2986 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2987 "nbport#nbcore#burst#verbose");
2988 cmdline_parse_token_num_t cmd_set_value =
2989 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2991 cmdline_parse_inst_t cmd_set_numbers = {
2992 .f = cmd_set_parsed,
2994 .help_str = "set nbport|nbcore|burst|verbose <value>",
2996 (void *)&cmd_set_set,
2997 (void *)&cmd_set_what,
2998 (void *)&cmd_set_value,
3003 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3005 struct cmd_set_txpkts_result {
3006 cmdline_fixed_string_t cmd_keyword;
3007 cmdline_fixed_string_t txpkts;
3008 cmdline_fixed_string_t seg_lengths;
3012 cmd_set_txpkts_parsed(void *parsed_result,
3013 __attribute__((unused)) struct cmdline *cl,
3014 __attribute__((unused)) void *data)
3016 struct cmd_set_txpkts_result *res;
3017 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3018 unsigned int nb_segs;
3020 res = parsed_result;
3021 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3022 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3024 set_tx_pkt_segments(seg_lengths, nb_segs);
3027 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3028 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3029 cmd_keyword, "set");
3030 cmdline_parse_token_string_t cmd_set_txpkts_name =
3031 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3033 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3034 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3037 cmdline_parse_inst_t cmd_set_txpkts = {
3038 .f = cmd_set_txpkts_parsed,
3040 .help_str = "set txpkts <len0[,len1]*>",
3042 (void *)&cmd_set_txpkts_keyword,
3043 (void *)&cmd_set_txpkts_name,
3044 (void *)&cmd_set_txpkts_lengths,
3049 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3051 struct cmd_set_txsplit_result {
3052 cmdline_fixed_string_t cmd_keyword;
3053 cmdline_fixed_string_t txsplit;
3054 cmdline_fixed_string_t mode;
3058 cmd_set_txsplit_parsed(void *parsed_result,
3059 __attribute__((unused)) struct cmdline *cl,
3060 __attribute__((unused)) void *data)
3062 struct cmd_set_txsplit_result *res;
3064 res = parsed_result;
3065 set_tx_pkt_split(res->mode);
3068 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3069 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3070 cmd_keyword, "set");
3071 cmdline_parse_token_string_t cmd_set_txsplit_name =
3072 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3073 txsplit, "txsplit");
3074 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3075 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3078 cmdline_parse_inst_t cmd_set_txsplit = {
3079 .f = cmd_set_txsplit_parsed,
3081 .help_str = "set txsplit on|off|rand",
3083 (void *)&cmd_set_txsplit_keyword,
3084 (void *)&cmd_set_txsplit_name,
3085 (void *)&cmd_set_txsplit_mode,
3090 /* *** CONFIG TX QUEUE FLAGS *** */
3092 struct cmd_config_txqflags_result {
3093 cmdline_fixed_string_t port;
3094 cmdline_fixed_string_t config;
3095 cmdline_fixed_string_t all;
3096 cmdline_fixed_string_t what;
3100 static void cmd_config_txqflags_parsed(void *parsed_result,
3101 __attribute__((unused)) struct cmdline *cl,
3102 __attribute__((unused)) void *data)
3104 struct cmd_config_txqflags_result *res = parsed_result;
3106 if (!all_ports_stopped()) {
3107 printf("Please stop all ports first\n");
3111 if (strcmp(res->what, "txqflags")) {
3112 printf("Unknown parameter\n");
3116 if (res->hexvalue >= 0) {
3117 txq_flags = res->hexvalue;
3119 printf("txqflags must be >= 0\n");
3125 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3128 cmdline_parse_token_string_t cmd_config_txqflags_port =
3129 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3131 cmdline_parse_token_string_t cmd_config_txqflags_config =
3132 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3134 cmdline_parse_token_string_t cmd_config_txqflags_all =
3135 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3137 cmdline_parse_token_string_t cmd_config_txqflags_what =
3138 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3140 cmdline_parse_token_num_t cmd_config_txqflags_value =
3141 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3144 cmdline_parse_inst_t cmd_config_txqflags = {
3145 .f = cmd_config_txqflags_parsed,
3147 .help_str = "port config all txqflags <value>",
3149 (void *)&cmd_config_txqflags_port,
3150 (void *)&cmd_config_txqflags_config,
3151 (void *)&cmd_config_txqflags_all,
3152 (void *)&cmd_config_txqflags_what,
3153 (void *)&cmd_config_txqflags_value,
3158 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3159 struct cmd_rx_vlan_filter_all_result {
3160 cmdline_fixed_string_t rx_vlan;
3161 cmdline_fixed_string_t what;
3162 cmdline_fixed_string_t all;
3167 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3168 __attribute__((unused)) struct cmdline *cl,
3169 __attribute__((unused)) void *data)
3171 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3173 if (!strcmp(res->what, "add"))
3174 rx_vlan_all_filter_set(res->port_id, 1);
3176 rx_vlan_all_filter_set(res->port_id, 0);
3179 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3180 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3181 rx_vlan, "rx_vlan");
3182 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3183 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3185 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3186 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3188 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3189 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3192 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3193 .f = cmd_rx_vlan_filter_all_parsed,
3195 .help_str = "rx_vlan add|rm all <port_id>: "
3196 "Add/Remove all identifiers to/from the set of VLAN "
3197 "identifiers filtered by a port",
3199 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3200 (void *)&cmd_rx_vlan_filter_all_what,
3201 (void *)&cmd_rx_vlan_filter_all_all,
3202 (void *)&cmd_rx_vlan_filter_all_portid,
3207 /* *** VLAN OFFLOAD SET ON A PORT *** */
3208 struct cmd_vlan_offload_result {
3209 cmdline_fixed_string_t vlan;
3210 cmdline_fixed_string_t set;
3211 cmdline_fixed_string_t vlan_type;
3212 cmdline_fixed_string_t what;
3213 cmdline_fixed_string_t on;
3214 cmdline_fixed_string_t port_id;
3218 cmd_vlan_offload_parsed(void *parsed_result,
3219 __attribute__((unused)) struct cmdline *cl,
3220 __attribute__((unused)) void *data)
3223 struct cmd_vlan_offload_result *res = parsed_result;
3226 portid_t port_id = 0;
3230 len = strnlen(str, STR_TOKEN_SIZE);
3232 /* Get port_id first */
3240 tmp = strtoul(str, NULL, 0);
3241 /* If port_id greater that what portid_t can represent, return */
3242 if(tmp >= RTE_MAX_ETHPORTS)
3244 port_id = (portid_t)tmp;
3246 if (!strcmp(res->on, "on"))
3251 if (!strcmp(res->what, "strip"))
3252 rx_vlan_strip_set(port_id, on);
3253 else if(!strcmp(res->what, "stripq")){
3254 uint16_t queue_id = 0;
3256 /* No queue_id, return */
3258 printf("must specify (port,queue_id)\n");
3261 tmp = strtoul(str + i + 1, NULL, 0);
3262 /* If queue_id greater that what 16-bits can represent, return */
3266 queue_id = (uint16_t)tmp;
3267 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3269 else if (!strcmp(res->what, "filter"))
3270 rx_vlan_filter_set(port_id, on);
3272 vlan_extend_set(port_id, on);
3277 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3278 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3280 cmdline_parse_token_string_t cmd_vlan_offload_set =
3281 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3283 cmdline_parse_token_string_t cmd_vlan_offload_what =
3284 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3285 what, "strip#filter#qinq#stripq");
3286 cmdline_parse_token_string_t cmd_vlan_offload_on =
3287 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3289 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3290 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3293 cmdline_parse_inst_t cmd_vlan_offload = {
3294 .f = cmd_vlan_offload_parsed,
3296 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3297 "<port_id[,queue_id]>: "
3298 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3300 (void *)&cmd_vlan_offload_vlan,
3301 (void *)&cmd_vlan_offload_set,
3302 (void *)&cmd_vlan_offload_what,
3303 (void *)&cmd_vlan_offload_on,
3304 (void *)&cmd_vlan_offload_portid,
3309 /* *** VLAN TPID SET ON A PORT *** */
3310 struct cmd_vlan_tpid_result {
3311 cmdline_fixed_string_t vlan;
3312 cmdline_fixed_string_t set;
3313 cmdline_fixed_string_t vlan_type;
3314 cmdline_fixed_string_t what;
3320 cmd_vlan_tpid_parsed(void *parsed_result,
3321 __attribute__((unused)) struct cmdline *cl,
3322 __attribute__((unused)) void *data)
3324 struct cmd_vlan_tpid_result *res = parsed_result;
3325 enum rte_vlan_type vlan_type;
3327 if (!strcmp(res->vlan_type, "inner"))
3328 vlan_type = ETH_VLAN_TYPE_INNER;
3329 else if (!strcmp(res->vlan_type, "outer"))
3330 vlan_type = ETH_VLAN_TYPE_OUTER;
3332 printf("Unknown vlan type\n");
3335 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3338 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3339 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3341 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3342 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3344 cmdline_parse_token_string_t cmd_vlan_type =
3345 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3346 vlan_type, "inner#outer");
3347 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3348 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3350 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3351 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3353 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3354 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3357 cmdline_parse_inst_t cmd_vlan_tpid = {
3358 .f = cmd_vlan_tpid_parsed,
3360 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3361 "Set the VLAN Ether type",
3363 (void *)&cmd_vlan_tpid_vlan,
3364 (void *)&cmd_vlan_tpid_set,
3365 (void *)&cmd_vlan_type,
3366 (void *)&cmd_vlan_tpid_what,
3367 (void *)&cmd_vlan_tpid_tpid,
3368 (void *)&cmd_vlan_tpid_portid,
3373 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3374 struct cmd_rx_vlan_filter_result {
3375 cmdline_fixed_string_t rx_vlan;
3376 cmdline_fixed_string_t what;
3382 cmd_rx_vlan_filter_parsed(void *parsed_result,
3383 __attribute__((unused)) struct cmdline *cl,
3384 __attribute__((unused)) void *data)
3386 struct cmd_rx_vlan_filter_result *res = parsed_result;
3388 if (!strcmp(res->what, "add"))
3389 rx_vft_set(res->port_id, res->vlan_id, 1);
3391 rx_vft_set(res->port_id, res->vlan_id, 0);
3394 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3395 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3396 rx_vlan, "rx_vlan");
3397 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3398 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3400 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3401 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3403 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3404 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3407 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3408 .f = cmd_rx_vlan_filter_parsed,
3410 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3411 "Add/Remove a VLAN identifier to/from the set of VLAN "
3412 "identifiers filtered by a port",
3414 (void *)&cmd_rx_vlan_filter_rx_vlan,
3415 (void *)&cmd_rx_vlan_filter_what,
3416 (void *)&cmd_rx_vlan_filter_vlanid,
3417 (void *)&cmd_rx_vlan_filter_portid,
3422 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3423 struct cmd_tx_vlan_set_result {
3424 cmdline_fixed_string_t tx_vlan;
3425 cmdline_fixed_string_t set;
3431 cmd_tx_vlan_set_parsed(void *parsed_result,
3432 __attribute__((unused)) struct cmdline *cl,
3433 __attribute__((unused)) void *data)
3435 struct cmd_tx_vlan_set_result *res = parsed_result;
3437 tx_vlan_set(res->port_id, res->vlan_id);
3440 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3441 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3442 tx_vlan, "tx_vlan");
3443 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3444 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3446 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3447 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3449 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3450 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3453 cmdline_parse_inst_t cmd_tx_vlan_set = {
3454 .f = cmd_tx_vlan_set_parsed,
3456 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3457 "Enable hardware insertion of a single VLAN header "
3458 "with a given TAG Identifier in packets sent on a port",
3460 (void *)&cmd_tx_vlan_set_tx_vlan,
3461 (void *)&cmd_tx_vlan_set_set,
3462 (void *)&cmd_tx_vlan_set_portid,
3463 (void *)&cmd_tx_vlan_set_vlanid,
3468 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3469 struct cmd_tx_vlan_set_qinq_result {
3470 cmdline_fixed_string_t tx_vlan;
3471 cmdline_fixed_string_t set;
3474 uint16_t vlan_id_outer;
3478 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3479 __attribute__((unused)) struct cmdline *cl,
3480 __attribute__((unused)) void *data)
3482 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3484 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3487 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3488 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3489 tx_vlan, "tx_vlan");
3490 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3491 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3493 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3494 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3496 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3497 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3499 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3500 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3501 vlan_id_outer, UINT16);
3503 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3504 .f = cmd_tx_vlan_set_qinq_parsed,
3506 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3507 "Enable hardware insertion of double VLAN header "
3508 "with given TAG Identifiers in packets sent on a port",
3510 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3511 (void *)&cmd_tx_vlan_set_qinq_set,
3512 (void *)&cmd_tx_vlan_set_qinq_portid,
3513 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3514 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3519 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3520 struct cmd_tx_vlan_set_pvid_result {
3521 cmdline_fixed_string_t tx_vlan;
3522 cmdline_fixed_string_t set;
3523 cmdline_fixed_string_t pvid;
3526 cmdline_fixed_string_t mode;
3530 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3531 __attribute__((unused)) struct cmdline *cl,
3532 __attribute__((unused)) void *data)
3534 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3536 if (strcmp(res->mode, "on") == 0)
3537 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3539 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3542 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3543 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3544 tx_vlan, "tx_vlan");
3545 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3546 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3548 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3549 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3551 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3552 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3554 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3555 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3557 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3558 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3561 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3562 .f = cmd_tx_vlan_set_pvid_parsed,
3564 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3566 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3567 (void *)&cmd_tx_vlan_set_pvid_set,
3568 (void *)&cmd_tx_vlan_set_pvid_pvid,
3569 (void *)&cmd_tx_vlan_set_pvid_port_id,
3570 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3571 (void *)&cmd_tx_vlan_set_pvid_mode,
3576 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3577 struct cmd_tx_vlan_reset_result {
3578 cmdline_fixed_string_t tx_vlan;
3579 cmdline_fixed_string_t reset;
3584 cmd_tx_vlan_reset_parsed(void *parsed_result,
3585 __attribute__((unused)) struct cmdline *cl,
3586 __attribute__((unused)) void *data)
3588 struct cmd_tx_vlan_reset_result *res = parsed_result;
3590 tx_vlan_reset(res->port_id);
3593 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3595 tx_vlan, "tx_vlan");
3596 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3597 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3599 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3600 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3603 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3604 .f = cmd_tx_vlan_reset_parsed,
3606 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3607 "VLAN header in packets sent on a port",
3609 (void *)&cmd_tx_vlan_reset_tx_vlan,
3610 (void *)&cmd_tx_vlan_reset_reset,
3611 (void *)&cmd_tx_vlan_reset_portid,
3617 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3618 struct cmd_csum_result {
3619 cmdline_fixed_string_t csum;
3620 cmdline_fixed_string_t mode;
3621 cmdline_fixed_string_t proto;
3622 cmdline_fixed_string_t hwsw;
3627 csum_show(int port_id)
3629 struct rte_eth_dev_info dev_info;
3632 ol_flags = ports[port_id].tx_ol_flags;
3633 printf("Parse tunnel is %s\n",
3634 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3635 printf("IP checksum offload is %s\n",
3636 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3637 printf("UDP checksum offload is %s\n",
3638 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3639 printf("TCP checksum offload is %s\n",
3640 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3641 printf("SCTP checksum offload is %s\n",
3642 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3643 printf("Outer-Ip checksum offload is %s\n",
3644 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3646 /* display warnings if configuration is not supported by the NIC */
3647 rte_eth_dev_info_get(port_id, &dev_info);
3648 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3650 printf("Warning: hardware IP checksum enabled but not "
3651 "supported by port %d\n", port_id);
3653 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3654 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3655 printf("Warning: hardware UDP checksum enabled but not "
3656 "supported by port %d\n", port_id);
3658 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3660 printf("Warning: hardware TCP checksum enabled but not "
3661 "supported by port %d\n", port_id);
3663 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3664 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3665 printf("Warning: hardware SCTP checksum enabled but not "
3666 "supported by port %d\n", port_id);
3668 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3669 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3670 printf("Warning: hardware outer IP checksum enabled but not "
3671 "supported by port %d\n", port_id);
3676 cmd_csum_parsed(void *parsed_result,
3677 __attribute__((unused)) struct cmdline *cl,
3678 __attribute__((unused)) void *data)
3680 struct cmd_csum_result *res = parsed_result;
3684 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3685 printf("invalid port %d\n", res->port_id);
3689 if (!strcmp(res->mode, "set")) {
3691 if (!strcmp(res->hwsw, "hw"))
3694 if (!strcmp(res->proto, "ip")) {
3695 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3696 } else if (!strcmp(res->proto, "udp")) {
3697 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3698 } else if (!strcmp(res->proto, "tcp")) {
3699 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3700 } else if (!strcmp(res->proto, "sctp")) {
3701 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3702 } else if (!strcmp(res->proto, "outer-ip")) {
3703 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3707 ports[res->port_id].tx_ol_flags |= mask;
3709 ports[res->port_id].tx_ol_flags &= (~mask);
3711 csum_show(res->port_id);
3714 cmdline_parse_token_string_t cmd_csum_csum =
3715 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3717 cmdline_parse_token_string_t cmd_csum_mode =
3718 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3720 cmdline_parse_token_string_t cmd_csum_proto =
3721 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3722 proto, "ip#tcp#udp#sctp#outer-ip");
3723 cmdline_parse_token_string_t cmd_csum_hwsw =
3724 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3726 cmdline_parse_token_num_t cmd_csum_portid =
3727 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3730 cmdline_parse_inst_t cmd_csum_set = {
3731 .f = cmd_csum_parsed,
3733 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3734 "Enable/Disable hardware calculation of L3/L4 checksum when "
3735 "using csum forward engine",
3737 (void *)&cmd_csum_csum,
3738 (void *)&cmd_csum_mode,
3739 (void *)&cmd_csum_proto,
3740 (void *)&cmd_csum_hwsw,
3741 (void *)&cmd_csum_portid,
3746 cmdline_parse_token_string_t cmd_csum_mode_show =
3747 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3750 cmdline_parse_inst_t cmd_csum_show = {
3751 .f = cmd_csum_parsed,
3753 .help_str = "csum show <port_id>: Show checksum offload configuration",
3755 (void *)&cmd_csum_csum,
3756 (void *)&cmd_csum_mode_show,
3757 (void *)&cmd_csum_portid,
3762 /* Enable/disable tunnel parsing */
3763 struct cmd_csum_tunnel_result {
3764 cmdline_fixed_string_t csum;
3765 cmdline_fixed_string_t parse;
3766 cmdline_fixed_string_t onoff;
3771 cmd_csum_tunnel_parsed(void *parsed_result,
3772 __attribute__((unused)) struct cmdline *cl,
3773 __attribute__((unused)) void *data)
3775 struct cmd_csum_tunnel_result *res = parsed_result;
3777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3780 if (!strcmp(res->onoff, "on"))
3781 ports[res->port_id].tx_ol_flags |=
3782 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3784 ports[res->port_id].tx_ol_flags &=
3785 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3787 csum_show(res->port_id);
3790 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3791 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3793 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3794 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3795 parse, "parse_tunnel");
3796 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3797 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3799 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3800 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3803 cmdline_parse_inst_t cmd_csum_tunnel = {
3804 .f = cmd_csum_tunnel_parsed,
3806 .help_str = "csum parse_tunnel on|off <port_id>: "
3807 "Enable/Disable parsing of tunnels for csum engine",
3809 (void *)&cmd_csum_tunnel_csum,
3810 (void *)&cmd_csum_tunnel_parse,
3811 (void *)&cmd_csum_tunnel_onoff,
3812 (void *)&cmd_csum_tunnel_portid,
3817 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3818 struct cmd_tso_set_result {
3819 cmdline_fixed_string_t tso;
3820 cmdline_fixed_string_t mode;
3826 cmd_tso_set_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_tso_set_result *res = parsed_result;
3831 struct rte_eth_dev_info dev_info;
3833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3836 if (!strcmp(res->mode, "set"))
3837 ports[res->port_id].tso_segsz = res->tso_segsz;
3839 if (ports[res->port_id].tso_segsz == 0)
3840 printf("TSO for non-tunneled packets is disabled\n");
3842 printf("TSO segment size for non-tunneled packets is %d\n",
3843 ports[res->port_id].tso_segsz);
3845 /* display warnings if configuration is not supported by the NIC */
3846 rte_eth_dev_info_get(res->port_id, &dev_info);
3847 if ((ports[res->port_id].tso_segsz != 0) &&
3848 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3849 printf("Warning: TSO enabled but not "
3850 "supported by port %d\n", res->port_id);
3854 cmdline_parse_token_string_t cmd_tso_set_tso =
3855 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3857 cmdline_parse_token_string_t cmd_tso_set_mode =
3858 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3860 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3861 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3863 cmdline_parse_token_num_t cmd_tso_set_portid =
3864 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3867 cmdline_parse_inst_t cmd_tso_set = {
3868 .f = cmd_tso_set_parsed,
3870 .help_str = "tso set <tso_segsz> <port_id>: "
3871 "Set TSO segment size of non-tunneled packets for csum engine "
3874 (void *)&cmd_tso_set_tso,
3875 (void *)&cmd_tso_set_mode,
3876 (void *)&cmd_tso_set_tso_segsz,
3877 (void *)&cmd_tso_set_portid,
3882 cmdline_parse_token_string_t cmd_tso_show_mode =
3883 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3887 cmdline_parse_inst_t cmd_tso_show = {
3888 .f = cmd_tso_set_parsed,
3890 .help_str = "tso show <port_id>: "
3891 "Show TSO segment size of non-tunneled packets for csum engine",
3893 (void *)&cmd_tso_set_tso,
3894 (void *)&cmd_tso_show_mode,
3895 (void *)&cmd_tso_set_portid,
3900 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3901 struct cmd_tunnel_tso_set_result {
3902 cmdline_fixed_string_t tso;
3903 cmdline_fixed_string_t mode;
3909 check_tunnel_tso_nic_support(portid_t port_id)
3911 struct rte_eth_dev_info dev_info;
3913 rte_eth_dev_info_get(port_id, &dev_info);
3914 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3915 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3916 "supported by port %d\n", port_id);
3917 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3918 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3919 "supported by port %d\n", port_id);
3920 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3921 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3922 "supported by port %d\n", port_id);
3923 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3924 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3925 "supported by port %d\n", port_id);
3929 cmd_tunnel_tso_set_parsed(void *parsed_result,
3930 __attribute__((unused)) struct cmdline *cl,
3931 __attribute__((unused)) void *data)
3933 struct cmd_tunnel_tso_set_result *res = parsed_result;
3935 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3938 if (!strcmp(res->mode, "set"))
3939 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3941 if (ports[res->port_id].tunnel_tso_segsz == 0)
3942 printf("TSO for tunneled packets is disabled\n");
3944 printf("TSO segment size for tunneled packets is %d\n",
3945 ports[res->port_id].tunnel_tso_segsz);
3947 /* Below conditions are needed to make it work:
3948 * (1) tunnel TSO is supported by the NIC;
3949 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3951 * (3) for tunneled pkts with outer L3 of IPv4,
3952 * "csum set outer-ip" must be set to hw, because after tso,
3953 * total_len of outer IP header is changed, and the checksum
3954 * of outer IP header calculated by sw should be wrong; that
3955 * is not necessary for IPv6 tunneled pkts because there's no
3956 * checksum in IP header anymore.
3958 check_tunnel_tso_nic_support(res->port_id);
3960 if (!(ports[res->port_id].tx_ol_flags &
3961 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3962 printf("Warning: csum parse_tunnel must be set "
3963 "so that tunneled packets are recognized\n");
3964 if (!(ports[res->port_id].tx_ol_flags &
3965 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3966 printf("Warning: csum set outer-ip must be set to hw "
3967 "if outer L3 is IPv4; not necessary for IPv6\n");
3971 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3972 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3974 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3975 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3977 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3978 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3980 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3981 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3984 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3985 .f = cmd_tunnel_tso_set_parsed,
3987 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3988 "Set TSO segment size of tunneled packets for csum engine "
3991 (void *)&cmd_tunnel_tso_set_tso,
3992 (void *)&cmd_tunnel_tso_set_mode,
3993 (void *)&cmd_tunnel_tso_set_tso_segsz,
3994 (void *)&cmd_tunnel_tso_set_portid,
3999 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4000 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4004 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4005 .f = cmd_tunnel_tso_set_parsed,
4007 .help_str = "tunnel_tso show <port_id> "
4008 "Show TSO segment size of tunneled packets for csum engine",
4010 (void *)&cmd_tunnel_tso_set_tso,
4011 (void *)&cmd_tunnel_tso_show_mode,
4012 (void *)&cmd_tunnel_tso_set_portid,
4017 /* *** SET GRO FOR A PORT *** */
4018 struct cmd_gro_enable_result {
4019 cmdline_fixed_string_t cmd_set;
4020 cmdline_fixed_string_t cmd_port;
4021 cmdline_fixed_string_t cmd_keyword;
4022 cmdline_fixed_string_t cmd_onoff;
4027 cmd_gro_enable_parsed(void *parsed_result,
4028 __attribute__((unused)) struct cmdline *cl,
4029 __attribute__((unused)) void *data)
4031 struct cmd_gro_enable_result *res;
4033 res = parsed_result;
4034 if (!strcmp(res->cmd_keyword, "gro"))
4035 setup_gro(res->cmd_onoff, res->cmd_pid);
4038 cmdline_parse_token_string_t cmd_gro_enable_set =
4039 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4041 cmdline_parse_token_string_t cmd_gro_enable_port =
4042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4043 cmd_keyword, "port");
4044 cmdline_parse_token_num_t cmd_gro_enable_pid =
4045 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4047 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4048 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4049 cmd_keyword, "gro");
4050 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4051 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4052 cmd_onoff, "on#off");
4054 cmdline_parse_inst_t cmd_gro_enable = {
4055 .f = cmd_gro_enable_parsed,
4057 .help_str = "set port <port_id> gro on|off",
4059 (void *)&cmd_gro_enable_set,
4060 (void *)&cmd_gro_enable_port,
4061 (void *)&cmd_gro_enable_pid,
4062 (void *)&cmd_gro_enable_keyword,
4063 (void *)&cmd_gro_enable_onoff,
4068 /* *** DISPLAY GRO CONFIGURATION *** */
4069 struct cmd_gro_show_result {
4070 cmdline_fixed_string_t cmd_show;
4071 cmdline_fixed_string_t cmd_port;
4072 cmdline_fixed_string_t cmd_keyword;
4077 cmd_gro_show_parsed(void *parsed_result,
4078 __attribute__((unused)) struct cmdline *cl,
4079 __attribute__((unused)) void *data)
4081 struct cmd_gro_show_result *res;
4083 res = parsed_result;
4084 if (!strcmp(res->cmd_keyword, "gro"))
4085 show_gro(res->cmd_pid);
4088 cmdline_parse_token_string_t cmd_gro_show_show =
4089 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4091 cmdline_parse_token_string_t cmd_gro_show_port =
4092 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4094 cmdline_parse_token_num_t cmd_gro_show_pid =
4095 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4097 cmdline_parse_token_string_t cmd_gro_show_keyword =
4098 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4099 cmd_keyword, "gro");
4101 cmdline_parse_inst_t cmd_gro_show = {
4102 .f = cmd_gro_show_parsed,
4104 .help_str = "show port <port_id> gro",
4106 (void *)&cmd_gro_show_show,
4107 (void *)&cmd_gro_show_port,
4108 (void *)&cmd_gro_show_pid,
4109 (void *)&cmd_gro_show_keyword,
4114 /* *** SET FLUSH CYCLES FOR GRO *** */
4115 struct cmd_gro_flush_result {
4116 cmdline_fixed_string_t cmd_set;
4117 cmdline_fixed_string_t cmd_keyword;
4118 cmdline_fixed_string_t cmd_flush;
4123 cmd_gro_flush_parsed(void *parsed_result,
4124 __attribute__((unused)) struct cmdline *cl,
4125 __attribute__((unused)) void *data)
4127 struct cmd_gro_flush_result *res;
4129 res = parsed_result;
4130 if ((!strcmp(res->cmd_keyword, "gro")) &&
4131 (!strcmp(res->cmd_flush, "flush")))
4132 setup_gro_flush_cycles(res->cmd_cycles);
4135 cmdline_parse_token_string_t cmd_gro_flush_set =
4136 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4138 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4139 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4140 cmd_keyword, "gro");
4141 cmdline_parse_token_string_t cmd_gro_flush_flush =
4142 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4143 cmd_flush, "flush");
4144 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4145 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4148 cmdline_parse_inst_t cmd_gro_flush = {
4149 .f = cmd_gro_flush_parsed,
4151 .help_str = "set gro flush <cycles>",
4153 (void *)&cmd_gro_flush_set,
4154 (void *)&cmd_gro_flush_keyword,
4155 (void *)&cmd_gro_flush_flush,
4156 (void *)&cmd_gro_flush_cycles,
4161 /* *** ENABLE/DISABLE GSO *** */
4162 struct cmd_gso_enable_result {
4163 cmdline_fixed_string_t cmd_set;
4164 cmdline_fixed_string_t cmd_port;
4165 cmdline_fixed_string_t cmd_keyword;
4166 cmdline_fixed_string_t cmd_mode;
4171 cmd_gso_enable_parsed(void *parsed_result,
4172 __attribute__((unused)) struct cmdline *cl,
4173 __attribute__((unused)) void *data)
4175 struct cmd_gso_enable_result *res;
4177 res = parsed_result;
4178 if (!strcmp(res->cmd_keyword, "gso"))
4179 setup_gso(res->cmd_mode, res->cmd_pid);
4182 cmdline_parse_token_string_t cmd_gso_enable_set =
4183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4185 cmdline_parse_token_string_t cmd_gso_enable_port =
4186 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4188 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4189 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4190 cmd_keyword, "gso");
4191 cmdline_parse_token_string_t cmd_gso_enable_mode =
4192 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4193 cmd_mode, "on#off");
4194 cmdline_parse_token_num_t cmd_gso_enable_pid =
4195 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4198 cmdline_parse_inst_t cmd_gso_enable = {
4199 .f = cmd_gso_enable_parsed,
4201 .help_str = "set port <port_id> gso on|off",
4203 (void *)&cmd_gso_enable_set,
4204 (void *)&cmd_gso_enable_port,
4205 (void *)&cmd_gso_enable_pid,
4206 (void *)&cmd_gso_enable_keyword,
4207 (void *)&cmd_gso_enable_mode,
4212 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4213 struct cmd_gso_size_result {
4214 cmdline_fixed_string_t cmd_set;
4215 cmdline_fixed_string_t cmd_keyword;
4216 cmdline_fixed_string_t cmd_segsz;
4221 cmd_gso_size_parsed(void *parsed_result,
4222 __attribute__((unused)) struct cmdline *cl,
4223 __attribute__((unused)) void *data)
4225 struct cmd_gso_size_result *res = parsed_result;
4227 if (test_done == 0) {
4228 printf("Before setting GSO segsz, please first"
4229 " stop fowarding\n");
4233 if (!strcmp(res->cmd_keyword, "gso") &&
4234 !strcmp(res->cmd_segsz, "segsz")) {
4235 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4236 printf("gso_size should be larger than %zu."
4237 " Please input a legal value\n",
4238 RTE_GSO_SEG_SIZE_MIN);
4240 gso_max_segment_size = res->cmd_size;
4244 cmdline_parse_token_string_t cmd_gso_size_set =
4245 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4247 cmdline_parse_token_string_t cmd_gso_size_keyword =
4248 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4249 cmd_keyword, "gso");
4250 cmdline_parse_token_string_t cmd_gso_size_segsz =
4251 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4252 cmd_segsz, "segsz");
4253 cmdline_parse_token_num_t cmd_gso_size_size =
4254 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4257 cmdline_parse_inst_t cmd_gso_size = {
4258 .f = cmd_gso_size_parsed,
4260 .help_str = "set gso segsz <length>",
4262 (void *)&cmd_gso_size_set,
4263 (void *)&cmd_gso_size_keyword,
4264 (void *)&cmd_gso_size_segsz,
4265 (void *)&cmd_gso_size_size,
4270 /* *** SHOW GSO CONFIGURATION *** */
4271 struct cmd_gso_show_result {
4272 cmdline_fixed_string_t cmd_show;
4273 cmdline_fixed_string_t cmd_port;
4274 cmdline_fixed_string_t cmd_keyword;
4279 cmd_gso_show_parsed(void *parsed_result,
4280 __attribute__((unused)) struct cmdline *cl,
4281 __attribute__((unused)) void *data)
4283 struct cmd_gso_show_result *res = parsed_result;
4285 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4286 printf("invalid port id %u\n", res->cmd_pid);
4289 if (!strcmp(res->cmd_keyword, "gso")) {
4290 if (gso_ports[res->cmd_pid].enable) {
4291 printf("Max GSO'd packet size: %uB\n"
4292 "Supported GSO types: TCP/IPv4, "
4293 "VxLAN with inner TCP/IPv4 packet, "
4294 "GRE with inner TCP/IPv4 packet\n",
4295 gso_max_segment_size);
4297 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4301 cmdline_parse_token_string_t cmd_gso_show_show =
4302 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4304 cmdline_parse_token_string_t cmd_gso_show_port =
4305 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4307 cmdline_parse_token_string_t cmd_gso_show_keyword =
4308 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4309 cmd_keyword, "gso");
4310 cmdline_parse_token_num_t cmd_gso_show_pid =
4311 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4314 cmdline_parse_inst_t cmd_gso_show = {
4315 .f = cmd_gso_show_parsed,
4317 .help_str = "show port <port_id> gso",
4319 (void *)&cmd_gso_show_show,
4320 (void *)&cmd_gso_show_port,
4321 (void *)&cmd_gso_show_pid,
4322 (void *)&cmd_gso_show_keyword,
4327 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4328 struct cmd_set_flush_rx {
4329 cmdline_fixed_string_t set;
4330 cmdline_fixed_string_t flush_rx;
4331 cmdline_fixed_string_t mode;
4335 cmd_set_flush_rx_parsed(void *parsed_result,
4336 __attribute__((unused)) struct cmdline *cl,
4337 __attribute__((unused)) void *data)
4339 struct cmd_set_flush_rx *res = parsed_result;
4340 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4343 cmdline_parse_token_string_t cmd_setflushrx_set =
4344 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4346 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4347 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4348 flush_rx, "flush_rx");
4349 cmdline_parse_token_string_t cmd_setflushrx_mode =
4350 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4354 cmdline_parse_inst_t cmd_set_flush_rx = {
4355 .f = cmd_set_flush_rx_parsed,
4356 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4359 (void *)&cmd_setflushrx_set,
4360 (void *)&cmd_setflushrx_flush_rx,
4361 (void *)&cmd_setflushrx_mode,
4366 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4367 struct cmd_set_link_check {
4368 cmdline_fixed_string_t set;
4369 cmdline_fixed_string_t link_check;
4370 cmdline_fixed_string_t mode;
4374 cmd_set_link_check_parsed(void *parsed_result,
4375 __attribute__((unused)) struct cmdline *cl,
4376 __attribute__((unused)) void *data)
4378 struct cmd_set_link_check *res = parsed_result;
4379 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4382 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4383 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4385 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4386 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4387 link_check, "link_check");
4388 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4393 cmdline_parse_inst_t cmd_set_link_check = {
4394 .f = cmd_set_link_check_parsed,
4395 .help_str = "set link_check on|off: Enable/Disable link status check "
4396 "when starting/stopping a port",
4399 (void *)&cmd_setlinkcheck_set,
4400 (void *)&cmd_setlinkcheck_link_check,
4401 (void *)&cmd_setlinkcheck_mode,
4406 /* *** SET NIC BYPASS MODE *** */
4407 struct cmd_set_bypass_mode_result {
4408 cmdline_fixed_string_t set;
4409 cmdline_fixed_string_t bypass;
4410 cmdline_fixed_string_t mode;
4411 cmdline_fixed_string_t value;
4416 cmd_set_bypass_mode_parsed(void *parsed_result,
4417 __attribute__((unused)) struct cmdline *cl,
4418 __attribute__((unused)) void *data)
4420 struct cmd_set_bypass_mode_result *res = parsed_result;
4421 portid_t port_id = res->port_id;
4422 int32_t rc = -EINVAL;
4424 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4425 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4427 if (!strcmp(res->value, "bypass"))
4428 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4429 else if (!strcmp(res->value, "isolate"))
4430 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4432 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4434 /* Set the bypass mode for the relevant port. */
4435 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4438 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4441 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4442 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4444 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4445 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4447 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4448 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4450 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4451 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4452 value, "normal#bypass#isolate");
4453 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4454 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4457 cmdline_parse_inst_t cmd_set_bypass_mode = {
4458 .f = cmd_set_bypass_mode_parsed,
4459 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4460 "Set the NIC bypass mode for port_id",
4463 (void *)&cmd_setbypass_mode_set,
4464 (void *)&cmd_setbypass_mode_bypass,
4465 (void *)&cmd_setbypass_mode_mode,
4466 (void *)&cmd_setbypass_mode_value,
4467 (void *)&cmd_setbypass_mode_port,
4472 /* *** SET NIC BYPASS EVENT *** */
4473 struct cmd_set_bypass_event_result {
4474 cmdline_fixed_string_t set;
4475 cmdline_fixed_string_t bypass;
4476 cmdline_fixed_string_t event;
4477 cmdline_fixed_string_t event_value;
4478 cmdline_fixed_string_t mode;
4479 cmdline_fixed_string_t mode_value;
4484 cmd_set_bypass_event_parsed(void *parsed_result,
4485 __attribute__((unused)) struct cmdline *cl,
4486 __attribute__((unused)) void *data)
4488 int32_t rc = -EINVAL;
4489 struct cmd_set_bypass_event_result *res = parsed_result;
4490 portid_t port_id = res->port_id;
4492 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4493 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4494 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4496 if (!strcmp(res->event_value, "timeout"))
4497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4498 else if (!strcmp(res->event_value, "os_on"))
4499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4500 else if (!strcmp(res->event_value, "os_off"))
4501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4502 else if (!strcmp(res->event_value, "power_on"))
4503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4504 else if (!strcmp(res->event_value, "power_off"))
4505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4509 if (!strcmp(res->mode_value, "bypass"))
4510 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4511 else if (!strcmp(res->mode_value, "isolate"))
4512 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4516 /* Set the watchdog timeout. */
4517 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4520 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4521 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4525 printf("Failed to set timeout value %u "
4526 "for port %d, errto code: %d.\n",
4527 bypass_timeout, port_id, rc);
4531 /* Set the bypass event to transition to bypass mode. */
4532 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4537 printf("\t Failed to set bypass event for port = %d.\n",
4541 cmdline_parse_token_string_t cmd_setbypass_event_set =
4542 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4544 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4545 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4547 cmdline_parse_token_string_t cmd_setbypass_event_event =
4548 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4550 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4551 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4552 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4553 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4554 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4556 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4557 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4558 mode_value, "normal#bypass#isolate");
4559 cmdline_parse_token_num_t cmd_setbypass_event_port =
4560 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4563 cmdline_parse_inst_t cmd_set_bypass_event = {
4564 .f = cmd_set_bypass_event_parsed,
4565 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4566 "power_off mode normal|bypass|isolate <port_id>: "
4567 "Set the NIC bypass event mode for port_id",
4570 (void *)&cmd_setbypass_event_set,
4571 (void *)&cmd_setbypass_event_bypass,
4572 (void *)&cmd_setbypass_event_event,
4573 (void *)&cmd_setbypass_event_event_value,
4574 (void *)&cmd_setbypass_event_mode,
4575 (void *)&cmd_setbypass_event_mode_value,
4576 (void *)&cmd_setbypass_event_port,
4582 /* *** SET NIC BYPASS TIMEOUT *** */
4583 struct cmd_set_bypass_timeout_result {
4584 cmdline_fixed_string_t set;
4585 cmdline_fixed_string_t bypass;
4586 cmdline_fixed_string_t timeout;
4587 cmdline_fixed_string_t value;
4591 cmd_set_bypass_timeout_parsed(void *parsed_result,
4592 __attribute__((unused)) struct cmdline *cl,
4593 __attribute__((unused)) void *data)
4595 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4597 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4598 if (!strcmp(res->value, "1.5"))
4599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4600 else if (!strcmp(res->value, "2"))
4601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4602 else if (!strcmp(res->value, "3"))
4603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4604 else if (!strcmp(res->value, "4"))
4605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4606 else if (!strcmp(res->value, "8"))
4607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4608 else if (!strcmp(res->value, "16"))
4609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4610 else if (!strcmp(res->value, "32"))
4611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4617 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4618 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4620 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4623 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4625 timeout, "timeout");
4626 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4628 value, "0#1.5#2#3#4#8#16#32");
4630 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4631 .f = cmd_set_bypass_timeout_parsed,
4632 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4633 "Set the NIC bypass watchdog timeout in seconds",
4636 (void *)&cmd_setbypass_timeout_set,
4637 (void *)&cmd_setbypass_timeout_bypass,
4638 (void *)&cmd_setbypass_timeout_timeout,
4639 (void *)&cmd_setbypass_timeout_value,
4644 /* *** SHOW NIC BYPASS MODE *** */
4645 struct cmd_show_bypass_config_result {
4646 cmdline_fixed_string_t show;
4647 cmdline_fixed_string_t bypass;
4648 cmdline_fixed_string_t config;
4653 cmd_show_bypass_config_parsed(void *parsed_result,
4654 __attribute__((unused)) struct cmdline *cl,
4655 __attribute__((unused)) void *data)
4657 struct cmd_show_bypass_config_result *res = parsed_result;
4658 portid_t port_id = res->port_id;
4660 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4661 uint32_t event_mode;
4662 uint32_t bypass_mode;
4663 uint32_t timeout = bypass_timeout;
4666 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4667 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4668 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4669 {"UNKNOWN", "normal", "bypass", "isolate"};
4670 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4677 int num_events = (sizeof events) / (sizeof events[0]);
4679 /* Display the bypass mode.*/
4680 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4681 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4685 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4686 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4688 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4691 /* Display the bypass timeout.*/
4692 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4693 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4695 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4697 /* Display the bypass events and associated modes. */
4698 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4700 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4701 printf("\tFailed to get bypass mode for event = %s\n",
4704 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4705 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4707 printf("\tbypass event: %-16s = %s\n", events[i],
4713 printf("\tFailed to get bypass configuration for port = %d\n",
4717 cmdline_parse_token_string_t cmd_showbypass_config_show =
4718 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4720 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4721 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4723 cmdline_parse_token_string_t cmd_showbypass_config_config =
4724 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4726 cmdline_parse_token_num_t cmd_showbypass_config_port =
4727 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4730 cmdline_parse_inst_t cmd_show_bypass_config = {
4731 .f = cmd_show_bypass_config_parsed,
4732 .help_str = "show bypass config <port_id>: "
4733 "Show the NIC bypass config for port_id",
4736 (void *)&cmd_showbypass_config_show,
4737 (void *)&cmd_showbypass_config_bypass,
4738 (void *)&cmd_showbypass_config_config,
4739 (void *)&cmd_showbypass_config_port,
4744 #ifdef RTE_LIBRTE_PMD_BOND
4745 /* *** SET BONDING MODE *** */
4746 struct cmd_set_bonding_mode_result {
4747 cmdline_fixed_string_t set;
4748 cmdline_fixed_string_t bonding;
4749 cmdline_fixed_string_t mode;
4754 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 struct cmd_set_bonding_mode_result *res = parsed_result;
4759 portid_t port_id = res->port_id;
4761 /* Set the bonding mode for the relevant port. */
4762 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4763 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4766 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4769 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4770 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4771 bonding, "bonding");
4772 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4773 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4775 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4776 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4778 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4779 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4782 cmdline_parse_inst_t cmd_set_bonding_mode = {
4783 .f = cmd_set_bonding_mode_parsed,
4784 .help_str = "set bonding mode <mode_value> <port_id>: "
4785 "Set the bonding mode for port_id",
4788 (void *) &cmd_setbonding_mode_set,
4789 (void *) &cmd_setbonding_mode_bonding,
4790 (void *) &cmd_setbonding_mode_mode,
4791 (void *) &cmd_setbonding_mode_value,
4792 (void *) &cmd_setbonding_mode_port,
4797 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4798 struct cmd_set_bonding_lacp_dedicated_queues_result {
4799 cmdline_fixed_string_t set;
4800 cmdline_fixed_string_t bonding;
4801 cmdline_fixed_string_t lacp;
4802 cmdline_fixed_string_t dedicated_queues;
4804 cmdline_fixed_string_t mode;
4807 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4808 __attribute__((unused)) struct cmdline *cl,
4809 __attribute__((unused)) void *data)
4811 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4812 portid_t port_id = res->port_id;
4813 struct rte_port *port;
4815 port = &ports[port_id];
4817 /** Check if the port is not started **/
4818 if (port->port_status != RTE_PORT_STOPPED) {
4819 printf("Please stop port %d first\n", port_id);
4823 if (!strcmp(res->mode, "enable")) {
4824 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4825 printf("Dedicate queues for LACP control packets"
4828 printf("Enabling dedicate queues for LACP control "
4829 "packets on port %d failed\n", port_id);
4830 } else if (!strcmp(res->mode, "disable")) {
4831 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4832 printf("Dedicated queues for LACP control packets "
4835 printf("Disabling dedicated queues for LACP control "
4836 "traffic on port %d failed\n", port_id);
4840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4845 bonding, "bonding");
4846 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4851 dedicated_queues, "dedicated_queues");
4852 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4853 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4855 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4857 mode, "enable#disable");
4859 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4860 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4861 .help_str = "set bonding lacp dedicated_queues <port_id> "
4863 "Enable/disable dedicated queues for LACP control traffic for port_id",
4866 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4867 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4868 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4869 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4870 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4871 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4876 /* *** SET BALANCE XMIT POLICY *** */
4877 struct cmd_set_bonding_balance_xmit_policy_result {
4878 cmdline_fixed_string_t set;
4879 cmdline_fixed_string_t bonding;
4880 cmdline_fixed_string_t balance_xmit_policy;
4882 cmdline_fixed_string_t policy;
4885 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4886 __attribute__((unused)) struct cmdline *cl,
4887 __attribute__((unused)) void *data)
4889 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4890 portid_t port_id = res->port_id;
4893 if (!strcmp(res->policy, "l2")) {
4894 policy = BALANCE_XMIT_POLICY_LAYER2;
4895 } else if (!strcmp(res->policy, "l23")) {
4896 policy = BALANCE_XMIT_POLICY_LAYER23;
4897 } else if (!strcmp(res->policy, "l34")) {
4898 policy = BALANCE_XMIT_POLICY_LAYER34;
4900 printf("\t Invalid xmit policy selection");
4904 /* Set the bonding mode for the relevant port. */
4905 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4906 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4916 bonding, "bonding");
4917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4919 balance_xmit_policy, "balance_xmit_policy");
4920 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4921 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4923 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4925 policy, "l2#l23#l34");
4927 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4928 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4929 .help_str = "set bonding balance_xmit_policy <port_id> "
4931 "Set the bonding balance_xmit_policy for port_id",
4934 (void *)&cmd_setbonding_balance_xmit_policy_set,
4935 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4936 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4937 (void *)&cmd_setbonding_balance_xmit_policy_port,
4938 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4943 /* *** SHOW NIC BONDING CONFIGURATION *** */
4944 struct cmd_show_bonding_config_result {
4945 cmdline_fixed_string_t show;
4946 cmdline_fixed_string_t bonding;
4947 cmdline_fixed_string_t config;
4951 static void cmd_show_bonding_config_parsed(void *parsed_result,
4952 __attribute__((unused)) struct cmdline *cl,
4953 __attribute__((unused)) void *data)
4955 struct cmd_show_bonding_config_result *res = parsed_result;
4956 int bonding_mode, agg_mode;
4957 portid_t slaves[RTE_MAX_ETHPORTS];
4958 int num_slaves, num_active_slaves;
4961 portid_t port_id = res->port_id;
4963 /* Display the bonding mode.*/
4964 bonding_mode = rte_eth_bond_mode_get(port_id);
4965 if (bonding_mode < 0) {
4966 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4969 printf("\tBonding mode: %d\n", bonding_mode);
4971 if (bonding_mode == BONDING_MODE_BALANCE) {
4972 int balance_xmit_policy;
4974 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4975 if (balance_xmit_policy < 0) {
4976 printf("\tFailed to get balance xmit policy for port = %d\n",
4980 printf("\tBalance Xmit Policy: ");
4982 switch (balance_xmit_policy) {
4983 case BALANCE_XMIT_POLICY_LAYER2:
4984 printf("BALANCE_XMIT_POLICY_LAYER2");
4986 case BALANCE_XMIT_POLICY_LAYER23:
4987 printf("BALANCE_XMIT_POLICY_LAYER23");
4989 case BALANCE_XMIT_POLICY_LAYER34:
4990 printf("BALANCE_XMIT_POLICY_LAYER34");
4997 if (bonding_mode == BONDING_MODE_8023AD) {
4998 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4999 printf("\tIEEE802.3AD Aggregator Mode: ");
5002 printf("bandwidth");
5014 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5016 if (num_slaves < 0) {
5017 printf("\tFailed to get slave list for port = %d\n", port_id);
5020 if (num_slaves > 0) {
5021 printf("\tSlaves (%d): [", num_slaves);
5022 for (i = 0; i < num_slaves - 1; i++)
5023 printf("%d ", slaves[i]);
5025 printf("%d]\n", slaves[num_slaves - 1]);
5027 printf("\tSlaves: []\n");
5031 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5034 if (num_active_slaves < 0) {
5035 printf("\tFailed to get active slave list for port = %d\n", port_id);
5038 if (num_active_slaves > 0) {
5039 printf("\tActive Slaves (%d): [", num_active_slaves);
5040 for (i = 0; i < num_active_slaves - 1; i++)
5041 printf("%d ", slaves[i]);
5043 printf("%d]\n", slaves[num_active_slaves - 1]);
5046 printf("\tActive Slaves: []\n");
5050 primary_id = rte_eth_bond_primary_get(port_id);
5051 if (primary_id < 0) {
5052 printf("\tFailed to get primary slave for port = %d\n", port_id);
5055 printf("\tPrimary: [%d]\n", primary_id);
5059 cmdline_parse_token_string_t cmd_showbonding_config_show =
5060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5062 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5063 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5064 bonding, "bonding");
5065 cmdline_parse_token_string_t cmd_showbonding_config_config =
5066 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5068 cmdline_parse_token_num_t cmd_showbonding_config_port =
5069 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5072 cmdline_parse_inst_t cmd_show_bonding_config = {
5073 .f = cmd_show_bonding_config_parsed,
5074 .help_str = "show bonding config <port_id>: "
5075 "Show the bonding config for port_id",
5078 (void *)&cmd_showbonding_config_show,
5079 (void *)&cmd_showbonding_config_bonding,
5080 (void *)&cmd_showbonding_config_config,
5081 (void *)&cmd_showbonding_config_port,
5086 /* *** SET BONDING PRIMARY *** */
5087 struct cmd_set_bonding_primary_result {
5088 cmdline_fixed_string_t set;
5089 cmdline_fixed_string_t bonding;
5090 cmdline_fixed_string_t primary;
5095 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5096 __attribute__((unused)) struct cmdline *cl,
5097 __attribute__((unused)) void *data)
5099 struct cmd_set_bonding_primary_result *res = parsed_result;
5100 portid_t master_port_id = res->port_id;
5101 portid_t slave_port_id = res->slave_id;
5103 /* Set the primary slave for a bonded device. */
5104 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5105 printf("\t Failed to set primary slave for port = %d.\n",
5112 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5115 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5117 bonding, "bonding");
5118 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5120 primary, "primary");
5121 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5122 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5124 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5125 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5128 cmdline_parse_inst_t cmd_set_bonding_primary = {
5129 .f = cmd_set_bonding_primary_parsed,
5130 .help_str = "set bonding primary <slave_id> <port_id>: "
5131 "Set the primary slave for port_id",
5134 (void *)&cmd_setbonding_primary_set,
5135 (void *)&cmd_setbonding_primary_bonding,
5136 (void *)&cmd_setbonding_primary_primary,
5137 (void *)&cmd_setbonding_primary_slave,
5138 (void *)&cmd_setbonding_primary_port,
5143 /* *** ADD SLAVE *** */
5144 struct cmd_add_bonding_slave_result {
5145 cmdline_fixed_string_t add;
5146 cmdline_fixed_string_t bonding;
5147 cmdline_fixed_string_t slave;
5152 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5153 __attribute__((unused)) struct cmdline *cl,
5154 __attribute__((unused)) void *data)
5156 struct cmd_add_bonding_slave_result *res = parsed_result;
5157 portid_t master_port_id = res->port_id;
5158 portid_t slave_port_id = res->slave_id;
5160 /* add the slave for a bonded device. */
5161 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5162 printf("\t Failed to add slave %d to master port = %d.\n",
5163 slave_port_id, master_port_id);
5167 set_port_slave_flag(slave_port_id);
5170 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5173 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5174 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5175 bonding, "bonding");
5176 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5177 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5179 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5180 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5182 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5183 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5186 cmdline_parse_inst_t cmd_add_bonding_slave = {
5187 .f = cmd_add_bonding_slave_parsed,
5188 .help_str = "add bonding slave <slave_id> <port_id>: "
5189 "Add a slave device to a bonded device",
5192 (void *)&cmd_addbonding_slave_add,
5193 (void *)&cmd_addbonding_slave_bonding,
5194 (void *)&cmd_addbonding_slave_slave,
5195 (void *)&cmd_addbonding_slave_slaveid,
5196 (void *)&cmd_addbonding_slave_port,
5201 /* *** REMOVE SLAVE *** */
5202 struct cmd_remove_bonding_slave_result {
5203 cmdline_fixed_string_t remove;
5204 cmdline_fixed_string_t bonding;
5205 cmdline_fixed_string_t slave;
5210 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5211 __attribute__((unused)) struct cmdline *cl,
5212 __attribute__((unused)) void *data)
5214 struct cmd_remove_bonding_slave_result *res = parsed_result;
5215 portid_t master_port_id = res->port_id;
5216 portid_t slave_port_id = res->slave_id;
5218 /* remove the slave from a bonded device. */
5219 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5220 printf("\t Failed to remove slave %d from master port = %d.\n",
5221 slave_port_id, master_port_id);
5225 clear_port_slave_flag(slave_port_id);
5228 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5229 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5231 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5232 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5233 bonding, "bonding");
5234 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5235 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5237 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5238 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5240 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5241 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5244 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5245 .f = cmd_remove_bonding_slave_parsed,
5246 .help_str = "remove bonding slave <slave_id> <port_id>: "
5247 "Remove a slave device from a bonded device",
5250 (void *)&cmd_removebonding_slave_remove,
5251 (void *)&cmd_removebonding_slave_bonding,
5252 (void *)&cmd_removebonding_slave_slave,
5253 (void *)&cmd_removebonding_slave_slaveid,
5254 (void *)&cmd_removebonding_slave_port,
5259 /* *** CREATE BONDED DEVICE *** */
5260 struct cmd_create_bonded_device_result {
5261 cmdline_fixed_string_t create;
5262 cmdline_fixed_string_t bonded;
5263 cmdline_fixed_string_t device;
5268 static int bond_dev_num = 0;
5270 static void cmd_create_bonded_device_parsed(void *parsed_result,
5271 __attribute__((unused)) struct cmdline *cl,
5272 __attribute__((unused)) void *data)
5274 struct cmd_create_bonded_device_result *res = parsed_result;
5275 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5278 if (test_done == 0) {
5279 printf("Please stop forwarding first\n");
5283 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5286 /* Create a new bonded device. */
5287 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5289 printf("\t Failed to create bonded device.\n");
5292 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5295 /* Update number of ports */
5296 nb_ports = rte_eth_dev_count();
5297 reconfig(port_id, res->socket);
5298 rte_eth_promiscuous_enable(port_id);
5303 cmdline_parse_token_string_t cmd_createbonded_device_create =
5304 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5306 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5307 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5309 cmdline_parse_token_string_t cmd_createbonded_device_device =
5310 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5312 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5313 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5315 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5316 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5319 cmdline_parse_inst_t cmd_create_bonded_device = {
5320 .f = cmd_create_bonded_device_parsed,
5321 .help_str = "create bonded device <mode> <socket>: "
5322 "Create a new bonded device with specific bonding mode and socket",
5325 (void *)&cmd_createbonded_device_create,
5326 (void *)&cmd_createbonded_device_bonded,
5327 (void *)&cmd_createbonded_device_device,
5328 (void *)&cmd_createbonded_device_mode,
5329 (void *)&cmd_createbonded_device_socket,
5334 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5335 struct cmd_set_bond_mac_addr_result {
5336 cmdline_fixed_string_t set;
5337 cmdline_fixed_string_t bonding;
5338 cmdline_fixed_string_t mac_addr;
5340 struct ether_addr address;
5343 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5347 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5350 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5353 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5355 /* check the return value and print it if is < 0 */
5357 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5360 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5362 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5363 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5365 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5366 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5368 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5369 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5371 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5372 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5374 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5375 .f = cmd_set_bond_mac_addr_parsed,
5377 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5379 (void *)&cmd_set_bond_mac_addr_set,
5380 (void *)&cmd_set_bond_mac_addr_bonding,
5381 (void *)&cmd_set_bond_mac_addr_mac,
5382 (void *)&cmd_set_bond_mac_addr_portnum,
5383 (void *)&cmd_set_bond_mac_addr_addr,
5389 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5390 struct cmd_set_bond_mon_period_result {
5391 cmdline_fixed_string_t set;
5392 cmdline_fixed_string_t bonding;
5393 cmdline_fixed_string_t mon_period;
5398 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5399 __attribute__((unused)) struct cmdline *cl,
5400 __attribute__((unused)) void *data)
5402 struct cmd_set_bond_mon_period_result *res = parsed_result;
5405 if (res->port_num >= nb_ports) {
5406 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5410 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5412 /* check the return value and print it if is < 0 */
5414 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5417 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5418 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5420 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5421 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5422 bonding, "bonding");
5423 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5425 mon_period, "mon_period");
5426 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5427 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5429 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5430 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5433 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5434 .f = cmd_set_bond_mon_period_parsed,
5436 .help_str = "set bonding mon_period <port_id> <period_ms>",
5438 (void *)&cmd_set_bond_mon_period_set,
5439 (void *)&cmd_set_bond_mon_period_bonding,
5440 (void *)&cmd_set_bond_mon_period_mon_period,
5441 (void *)&cmd_set_bond_mon_period_portnum,
5442 (void *)&cmd_set_bond_mon_period_period_ms,
5449 struct cmd_set_bonding_agg_mode_policy_result {
5450 cmdline_fixed_string_t set;
5451 cmdline_fixed_string_t bonding;
5452 cmdline_fixed_string_t agg_mode;
5454 cmdline_fixed_string_t policy;
5459 cmd_set_bonding_agg_mode(void *parsed_result,
5460 __attribute__((unused)) struct cmdline *cl,
5461 __attribute__((unused)) void *data)
5463 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5464 uint8_t policy = AGG_BANDWIDTH;
5466 if (res->port_num >= nb_ports) {
5467 printf("Port id %d must be less than %d\n",
5468 res->port_num, nb_ports);
5472 if (!strcmp(res->policy, "bandwidth"))
5473 policy = AGG_BANDWIDTH;
5474 else if (!strcmp(res->policy, "stable"))
5475 policy = AGG_STABLE;
5476 else if (!strcmp(res->policy, "count"))
5479 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5483 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5486 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5488 bonding, "bonding");
5490 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5492 agg_mode, "agg_mode");
5494 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5495 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5498 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5499 TOKEN_STRING_INITIALIZER(
5500 struct cmd_set_bonding_balance_xmit_policy_result,
5501 policy, "stable#bandwidth#count");
5503 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5504 .f = cmd_set_bonding_agg_mode,
5506 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5508 (void *)&cmd_set_bonding_agg_mode_set,
5509 (void *)&cmd_set_bonding_agg_mode_bonding,
5510 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5511 (void *)&cmd_set_bonding_agg_mode_portnum,
5512 (void *)&cmd_set_bonding_agg_mode_policy_string,
5518 #endif /* RTE_LIBRTE_PMD_BOND */
5520 /* *** SET FORWARDING MODE *** */
5521 struct cmd_set_fwd_mode_result {
5522 cmdline_fixed_string_t set;
5523 cmdline_fixed_string_t fwd;
5524 cmdline_fixed_string_t mode;
5527 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5528 __attribute__((unused)) struct cmdline *cl,
5529 __attribute__((unused)) void *data)
5531 struct cmd_set_fwd_mode_result *res = parsed_result;
5534 set_pkt_forwarding_mode(res->mode);
5537 cmdline_parse_token_string_t cmd_setfwd_set =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5539 cmdline_parse_token_string_t cmd_setfwd_fwd =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5541 cmdline_parse_token_string_t cmd_setfwd_mode =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5543 "" /* defined at init */);
5545 cmdline_parse_inst_t cmd_set_fwd_mode = {
5546 .f = cmd_set_fwd_mode_parsed,
5548 .help_str = NULL, /* defined at init */
5550 (void *)&cmd_setfwd_set,
5551 (void *)&cmd_setfwd_fwd,
5552 (void *)&cmd_setfwd_mode,
5557 static void cmd_set_fwd_mode_init(void)
5560 static char token[128];
5561 static char help[256];
5562 cmdline_parse_token_string_t *token_struct;
5564 modes = list_pkt_forwarding_modes();
5565 snprintf(help, sizeof(help), "set fwd %s: "
5566 "Set packet forwarding mode", modes);
5567 cmd_set_fwd_mode.help_str = help;
5569 /* string token separator is # */
5570 for (c = token; *modes != '\0'; modes++)
5575 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5576 token_struct->string_data.str = token;
5579 /* *** SET RETRY FORWARDING MODE *** */
5580 struct cmd_set_fwd_retry_mode_result {
5581 cmdline_fixed_string_t set;
5582 cmdline_fixed_string_t fwd;
5583 cmdline_fixed_string_t mode;
5584 cmdline_fixed_string_t retry;
5587 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5588 __attribute__((unused)) struct cmdline *cl,
5589 __attribute__((unused)) void *data)
5591 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5594 set_pkt_forwarding_mode(res->mode);
5597 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5600 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5603 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5606 "" /* defined at init */);
5607 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5611 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5612 .f = cmd_set_fwd_retry_mode_parsed,
5614 .help_str = NULL, /* defined at init */
5616 (void *)&cmd_setfwd_retry_set,
5617 (void *)&cmd_setfwd_retry_fwd,
5618 (void *)&cmd_setfwd_retry_mode,
5619 (void *)&cmd_setfwd_retry_retry,
5624 static void cmd_set_fwd_retry_mode_init(void)
5627 static char token[128];
5628 static char help[256];
5629 cmdline_parse_token_string_t *token_struct;
5631 modes = list_pkt_forwarding_retry_modes();
5632 snprintf(help, sizeof(help), "set fwd %s retry: "
5633 "Set packet forwarding mode with retry", modes);
5634 cmd_set_fwd_retry_mode.help_str = help;
5636 /* string token separator is # */
5637 for (c = token; *modes != '\0'; modes++)
5642 token_struct = (cmdline_parse_token_string_t *)
5643 cmd_set_fwd_retry_mode.tokens[2];
5644 token_struct->string_data.str = token;
5647 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5648 struct cmd_set_burst_tx_retry_result {
5649 cmdline_fixed_string_t set;
5650 cmdline_fixed_string_t burst;
5651 cmdline_fixed_string_t tx;
5652 cmdline_fixed_string_t delay;
5654 cmdline_fixed_string_t retry;
5658 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5659 __attribute__((unused)) struct cmdline *cl,
5660 __attribute__((unused)) void *data)
5662 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5664 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5665 && !strcmp(res->tx, "tx")) {
5666 if (!strcmp(res->delay, "delay"))
5667 burst_tx_delay_time = res->time;
5668 if (!strcmp(res->retry, "retry"))
5669 burst_tx_retry_num = res->retry_num;
5674 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5676 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5679 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5681 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5683 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5684 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5685 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5687 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5688 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5690 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5691 .f = cmd_set_burst_tx_retry_parsed,
5692 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5694 (void *)&cmd_set_burst_tx_retry_set,
5695 (void *)&cmd_set_burst_tx_retry_burst,
5696 (void *)&cmd_set_burst_tx_retry_tx,
5697 (void *)&cmd_set_burst_tx_retry_delay,
5698 (void *)&cmd_set_burst_tx_retry_time,
5699 (void *)&cmd_set_burst_tx_retry_retry,
5700 (void *)&cmd_set_burst_tx_retry_retry_num,
5705 /* *** SET PROMISC MODE *** */
5706 struct cmd_set_promisc_mode_result {
5707 cmdline_fixed_string_t set;
5708 cmdline_fixed_string_t promisc;
5709 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5710 uint16_t port_num; /* valid if "allports" argument == 0 */
5711 cmdline_fixed_string_t mode;
5714 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5715 __attribute__((unused)) struct cmdline *cl,
5718 struct cmd_set_promisc_mode_result *res = parsed_result;
5722 if (!strcmp(res->mode, "on"))
5729 RTE_ETH_FOREACH_DEV(i) {
5731 rte_eth_promiscuous_enable(i);
5733 rte_eth_promiscuous_disable(i);
5738 rte_eth_promiscuous_enable(res->port_num);
5740 rte_eth_promiscuous_disable(res->port_num);
5744 cmdline_parse_token_string_t cmd_setpromisc_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5746 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5749 cmdline_parse_token_string_t cmd_setpromisc_portall =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5752 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5753 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5755 cmdline_parse_token_string_t cmd_setpromisc_mode =
5756 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5759 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5760 .f = cmd_set_promisc_mode_parsed,
5762 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5764 (void *)&cmd_setpromisc_set,
5765 (void *)&cmd_setpromisc_promisc,
5766 (void *)&cmd_setpromisc_portall,
5767 (void *)&cmd_setpromisc_mode,
5772 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5773 .f = cmd_set_promisc_mode_parsed,
5775 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5777 (void *)&cmd_setpromisc_set,
5778 (void *)&cmd_setpromisc_promisc,
5779 (void *)&cmd_setpromisc_portnum,
5780 (void *)&cmd_setpromisc_mode,
5785 /* *** SET ALLMULTI MODE *** */
5786 struct cmd_set_allmulti_mode_result {
5787 cmdline_fixed_string_t set;
5788 cmdline_fixed_string_t allmulti;
5789 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5790 uint16_t port_num; /* valid if "allports" argument == 0 */
5791 cmdline_fixed_string_t mode;
5794 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5795 __attribute__((unused)) struct cmdline *cl,
5798 struct cmd_set_allmulti_mode_result *res = parsed_result;
5802 if (!strcmp(res->mode, "on"))
5809 RTE_ETH_FOREACH_DEV(i) {
5811 rte_eth_allmulticast_enable(i);
5813 rte_eth_allmulticast_disable(i);
5818 rte_eth_allmulticast_enable(res->port_num);
5820 rte_eth_allmulticast_disable(res->port_num);
5824 cmdline_parse_token_string_t cmd_setallmulti_set =
5825 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5826 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5827 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5829 cmdline_parse_token_string_t cmd_setallmulti_portall =
5830 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5832 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5833 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5835 cmdline_parse_token_string_t cmd_setallmulti_mode =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5839 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5840 .f = cmd_set_allmulti_mode_parsed,
5842 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5844 (void *)&cmd_setallmulti_set,
5845 (void *)&cmd_setallmulti_allmulti,
5846 (void *)&cmd_setallmulti_portall,
5847 (void *)&cmd_setallmulti_mode,
5852 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5853 .f = cmd_set_allmulti_mode_parsed,
5855 .help_str = "set allmulti <port_id> on|off: "
5856 "Set allmulti mode on port_id",
5858 (void *)&cmd_setallmulti_set,
5859 (void *)&cmd_setallmulti_allmulti,
5860 (void *)&cmd_setallmulti_portnum,
5861 (void *)&cmd_setallmulti_mode,
5866 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5867 struct cmd_link_flow_ctrl_set_result {
5868 cmdline_fixed_string_t set;
5869 cmdline_fixed_string_t flow_ctrl;
5870 cmdline_fixed_string_t rx;
5871 cmdline_fixed_string_t rx_lfc_mode;
5872 cmdline_fixed_string_t tx;
5873 cmdline_fixed_string_t tx_lfc_mode;
5874 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5875 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5876 cmdline_fixed_string_t autoneg_str;
5877 cmdline_fixed_string_t autoneg;
5878 cmdline_fixed_string_t hw_str;
5879 uint32_t high_water;
5880 cmdline_fixed_string_t lw_str;
5882 cmdline_fixed_string_t pt_str;
5883 uint16_t pause_time;
5884 cmdline_fixed_string_t xon_str;
5889 cmdline_parse_token_string_t cmd_lfc_set_set =
5890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5892 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5894 flow_ctrl, "flow_ctrl");
5895 cmdline_parse_token_string_t cmd_lfc_set_rx =
5896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5898 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5900 rx_lfc_mode, "on#off");
5901 cmdline_parse_token_string_t cmd_lfc_set_tx =
5902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5904 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5906 tx_lfc_mode, "on#off");
5907 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5909 hw_str, "high_water");
5910 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5911 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5912 high_water, UINT32);
5913 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5915 lw_str, "low_water");
5916 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5919 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5921 pt_str, "pause_time");
5922 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5924 pause_time, UINT16);
5925 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5927 xon_str, "send_xon");
5928 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5929 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5931 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5933 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5934 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5935 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5936 mac_ctrl_frame_fwd_mode, "on#off");
5937 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5938 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5939 autoneg_str, "autoneg");
5940 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5941 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5943 cmdline_parse_token_num_t cmd_lfc_set_portid =
5944 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5947 /* forward declaration */
5949 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5952 cmdline_parse_inst_t cmd_link_flow_control_set = {
5953 .f = cmd_link_flow_ctrl_set_parsed,
5955 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5956 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5957 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5959 (void *)&cmd_lfc_set_set,
5960 (void *)&cmd_lfc_set_flow_ctrl,
5961 (void *)&cmd_lfc_set_rx,
5962 (void *)&cmd_lfc_set_rx_mode,
5963 (void *)&cmd_lfc_set_tx,
5964 (void *)&cmd_lfc_set_tx_mode,
5965 (void *)&cmd_lfc_set_high_water,
5966 (void *)&cmd_lfc_set_low_water,
5967 (void *)&cmd_lfc_set_pause_time,
5968 (void *)&cmd_lfc_set_send_xon,
5969 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5970 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5971 (void *)&cmd_lfc_set_autoneg_str,
5972 (void *)&cmd_lfc_set_autoneg,
5973 (void *)&cmd_lfc_set_portid,
5978 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5979 .f = cmd_link_flow_ctrl_set_parsed,
5980 .data = (void *)&cmd_link_flow_control_set_rx,
5981 .help_str = "set flow_ctrl rx on|off <port_id>: "
5982 "Change rx flow control parameter",
5984 (void *)&cmd_lfc_set_set,
5985 (void *)&cmd_lfc_set_flow_ctrl,
5986 (void *)&cmd_lfc_set_rx,
5987 (void *)&cmd_lfc_set_rx_mode,
5988 (void *)&cmd_lfc_set_portid,
5993 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5994 .f = cmd_link_flow_ctrl_set_parsed,
5995 .data = (void *)&cmd_link_flow_control_set_tx,
5996 .help_str = "set flow_ctrl tx on|off <port_id>: "
5997 "Change tx flow control parameter",
5999 (void *)&cmd_lfc_set_set,
6000 (void *)&cmd_lfc_set_flow_ctrl,
6001 (void *)&cmd_lfc_set_tx,
6002 (void *)&cmd_lfc_set_tx_mode,
6003 (void *)&cmd_lfc_set_portid,
6008 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6009 .f = cmd_link_flow_ctrl_set_parsed,
6010 .data = (void *)&cmd_link_flow_control_set_hw,
6011 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6012 "Change high water flow control parameter",
6014 (void *)&cmd_lfc_set_set,
6015 (void *)&cmd_lfc_set_flow_ctrl,
6016 (void *)&cmd_lfc_set_high_water_str,
6017 (void *)&cmd_lfc_set_high_water,
6018 (void *)&cmd_lfc_set_portid,
6023 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6024 .f = cmd_link_flow_ctrl_set_parsed,
6025 .data = (void *)&cmd_link_flow_control_set_lw,
6026 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6027 "Change low water flow control parameter",
6029 (void *)&cmd_lfc_set_set,
6030 (void *)&cmd_lfc_set_flow_ctrl,
6031 (void *)&cmd_lfc_set_low_water_str,
6032 (void *)&cmd_lfc_set_low_water,
6033 (void *)&cmd_lfc_set_portid,
6038 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6039 .f = cmd_link_flow_ctrl_set_parsed,
6040 .data = (void *)&cmd_link_flow_control_set_pt,
6041 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6042 "Change pause time flow control parameter",
6044 (void *)&cmd_lfc_set_set,
6045 (void *)&cmd_lfc_set_flow_ctrl,
6046 (void *)&cmd_lfc_set_pause_time_str,
6047 (void *)&cmd_lfc_set_pause_time,
6048 (void *)&cmd_lfc_set_portid,
6053 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6054 .f = cmd_link_flow_ctrl_set_parsed,
6055 .data = (void *)&cmd_link_flow_control_set_xon,
6056 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6057 "Change send_xon flow control parameter",
6059 (void *)&cmd_lfc_set_set,
6060 (void *)&cmd_lfc_set_flow_ctrl,
6061 (void *)&cmd_lfc_set_send_xon_str,
6062 (void *)&cmd_lfc_set_send_xon,
6063 (void *)&cmd_lfc_set_portid,
6068 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6069 .f = cmd_link_flow_ctrl_set_parsed,
6070 .data = (void *)&cmd_link_flow_control_set_macfwd,
6071 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6072 "Change mac ctrl fwd flow control parameter",
6074 (void *)&cmd_lfc_set_set,
6075 (void *)&cmd_lfc_set_flow_ctrl,
6076 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6077 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6078 (void *)&cmd_lfc_set_portid,
6083 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6084 .f = cmd_link_flow_ctrl_set_parsed,
6085 .data = (void *)&cmd_link_flow_control_set_autoneg,
6086 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6087 "Change autoneg flow control parameter",
6089 (void *)&cmd_lfc_set_set,
6090 (void *)&cmd_lfc_set_flow_ctrl,
6091 (void *)&cmd_lfc_set_autoneg_str,
6092 (void *)&cmd_lfc_set_autoneg,
6093 (void *)&cmd_lfc_set_portid,
6099 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6100 __attribute__((unused)) struct cmdline *cl,
6103 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6104 cmdline_parse_inst_t *cmd = data;
6105 struct rte_eth_fc_conf fc_conf;
6111 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6112 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6113 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6114 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6116 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6117 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6120 /* Partial command line, retrieve current configuration */
6122 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6124 printf("cannot get current flow ctrl parameters, return"
6125 "code = %d\n", ret);
6129 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6130 (fc_conf.mode == RTE_FC_FULL))
6132 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6133 (fc_conf.mode == RTE_FC_FULL))
6137 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6138 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6140 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6141 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6143 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6145 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6146 fc_conf.high_water = res->high_water;
6148 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6149 fc_conf.low_water = res->low_water;
6151 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6152 fc_conf.pause_time = res->pause_time;
6154 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6155 fc_conf.send_xon = res->send_xon;
6157 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6158 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6159 fc_conf.mac_ctrl_frame_fwd = 1;
6161 fc_conf.mac_ctrl_frame_fwd = 0;
6164 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6165 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6167 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6169 printf("bad flow contrl parameter, return code = %d \n", ret);
6172 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6173 struct cmd_priority_flow_ctrl_set_result {
6174 cmdline_fixed_string_t set;
6175 cmdline_fixed_string_t pfc_ctrl;
6176 cmdline_fixed_string_t rx;
6177 cmdline_fixed_string_t rx_pfc_mode;
6178 cmdline_fixed_string_t tx;
6179 cmdline_fixed_string_t tx_pfc_mode;
6180 uint32_t high_water;
6182 uint16_t pause_time;
6188 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6189 __attribute__((unused)) struct cmdline *cl,
6190 __attribute__((unused)) void *data)
6192 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6193 struct rte_eth_pfc_conf pfc_conf;
6194 int rx_fc_enable, tx_fc_enable;
6198 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6199 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6200 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6201 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6203 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6204 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6207 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6208 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6209 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6210 pfc_conf.fc.high_water = res->high_water;
6211 pfc_conf.fc.low_water = res->low_water;
6212 pfc_conf.fc.pause_time = res->pause_time;
6213 pfc_conf.priority = res->priority;
6215 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6217 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6220 cmdline_parse_token_string_t cmd_pfc_set_set =
6221 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6223 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6224 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6225 pfc_ctrl, "pfc_ctrl");
6226 cmdline_parse_token_string_t cmd_pfc_set_rx =
6227 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6229 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6230 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6231 rx_pfc_mode, "on#off");
6232 cmdline_parse_token_string_t cmd_pfc_set_tx =
6233 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6235 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6236 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6237 tx_pfc_mode, "on#off");
6238 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6239 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6240 high_water, UINT32);
6241 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6242 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6244 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6245 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6246 pause_time, UINT16);
6247 cmdline_parse_token_num_t cmd_pfc_set_priority =
6248 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6250 cmdline_parse_token_num_t cmd_pfc_set_portid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6254 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6255 .f = cmd_priority_flow_ctrl_set_parsed,
6257 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6258 "<pause_time> <priority> <port_id>: "
6259 "Configure the Ethernet priority flow control",
6261 (void *)&cmd_pfc_set_set,
6262 (void *)&cmd_pfc_set_flow_ctrl,
6263 (void *)&cmd_pfc_set_rx,
6264 (void *)&cmd_pfc_set_rx_mode,
6265 (void *)&cmd_pfc_set_tx,
6266 (void *)&cmd_pfc_set_tx_mode,
6267 (void *)&cmd_pfc_set_high_water,
6268 (void *)&cmd_pfc_set_low_water,
6269 (void *)&cmd_pfc_set_pause_time,
6270 (void *)&cmd_pfc_set_priority,
6271 (void *)&cmd_pfc_set_portid,
6276 /* *** RESET CONFIGURATION *** */
6277 struct cmd_reset_result {
6278 cmdline_fixed_string_t reset;
6279 cmdline_fixed_string_t def;
6282 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6284 __attribute__((unused)) void *data)
6286 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6287 set_def_fwd_config();
6290 cmdline_parse_token_string_t cmd_reset_set =
6291 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6292 cmdline_parse_token_string_t cmd_reset_def =
6293 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6296 cmdline_parse_inst_t cmd_reset = {
6297 .f = cmd_reset_parsed,
6299 .help_str = "set default: Reset default forwarding configuration",
6301 (void *)&cmd_reset_set,
6302 (void *)&cmd_reset_def,
6307 /* *** START FORWARDING *** */
6308 struct cmd_start_result {
6309 cmdline_fixed_string_t start;
6312 cmdline_parse_token_string_t cmd_start_start =
6313 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6315 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6316 __attribute__((unused)) struct cmdline *cl,
6317 __attribute__((unused)) void *data)
6319 start_packet_forwarding(0);
6322 cmdline_parse_inst_t cmd_start = {
6323 .f = cmd_start_parsed,
6325 .help_str = "start: Start packet forwarding",
6327 (void *)&cmd_start_start,
6332 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6333 struct cmd_start_tx_first_result {
6334 cmdline_fixed_string_t start;
6335 cmdline_fixed_string_t tx_first;
6339 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6340 __attribute__((unused)) struct cmdline *cl,
6341 __attribute__((unused)) void *data)
6343 start_packet_forwarding(1);
6346 cmdline_parse_token_string_t cmd_start_tx_first_start =
6347 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6349 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6350 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6351 tx_first, "tx_first");
6353 cmdline_parse_inst_t cmd_start_tx_first = {
6354 .f = cmd_start_tx_first_parsed,
6356 .help_str = "start tx_first: Start packet forwarding, "
6357 "after sending 1 burst of packets",
6359 (void *)&cmd_start_tx_first_start,
6360 (void *)&cmd_start_tx_first_tx_first,
6365 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6366 struct cmd_start_tx_first_n_result {
6367 cmdline_fixed_string_t start;
6368 cmdline_fixed_string_t tx_first;
6373 cmd_start_tx_first_n_parsed(void *parsed_result,
6374 __attribute__((unused)) struct cmdline *cl,
6375 __attribute__((unused)) void *data)
6377 struct cmd_start_tx_first_n_result *res = parsed_result;
6379 start_packet_forwarding(res->tx_num);
6382 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6383 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6385 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6386 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6387 tx_first, "tx_first");
6388 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6389 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6392 cmdline_parse_inst_t cmd_start_tx_first_n = {
6393 .f = cmd_start_tx_first_n_parsed,
6395 .help_str = "start tx_first <num>: "
6396 "packet forwarding, after sending <num> bursts of packets",
6398 (void *)&cmd_start_tx_first_n_start,
6399 (void *)&cmd_start_tx_first_n_tx_first,
6400 (void *)&cmd_start_tx_first_n_tx_num,
6405 /* *** SET LINK UP *** */
6406 struct cmd_set_link_up_result {
6407 cmdline_fixed_string_t set;
6408 cmdline_fixed_string_t link_up;
6409 cmdline_fixed_string_t port;
6413 cmdline_parse_token_string_t cmd_set_link_up_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6415 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6418 cmdline_parse_token_string_t cmd_set_link_up_port =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6420 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6421 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6423 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6424 __attribute__((unused)) struct cmdline *cl,
6425 __attribute__((unused)) void *data)
6427 struct cmd_set_link_up_result *res = parsed_result;
6428 dev_set_link_up(res->port_id);
6431 cmdline_parse_inst_t cmd_set_link_up = {
6432 .f = cmd_set_link_up_parsed,
6434 .help_str = "set link-up port <port id>",
6436 (void *)&cmd_set_link_up_set,
6437 (void *)&cmd_set_link_up_link_up,
6438 (void *)&cmd_set_link_up_port,
6439 (void *)&cmd_set_link_up_port_id,
6444 /* *** SET LINK DOWN *** */
6445 struct cmd_set_link_down_result {
6446 cmdline_fixed_string_t set;
6447 cmdline_fixed_string_t link_down;
6448 cmdline_fixed_string_t port;
6452 cmdline_parse_token_string_t cmd_set_link_down_set =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6454 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6455 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6457 cmdline_parse_token_string_t cmd_set_link_down_port =
6458 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6459 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6462 static void cmd_set_link_down_parsed(
6463 __attribute__((unused)) void *parsed_result,
6464 __attribute__((unused)) struct cmdline *cl,
6465 __attribute__((unused)) void *data)
6467 struct cmd_set_link_down_result *res = parsed_result;
6468 dev_set_link_down(res->port_id);
6471 cmdline_parse_inst_t cmd_set_link_down = {
6472 .f = cmd_set_link_down_parsed,
6474 .help_str = "set link-down port <port id>",
6476 (void *)&cmd_set_link_down_set,
6477 (void *)&cmd_set_link_down_link_down,
6478 (void *)&cmd_set_link_down_port,
6479 (void *)&cmd_set_link_down_port_id,
6484 /* *** SHOW CFG *** */
6485 struct cmd_showcfg_result {
6486 cmdline_fixed_string_t show;
6487 cmdline_fixed_string_t cfg;
6488 cmdline_fixed_string_t what;
6491 static void cmd_showcfg_parsed(void *parsed_result,
6492 __attribute__((unused)) struct cmdline *cl,
6493 __attribute__((unused)) void *data)
6495 struct cmd_showcfg_result *res = parsed_result;
6496 if (!strcmp(res->what, "rxtx"))
6497 rxtx_config_display();
6498 else if (!strcmp(res->what, "cores"))
6499 fwd_lcores_config_display();
6500 else if (!strcmp(res->what, "fwd"))
6501 pkt_fwd_config_display(&cur_fwd_config);
6502 else if (!strcmp(res->what, "txpkts"))
6503 show_tx_pkt_segments();
6506 cmdline_parse_token_string_t cmd_showcfg_show =
6507 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6508 cmdline_parse_token_string_t cmd_showcfg_port =
6509 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6510 cmdline_parse_token_string_t cmd_showcfg_what =
6511 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6512 "rxtx#cores#fwd#txpkts");
6514 cmdline_parse_inst_t cmd_showcfg = {
6515 .f = cmd_showcfg_parsed,
6517 .help_str = "show config rxtx|cores|fwd|txpkts",
6519 (void *)&cmd_showcfg_show,
6520 (void *)&cmd_showcfg_port,
6521 (void *)&cmd_showcfg_what,
6526 /* *** SHOW ALL PORT INFO *** */
6527 struct cmd_showportall_result {
6528 cmdline_fixed_string_t show;
6529 cmdline_fixed_string_t port;
6530 cmdline_fixed_string_t what;
6531 cmdline_fixed_string_t all;
6534 static void cmd_showportall_parsed(void *parsed_result,
6535 __attribute__((unused)) struct cmdline *cl,
6536 __attribute__((unused)) void *data)
6540 struct cmd_showportall_result *res = parsed_result;
6541 if (!strcmp(res->show, "clear")) {
6542 if (!strcmp(res->what, "stats"))
6543 RTE_ETH_FOREACH_DEV(i)
6545 else if (!strcmp(res->what, "xstats"))
6546 RTE_ETH_FOREACH_DEV(i)
6547 nic_xstats_clear(i);
6548 } else if (!strcmp(res->what, "info"))
6549 RTE_ETH_FOREACH_DEV(i)
6550 port_infos_display(i);
6551 else if (!strcmp(res->what, "stats"))
6552 RTE_ETH_FOREACH_DEV(i)
6553 nic_stats_display(i);
6554 else if (!strcmp(res->what, "xstats"))
6555 RTE_ETH_FOREACH_DEV(i)
6556 nic_xstats_display(i);
6557 else if (!strcmp(res->what, "fdir"))
6558 RTE_ETH_FOREACH_DEV(i)
6560 else if (!strcmp(res->what, "stat_qmap"))
6561 RTE_ETH_FOREACH_DEV(i)
6562 nic_stats_mapping_display(i);
6563 else if (!strcmp(res->what, "dcb_tc"))
6564 RTE_ETH_FOREACH_DEV(i)
6565 port_dcb_info_display(i);
6566 else if (!strcmp(res->what, "cap"))
6567 RTE_ETH_FOREACH_DEV(i)
6568 port_offload_cap_display(i);
6571 cmdline_parse_token_string_t cmd_showportall_show =
6572 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6574 cmdline_parse_token_string_t cmd_showportall_port =
6575 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6576 cmdline_parse_token_string_t cmd_showportall_what =
6577 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6578 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6579 cmdline_parse_token_string_t cmd_showportall_all =
6580 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6581 cmdline_parse_inst_t cmd_showportall = {
6582 .f = cmd_showportall_parsed,
6584 .help_str = "show|clear port "
6585 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6587 (void *)&cmd_showportall_show,
6588 (void *)&cmd_showportall_port,
6589 (void *)&cmd_showportall_what,
6590 (void *)&cmd_showportall_all,
6595 /* *** SHOW PORT INFO *** */
6596 struct cmd_showport_result {
6597 cmdline_fixed_string_t show;
6598 cmdline_fixed_string_t port;
6599 cmdline_fixed_string_t what;
6603 static void cmd_showport_parsed(void *parsed_result,
6604 __attribute__((unused)) struct cmdline *cl,
6605 __attribute__((unused)) void *data)
6607 struct cmd_showport_result *res = parsed_result;
6608 if (!strcmp(res->show, "clear")) {
6609 if (!strcmp(res->what, "stats"))
6610 nic_stats_clear(res->portnum);
6611 else if (!strcmp(res->what, "xstats"))
6612 nic_xstats_clear(res->portnum);
6613 } else if (!strcmp(res->what, "info"))
6614 port_infos_display(res->portnum);
6615 else if (!strcmp(res->what, "stats"))
6616 nic_stats_display(res->portnum);
6617 else if (!strcmp(res->what, "xstats"))
6618 nic_xstats_display(res->portnum);
6619 else if (!strcmp(res->what, "fdir"))
6620 fdir_get_infos(res->portnum);
6621 else if (!strcmp(res->what, "stat_qmap"))
6622 nic_stats_mapping_display(res->portnum);
6623 else if (!strcmp(res->what, "dcb_tc"))
6624 port_dcb_info_display(res->portnum);
6625 else if (!strcmp(res->what, "cap"))
6626 port_offload_cap_display(res->portnum);
6629 cmdline_parse_token_string_t cmd_showport_show =
6630 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6632 cmdline_parse_token_string_t cmd_showport_port =
6633 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6634 cmdline_parse_token_string_t cmd_showport_what =
6635 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6636 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6637 cmdline_parse_token_num_t cmd_showport_portnum =
6638 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6640 cmdline_parse_inst_t cmd_showport = {
6641 .f = cmd_showport_parsed,
6643 .help_str = "show|clear port "
6644 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6647 (void *)&cmd_showport_show,
6648 (void *)&cmd_showport_port,
6649 (void *)&cmd_showport_what,
6650 (void *)&cmd_showport_portnum,
6655 /* *** SHOW QUEUE INFO *** */
6656 struct cmd_showqueue_result {
6657 cmdline_fixed_string_t show;
6658 cmdline_fixed_string_t type;
6659 cmdline_fixed_string_t what;
6665 cmd_showqueue_parsed(void *parsed_result,
6666 __attribute__((unused)) struct cmdline *cl,
6667 __attribute__((unused)) void *data)
6669 struct cmd_showqueue_result *res = parsed_result;
6671 if (!strcmp(res->type, "rxq"))
6672 rx_queue_infos_display(res->portnum, res->queuenum);
6673 else if (!strcmp(res->type, "txq"))
6674 tx_queue_infos_display(res->portnum, res->queuenum);
6677 cmdline_parse_token_string_t cmd_showqueue_show =
6678 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6679 cmdline_parse_token_string_t cmd_showqueue_type =
6680 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6681 cmdline_parse_token_string_t cmd_showqueue_what =
6682 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6683 cmdline_parse_token_num_t cmd_showqueue_portnum =
6684 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6685 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6686 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6688 cmdline_parse_inst_t cmd_showqueue = {
6689 .f = cmd_showqueue_parsed,
6691 .help_str = "show rxq|txq info <port_id> <queue_id>",
6693 (void *)&cmd_showqueue_show,
6694 (void *)&cmd_showqueue_type,
6695 (void *)&cmd_showqueue_what,
6696 (void *)&cmd_showqueue_portnum,
6697 (void *)&cmd_showqueue_queuenum,
6702 /* *** READ PORT REGISTER *** */
6703 struct cmd_read_reg_result {
6704 cmdline_fixed_string_t read;
6705 cmdline_fixed_string_t reg;
6711 cmd_read_reg_parsed(void *parsed_result,
6712 __attribute__((unused)) struct cmdline *cl,
6713 __attribute__((unused)) void *data)
6715 struct cmd_read_reg_result *res = parsed_result;
6716 port_reg_display(res->port_id, res->reg_off);
6719 cmdline_parse_token_string_t cmd_read_reg_read =
6720 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6721 cmdline_parse_token_string_t cmd_read_reg_reg =
6722 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6723 cmdline_parse_token_num_t cmd_read_reg_port_id =
6724 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6725 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6726 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6728 cmdline_parse_inst_t cmd_read_reg = {
6729 .f = cmd_read_reg_parsed,
6731 .help_str = "read reg <port_id> <reg_off>",
6733 (void *)&cmd_read_reg_read,
6734 (void *)&cmd_read_reg_reg,
6735 (void *)&cmd_read_reg_port_id,
6736 (void *)&cmd_read_reg_reg_off,
6741 /* *** READ PORT REGISTER BIT FIELD *** */
6742 struct cmd_read_reg_bit_field_result {
6743 cmdline_fixed_string_t read;
6744 cmdline_fixed_string_t regfield;
6752 cmd_read_reg_bit_field_parsed(void *parsed_result,
6753 __attribute__((unused)) struct cmdline *cl,
6754 __attribute__((unused)) void *data)
6756 struct cmd_read_reg_bit_field_result *res = parsed_result;
6757 port_reg_bit_field_display(res->port_id, res->reg_off,
6758 res->bit1_pos, res->bit2_pos);
6761 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6762 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6764 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6765 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6766 regfield, "regfield");
6767 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6768 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6770 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6771 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6773 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6774 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6776 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6777 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6780 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6781 .f = cmd_read_reg_bit_field_parsed,
6783 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6784 "Read register bit field between bit_x and bit_y included",
6786 (void *)&cmd_read_reg_bit_field_read,
6787 (void *)&cmd_read_reg_bit_field_regfield,
6788 (void *)&cmd_read_reg_bit_field_port_id,
6789 (void *)&cmd_read_reg_bit_field_reg_off,
6790 (void *)&cmd_read_reg_bit_field_bit1_pos,
6791 (void *)&cmd_read_reg_bit_field_bit2_pos,
6796 /* *** READ PORT REGISTER BIT *** */
6797 struct cmd_read_reg_bit_result {
6798 cmdline_fixed_string_t read;
6799 cmdline_fixed_string_t regbit;
6806 cmd_read_reg_bit_parsed(void *parsed_result,
6807 __attribute__((unused)) struct cmdline *cl,
6808 __attribute__((unused)) void *data)
6810 struct cmd_read_reg_bit_result *res = parsed_result;
6811 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6814 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6815 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6816 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6817 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6819 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6820 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6821 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6822 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6823 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6824 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6826 cmdline_parse_inst_t cmd_read_reg_bit = {
6827 .f = cmd_read_reg_bit_parsed,
6829 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6831 (void *)&cmd_read_reg_bit_read,
6832 (void *)&cmd_read_reg_bit_regbit,
6833 (void *)&cmd_read_reg_bit_port_id,
6834 (void *)&cmd_read_reg_bit_reg_off,
6835 (void *)&cmd_read_reg_bit_bit_pos,
6840 /* *** WRITE PORT REGISTER *** */
6841 struct cmd_write_reg_result {
6842 cmdline_fixed_string_t write;
6843 cmdline_fixed_string_t reg;
6850 cmd_write_reg_parsed(void *parsed_result,
6851 __attribute__((unused)) struct cmdline *cl,
6852 __attribute__((unused)) void *data)
6854 struct cmd_write_reg_result *res = parsed_result;
6855 port_reg_set(res->port_id, res->reg_off, res->value);
6858 cmdline_parse_token_string_t cmd_write_reg_write =
6859 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6860 cmdline_parse_token_string_t cmd_write_reg_reg =
6861 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6862 cmdline_parse_token_num_t cmd_write_reg_port_id =
6863 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6864 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6865 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6866 cmdline_parse_token_num_t cmd_write_reg_value =
6867 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6869 cmdline_parse_inst_t cmd_write_reg = {
6870 .f = cmd_write_reg_parsed,
6872 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6874 (void *)&cmd_write_reg_write,
6875 (void *)&cmd_write_reg_reg,
6876 (void *)&cmd_write_reg_port_id,
6877 (void *)&cmd_write_reg_reg_off,
6878 (void *)&cmd_write_reg_value,
6883 /* *** WRITE PORT REGISTER BIT FIELD *** */
6884 struct cmd_write_reg_bit_field_result {
6885 cmdline_fixed_string_t write;
6886 cmdline_fixed_string_t regfield;
6895 cmd_write_reg_bit_field_parsed(void *parsed_result,
6896 __attribute__((unused)) struct cmdline *cl,
6897 __attribute__((unused)) void *data)
6899 struct cmd_write_reg_bit_field_result *res = parsed_result;
6900 port_reg_bit_field_set(res->port_id, res->reg_off,
6901 res->bit1_pos, res->bit2_pos, res->value);
6904 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6905 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6907 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6908 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6909 regfield, "regfield");
6910 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6911 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6913 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6914 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6916 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6917 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6919 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6920 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6922 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6923 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6926 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6927 .f = cmd_write_reg_bit_field_parsed,
6929 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6931 "Set register bit field between bit_x and bit_y included",
6933 (void *)&cmd_write_reg_bit_field_write,
6934 (void *)&cmd_write_reg_bit_field_regfield,
6935 (void *)&cmd_write_reg_bit_field_port_id,
6936 (void *)&cmd_write_reg_bit_field_reg_off,
6937 (void *)&cmd_write_reg_bit_field_bit1_pos,
6938 (void *)&cmd_write_reg_bit_field_bit2_pos,
6939 (void *)&cmd_write_reg_bit_field_value,
6944 /* *** WRITE PORT REGISTER BIT *** */
6945 struct cmd_write_reg_bit_result {
6946 cmdline_fixed_string_t write;
6947 cmdline_fixed_string_t regbit;
6955 cmd_write_reg_bit_parsed(void *parsed_result,
6956 __attribute__((unused)) struct cmdline *cl,
6957 __attribute__((unused)) void *data)
6959 struct cmd_write_reg_bit_result *res = parsed_result;
6960 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6963 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6964 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6966 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6967 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6969 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6970 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6971 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6972 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6973 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6975 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6978 cmdline_parse_inst_t cmd_write_reg_bit = {
6979 .f = cmd_write_reg_bit_parsed,
6981 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6984 (void *)&cmd_write_reg_bit_write,
6985 (void *)&cmd_write_reg_bit_regbit,
6986 (void *)&cmd_write_reg_bit_port_id,
6987 (void *)&cmd_write_reg_bit_reg_off,
6988 (void *)&cmd_write_reg_bit_bit_pos,
6989 (void *)&cmd_write_reg_bit_value,
6994 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6995 struct cmd_read_rxd_txd_result {
6996 cmdline_fixed_string_t read;
6997 cmdline_fixed_string_t rxd_txd;
7004 cmd_read_rxd_txd_parsed(void *parsed_result,
7005 __attribute__((unused)) struct cmdline *cl,
7006 __attribute__((unused)) void *data)
7008 struct cmd_read_rxd_txd_result *res = parsed_result;
7010 if (!strcmp(res->rxd_txd, "rxd"))
7011 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7012 else if (!strcmp(res->rxd_txd, "txd"))
7013 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7016 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7017 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7018 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7019 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7021 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7022 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7023 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7024 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7025 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7026 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7028 cmdline_parse_inst_t cmd_read_rxd_txd = {
7029 .f = cmd_read_rxd_txd_parsed,
7031 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7033 (void *)&cmd_read_rxd_txd_read,
7034 (void *)&cmd_read_rxd_txd_rxd_txd,
7035 (void *)&cmd_read_rxd_txd_port_id,
7036 (void *)&cmd_read_rxd_txd_queue_id,
7037 (void *)&cmd_read_rxd_txd_desc_id,
7043 struct cmd_quit_result {
7044 cmdline_fixed_string_t quit;
7047 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7049 __attribute__((unused)) void *data)
7055 cmdline_parse_token_string_t cmd_quit_quit =
7056 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7058 cmdline_parse_inst_t cmd_quit = {
7059 .f = cmd_quit_parsed,
7061 .help_str = "quit: Exit application",
7063 (void *)&cmd_quit_quit,
7068 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7069 struct cmd_mac_addr_result {
7070 cmdline_fixed_string_t mac_addr_cmd;
7071 cmdline_fixed_string_t what;
7073 struct ether_addr address;
7076 static void cmd_mac_addr_parsed(void *parsed_result,
7077 __attribute__((unused)) struct cmdline *cl,
7078 __attribute__((unused)) void *data)
7080 struct cmd_mac_addr_result *res = parsed_result;
7083 if (strcmp(res->what, "add") == 0)
7084 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7085 else if (strcmp(res->what, "set") == 0)
7086 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7089 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7091 /* check the return value and print it if is < 0 */
7093 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7097 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7098 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7100 cmdline_parse_token_string_t cmd_mac_addr_what =
7101 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7103 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7104 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7106 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7107 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7109 cmdline_parse_inst_t cmd_mac_addr = {
7110 .f = cmd_mac_addr_parsed,
7112 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7113 "Add/Remove/Set MAC address on port_id",
7115 (void *)&cmd_mac_addr_cmd,
7116 (void *)&cmd_mac_addr_what,
7117 (void *)&cmd_mac_addr_portnum,
7118 (void *)&cmd_mac_addr_addr,
7124 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7125 struct cmd_set_qmap_result {
7126 cmdline_fixed_string_t set;
7127 cmdline_fixed_string_t qmap;
7128 cmdline_fixed_string_t what;
7135 cmd_set_qmap_parsed(void *parsed_result,
7136 __attribute__((unused)) struct cmdline *cl,
7137 __attribute__((unused)) void *data)
7139 struct cmd_set_qmap_result *res = parsed_result;
7140 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7142 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7145 cmdline_parse_token_string_t cmd_setqmap_set =
7146 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7148 cmdline_parse_token_string_t cmd_setqmap_qmap =
7149 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7151 cmdline_parse_token_string_t cmd_setqmap_what =
7152 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7154 cmdline_parse_token_num_t cmd_setqmap_portid =
7155 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7157 cmdline_parse_token_num_t cmd_setqmap_queueid =
7158 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7160 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7161 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7164 cmdline_parse_inst_t cmd_set_qmap = {
7165 .f = cmd_set_qmap_parsed,
7167 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7168 "Set statistics mapping value on tx|rx queue_id of port_id",
7170 (void *)&cmd_setqmap_set,
7171 (void *)&cmd_setqmap_qmap,
7172 (void *)&cmd_setqmap_what,
7173 (void *)&cmd_setqmap_portid,
7174 (void *)&cmd_setqmap_queueid,
7175 (void *)&cmd_setqmap_mapvalue,
7180 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7181 struct cmd_set_xstats_hide_zero_result {
7182 cmdline_fixed_string_t keyword;
7183 cmdline_fixed_string_t name;
7184 cmdline_fixed_string_t on_off;
7188 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7189 __attribute__((unused)) struct cmdline *cl,
7190 __attribute__((unused)) void *data)
7192 struct cmd_set_xstats_hide_zero_result *res;
7193 uint16_t on_off = 0;
7195 res = parsed_result;
7196 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7197 set_xstats_hide_zero(on_off);
7200 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7201 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7203 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7204 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7205 name, "xstats-hide-zero");
7206 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7207 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7210 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7211 .f = cmd_set_xstats_hide_zero_parsed,
7213 .help_str = "set xstats-hide-zero on|off",
7215 (void *)&cmd_set_xstats_hide_zero_keyword,
7216 (void *)&cmd_set_xstats_hide_zero_name,
7217 (void *)&cmd_set_xstats_hide_zero_on_off,
7222 /* *** CONFIGURE UNICAST HASH TABLE *** */
7223 struct cmd_set_uc_hash_table {
7224 cmdline_fixed_string_t set;
7225 cmdline_fixed_string_t port;
7227 cmdline_fixed_string_t what;
7228 struct ether_addr address;
7229 cmdline_fixed_string_t mode;
7233 cmd_set_uc_hash_parsed(void *parsed_result,
7234 __attribute__((unused)) struct cmdline *cl,
7235 __attribute__((unused)) void *data)
7238 struct cmd_set_uc_hash_table *res = parsed_result;
7240 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7242 if (strcmp(res->what, "uta") == 0)
7243 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7244 &res->address,(uint8_t)is_on);
7246 printf("bad unicast hash table parameter, return code = %d \n", ret);
7250 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7251 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7253 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7254 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7256 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7257 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7259 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7262 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7263 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7265 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7269 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7270 .f = cmd_set_uc_hash_parsed,
7272 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7274 (void *)&cmd_set_uc_hash_set,
7275 (void *)&cmd_set_uc_hash_port,
7276 (void *)&cmd_set_uc_hash_portid,
7277 (void *)&cmd_set_uc_hash_what,
7278 (void *)&cmd_set_uc_hash_mac,
7279 (void *)&cmd_set_uc_hash_mode,
7284 struct cmd_set_uc_all_hash_table {
7285 cmdline_fixed_string_t set;
7286 cmdline_fixed_string_t port;
7288 cmdline_fixed_string_t what;
7289 cmdline_fixed_string_t value;
7290 cmdline_fixed_string_t mode;
7294 cmd_set_uc_all_hash_parsed(void *parsed_result,
7295 __attribute__((unused)) struct cmdline *cl,
7296 __attribute__((unused)) void *data)
7299 struct cmd_set_uc_all_hash_table *res = parsed_result;
7301 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7303 if ((strcmp(res->what, "uta") == 0) &&
7304 (strcmp(res->value, "all") == 0))
7305 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7307 printf("bad unicast hash table parameter,"
7308 "return code = %d \n", ret);
7311 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7314 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7315 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7317 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7318 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7320 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7321 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7323 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7324 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7326 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7330 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7331 .f = cmd_set_uc_all_hash_parsed,
7333 .help_str = "set port <port_id> uta all on|off",
7335 (void *)&cmd_set_uc_all_hash_set,
7336 (void *)&cmd_set_uc_all_hash_port,
7337 (void *)&cmd_set_uc_all_hash_portid,
7338 (void *)&cmd_set_uc_all_hash_what,
7339 (void *)&cmd_set_uc_all_hash_value,
7340 (void *)&cmd_set_uc_all_hash_mode,
7345 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7346 struct cmd_set_vf_macvlan_filter {
7347 cmdline_fixed_string_t set;
7348 cmdline_fixed_string_t port;
7350 cmdline_fixed_string_t vf;
7352 struct ether_addr address;
7353 cmdline_fixed_string_t filter_type;
7354 cmdline_fixed_string_t mode;
7358 cmd_set_vf_macvlan_parsed(void *parsed_result,
7359 __attribute__((unused)) struct cmdline *cl,
7360 __attribute__((unused)) void *data)
7363 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7364 struct rte_eth_mac_filter filter;
7366 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7368 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7370 /* set VF MAC filter */
7374 filter.dst_id = res->vf_id;
7376 if (!strcmp(res->filter_type, "exact-mac"))
7377 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7378 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7379 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7380 else if (!strcmp(res->filter_type, "hashmac"))
7381 filter.filter_type = RTE_MAC_HASH_MATCH;
7382 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7383 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7385 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7388 ret = rte_eth_dev_filter_ctrl(res->port_id,
7389 RTE_ETH_FILTER_MACVLAN,
7393 ret = rte_eth_dev_filter_ctrl(res->port_id,
7394 RTE_ETH_FILTER_MACVLAN,
7395 RTE_ETH_FILTER_DELETE,
7399 printf("bad set MAC hash parameter, return code = %d\n", ret);
7403 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7404 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7406 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7407 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7409 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7410 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7412 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7413 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7415 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7416 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7418 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7419 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7421 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7422 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7423 filter_type, "exact-mac#exact-mac-vlan"
7424 "#hashmac#hashmac-vlan");
7425 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7429 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7430 .f = cmd_set_vf_macvlan_parsed,
7432 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7433 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7434 "Exact match rule: exact match of MAC or MAC and VLAN; "
7435 "hash match rule: hash match of MAC and exact match of VLAN",
7437 (void *)&cmd_set_vf_macvlan_set,
7438 (void *)&cmd_set_vf_macvlan_port,
7439 (void *)&cmd_set_vf_macvlan_portid,
7440 (void *)&cmd_set_vf_macvlan_vf,
7441 (void *)&cmd_set_vf_macvlan_vf_id,
7442 (void *)&cmd_set_vf_macvlan_mac,
7443 (void *)&cmd_set_vf_macvlan_filter_type,
7444 (void *)&cmd_set_vf_macvlan_mode,
7449 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7450 struct cmd_set_vf_traffic {
7451 cmdline_fixed_string_t set;
7452 cmdline_fixed_string_t port;
7454 cmdline_fixed_string_t vf;
7456 cmdline_fixed_string_t what;
7457 cmdline_fixed_string_t mode;
7461 cmd_set_vf_traffic_parsed(void *parsed_result,
7462 __attribute__((unused)) struct cmdline *cl,
7463 __attribute__((unused)) void *data)
7465 struct cmd_set_vf_traffic *res = parsed_result;
7466 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7467 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7469 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7472 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7475 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7478 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7479 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7481 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7484 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7485 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7487 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7488 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7490 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7494 cmdline_parse_inst_t cmd_set_vf_traffic = {
7495 .f = cmd_set_vf_traffic_parsed,
7497 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7499 (void *)&cmd_setvf_traffic_set,
7500 (void *)&cmd_setvf_traffic_port,
7501 (void *)&cmd_setvf_traffic_portid,
7502 (void *)&cmd_setvf_traffic_vf,
7503 (void *)&cmd_setvf_traffic_vfid,
7504 (void *)&cmd_setvf_traffic_what,
7505 (void *)&cmd_setvf_traffic_mode,
7510 /* *** CONFIGURE VF RECEIVE MODE *** */
7511 struct cmd_set_vf_rxmode {
7512 cmdline_fixed_string_t set;
7513 cmdline_fixed_string_t port;
7515 cmdline_fixed_string_t vf;
7517 cmdline_fixed_string_t what;
7518 cmdline_fixed_string_t mode;
7519 cmdline_fixed_string_t on;
7523 cmd_set_vf_rxmode_parsed(void *parsed_result,
7524 __attribute__((unused)) struct cmdline *cl,
7525 __attribute__((unused)) void *data)
7528 uint16_t rx_mode = 0;
7529 struct cmd_set_vf_rxmode *res = parsed_result;
7531 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7532 if (!strcmp(res->what,"rxmode")) {
7533 if (!strcmp(res->mode, "AUPE"))
7534 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7535 else if (!strcmp(res->mode, "ROPE"))
7536 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7537 else if (!strcmp(res->mode, "BAM"))
7538 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7539 else if (!strncmp(res->mode, "MPE",3))
7540 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7543 RTE_SET_USED(is_on);
7545 #ifdef RTE_LIBRTE_IXGBE_PMD
7546 if (ret == -ENOTSUP)
7547 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7548 rx_mode, (uint8_t)is_on);
7550 #ifdef RTE_LIBRTE_BNXT_PMD
7551 if (ret == -ENOTSUP)
7552 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7553 rx_mode, (uint8_t)is_on);
7556 printf("bad VF receive mode parameter, return code = %d \n",
7560 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7561 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7563 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7564 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7566 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7567 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7569 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7570 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7572 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7573 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7575 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7576 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7578 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7579 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7580 mode, "AUPE#ROPE#BAM#MPE");
7581 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7582 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7585 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7586 .f = cmd_set_vf_rxmode_parsed,
7588 .help_str = "set port <port_id> vf <vf_id> rxmode "
7589 "AUPE|ROPE|BAM|MPE on|off",
7591 (void *)&cmd_set_vf_rxmode_set,
7592 (void *)&cmd_set_vf_rxmode_port,
7593 (void *)&cmd_set_vf_rxmode_portid,
7594 (void *)&cmd_set_vf_rxmode_vf,
7595 (void *)&cmd_set_vf_rxmode_vfid,
7596 (void *)&cmd_set_vf_rxmode_what,
7597 (void *)&cmd_set_vf_rxmode_mode,
7598 (void *)&cmd_set_vf_rxmode_on,
7603 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7604 struct cmd_vf_mac_addr_result {
7605 cmdline_fixed_string_t mac_addr_cmd;
7606 cmdline_fixed_string_t what;
7607 cmdline_fixed_string_t port;
7609 cmdline_fixed_string_t vf;
7611 struct ether_addr address;
7614 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7615 __attribute__((unused)) struct cmdline *cl,
7616 __attribute__((unused)) void *data)
7618 struct cmd_vf_mac_addr_result *res = parsed_result;
7621 if (strcmp(res->what, "add") != 0)
7624 #ifdef RTE_LIBRTE_I40E_PMD
7625 if (ret == -ENOTSUP)
7626 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7629 #ifdef RTE_LIBRTE_BNXT_PMD
7630 if (ret == -ENOTSUP)
7631 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7636 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7640 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7641 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7642 mac_addr_cmd,"mac_addr");
7643 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7644 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7646 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7647 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7649 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7650 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7652 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7653 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7655 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7656 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7658 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7662 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7663 .f = cmd_vf_mac_addr_parsed,
7665 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7666 "Add MAC address filtering for a VF on port_id",
7668 (void *)&cmd_vf_mac_addr_cmd,
7669 (void *)&cmd_vf_mac_addr_what,
7670 (void *)&cmd_vf_mac_addr_port,
7671 (void *)&cmd_vf_mac_addr_portnum,
7672 (void *)&cmd_vf_mac_addr_vf,
7673 (void *)&cmd_vf_mac_addr_vfnum,
7674 (void *)&cmd_vf_mac_addr_addr,
7679 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7680 struct cmd_vf_rx_vlan_filter {
7681 cmdline_fixed_string_t rx_vlan;
7682 cmdline_fixed_string_t what;
7684 cmdline_fixed_string_t port;
7686 cmdline_fixed_string_t vf;
7691 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7692 __attribute__((unused)) struct cmdline *cl,
7693 __attribute__((unused)) void *data)
7695 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7698 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7700 #ifdef RTE_LIBRTE_IXGBE_PMD
7701 if (ret == -ENOTSUP)
7702 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7703 res->vlan_id, res->vf_mask, is_add);
7705 #ifdef RTE_LIBRTE_I40E_PMD
7706 if (ret == -ENOTSUP)
7707 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7708 res->vlan_id, res->vf_mask, is_add);
7710 #ifdef RTE_LIBRTE_BNXT_PMD
7711 if (ret == -ENOTSUP)
7712 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7713 res->vlan_id, res->vf_mask, is_add);
7720 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7721 res->vlan_id, res->vf_mask);
7724 printf("invalid port_id %d\n", res->port_id);
7727 printf("function not implemented or supported\n");
7730 printf("programming error: (%s)\n", strerror(-ret));
7734 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7735 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7736 rx_vlan, "rx_vlan");
7737 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7738 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7740 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7741 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7743 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7744 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7746 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7747 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7749 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7750 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7752 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7753 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7756 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7757 .f = cmd_vf_rx_vlan_filter_parsed,
7759 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7760 "(vf_mask = hexadecimal VF mask)",
7762 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7763 (void *)&cmd_vf_rx_vlan_filter_what,
7764 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7765 (void *)&cmd_vf_rx_vlan_filter_port,
7766 (void *)&cmd_vf_rx_vlan_filter_portid,
7767 (void *)&cmd_vf_rx_vlan_filter_vf,
7768 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7773 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7774 struct cmd_queue_rate_limit_result {
7775 cmdline_fixed_string_t set;
7776 cmdline_fixed_string_t port;
7778 cmdline_fixed_string_t queue;
7780 cmdline_fixed_string_t rate;
7784 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7785 __attribute__((unused)) struct cmdline *cl,
7786 __attribute__((unused)) void *data)
7788 struct cmd_queue_rate_limit_result *res = parsed_result;
7791 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7792 && (strcmp(res->queue, "queue") == 0)
7793 && (strcmp(res->rate, "rate") == 0))
7794 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7797 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7801 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7802 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7804 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7805 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7807 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7808 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7810 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7811 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7813 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7814 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7816 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7817 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7819 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7820 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7823 cmdline_parse_inst_t cmd_queue_rate_limit = {
7824 .f = cmd_queue_rate_limit_parsed,
7826 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7827 "Set rate limit for a queue on port_id",
7829 (void *)&cmd_queue_rate_limit_set,
7830 (void *)&cmd_queue_rate_limit_port,
7831 (void *)&cmd_queue_rate_limit_portnum,
7832 (void *)&cmd_queue_rate_limit_queue,
7833 (void *)&cmd_queue_rate_limit_queuenum,
7834 (void *)&cmd_queue_rate_limit_rate,
7835 (void *)&cmd_queue_rate_limit_ratenum,
7840 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7841 struct cmd_vf_rate_limit_result {
7842 cmdline_fixed_string_t set;
7843 cmdline_fixed_string_t port;
7845 cmdline_fixed_string_t vf;
7847 cmdline_fixed_string_t rate;
7849 cmdline_fixed_string_t q_msk;
7853 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7854 __attribute__((unused)) struct cmdline *cl,
7855 __attribute__((unused)) void *data)
7857 struct cmd_vf_rate_limit_result *res = parsed_result;
7860 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7861 && (strcmp(res->vf, "vf") == 0)
7862 && (strcmp(res->rate, "rate") == 0)
7863 && (strcmp(res->q_msk, "queue_mask") == 0))
7864 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7865 res->rate_num, res->q_msk_val);
7867 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7871 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7872 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7874 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7875 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7877 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7878 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7880 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7881 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7883 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7884 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7886 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7887 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7889 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7890 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7892 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7893 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7894 q_msk, "queue_mask");
7895 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7896 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7899 cmdline_parse_inst_t cmd_vf_rate_limit = {
7900 .f = cmd_vf_rate_limit_parsed,
7902 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7903 "queue_mask <queue_mask_value>: "
7904 "Set rate limit for queues of VF on port_id",
7906 (void *)&cmd_vf_rate_limit_set,
7907 (void *)&cmd_vf_rate_limit_port,
7908 (void *)&cmd_vf_rate_limit_portnum,
7909 (void *)&cmd_vf_rate_limit_vf,
7910 (void *)&cmd_vf_rate_limit_vfnum,
7911 (void *)&cmd_vf_rate_limit_rate,
7912 (void *)&cmd_vf_rate_limit_ratenum,
7913 (void *)&cmd_vf_rate_limit_q_msk,
7914 (void *)&cmd_vf_rate_limit_q_msk_val,
7919 /* *** ADD TUNNEL FILTER OF A PORT *** */
7920 struct cmd_tunnel_filter_result {
7921 cmdline_fixed_string_t cmd;
7922 cmdline_fixed_string_t what;
7924 struct ether_addr outer_mac;
7925 struct ether_addr inner_mac;
7926 cmdline_ipaddr_t ip_value;
7927 uint16_t inner_vlan;
7928 cmdline_fixed_string_t tunnel_type;
7929 cmdline_fixed_string_t filter_type;
7935 cmd_tunnel_filter_parsed(void *parsed_result,
7936 __attribute__((unused)) struct cmdline *cl,
7937 __attribute__((unused)) void *data)
7939 struct cmd_tunnel_filter_result *res = parsed_result;
7940 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7943 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7945 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7946 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7947 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7949 if (res->ip_value.family == AF_INET) {
7950 tunnel_filter_conf.ip_addr.ipv4_addr =
7951 res->ip_value.addr.ipv4.s_addr;
7952 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7954 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7955 &(res->ip_value.addr.ipv6),
7956 sizeof(struct in6_addr));
7957 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7960 if (!strcmp(res->filter_type, "imac-ivlan"))
7961 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7962 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7963 tunnel_filter_conf.filter_type =
7964 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7965 else if (!strcmp(res->filter_type, "imac-tenid"))
7966 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7967 else if (!strcmp(res->filter_type, "imac"))
7968 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7969 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7970 tunnel_filter_conf.filter_type =
7971 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7972 else if (!strcmp(res->filter_type, "oip"))
7973 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7974 else if (!strcmp(res->filter_type, "iip"))
7975 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7977 printf("The filter type is not supported");
7981 if (!strcmp(res->tunnel_type, "vxlan"))
7982 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7983 else if (!strcmp(res->tunnel_type, "nvgre"))
7984 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7985 else if (!strcmp(res->tunnel_type, "ipingre"))
7986 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7988 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7992 tunnel_filter_conf.tenant_id = res->tenant_id;
7993 tunnel_filter_conf.queue_id = res->queue_num;
7994 if (!strcmp(res->what, "add"))
7995 ret = rte_eth_dev_filter_ctrl(res->port_id,
7996 RTE_ETH_FILTER_TUNNEL,
7998 &tunnel_filter_conf);
8000 ret = rte_eth_dev_filter_ctrl(res->port_id,
8001 RTE_ETH_FILTER_TUNNEL,
8002 RTE_ETH_FILTER_DELETE,
8003 &tunnel_filter_conf);
8005 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8009 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8011 cmd, "tunnel_filter");
8012 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8015 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8018 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8019 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8021 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8022 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8024 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8025 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8026 inner_vlan, UINT16);
8027 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8028 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8030 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8031 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8032 tunnel_type, "vxlan#nvgre#ipingre");
8034 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8036 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8037 "imac#omac-imac-tenid");
8038 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8039 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8041 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8042 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8045 cmdline_parse_inst_t cmd_tunnel_filter = {
8046 .f = cmd_tunnel_filter_parsed,
8048 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8049 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8050 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8051 "<queue_id>: Add/Rm tunnel filter of a port",
8053 (void *)&cmd_tunnel_filter_cmd,
8054 (void *)&cmd_tunnel_filter_what,
8055 (void *)&cmd_tunnel_filter_port_id,
8056 (void *)&cmd_tunnel_filter_outer_mac,
8057 (void *)&cmd_tunnel_filter_inner_mac,
8058 (void *)&cmd_tunnel_filter_ip_value,
8059 (void *)&cmd_tunnel_filter_innner_vlan,
8060 (void *)&cmd_tunnel_filter_tunnel_type,
8061 (void *)&cmd_tunnel_filter_filter_type,
8062 (void *)&cmd_tunnel_filter_tenant_id,
8063 (void *)&cmd_tunnel_filter_queue_num,
8068 /* *** CONFIGURE TUNNEL UDP PORT *** */
8069 struct cmd_tunnel_udp_config {
8070 cmdline_fixed_string_t cmd;
8071 cmdline_fixed_string_t what;
8077 cmd_tunnel_udp_config_parsed(void *parsed_result,
8078 __attribute__((unused)) struct cmdline *cl,
8079 __attribute__((unused)) void *data)
8081 struct cmd_tunnel_udp_config *res = parsed_result;
8082 struct rte_eth_udp_tunnel tunnel_udp;
8085 tunnel_udp.udp_port = res->udp_port;
8087 if (!strcmp(res->cmd, "rx_vxlan_port"))
8088 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8090 if (!strcmp(res->what, "add"))
8091 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8094 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8098 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8101 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8102 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8103 cmd, "rx_vxlan_port");
8104 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8107 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8108 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8110 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8111 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8114 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8115 .f = cmd_tunnel_udp_config_parsed,
8117 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8118 "Add/Remove a tunneling UDP port filter",
8120 (void *)&cmd_tunnel_udp_config_cmd,
8121 (void *)&cmd_tunnel_udp_config_what,
8122 (void *)&cmd_tunnel_udp_config_udp_port,
8123 (void *)&cmd_tunnel_udp_config_port_id,
8128 /* *** GLOBAL CONFIG *** */
8129 struct cmd_global_config_result {
8130 cmdline_fixed_string_t cmd;
8132 cmdline_fixed_string_t cfg_type;
8137 cmd_global_config_parsed(void *parsed_result,
8138 __attribute__((unused)) struct cmdline *cl,
8139 __attribute__((unused)) void *data)
8141 struct cmd_global_config_result *res = parsed_result;
8142 struct rte_eth_global_cfg conf;
8145 memset(&conf, 0, sizeof(conf));
8146 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8147 conf.cfg.gre_key_len = res->len;
8148 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8149 RTE_ETH_FILTER_SET, &conf);
8151 printf("Global config error\n");
8154 cmdline_parse_token_string_t cmd_global_config_cmd =
8155 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8157 cmdline_parse_token_num_t cmd_global_config_port_id =
8158 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8160 cmdline_parse_token_string_t cmd_global_config_type =
8161 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8162 cfg_type, "gre-key-len");
8163 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8164 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8167 cmdline_parse_inst_t cmd_global_config = {
8168 .f = cmd_global_config_parsed,
8169 .data = (void *)NULL,
8170 .help_str = "global_config <port_id> gre-key-len <key_len>",
8172 (void *)&cmd_global_config_cmd,
8173 (void *)&cmd_global_config_port_id,
8174 (void *)&cmd_global_config_type,
8175 (void *)&cmd_global_config_gre_key_len,
8180 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8181 struct cmd_set_mirror_mask_result {
8182 cmdline_fixed_string_t set;
8183 cmdline_fixed_string_t port;
8185 cmdline_fixed_string_t mirror;
8187 cmdline_fixed_string_t what;
8188 cmdline_fixed_string_t value;
8189 cmdline_fixed_string_t dstpool;
8191 cmdline_fixed_string_t on;
8194 cmdline_parse_token_string_t cmd_mirror_mask_set =
8195 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8197 cmdline_parse_token_string_t cmd_mirror_mask_port =
8198 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8200 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8201 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8203 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8205 mirror, "mirror-rule");
8206 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8207 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8209 cmdline_parse_token_string_t cmd_mirror_mask_what =
8210 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8211 what, "pool-mirror-up#pool-mirror-down"
8213 cmdline_parse_token_string_t cmd_mirror_mask_value =
8214 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8216 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8217 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8218 dstpool, "dst-pool");
8219 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8220 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8222 cmdline_parse_token_string_t cmd_mirror_mask_on =
8223 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8227 cmd_set_mirror_mask_parsed(void *parsed_result,
8228 __attribute__((unused)) struct cmdline *cl,
8229 __attribute__((unused)) void *data)
8232 struct cmd_set_mirror_mask_result *res = parsed_result;
8233 struct rte_eth_mirror_conf mr_conf;
8235 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8237 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8239 mr_conf.dst_pool = res->dstpool_id;
8241 if (!strcmp(res->what, "pool-mirror-up")) {
8242 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8243 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8244 } else if (!strcmp(res->what, "pool-mirror-down")) {
8245 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8246 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8247 } else if (!strcmp(res->what, "vlan-mirror")) {
8248 mr_conf.rule_type = ETH_MIRROR_VLAN;
8249 nb_item = parse_item_list(res->value, "vlan",
8250 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8254 for (i = 0; i < nb_item; i++) {
8255 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8256 printf("Invalid vlan_id: must be < 4096\n");
8260 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8261 mr_conf.vlan.vlan_mask |= 1ULL << i;
8265 if (!strcmp(res->on, "on"))
8266 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8269 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8272 printf("mirror rule add error: (%s)\n", strerror(-ret));
8275 cmdline_parse_inst_t cmd_set_mirror_mask = {
8276 .f = cmd_set_mirror_mask_parsed,
8278 .help_str = "set port <port_id> mirror-rule <rule_id> "
8279 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8280 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8282 (void *)&cmd_mirror_mask_set,
8283 (void *)&cmd_mirror_mask_port,
8284 (void *)&cmd_mirror_mask_portid,
8285 (void *)&cmd_mirror_mask_mirror,
8286 (void *)&cmd_mirror_mask_ruleid,
8287 (void *)&cmd_mirror_mask_what,
8288 (void *)&cmd_mirror_mask_value,
8289 (void *)&cmd_mirror_mask_dstpool,
8290 (void *)&cmd_mirror_mask_poolid,
8291 (void *)&cmd_mirror_mask_on,
8296 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8297 struct cmd_set_mirror_link_result {
8298 cmdline_fixed_string_t set;
8299 cmdline_fixed_string_t port;
8301 cmdline_fixed_string_t mirror;
8303 cmdline_fixed_string_t what;
8304 cmdline_fixed_string_t dstpool;
8306 cmdline_fixed_string_t on;
8309 cmdline_parse_token_string_t cmd_mirror_link_set =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8312 cmdline_parse_token_string_t cmd_mirror_link_port =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8315 cmdline_parse_token_num_t cmd_mirror_link_portid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8318 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8320 mirror, "mirror-rule");
8321 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8322 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8324 cmdline_parse_token_string_t cmd_mirror_link_what =
8325 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8326 what, "uplink-mirror#downlink-mirror");
8327 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8329 dstpool, "dst-pool");
8330 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8331 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8333 cmdline_parse_token_string_t cmd_mirror_link_on =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8338 cmd_set_mirror_link_parsed(void *parsed_result,
8339 __attribute__((unused)) struct cmdline *cl,
8340 __attribute__((unused)) void *data)
8343 struct cmd_set_mirror_link_result *res = parsed_result;
8344 struct rte_eth_mirror_conf mr_conf;
8346 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8347 if (!strcmp(res->what, "uplink-mirror"))
8348 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8350 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8352 mr_conf.dst_pool = res->dstpool_id;
8354 if (!strcmp(res->on, "on"))
8355 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8358 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8361 /* check the return value and print it if is < 0 */
8363 printf("mirror rule add error: (%s)\n", strerror(-ret));
8367 cmdline_parse_inst_t cmd_set_mirror_link = {
8368 .f = cmd_set_mirror_link_parsed,
8370 .help_str = "set port <port_id> mirror-rule <rule_id> "
8371 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8373 (void *)&cmd_mirror_link_set,
8374 (void *)&cmd_mirror_link_port,
8375 (void *)&cmd_mirror_link_portid,
8376 (void *)&cmd_mirror_link_mirror,
8377 (void *)&cmd_mirror_link_ruleid,
8378 (void *)&cmd_mirror_link_what,
8379 (void *)&cmd_mirror_link_dstpool,
8380 (void *)&cmd_mirror_link_poolid,
8381 (void *)&cmd_mirror_link_on,
8386 /* *** RESET VM MIRROR RULE *** */
8387 struct cmd_rm_mirror_rule_result {
8388 cmdline_fixed_string_t reset;
8389 cmdline_fixed_string_t port;
8391 cmdline_fixed_string_t mirror;
8395 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8396 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8398 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8399 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8401 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8402 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8404 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8405 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8406 mirror, "mirror-rule");
8407 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8408 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8412 cmd_reset_mirror_rule_parsed(void *parsed_result,
8413 __attribute__((unused)) struct cmdline *cl,
8414 __attribute__((unused)) void *data)
8417 struct cmd_set_mirror_link_result *res = parsed_result;
8419 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8421 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8424 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8425 .f = cmd_reset_mirror_rule_parsed,
8427 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8429 (void *)&cmd_rm_mirror_rule_reset,
8430 (void *)&cmd_rm_mirror_rule_port,
8431 (void *)&cmd_rm_mirror_rule_portid,
8432 (void *)&cmd_rm_mirror_rule_mirror,
8433 (void *)&cmd_rm_mirror_rule_ruleid,
8438 /* ******************************************************************************** */
8440 struct cmd_dump_result {
8441 cmdline_fixed_string_t dump;
8445 dump_struct_sizes(void)
8447 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8448 DUMP_SIZE(struct rte_mbuf);
8449 DUMP_SIZE(struct rte_mempool);
8450 DUMP_SIZE(struct rte_ring);
8454 static void cmd_dump_parsed(void *parsed_result,
8455 __attribute__((unused)) struct cmdline *cl,
8456 __attribute__((unused)) void *data)
8458 struct cmd_dump_result *res = parsed_result;
8460 if (!strcmp(res->dump, "dump_physmem"))
8461 rte_dump_physmem_layout(stdout);
8462 else if (!strcmp(res->dump, "dump_memzone"))
8463 rte_memzone_dump(stdout);
8464 else if (!strcmp(res->dump, "dump_struct_sizes"))
8465 dump_struct_sizes();
8466 else if (!strcmp(res->dump, "dump_ring"))
8467 rte_ring_list_dump(stdout);
8468 else if (!strcmp(res->dump, "dump_mempool"))
8469 rte_mempool_list_dump(stdout);
8470 else if (!strcmp(res->dump, "dump_devargs"))
8471 rte_eal_devargs_dump(stdout);
8472 else if (!strcmp(res->dump, "dump_log_types"))
8473 rte_log_dump(stdout);
8476 cmdline_parse_token_string_t cmd_dump_dump =
8477 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8480 "dump_struct_sizes#"
8486 cmdline_parse_inst_t cmd_dump = {
8487 .f = cmd_dump_parsed, /* function to call */
8488 .data = NULL, /* 2nd arg of func */
8489 .help_str = "Dump status",
8490 .tokens = { /* token list, NULL terminated */
8491 (void *)&cmd_dump_dump,
8496 /* ******************************************************************************** */
8498 struct cmd_dump_one_result {
8499 cmdline_fixed_string_t dump;
8500 cmdline_fixed_string_t name;
8503 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8504 __attribute__((unused)) void *data)
8506 struct cmd_dump_one_result *res = parsed_result;
8508 if (!strcmp(res->dump, "dump_ring")) {
8510 r = rte_ring_lookup(res->name);
8512 cmdline_printf(cl, "Cannot find ring\n");
8515 rte_ring_dump(stdout, r);
8516 } else if (!strcmp(res->dump, "dump_mempool")) {
8517 struct rte_mempool *mp;
8518 mp = rte_mempool_lookup(res->name);
8520 cmdline_printf(cl, "Cannot find mempool\n");
8523 rte_mempool_dump(stdout, mp);
8527 cmdline_parse_token_string_t cmd_dump_one_dump =
8528 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8529 "dump_ring#dump_mempool");
8531 cmdline_parse_token_string_t cmd_dump_one_name =
8532 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8534 cmdline_parse_inst_t cmd_dump_one = {
8535 .f = cmd_dump_one_parsed, /* function to call */
8536 .data = NULL, /* 2nd arg of func */
8537 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8538 .tokens = { /* token list, NULL terminated */
8539 (void *)&cmd_dump_one_dump,
8540 (void *)&cmd_dump_one_name,
8545 /* *** Add/Del syn filter *** */
8546 struct cmd_syn_filter_result {
8547 cmdline_fixed_string_t filter;
8549 cmdline_fixed_string_t ops;
8550 cmdline_fixed_string_t priority;
8551 cmdline_fixed_string_t high;
8552 cmdline_fixed_string_t queue;
8557 cmd_syn_filter_parsed(void *parsed_result,
8558 __attribute__((unused)) struct cmdline *cl,
8559 __attribute__((unused)) void *data)
8561 struct cmd_syn_filter_result *res = parsed_result;
8562 struct rte_eth_syn_filter syn_filter;
8565 ret = rte_eth_dev_filter_supported(res->port_id,
8566 RTE_ETH_FILTER_SYN);
8568 printf("syn filter is not supported on port %u.\n",
8573 memset(&syn_filter, 0, sizeof(syn_filter));
8575 if (!strcmp(res->ops, "add")) {
8576 if (!strcmp(res->high, "high"))
8577 syn_filter.hig_pri = 1;
8579 syn_filter.hig_pri = 0;
8581 syn_filter.queue = res->queue_id;
8582 ret = rte_eth_dev_filter_ctrl(res->port_id,
8587 ret = rte_eth_dev_filter_ctrl(res->port_id,
8589 RTE_ETH_FILTER_DELETE,
8593 printf("syn filter programming error: (%s)\n",
8597 cmdline_parse_token_string_t cmd_syn_filter_filter =
8598 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8599 filter, "syn_filter");
8600 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8601 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8603 cmdline_parse_token_string_t cmd_syn_filter_ops =
8604 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8606 cmdline_parse_token_string_t cmd_syn_filter_priority =
8607 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8608 priority, "priority");
8609 cmdline_parse_token_string_t cmd_syn_filter_high =
8610 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8612 cmdline_parse_token_string_t cmd_syn_filter_queue =
8613 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8615 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8616 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8619 cmdline_parse_inst_t cmd_syn_filter = {
8620 .f = cmd_syn_filter_parsed,
8622 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8623 "<queue_id>: Add/Delete syn filter",
8625 (void *)&cmd_syn_filter_filter,
8626 (void *)&cmd_syn_filter_port_id,
8627 (void *)&cmd_syn_filter_ops,
8628 (void *)&cmd_syn_filter_priority,
8629 (void *)&cmd_syn_filter_high,
8630 (void *)&cmd_syn_filter_queue,
8631 (void *)&cmd_syn_filter_queue_id,
8636 /* *** queue region set *** */
8637 struct cmd_queue_region_result {
8638 cmdline_fixed_string_t set;
8639 cmdline_fixed_string_t port;
8641 cmdline_fixed_string_t cmd;
8642 cmdline_fixed_string_t region;
8644 cmdline_fixed_string_t queue_start_index;
8646 cmdline_fixed_string_t queue_num;
8647 uint8_t queue_num_value;
8651 cmd_queue_region_parsed(void *parsed_result,
8652 __attribute__((unused)) struct cmdline *cl,
8653 __attribute__((unused)) void *data)
8655 struct cmd_queue_region_result *res = parsed_result;
8657 #ifdef RTE_LIBRTE_I40E_PMD
8658 struct rte_pmd_i40e_queue_region_conf region_conf;
8659 enum rte_pmd_i40e_queue_region_op op_type;
8662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8665 #ifdef RTE_LIBRTE_I40E_PMD
8666 memset(®ion_conf, 0, sizeof(region_conf));
8667 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8668 region_conf.region_id = res->region_id;
8669 region_conf.queue_num = res->queue_num_value;
8670 region_conf.queue_start_index = res->queue_id;
8672 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8673 op_type, ®ion_conf);
8680 printf("function not implemented or supported\n");
8683 printf("queue region config error: (%s)\n", strerror(-ret));
8687 cmdline_parse_token_string_t cmd_queue_region_set =
8688 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8690 cmdline_parse_token_string_t cmd_queue_region_port =
8691 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8692 cmdline_parse_token_num_t cmd_queue_region_port_id =
8693 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8695 cmdline_parse_token_string_t cmd_queue_region_cmd =
8696 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8697 cmd, "queue-region");
8698 cmdline_parse_token_string_t cmd_queue_region_id =
8699 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8700 region, "region_id");
8701 cmdline_parse_token_num_t cmd_queue_region_index =
8702 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8704 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8706 queue_start_index, "queue_start_index");
8707 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8708 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8710 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8711 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8712 queue_num, "queue_num");
8713 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8714 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8715 queue_num_value, UINT8);
8717 cmdline_parse_inst_t cmd_queue_region = {
8718 .f = cmd_queue_region_parsed,
8720 .help_str = "set port <port_id> queue-region region_id <value> "
8721 "queue_start_index <value> queue_num <value>: Set a queue region",
8723 (void *)&cmd_queue_region_set,
8724 (void *)&cmd_queue_region_port,
8725 (void *)&cmd_queue_region_port_id,
8726 (void *)&cmd_queue_region_cmd,
8727 (void *)&cmd_queue_region_id,
8728 (void *)&cmd_queue_region_index,
8729 (void *)&cmd_queue_region_queue_start_index,
8730 (void *)&cmd_queue_region_queue_id,
8731 (void *)&cmd_queue_region_queue_num,
8732 (void *)&cmd_queue_region_queue_num_value,
8737 /* *** queue region and flowtype set *** */
8738 struct cmd_region_flowtype_result {
8739 cmdline_fixed_string_t set;
8740 cmdline_fixed_string_t port;
8742 cmdline_fixed_string_t cmd;
8743 cmdline_fixed_string_t region;
8745 cmdline_fixed_string_t flowtype;
8746 uint8_t flowtype_id;
8750 cmd_region_flowtype_parsed(void *parsed_result,
8751 __attribute__((unused)) struct cmdline *cl,
8752 __attribute__((unused)) void *data)
8754 struct cmd_region_flowtype_result *res = parsed_result;
8756 #ifdef RTE_LIBRTE_I40E_PMD
8757 struct rte_pmd_i40e_queue_region_conf region_conf;
8758 enum rte_pmd_i40e_queue_region_op op_type;
8761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8764 #ifdef RTE_LIBRTE_I40E_PMD
8765 memset(®ion_conf, 0, sizeof(region_conf));
8767 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8768 region_conf.region_id = res->region_id;
8769 region_conf.hw_flowtype = res->flowtype_id;
8771 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8772 op_type, ®ion_conf);
8779 printf("function not implemented or supported\n");
8782 printf("region flowtype config error: (%s)\n", strerror(-ret));
8786 cmdline_parse_token_string_t cmd_region_flowtype_set =
8787 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8789 cmdline_parse_token_string_t cmd_region_flowtype_port =
8790 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8792 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8793 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8795 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8796 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8797 cmd, "queue-region");
8798 cmdline_parse_token_string_t cmd_region_flowtype_index =
8799 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8800 region, "region_id");
8801 cmdline_parse_token_num_t cmd_region_flowtype_id =
8802 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8804 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8805 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8806 flowtype, "flowtype");
8807 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8808 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8809 flowtype_id, UINT8);
8810 cmdline_parse_inst_t cmd_region_flowtype = {
8811 .f = cmd_region_flowtype_parsed,
8813 .help_str = "set port <port_id> queue-region region_id <value> "
8814 "flowtype <value>: Set a flowtype region index",
8816 (void *)&cmd_region_flowtype_set,
8817 (void *)&cmd_region_flowtype_port,
8818 (void *)&cmd_region_flowtype_port_index,
8819 (void *)&cmd_region_flowtype_cmd,
8820 (void *)&cmd_region_flowtype_index,
8821 (void *)&cmd_region_flowtype_id,
8822 (void *)&cmd_region_flowtype_flow_index,
8823 (void *)&cmd_region_flowtype_flow_id,
8828 /* *** User Priority (UP) to queue region (region_id) set *** */
8829 struct cmd_user_priority_region_result {
8830 cmdline_fixed_string_t set;
8831 cmdline_fixed_string_t port;
8833 cmdline_fixed_string_t cmd;
8834 cmdline_fixed_string_t user_priority;
8835 uint8_t user_priority_id;
8836 cmdline_fixed_string_t region;
8841 cmd_user_priority_region_parsed(void *parsed_result,
8842 __attribute__((unused)) struct cmdline *cl,
8843 __attribute__((unused)) void *data)
8845 struct cmd_user_priority_region_result *res = parsed_result;
8847 #ifdef RTE_LIBRTE_I40E_PMD
8848 struct rte_pmd_i40e_queue_region_conf region_conf;
8849 enum rte_pmd_i40e_queue_region_op op_type;
8852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8855 #ifdef RTE_LIBRTE_I40E_PMD
8856 memset(®ion_conf, 0, sizeof(region_conf));
8857 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8858 region_conf.user_priority = res->user_priority_id;
8859 region_conf.region_id = res->region_id;
8861 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8862 op_type, ®ion_conf);
8869 printf("function not implemented or supported\n");
8872 printf("user_priority region config error: (%s)\n",
8877 cmdline_parse_token_string_t cmd_user_priority_region_set =
8878 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8880 cmdline_parse_token_string_t cmd_user_priority_region_port =
8881 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8883 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8884 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8886 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8887 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8888 cmd, "queue-region");
8889 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8890 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8891 user_priority, "UP");
8892 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8893 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8894 user_priority_id, UINT8);
8895 cmdline_parse_token_string_t cmd_user_priority_region_region =
8896 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8897 region, "region_id");
8898 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8899 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8902 cmdline_parse_inst_t cmd_user_priority_region = {
8903 .f = cmd_user_priority_region_parsed,
8905 .help_str = "set port <port_id> queue-region UP <value> "
8906 "region_id <value>: Set the mapping of User Priority (UP) "
8907 "to queue region (region_id) ",
8909 (void *)&cmd_user_priority_region_set,
8910 (void *)&cmd_user_priority_region_port,
8911 (void *)&cmd_user_priority_region_port_index,
8912 (void *)&cmd_user_priority_region_cmd,
8913 (void *)&cmd_user_priority_region_UP,
8914 (void *)&cmd_user_priority_region_UP_id,
8915 (void *)&cmd_user_priority_region_region,
8916 (void *)&cmd_user_priority_region_region_id,
8921 /* *** flush all queue region related configuration *** */
8922 struct cmd_flush_queue_region_result {
8923 cmdline_fixed_string_t set;
8924 cmdline_fixed_string_t port;
8926 cmdline_fixed_string_t cmd;
8927 cmdline_fixed_string_t flush;
8928 cmdline_fixed_string_t what;
8932 cmd_flush_queue_region_parsed(void *parsed_result,
8933 __attribute__((unused)) struct cmdline *cl,
8934 __attribute__((unused)) void *data)
8936 struct cmd_flush_queue_region_result *res = parsed_result;
8938 #ifdef RTE_LIBRTE_I40E_PMD
8939 struct rte_pmd_i40e_queue_region_conf region_conf;
8940 enum rte_pmd_i40e_queue_region_op op_type;
8943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8946 #ifdef RTE_LIBRTE_I40E_PMD
8947 memset(®ion_conf, 0, sizeof(region_conf));
8949 if (strcmp(res->what, "on") == 0)
8950 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8952 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8954 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8955 op_type, ®ion_conf);
8962 printf("function not implemented or supported\n");
8965 printf("queue region config flush error: (%s)\n",
8970 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8971 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8973 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8974 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8976 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8977 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8979 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8980 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8981 cmd, "queue-region");
8982 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8983 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8985 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8986 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8989 cmdline_parse_inst_t cmd_flush_queue_region = {
8990 .f = cmd_flush_queue_region_parsed,
8992 .help_str = "set port <port_id> queue-region flush on|off"
8993 ": flush all queue region related configuration",
8995 (void *)&cmd_flush_queue_region_set,
8996 (void *)&cmd_flush_queue_region_port,
8997 (void *)&cmd_flush_queue_region_port_index,
8998 (void *)&cmd_flush_queue_region_cmd,
8999 (void *)&cmd_flush_queue_region_flush,
9000 (void *)&cmd_flush_queue_region_what,
9005 /* *** get all queue region related configuration info *** */
9006 struct cmd_show_queue_region_info {
9007 cmdline_fixed_string_t show;
9008 cmdline_fixed_string_t port;
9010 cmdline_fixed_string_t cmd;
9014 cmd_show_queue_region_info_parsed(void *parsed_result,
9015 __attribute__((unused)) struct cmdline *cl,
9016 __attribute__((unused)) void *data)
9018 struct cmd_show_queue_region_info *res = parsed_result;
9020 #ifdef RTE_LIBRTE_I40E_PMD
9021 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9022 enum rte_pmd_i40e_queue_region_op op_type;
9025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9028 #ifdef RTE_LIBRTE_I40E_PMD
9029 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9031 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9033 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9034 op_type, &rte_pmd_regions);
9036 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9043 printf("function not implemented or supported\n");
9046 printf("queue region config info show error: (%s)\n",
9051 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9052 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9054 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9055 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9057 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9058 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9060 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9061 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9062 cmd, "queue-region");
9064 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9065 .f = cmd_show_queue_region_info_parsed,
9067 .help_str = "show port <port_id> queue-region"
9068 ": show all queue region related configuration info",
9070 (void *)&cmd_show_queue_region_info_get,
9071 (void *)&cmd_show_queue_region_info_port,
9072 (void *)&cmd_show_queue_region_info_port_index,
9073 (void *)&cmd_show_queue_region_info_cmd,
9078 /* *** ADD/REMOVE A 2tuple FILTER *** */
9079 struct cmd_2tuple_filter_result {
9080 cmdline_fixed_string_t filter;
9082 cmdline_fixed_string_t ops;
9083 cmdline_fixed_string_t dst_port;
9084 uint16_t dst_port_value;
9085 cmdline_fixed_string_t protocol;
9086 uint8_t protocol_value;
9087 cmdline_fixed_string_t mask;
9089 cmdline_fixed_string_t tcp_flags;
9090 uint8_t tcp_flags_value;
9091 cmdline_fixed_string_t priority;
9092 uint8_t priority_value;
9093 cmdline_fixed_string_t queue;
9098 cmd_2tuple_filter_parsed(void *parsed_result,
9099 __attribute__((unused)) struct cmdline *cl,
9100 __attribute__((unused)) void *data)
9102 struct rte_eth_ntuple_filter filter;
9103 struct cmd_2tuple_filter_result *res = parsed_result;
9106 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9108 printf("ntuple filter is not supported on port %u.\n",
9113 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9115 filter.flags = RTE_2TUPLE_FLAGS;
9116 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9117 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9118 filter.proto = res->protocol_value;
9119 filter.priority = res->priority_value;
9120 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9121 printf("nonzero tcp_flags is only meaningful"
9122 " when protocol is TCP.\n");
9125 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9126 printf("invalid TCP flags.\n");
9130 if (res->tcp_flags_value != 0) {
9131 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9132 filter.tcp_flags = res->tcp_flags_value;
9135 /* need convert to big endian. */
9136 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9137 filter.queue = res->queue_id;
9139 if (!strcmp(res->ops, "add"))
9140 ret = rte_eth_dev_filter_ctrl(res->port_id,
9141 RTE_ETH_FILTER_NTUPLE,
9145 ret = rte_eth_dev_filter_ctrl(res->port_id,
9146 RTE_ETH_FILTER_NTUPLE,
9147 RTE_ETH_FILTER_DELETE,
9150 printf("2tuple filter programming error: (%s)\n",
9155 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9156 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9157 filter, "2tuple_filter");
9158 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9159 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9161 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9162 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9164 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9165 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9166 dst_port, "dst_port");
9167 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9168 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9169 dst_port_value, UINT16);
9170 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9171 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9172 protocol, "protocol");
9173 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9174 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9175 protocol_value, UINT8);
9176 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9177 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9179 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9180 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9182 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9183 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9184 tcp_flags, "tcp_flags");
9185 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9186 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9187 tcp_flags_value, UINT8);
9188 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9189 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9190 priority, "priority");
9191 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9192 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9193 priority_value, UINT8);
9194 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9195 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9197 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9198 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9201 cmdline_parse_inst_t cmd_2tuple_filter = {
9202 .f = cmd_2tuple_filter_parsed,
9204 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9205 "<value> mask <value> tcp_flags <value> priority <value> queue "
9206 "<queue_id>: Add a 2tuple filter",
9208 (void *)&cmd_2tuple_filter_filter,
9209 (void *)&cmd_2tuple_filter_port_id,
9210 (void *)&cmd_2tuple_filter_ops,
9211 (void *)&cmd_2tuple_filter_dst_port,
9212 (void *)&cmd_2tuple_filter_dst_port_value,
9213 (void *)&cmd_2tuple_filter_protocol,
9214 (void *)&cmd_2tuple_filter_protocol_value,
9215 (void *)&cmd_2tuple_filter_mask,
9216 (void *)&cmd_2tuple_filter_mask_value,
9217 (void *)&cmd_2tuple_filter_tcp_flags,
9218 (void *)&cmd_2tuple_filter_tcp_flags_value,
9219 (void *)&cmd_2tuple_filter_priority,
9220 (void *)&cmd_2tuple_filter_priority_value,
9221 (void *)&cmd_2tuple_filter_queue,
9222 (void *)&cmd_2tuple_filter_queue_id,
9227 /* *** ADD/REMOVE A 5tuple FILTER *** */
9228 struct cmd_5tuple_filter_result {
9229 cmdline_fixed_string_t filter;
9231 cmdline_fixed_string_t ops;
9232 cmdline_fixed_string_t dst_ip;
9233 cmdline_ipaddr_t dst_ip_value;
9234 cmdline_fixed_string_t src_ip;
9235 cmdline_ipaddr_t src_ip_value;
9236 cmdline_fixed_string_t dst_port;
9237 uint16_t dst_port_value;
9238 cmdline_fixed_string_t src_port;
9239 uint16_t src_port_value;
9240 cmdline_fixed_string_t protocol;
9241 uint8_t protocol_value;
9242 cmdline_fixed_string_t mask;
9244 cmdline_fixed_string_t tcp_flags;
9245 uint8_t tcp_flags_value;
9246 cmdline_fixed_string_t priority;
9247 uint8_t priority_value;
9248 cmdline_fixed_string_t queue;
9253 cmd_5tuple_filter_parsed(void *parsed_result,
9254 __attribute__((unused)) struct cmdline *cl,
9255 __attribute__((unused)) void *data)
9257 struct rte_eth_ntuple_filter filter;
9258 struct cmd_5tuple_filter_result *res = parsed_result;
9261 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9263 printf("ntuple filter is not supported on port %u.\n",
9268 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9270 filter.flags = RTE_5TUPLE_FLAGS;
9271 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9272 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9273 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9274 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9275 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9276 filter.proto = res->protocol_value;
9277 filter.priority = res->priority_value;
9278 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9279 printf("nonzero tcp_flags is only meaningful"
9280 " when protocol is TCP.\n");
9283 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9284 printf("invalid TCP flags.\n");
9288 if (res->tcp_flags_value != 0) {
9289 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9290 filter.tcp_flags = res->tcp_flags_value;
9293 if (res->dst_ip_value.family == AF_INET)
9294 /* no need to convert, already big endian. */
9295 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9297 if (filter.dst_ip_mask == 0) {
9298 printf("can not support ipv6 involved compare.\n");
9304 if (res->src_ip_value.family == AF_INET)
9305 /* no need to convert, already big endian. */
9306 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9308 if (filter.src_ip_mask == 0) {
9309 printf("can not support ipv6 involved compare.\n");
9314 /* need convert to big endian. */
9315 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9316 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9317 filter.queue = res->queue_id;
9319 if (!strcmp(res->ops, "add"))
9320 ret = rte_eth_dev_filter_ctrl(res->port_id,
9321 RTE_ETH_FILTER_NTUPLE,
9325 ret = rte_eth_dev_filter_ctrl(res->port_id,
9326 RTE_ETH_FILTER_NTUPLE,
9327 RTE_ETH_FILTER_DELETE,
9330 printf("5tuple filter programming error: (%s)\n",
9334 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9335 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9336 filter, "5tuple_filter");
9337 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9338 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9340 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9341 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9343 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9344 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9346 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9347 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9349 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9350 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9352 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9353 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9355 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9356 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9357 dst_port, "dst_port");
9358 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9359 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9360 dst_port_value, UINT16);
9361 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9362 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9363 src_port, "src_port");
9364 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9365 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9366 src_port_value, UINT16);
9367 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9368 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9369 protocol, "protocol");
9370 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9371 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9372 protocol_value, UINT8);
9373 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9374 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9376 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9377 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9379 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9380 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9381 tcp_flags, "tcp_flags");
9382 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9383 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9384 tcp_flags_value, UINT8);
9385 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9386 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9387 priority, "priority");
9388 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9389 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9390 priority_value, UINT8);
9391 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9392 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9394 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9395 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9398 cmdline_parse_inst_t cmd_5tuple_filter = {
9399 .f = cmd_5tuple_filter_parsed,
9401 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9402 "src_ip <value> dst_port <value> src_port <value> "
9403 "protocol <value> mask <value> tcp_flags <value> "
9404 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9406 (void *)&cmd_5tuple_filter_filter,
9407 (void *)&cmd_5tuple_filter_port_id,
9408 (void *)&cmd_5tuple_filter_ops,
9409 (void *)&cmd_5tuple_filter_dst_ip,
9410 (void *)&cmd_5tuple_filter_dst_ip_value,
9411 (void *)&cmd_5tuple_filter_src_ip,
9412 (void *)&cmd_5tuple_filter_src_ip_value,
9413 (void *)&cmd_5tuple_filter_dst_port,
9414 (void *)&cmd_5tuple_filter_dst_port_value,
9415 (void *)&cmd_5tuple_filter_src_port,
9416 (void *)&cmd_5tuple_filter_src_port_value,
9417 (void *)&cmd_5tuple_filter_protocol,
9418 (void *)&cmd_5tuple_filter_protocol_value,
9419 (void *)&cmd_5tuple_filter_mask,
9420 (void *)&cmd_5tuple_filter_mask_value,
9421 (void *)&cmd_5tuple_filter_tcp_flags,
9422 (void *)&cmd_5tuple_filter_tcp_flags_value,
9423 (void *)&cmd_5tuple_filter_priority,
9424 (void *)&cmd_5tuple_filter_priority_value,
9425 (void *)&cmd_5tuple_filter_queue,
9426 (void *)&cmd_5tuple_filter_queue_id,
9431 /* *** ADD/REMOVE A flex FILTER *** */
9432 struct cmd_flex_filter_result {
9433 cmdline_fixed_string_t filter;
9434 cmdline_fixed_string_t ops;
9436 cmdline_fixed_string_t len;
9438 cmdline_fixed_string_t bytes;
9439 cmdline_fixed_string_t bytes_value;
9440 cmdline_fixed_string_t mask;
9441 cmdline_fixed_string_t mask_value;
9442 cmdline_fixed_string_t priority;
9443 uint8_t priority_value;
9444 cmdline_fixed_string_t queue;
9448 static int xdigit2val(unsigned char c)
9453 else if (isupper(c))
9461 cmd_flex_filter_parsed(void *parsed_result,
9462 __attribute__((unused)) struct cmdline *cl,
9463 __attribute__((unused)) void *data)
9466 struct rte_eth_flex_filter filter;
9467 struct cmd_flex_filter_result *res = parsed_result;
9468 char *bytes_ptr, *mask_ptr;
9469 uint16_t len, i, j = 0;
9474 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9475 printf("the len exceed the max length 128\n");
9478 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9479 filter.len = res->len_value;
9480 filter.priority = res->priority_value;
9481 filter.queue = res->queue_id;
9482 bytes_ptr = res->bytes_value;
9483 mask_ptr = res->mask_value;
9485 /* translate bytes string to array. */
9486 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9487 (bytes_ptr[1] == 'X')))
9489 len = strnlen(bytes_ptr, res->len_value * 2);
9490 if (len == 0 || (len % 8 != 0)) {
9491 printf("please check len and bytes input\n");
9494 for (i = 0; i < len; i++) {
9496 if (isxdigit(c) == 0) {
9497 /* invalid characters. */
9498 printf("invalid input\n");
9501 val = xdigit2val(c);
9504 filter.bytes[j] = byte;
9505 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9512 /* translate mask string to uint8_t array. */
9513 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9514 (mask_ptr[1] == 'X')))
9516 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9518 printf("invalid input\n");
9523 for (i = 0; i < len; i++) {
9525 if (isxdigit(c) == 0) {
9526 /* invalid characters. */
9527 printf("invalid input\n");
9530 val = xdigit2val(c);
9533 filter.mask[j] = byte;
9534 printf("mask[%d]:%02x ", j, filter.mask[j]);
9542 if (!strcmp(res->ops, "add"))
9543 ret = rte_eth_dev_filter_ctrl(res->port_id,
9544 RTE_ETH_FILTER_FLEXIBLE,
9548 ret = rte_eth_dev_filter_ctrl(res->port_id,
9549 RTE_ETH_FILTER_FLEXIBLE,
9550 RTE_ETH_FILTER_DELETE,
9554 printf("flex filter setting error: (%s)\n", strerror(-ret));
9557 cmdline_parse_token_string_t cmd_flex_filter_filter =
9558 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9559 filter, "flex_filter");
9560 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9561 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9563 cmdline_parse_token_string_t cmd_flex_filter_ops =
9564 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9566 cmdline_parse_token_string_t cmd_flex_filter_len =
9567 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9569 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9570 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9572 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9573 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9575 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9576 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9578 cmdline_parse_token_string_t cmd_flex_filter_mask =
9579 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9581 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9582 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9584 cmdline_parse_token_string_t cmd_flex_filter_priority =
9585 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9586 priority, "priority");
9587 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9588 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9589 priority_value, UINT8);
9590 cmdline_parse_token_string_t cmd_flex_filter_queue =
9591 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9593 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9596 cmdline_parse_inst_t cmd_flex_filter = {
9597 .f = cmd_flex_filter_parsed,
9599 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9600 "<value> mask <value> priority <value> queue <queue_id>: "
9601 "Add/Del a flex filter",
9603 (void *)&cmd_flex_filter_filter,
9604 (void *)&cmd_flex_filter_port_id,
9605 (void *)&cmd_flex_filter_ops,
9606 (void *)&cmd_flex_filter_len,
9607 (void *)&cmd_flex_filter_len_value,
9608 (void *)&cmd_flex_filter_bytes,
9609 (void *)&cmd_flex_filter_bytes_value,
9610 (void *)&cmd_flex_filter_mask,
9611 (void *)&cmd_flex_filter_mask_value,
9612 (void *)&cmd_flex_filter_priority,
9613 (void *)&cmd_flex_filter_priority_value,
9614 (void *)&cmd_flex_filter_queue,
9615 (void *)&cmd_flex_filter_queue_id,
9620 /* *** Filters Control *** */
9622 /* *** deal with ethertype filter *** */
9623 struct cmd_ethertype_filter_result {
9624 cmdline_fixed_string_t filter;
9626 cmdline_fixed_string_t ops;
9627 cmdline_fixed_string_t mac;
9628 struct ether_addr mac_addr;
9629 cmdline_fixed_string_t ethertype;
9630 uint16_t ethertype_value;
9631 cmdline_fixed_string_t drop;
9632 cmdline_fixed_string_t queue;
9636 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9637 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9638 filter, "ethertype_filter");
9639 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9640 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9642 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9643 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9645 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9646 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9647 mac, "mac_addr#mac_ignr");
9648 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9649 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9651 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9652 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9653 ethertype, "ethertype");
9654 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9655 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9656 ethertype_value, UINT16);
9657 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9658 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9660 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9661 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9663 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9664 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9668 cmd_ethertype_filter_parsed(void *parsed_result,
9669 __attribute__((unused)) struct cmdline *cl,
9670 __attribute__((unused)) void *data)
9672 struct cmd_ethertype_filter_result *res = parsed_result;
9673 struct rte_eth_ethertype_filter filter;
9676 ret = rte_eth_dev_filter_supported(res->port_id,
9677 RTE_ETH_FILTER_ETHERTYPE);
9679 printf("ethertype filter is not supported on port %u.\n",
9684 memset(&filter, 0, sizeof(filter));
9685 if (!strcmp(res->mac, "mac_addr")) {
9686 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9687 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9688 sizeof(struct ether_addr));
9690 if (!strcmp(res->drop, "drop"))
9691 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9692 filter.ether_type = res->ethertype_value;
9693 filter.queue = res->queue_id;
9695 if (!strcmp(res->ops, "add"))
9696 ret = rte_eth_dev_filter_ctrl(res->port_id,
9697 RTE_ETH_FILTER_ETHERTYPE,
9701 ret = rte_eth_dev_filter_ctrl(res->port_id,
9702 RTE_ETH_FILTER_ETHERTYPE,
9703 RTE_ETH_FILTER_DELETE,
9706 printf("ethertype filter programming error: (%s)\n",
9710 cmdline_parse_inst_t cmd_ethertype_filter = {
9711 .f = cmd_ethertype_filter_parsed,
9713 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9714 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9715 "Add or delete an ethertype filter entry",
9717 (void *)&cmd_ethertype_filter_filter,
9718 (void *)&cmd_ethertype_filter_port_id,
9719 (void *)&cmd_ethertype_filter_ops,
9720 (void *)&cmd_ethertype_filter_mac,
9721 (void *)&cmd_ethertype_filter_mac_addr,
9722 (void *)&cmd_ethertype_filter_ethertype,
9723 (void *)&cmd_ethertype_filter_ethertype_value,
9724 (void *)&cmd_ethertype_filter_drop,
9725 (void *)&cmd_ethertype_filter_queue,
9726 (void *)&cmd_ethertype_filter_queue_id,
9731 /* *** deal with flow director filter *** */
9732 struct cmd_flow_director_result {
9733 cmdline_fixed_string_t flow_director_filter;
9735 cmdline_fixed_string_t mode;
9736 cmdline_fixed_string_t mode_value;
9737 cmdline_fixed_string_t ops;
9738 cmdline_fixed_string_t flow;
9739 cmdline_fixed_string_t flow_type;
9740 cmdline_fixed_string_t ether;
9741 uint16_t ether_type;
9742 cmdline_fixed_string_t src;
9743 cmdline_ipaddr_t ip_src;
9745 cmdline_fixed_string_t dst;
9746 cmdline_ipaddr_t ip_dst;
9748 cmdline_fixed_string_t verify_tag;
9749 uint32_t verify_tag_value;
9750 cmdline_ipaddr_t tos;
9752 cmdline_ipaddr_t proto;
9753 uint8_t proto_value;
9754 cmdline_ipaddr_t ttl;
9756 cmdline_fixed_string_t vlan;
9757 uint16_t vlan_value;
9758 cmdline_fixed_string_t flexbytes;
9759 cmdline_fixed_string_t flexbytes_value;
9760 cmdline_fixed_string_t pf_vf;
9761 cmdline_fixed_string_t drop;
9762 cmdline_fixed_string_t queue;
9764 cmdline_fixed_string_t fd_id;
9765 uint32_t fd_id_value;
9766 cmdline_fixed_string_t mac;
9767 struct ether_addr mac_addr;
9768 cmdline_fixed_string_t tunnel;
9769 cmdline_fixed_string_t tunnel_type;
9770 cmdline_fixed_string_t tunnel_id;
9771 uint32_t tunnel_id_value;
9775 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9778 const char *p, *p0 = q_arg;
9780 unsigned long int_fld;
9781 char *str_fld[max_num];
9786 p = strchr(p0, '(');
9790 p0 = strchr(p, ')');
9795 if (size >= sizeof(s))
9798 snprintf(s, sizeof(s), "%.*s", size, p);
9799 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9800 if (ret < 0 || ret > max_num)
9802 for (i = 0; i < ret; i++) {
9804 int_fld = strtoul(str_fld[i], &end, 0);
9805 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9807 flexbytes[i] = (uint8_t)int_fld;
9813 str2flowtype(char *string)
9816 static const struct {
9819 } flowtype_str[] = {
9820 {"raw", RTE_ETH_FLOW_RAW},
9821 {"ipv4", RTE_ETH_FLOW_IPV4},
9822 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9823 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9824 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9825 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9826 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9827 {"ipv6", RTE_ETH_FLOW_IPV6},
9828 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9829 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9830 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9831 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9832 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9833 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9836 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9837 if (!strcmp(flowtype_str[i].str, string))
9838 return flowtype_str[i].type;
9841 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9842 return (uint16_t)atoi(string);
9844 return RTE_ETH_FLOW_UNKNOWN;
9847 static enum rte_eth_fdir_tunnel_type
9848 str2fdir_tunneltype(char *string)
9852 static const struct {
9854 enum rte_eth_fdir_tunnel_type type;
9855 } tunneltype_str[] = {
9856 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9857 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9860 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9861 if (!strcmp(tunneltype_str[i].str, string))
9862 return tunneltype_str[i].type;
9864 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9867 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9869 if ((ip_addr).family == AF_INET) \
9870 (ip) = (ip_addr).addr.ipv4.s_addr; \
9872 printf("invalid parameter.\n"); \
9877 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9879 if ((ip_addr).family == AF_INET6) \
9881 &((ip_addr).addr.ipv6), \
9882 sizeof(struct in6_addr)); \
9884 printf("invalid parameter.\n"); \
9890 cmd_flow_director_filter_parsed(void *parsed_result,
9891 __attribute__((unused)) struct cmdline *cl,
9892 __attribute__((unused)) void *data)
9894 struct cmd_flow_director_result *res = parsed_result;
9895 struct rte_eth_fdir_filter entry;
9896 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9898 unsigned long vf_id;
9901 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9903 printf("flow director is not supported on port %u.\n",
9907 memset(flexbytes, 0, sizeof(flexbytes));
9908 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9910 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9911 if (strcmp(res->mode_value, "MAC-VLAN")) {
9912 printf("Please set mode to MAC-VLAN.\n");
9915 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9916 if (strcmp(res->mode_value, "Tunnel")) {
9917 printf("Please set mode to Tunnel.\n");
9921 if (strcmp(res->mode_value, "IP")) {
9922 printf("Please set mode to IP.\n");
9925 entry.input.flow_type = str2flowtype(res->flow_type);
9928 ret = parse_flexbytes(res->flexbytes_value,
9930 RTE_ETH_FDIR_MAX_FLEXLEN);
9932 printf("error: Cannot parse flexbytes input.\n");
9936 switch (entry.input.flow_type) {
9937 case RTE_ETH_FLOW_FRAG_IPV4:
9938 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9939 entry.input.flow.ip4_flow.proto = res->proto_value;
9941 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9942 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9943 IPV4_ADDR_TO_UINT(res->ip_dst,
9944 entry.input.flow.ip4_flow.dst_ip);
9945 IPV4_ADDR_TO_UINT(res->ip_src,
9946 entry.input.flow.ip4_flow.src_ip);
9947 entry.input.flow.ip4_flow.tos = res->tos_value;
9948 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9949 /* need convert to big endian. */
9950 entry.input.flow.udp4_flow.dst_port =
9951 rte_cpu_to_be_16(res->port_dst);
9952 entry.input.flow.udp4_flow.src_port =
9953 rte_cpu_to_be_16(res->port_src);
9955 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9956 IPV4_ADDR_TO_UINT(res->ip_dst,
9957 entry.input.flow.sctp4_flow.ip.dst_ip);
9958 IPV4_ADDR_TO_UINT(res->ip_src,
9959 entry.input.flow.sctp4_flow.ip.src_ip);
9960 entry.input.flow.ip4_flow.tos = res->tos_value;
9961 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9962 /* need convert to big endian. */
9963 entry.input.flow.sctp4_flow.dst_port =
9964 rte_cpu_to_be_16(res->port_dst);
9965 entry.input.flow.sctp4_flow.src_port =
9966 rte_cpu_to_be_16(res->port_src);
9967 entry.input.flow.sctp4_flow.verify_tag =
9968 rte_cpu_to_be_32(res->verify_tag_value);
9970 case RTE_ETH_FLOW_FRAG_IPV6:
9971 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9972 entry.input.flow.ipv6_flow.proto = res->proto_value;
9974 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9975 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9976 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9977 entry.input.flow.ipv6_flow.dst_ip);
9978 IPV6_ADDR_TO_ARRAY(res->ip_src,
9979 entry.input.flow.ipv6_flow.src_ip);
9980 entry.input.flow.ipv6_flow.tc = res->tos_value;
9981 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9982 /* need convert to big endian. */
9983 entry.input.flow.udp6_flow.dst_port =
9984 rte_cpu_to_be_16(res->port_dst);
9985 entry.input.flow.udp6_flow.src_port =
9986 rte_cpu_to_be_16(res->port_src);
9988 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9989 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9990 entry.input.flow.sctp6_flow.ip.dst_ip);
9991 IPV6_ADDR_TO_ARRAY(res->ip_src,
9992 entry.input.flow.sctp6_flow.ip.src_ip);
9993 entry.input.flow.ipv6_flow.tc = res->tos_value;
9994 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9995 /* need convert to big endian. */
9996 entry.input.flow.sctp6_flow.dst_port =
9997 rte_cpu_to_be_16(res->port_dst);
9998 entry.input.flow.sctp6_flow.src_port =
9999 rte_cpu_to_be_16(res->port_src);
10000 entry.input.flow.sctp6_flow.verify_tag =
10001 rte_cpu_to_be_32(res->verify_tag_value);
10003 case RTE_ETH_FLOW_L2_PAYLOAD:
10004 entry.input.flow.l2_flow.ether_type =
10005 rte_cpu_to_be_16(res->ether_type);
10011 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10012 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10014 sizeof(struct ether_addr));
10016 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10017 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10019 sizeof(struct ether_addr));
10020 entry.input.flow.tunnel_flow.tunnel_type =
10021 str2fdir_tunneltype(res->tunnel_type);
10022 entry.input.flow.tunnel_flow.tunnel_id =
10023 rte_cpu_to_be_32(res->tunnel_id_value);
10026 rte_memcpy(entry.input.flow_ext.flexbytes,
10028 RTE_ETH_FDIR_MAX_FLEXLEN);
10030 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10032 entry.action.flex_off = 0; /*use 0 by default */
10033 if (!strcmp(res->drop, "drop"))
10034 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10036 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10038 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10039 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10040 if (!strcmp(res->pf_vf, "pf"))
10041 entry.input.flow_ext.is_vf = 0;
10042 else if (!strncmp(res->pf_vf, "vf", 2)) {
10043 struct rte_eth_dev_info dev_info;
10045 memset(&dev_info, 0, sizeof(dev_info));
10046 rte_eth_dev_info_get(res->port_id, &dev_info);
10048 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10049 if (errno != 0 || *end != '\0' ||
10050 vf_id >= dev_info.max_vfs) {
10051 printf("invalid parameter %s.\n", res->pf_vf);
10054 entry.input.flow_ext.is_vf = 1;
10055 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10057 printf("invalid parameter %s.\n", res->pf_vf);
10062 /* set to report FD ID by default */
10063 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10064 entry.action.rx_queue = res->queue_id;
10065 entry.soft_id = res->fd_id_value;
10066 if (!strcmp(res->ops, "add"))
10067 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10068 RTE_ETH_FILTER_ADD, &entry);
10069 else if (!strcmp(res->ops, "del"))
10070 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10071 RTE_ETH_FILTER_DELETE, &entry);
10073 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10074 RTE_ETH_FILTER_UPDATE, &entry);
10076 printf("flow director programming error: (%s)\n",
10080 cmdline_parse_token_string_t cmd_flow_director_filter =
10081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10082 flow_director_filter, "flow_director_filter");
10083 cmdline_parse_token_num_t cmd_flow_director_port_id =
10084 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10086 cmdline_parse_token_string_t cmd_flow_director_ops =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10088 ops, "add#del#update");
10089 cmdline_parse_token_string_t cmd_flow_director_flow =
10090 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10092 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10094 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10095 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10096 cmdline_parse_token_string_t cmd_flow_director_ether =
10097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10099 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10100 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10101 ether_type, UINT16);
10102 cmdline_parse_token_string_t cmd_flow_director_src =
10103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10105 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10106 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10108 cmdline_parse_token_num_t cmd_flow_director_port_src =
10109 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10111 cmdline_parse_token_string_t cmd_flow_director_dst =
10112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10114 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10115 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10117 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10118 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10120 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10122 verify_tag, "verify_tag");
10123 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10125 verify_tag_value, UINT32);
10126 cmdline_parse_token_string_t cmd_flow_director_tos =
10127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10129 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10130 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10132 cmdline_parse_token_string_t cmd_flow_director_proto =
10133 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10135 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10136 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10137 proto_value, UINT8);
10138 cmdline_parse_token_string_t cmd_flow_director_ttl =
10139 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10141 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10142 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10144 cmdline_parse_token_string_t cmd_flow_director_vlan =
10145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10147 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10148 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10149 vlan_value, UINT16);
10150 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10152 flexbytes, "flexbytes");
10153 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10155 flexbytes_value, NULL);
10156 cmdline_parse_token_string_t cmd_flow_director_drop =
10157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10159 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10162 cmdline_parse_token_string_t cmd_flow_director_queue =
10163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10165 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10166 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10168 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10171 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10173 fd_id_value, UINT32);
10175 cmdline_parse_token_string_t cmd_flow_director_mode =
10176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10178 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10181 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10183 mode_value, "MAC-VLAN");
10184 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10185 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10186 mode_value, "Tunnel");
10187 cmdline_parse_token_string_t cmd_flow_director_mac =
10188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10190 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10191 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10193 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10196 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10198 tunnel_type, "NVGRE#VxLAN");
10199 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10201 tunnel_id, "tunnel-id");
10202 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10203 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10204 tunnel_id_value, UINT32);
10206 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10207 .f = cmd_flow_director_filter_parsed,
10209 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10210 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10211 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10212 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10213 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10214 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10215 "fd_id <fd_id_value>: "
10216 "Add or delete an ip flow director entry on NIC",
10218 (void *)&cmd_flow_director_filter,
10219 (void *)&cmd_flow_director_port_id,
10220 (void *)&cmd_flow_director_mode,
10221 (void *)&cmd_flow_director_mode_ip,
10222 (void *)&cmd_flow_director_ops,
10223 (void *)&cmd_flow_director_flow,
10224 (void *)&cmd_flow_director_flow_type,
10225 (void *)&cmd_flow_director_src,
10226 (void *)&cmd_flow_director_ip_src,
10227 (void *)&cmd_flow_director_dst,
10228 (void *)&cmd_flow_director_ip_dst,
10229 (void *)&cmd_flow_director_tos,
10230 (void *)&cmd_flow_director_tos_value,
10231 (void *)&cmd_flow_director_proto,
10232 (void *)&cmd_flow_director_proto_value,
10233 (void *)&cmd_flow_director_ttl,
10234 (void *)&cmd_flow_director_ttl_value,
10235 (void *)&cmd_flow_director_vlan,
10236 (void *)&cmd_flow_director_vlan_value,
10237 (void *)&cmd_flow_director_flexbytes,
10238 (void *)&cmd_flow_director_flexbytes_value,
10239 (void *)&cmd_flow_director_drop,
10240 (void *)&cmd_flow_director_pf_vf,
10241 (void *)&cmd_flow_director_queue,
10242 (void *)&cmd_flow_director_queue_id,
10243 (void *)&cmd_flow_director_fd_id,
10244 (void *)&cmd_flow_director_fd_id_value,
10249 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10250 .f = cmd_flow_director_filter_parsed,
10252 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10253 "director entry on NIC",
10255 (void *)&cmd_flow_director_filter,
10256 (void *)&cmd_flow_director_port_id,
10257 (void *)&cmd_flow_director_mode,
10258 (void *)&cmd_flow_director_mode_ip,
10259 (void *)&cmd_flow_director_ops,
10260 (void *)&cmd_flow_director_flow,
10261 (void *)&cmd_flow_director_flow_type,
10262 (void *)&cmd_flow_director_src,
10263 (void *)&cmd_flow_director_ip_src,
10264 (void *)&cmd_flow_director_port_src,
10265 (void *)&cmd_flow_director_dst,
10266 (void *)&cmd_flow_director_ip_dst,
10267 (void *)&cmd_flow_director_port_dst,
10268 (void *)&cmd_flow_director_tos,
10269 (void *)&cmd_flow_director_tos_value,
10270 (void *)&cmd_flow_director_ttl,
10271 (void *)&cmd_flow_director_ttl_value,
10272 (void *)&cmd_flow_director_vlan,
10273 (void *)&cmd_flow_director_vlan_value,
10274 (void *)&cmd_flow_director_flexbytes,
10275 (void *)&cmd_flow_director_flexbytes_value,
10276 (void *)&cmd_flow_director_drop,
10277 (void *)&cmd_flow_director_pf_vf,
10278 (void *)&cmd_flow_director_queue,
10279 (void *)&cmd_flow_director_queue_id,
10280 (void *)&cmd_flow_director_fd_id,
10281 (void *)&cmd_flow_director_fd_id_value,
10286 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10287 .f = cmd_flow_director_filter_parsed,
10289 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10290 "director entry on NIC",
10292 (void *)&cmd_flow_director_filter,
10293 (void *)&cmd_flow_director_port_id,
10294 (void *)&cmd_flow_director_mode,
10295 (void *)&cmd_flow_director_mode_ip,
10296 (void *)&cmd_flow_director_ops,
10297 (void *)&cmd_flow_director_flow,
10298 (void *)&cmd_flow_director_flow_type,
10299 (void *)&cmd_flow_director_src,
10300 (void *)&cmd_flow_director_ip_src,
10301 (void *)&cmd_flow_director_port_dst,
10302 (void *)&cmd_flow_director_dst,
10303 (void *)&cmd_flow_director_ip_dst,
10304 (void *)&cmd_flow_director_port_dst,
10305 (void *)&cmd_flow_director_verify_tag,
10306 (void *)&cmd_flow_director_verify_tag_value,
10307 (void *)&cmd_flow_director_tos,
10308 (void *)&cmd_flow_director_tos_value,
10309 (void *)&cmd_flow_director_ttl,
10310 (void *)&cmd_flow_director_ttl_value,
10311 (void *)&cmd_flow_director_vlan,
10312 (void *)&cmd_flow_director_vlan_value,
10313 (void *)&cmd_flow_director_flexbytes,
10314 (void *)&cmd_flow_director_flexbytes_value,
10315 (void *)&cmd_flow_director_drop,
10316 (void *)&cmd_flow_director_pf_vf,
10317 (void *)&cmd_flow_director_queue,
10318 (void *)&cmd_flow_director_queue_id,
10319 (void *)&cmd_flow_director_fd_id,
10320 (void *)&cmd_flow_director_fd_id_value,
10325 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10326 .f = cmd_flow_director_filter_parsed,
10328 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10329 "director entry on NIC",
10331 (void *)&cmd_flow_director_filter,
10332 (void *)&cmd_flow_director_port_id,
10333 (void *)&cmd_flow_director_mode,
10334 (void *)&cmd_flow_director_mode_ip,
10335 (void *)&cmd_flow_director_ops,
10336 (void *)&cmd_flow_director_flow,
10337 (void *)&cmd_flow_director_flow_type,
10338 (void *)&cmd_flow_director_ether,
10339 (void *)&cmd_flow_director_ether_type,
10340 (void *)&cmd_flow_director_flexbytes,
10341 (void *)&cmd_flow_director_flexbytes_value,
10342 (void *)&cmd_flow_director_drop,
10343 (void *)&cmd_flow_director_pf_vf,
10344 (void *)&cmd_flow_director_queue,
10345 (void *)&cmd_flow_director_queue_id,
10346 (void *)&cmd_flow_director_fd_id,
10347 (void *)&cmd_flow_director_fd_id_value,
10352 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10353 .f = cmd_flow_director_filter_parsed,
10355 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10356 "director entry on NIC",
10358 (void *)&cmd_flow_director_filter,
10359 (void *)&cmd_flow_director_port_id,
10360 (void *)&cmd_flow_director_mode,
10361 (void *)&cmd_flow_director_mode_mac_vlan,
10362 (void *)&cmd_flow_director_ops,
10363 (void *)&cmd_flow_director_mac,
10364 (void *)&cmd_flow_director_mac_addr,
10365 (void *)&cmd_flow_director_vlan,
10366 (void *)&cmd_flow_director_vlan_value,
10367 (void *)&cmd_flow_director_flexbytes,
10368 (void *)&cmd_flow_director_flexbytes_value,
10369 (void *)&cmd_flow_director_drop,
10370 (void *)&cmd_flow_director_queue,
10371 (void *)&cmd_flow_director_queue_id,
10372 (void *)&cmd_flow_director_fd_id,
10373 (void *)&cmd_flow_director_fd_id_value,
10378 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10379 .f = cmd_flow_director_filter_parsed,
10381 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10382 "director entry on NIC",
10384 (void *)&cmd_flow_director_filter,
10385 (void *)&cmd_flow_director_port_id,
10386 (void *)&cmd_flow_director_mode,
10387 (void *)&cmd_flow_director_mode_tunnel,
10388 (void *)&cmd_flow_director_ops,
10389 (void *)&cmd_flow_director_mac,
10390 (void *)&cmd_flow_director_mac_addr,
10391 (void *)&cmd_flow_director_vlan,
10392 (void *)&cmd_flow_director_vlan_value,
10393 (void *)&cmd_flow_director_tunnel,
10394 (void *)&cmd_flow_director_tunnel_type,
10395 (void *)&cmd_flow_director_tunnel_id,
10396 (void *)&cmd_flow_director_tunnel_id_value,
10397 (void *)&cmd_flow_director_flexbytes,
10398 (void *)&cmd_flow_director_flexbytes_value,
10399 (void *)&cmd_flow_director_drop,
10400 (void *)&cmd_flow_director_queue,
10401 (void *)&cmd_flow_director_queue_id,
10402 (void *)&cmd_flow_director_fd_id,
10403 (void *)&cmd_flow_director_fd_id_value,
10408 struct cmd_flush_flow_director_result {
10409 cmdline_fixed_string_t flush_flow_director;
10413 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10414 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10415 flush_flow_director, "flush_flow_director");
10416 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10417 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10421 cmd_flush_flow_director_parsed(void *parsed_result,
10422 __attribute__((unused)) struct cmdline *cl,
10423 __attribute__((unused)) void *data)
10425 struct cmd_flow_director_result *res = parsed_result;
10428 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10430 printf("flow director is not supported on port %u.\n",
10435 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10436 RTE_ETH_FILTER_FLUSH, NULL);
10438 printf("flow director table flushing error: (%s)\n",
10442 cmdline_parse_inst_t cmd_flush_flow_director = {
10443 .f = cmd_flush_flow_director_parsed,
10445 .help_str = "flush_flow_director <port_id>: "
10446 "Flush all flow director entries of a device on NIC",
10448 (void *)&cmd_flush_flow_director_flush,
10449 (void *)&cmd_flush_flow_director_port_id,
10454 /* *** deal with flow director mask *** */
10455 struct cmd_flow_director_mask_result {
10456 cmdline_fixed_string_t flow_director_mask;
10458 cmdline_fixed_string_t mode;
10459 cmdline_fixed_string_t mode_value;
10460 cmdline_fixed_string_t vlan;
10461 uint16_t vlan_mask;
10462 cmdline_fixed_string_t src_mask;
10463 cmdline_ipaddr_t ipv4_src;
10464 cmdline_ipaddr_t ipv6_src;
10466 cmdline_fixed_string_t dst_mask;
10467 cmdline_ipaddr_t ipv4_dst;
10468 cmdline_ipaddr_t ipv6_dst;
10470 cmdline_fixed_string_t mac;
10471 uint8_t mac_addr_byte_mask;
10472 cmdline_fixed_string_t tunnel_id;
10473 uint32_t tunnel_id_mask;
10474 cmdline_fixed_string_t tunnel_type;
10475 uint8_t tunnel_type_mask;
10479 cmd_flow_director_mask_parsed(void *parsed_result,
10480 __attribute__((unused)) struct cmdline *cl,
10481 __attribute__((unused)) void *data)
10483 struct cmd_flow_director_mask_result *res = parsed_result;
10484 struct rte_eth_fdir_masks *mask;
10485 struct rte_port *port;
10487 if (res->port_id > nb_ports) {
10488 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10492 port = &ports[res->port_id];
10493 /** Check if the port is not started **/
10494 if (port->port_status != RTE_PORT_STOPPED) {
10495 printf("Please stop port %d first\n", res->port_id);
10499 mask = &port->dev_conf.fdir_conf.mask;
10501 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10502 if (strcmp(res->mode_value, "MAC-VLAN")) {
10503 printf("Please set mode to MAC-VLAN.\n");
10507 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10508 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10509 if (strcmp(res->mode_value, "Tunnel")) {
10510 printf("Please set mode to Tunnel.\n");
10514 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10515 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10516 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10517 mask->tunnel_type_mask = res->tunnel_type_mask;
10519 if (strcmp(res->mode_value, "IP")) {
10520 printf("Please set mode to IP.\n");
10524 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10525 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10526 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10527 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10528 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10529 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10530 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10533 cmd_reconfig_device_queue(res->port_id, 1, 1);
10536 cmdline_parse_token_string_t cmd_flow_director_mask =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10538 flow_director_mask, "flow_director_mask");
10539 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10540 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10542 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10545 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10546 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10547 vlan_mask, UINT16);
10548 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10550 src_mask, "src_mask");
10551 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10552 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10554 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10555 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10557 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10558 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10560 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10562 dst_mask, "dst_mask");
10563 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10564 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10566 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10567 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10569 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10570 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10573 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10576 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10579 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10581 mode_value, "MAC-VLAN");
10582 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10584 mode_value, "Tunnel");
10585 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10586 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10588 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10589 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10590 mac_addr_byte_mask, UINT8);
10591 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10593 tunnel_type, "tunnel-type");
10594 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10595 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10596 tunnel_type_mask, UINT8);
10597 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10599 tunnel_id, "tunnel-id");
10600 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10601 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10602 tunnel_id_mask, UINT32);
10604 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10605 .f = cmd_flow_director_mask_parsed,
10607 .help_str = "flow_director_mask ... : "
10608 "Set IP mode flow director's mask on NIC",
10610 (void *)&cmd_flow_director_mask,
10611 (void *)&cmd_flow_director_mask_port_id,
10612 (void *)&cmd_flow_director_mask_mode,
10613 (void *)&cmd_flow_director_mask_mode_ip,
10614 (void *)&cmd_flow_director_mask_vlan,
10615 (void *)&cmd_flow_director_mask_vlan_value,
10616 (void *)&cmd_flow_director_mask_src,
10617 (void *)&cmd_flow_director_mask_ipv4_src,
10618 (void *)&cmd_flow_director_mask_ipv6_src,
10619 (void *)&cmd_flow_director_mask_port_src,
10620 (void *)&cmd_flow_director_mask_dst,
10621 (void *)&cmd_flow_director_mask_ipv4_dst,
10622 (void *)&cmd_flow_director_mask_ipv6_dst,
10623 (void *)&cmd_flow_director_mask_port_dst,
10628 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10629 .f = cmd_flow_director_mask_parsed,
10631 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10632 "flow director's mask on NIC",
10634 (void *)&cmd_flow_director_mask,
10635 (void *)&cmd_flow_director_mask_port_id,
10636 (void *)&cmd_flow_director_mask_mode,
10637 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10638 (void *)&cmd_flow_director_mask_vlan,
10639 (void *)&cmd_flow_director_mask_vlan_value,
10644 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10645 .f = cmd_flow_director_mask_parsed,
10647 .help_str = "flow_director_mask ... : Set tunnel mode "
10648 "flow director's mask on NIC",
10650 (void *)&cmd_flow_director_mask,
10651 (void *)&cmd_flow_director_mask_port_id,
10652 (void *)&cmd_flow_director_mask_mode,
10653 (void *)&cmd_flow_director_mask_mode_tunnel,
10654 (void *)&cmd_flow_director_mask_vlan,
10655 (void *)&cmd_flow_director_mask_vlan_value,
10656 (void *)&cmd_flow_director_mask_mac,
10657 (void *)&cmd_flow_director_mask_mac_value,
10658 (void *)&cmd_flow_director_mask_tunnel_type,
10659 (void *)&cmd_flow_director_mask_tunnel_type_value,
10660 (void *)&cmd_flow_director_mask_tunnel_id,
10661 (void *)&cmd_flow_director_mask_tunnel_id_value,
10666 /* *** deal with flow director mask on flexible payload *** */
10667 struct cmd_flow_director_flex_mask_result {
10668 cmdline_fixed_string_t flow_director_flexmask;
10670 cmdline_fixed_string_t flow;
10671 cmdline_fixed_string_t flow_type;
10672 cmdline_fixed_string_t mask;
10676 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10677 __attribute__((unused)) struct cmdline *cl,
10678 __attribute__((unused)) void *data)
10680 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10681 struct rte_eth_fdir_info fdir_info;
10682 struct rte_eth_fdir_flex_mask flex_mask;
10683 struct rte_port *port;
10684 uint32_t flow_type_mask;
10688 if (res->port_id > nb_ports) {
10689 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10693 port = &ports[res->port_id];
10694 /** Check if the port is not started **/
10695 if (port->port_status != RTE_PORT_STOPPED) {
10696 printf("Please stop port %d first\n", res->port_id);
10700 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10701 ret = parse_flexbytes(res->mask,
10703 RTE_ETH_FDIR_MAX_FLEXLEN);
10705 printf("error: Cannot parse mask input.\n");
10709 memset(&fdir_info, 0, sizeof(fdir_info));
10710 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10711 RTE_ETH_FILTER_INFO, &fdir_info);
10713 printf("Cannot get FDir filter info\n");
10717 if (!strcmp(res->flow_type, "none")) {
10718 /* means don't specify the flow type */
10719 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10720 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10721 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10722 0, sizeof(struct rte_eth_fdir_flex_mask));
10723 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10724 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10726 sizeof(struct rte_eth_fdir_flex_mask));
10727 cmd_reconfig_device_queue(res->port_id, 1, 1);
10730 flow_type_mask = fdir_info.flow_types_mask[0];
10731 if (!strcmp(res->flow_type, "all")) {
10732 if (!flow_type_mask) {
10733 printf("No flow type supported\n");
10736 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10737 if (flow_type_mask & (1 << i)) {
10738 flex_mask.flow_type = i;
10739 fdir_set_flex_mask(res->port_id, &flex_mask);
10742 cmd_reconfig_device_queue(res->port_id, 1, 1);
10745 flex_mask.flow_type = str2flowtype(res->flow_type);
10746 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10747 printf("Flow type %s not supported on port %d\n",
10748 res->flow_type, res->port_id);
10751 fdir_set_flex_mask(res->port_id, &flex_mask);
10752 cmd_reconfig_device_queue(res->port_id, 1, 1);
10755 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10757 flow_director_flexmask,
10758 "flow_director_flex_mask");
10759 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10762 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10765 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10767 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10768 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10769 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10773 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10774 .f = cmd_flow_director_flex_mask_parsed,
10776 .help_str = "flow_director_flex_mask ... : "
10777 "Set flow director's flex mask on NIC",
10779 (void *)&cmd_flow_director_flexmask,
10780 (void *)&cmd_flow_director_flexmask_port_id,
10781 (void *)&cmd_flow_director_flexmask_flow,
10782 (void *)&cmd_flow_director_flexmask_flow_type,
10783 (void *)&cmd_flow_director_flexmask_mask,
10788 /* *** deal with flow director flexible payload configuration *** */
10789 struct cmd_flow_director_flexpayload_result {
10790 cmdline_fixed_string_t flow_director_flexpayload;
10792 cmdline_fixed_string_t payload_layer;
10793 cmdline_fixed_string_t payload_cfg;
10797 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10800 const char *p, *p0 = q_arg;
10802 unsigned long int_fld;
10803 char *str_fld[max_num];
10808 p = strchr(p0, '(');
10812 p0 = strchr(p, ')');
10817 if (size >= sizeof(s))
10820 snprintf(s, sizeof(s), "%.*s", size, p);
10821 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10822 if (ret < 0 || ret > max_num)
10824 for (i = 0; i < ret; i++) {
10826 int_fld = strtoul(str_fld[i], &end, 0);
10827 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10829 offsets[i] = (uint16_t)int_fld;
10835 cmd_flow_director_flxpld_parsed(void *parsed_result,
10836 __attribute__((unused)) struct cmdline *cl,
10837 __attribute__((unused)) void *data)
10839 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10840 struct rte_eth_flex_payload_cfg flex_cfg;
10841 struct rte_port *port;
10844 if (res->port_id > nb_ports) {
10845 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10849 port = &ports[res->port_id];
10850 /** Check if the port is not started **/
10851 if (port->port_status != RTE_PORT_STOPPED) {
10852 printf("Please stop port %d first\n", res->port_id);
10856 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10858 if (!strcmp(res->payload_layer, "raw"))
10859 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10860 else if (!strcmp(res->payload_layer, "l2"))
10861 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10862 else if (!strcmp(res->payload_layer, "l3"))
10863 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10864 else if (!strcmp(res->payload_layer, "l4"))
10865 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10867 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10868 RTE_ETH_FDIR_MAX_FLEXLEN);
10870 printf("error: Cannot parse flex payload input.\n");
10874 fdir_set_flex_payload(res->port_id, &flex_cfg);
10875 cmd_reconfig_device_queue(res->port_id, 1, 1);
10878 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10880 flow_director_flexpayload,
10881 "flow_director_flex_payload");
10882 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10885 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10887 payload_layer, "raw#l2#l3#l4");
10888 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10890 payload_cfg, NULL);
10892 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10893 .f = cmd_flow_director_flxpld_parsed,
10895 .help_str = "flow_director_flexpayload ... : "
10896 "Set flow director's flex payload on NIC",
10898 (void *)&cmd_flow_director_flexpayload,
10899 (void *)&cmd_flow_director_flexpayload_port_id,
10900 (void *)&cmd_flow_director_flexpayload_payload_layer,
10901 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10906 /* Generic flow interface command. */
10907 extern cmdline_parse_inst_t cmd_flow;
10909 /* *** Classification Filters Control *** */
10910 /* *** Get symmetric hash enable per port *** */
10911 struct cmd_get_sym_hash_ena_per_port_result {
10912 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10917 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10918 __rte_unused struct cmdline *cl,
10919 __rte_unused void *data)
10921 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10922 struct rte_eth_hash_filter_info info;
10925 if (rte_eth_dev_filter_supported(res->port_id,
10926 RTE_ETH_FILTER_HASH) < 0) {
10927 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10932 memset(&info, 0, sizeof(info));
10933 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10934 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10935 RTE_ETH_FILTER_GET, &info);
10938 printf("Cannot get symmetric hash enable per port "
10939 "on port %u\n", res->port_id);
10943 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10944 "enabled" : "disabled", res->port_id);
10947 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10948 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10949 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10950 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10951 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10954 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10955 .f = cmd_get_sym_hash_per_port_parsed,
10957 .help_str = "get_sym_hash_ena_per_port <port_id>",
10959 (void *)&cmd_get_sym_hash_ena_per_port_all,
10960 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10965 /* *** Set symmetric hash enable per port *** */
10966 struct cmd_set_sym_hash_ena_per_port_result {
10967 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10968 cmdline_fixed_string_t enable;
10973 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10974 __rte_unused struct cmdline *cl,
10975 __rte_unused void *data)
10977 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10978 struct rte_eth_hash_filter_info info;
10981 if (rte_eth_dev_filter_supported(res->port_id,
10982 RTE_ETH_FILTER_HASH) < 0) {
10983 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10988 memset(&info, 0, sizeof(info));
10989 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10990 if (!strcmp(res->enable, "enable"))
10991 info.info.enable = 1;
10992 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10993 RTE_ETH_FILTER_SET, &info);
10995 printf("Cannot set symmetric hash enable per port on "
10996 "port %u\n", res->port_id);
10999 printf("Symmetric hash has been set to %s on port %u\n",
11000 res->enable, res->port_id);
11003 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11004 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11005 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11006 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11007 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11009 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11010 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11011 enable, "enable#disable");
11013 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11014 .f = cmd_set_sym_hash_per_port_parsed,
11016 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11018 (void *)&cmd_set_sym_hash_ena_per_port_all,
11019 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11020 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11025 /* Get global config of hash function */
11026 struct cmd_get_hash_global_config_result {
11027 cmdline_fixed_string_t get_hash_global_config;
11032 flowtype_to_str(uint16_t ftype)
11038 } ftype_table[] = {
11039 {"ipv4", RTE_ETH_FLOW_IPV4},
11040 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11041 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11042 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11043 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11044 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11045 {"ipv6", RTE_ETH_FLOW_IPV6},
11046 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11047 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11048 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11049 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11050 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11051 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11052 {"port", RTE_ETH_FLOW_PORT},
11053 {"vxlan", RTE_ETH_FLOW_VXLAN},
11054 {"geneve", RTE_ETH_FLOW_GENEVE},
11055 {"nvgre", RTE_ETH_FLOW_NVGRE},
11058 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11059 if (ftype_table[i].ftype == ftype)
11060 return ftype_table[i].str;
11067 cmd_get_hash_global_config_parsed(void *parsed_result,
11068 __rte_unused struct cmdline *cl,
11069 __rte_unused void *data)
11071 struct cmd_get_hash_global_config_result *res = parsed_result;
11072 struct rte_eth_hash_filter_info info;
11073 uint32_t idx, offset;
11078 if (rte_eth_dev_filter_supported(res->port_id,
11079 RTE_ETH_FILTER_HASH) < 0) {
11080 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11085 memset(&info, 0, sizeof(info));
11086 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11087 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11088 RTE_ETH_FILTER_GET, &info);
11090 printf("Cannot get hash global configurations by port %d\n",
11095 switch (info.info.global_conf.hash_func) {
11096 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11097 printf("Hash function is Toeplitz\n");
11099 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11100 printf("Hash function is Simple XOR\n");
11103 printf("Unknown hash function\n");
11107 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11108 idx = i / UINT32_BIT;
11109 offset = i % UINT32_BIT;
11110 if (!(info.info.global_conf.valid_bit_mask[idx] &
11113 str = flowtype_to_str(i);
11116 printf("Symmetric hash is %s globally for flow type %s "
11118 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11119 (1UL << offset)) ? "enabled" : "disabled"), str,
11124 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11125 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11126 get_hash_global_config, "get_hash_global_config");
11127 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11128 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11131 cmdline_parse_inst_t cmd_get_hash_global_config = {
11132 .f = cmd_get_hash_global_config_parsed,
11134 .help_str = "get_hash_global_config <port_id>",
11136 (void *)&cmd_get_hash_global_config_all,
11137 (void *)&cmd_get_hash_global_config_port_id,
11142 /* Set global config of hash function */
11143 struct cmd_set_hash_global_config_result {
11144 cmdline_fixed_string_t set_hash_global_config;
11146 cmdline_fixed_string_t hash_func;
11147 cmdline_fixed_string_t flow_type;
11148 cmdline_fixed_string_t enable;
11152 cmd_set_hash_global_config_parsed(void *parsed_result,
11153 __rte_unused struct cmdline *cl,
11154 __rte_unused void *data)
11156 struct cmd_set_hash_global_config_result *res = parsed_result;
11157 struct rte_eth_hash_filter_info info;
11158 uint32_t ftype, idx, offset;
11161 if (rte_eth_dev_filter_supported(res->port_id,
11162 RTE_ETH_FILTER_HASH) < 0) {
11163 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11167 memset(&info, 0, sizeof(info));
11168 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11169 if (!strcmp(res->hash_func, "toeplitz"))
11170 info.info.global_conf.hash_func =
11171 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11172 else if (!strcmp(res->hash_func, "simple_xor"))
11173 info.info.global_conf.hash_func =
11174 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11175 else if (!strcmp(res->hash_func, "default"))
11176 info.info.global_conf.hash_func =
11177 RTE_ETH_HASH_FUNCTION_DEFAULT;
11179 ftype = str2flowtype(res->flow_type);
11180 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11181 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11182 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11183 if (!strcmp(res->enable, "enable"))
11184 info.info.global_conf.sym_hash_enable_mask[idx] |=
11186 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11187 RTE_ETH_FILTER_SET, &info);
11189 printf("Cannot set global hash configurations by port %d\n",
11192 printf("Global hash configurations have been set "
11193 "succcessfully by port %d\n", res->port_id);
11196 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11197 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11198 set_hash_global_config, "set_hash_global_config");
11199 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11200 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11202 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11203 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11204 hash_func, "toeplitz#simple_xor#default");
11205 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11206 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11208 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11209 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11210 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11211 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11212 enable, "enable#disable");
11214 cmdline_parse_inst_t cmd_set_hash_global_config = {
11215 .f = cmd_set_hash_global_config_parsed,
11217 .help_str = "set_hash_global_config <port_id> "
11218 "toeplitz|simple_xor|default "
11219 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11220 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11221 "l2_payload enable|disable",
11223 (void *)&cmd_set_hash_global_config_all,
11224 (void *)&cmd_set_hash_global_config_port_id,
11225 (void *)&cmd_set_hash_global_config_hash_func,
11226 (void *)&cmd_set_hash_global_config_flow_type,
11227 (void *)&cmd_set_hash_global_config_enable,
11232 /* Set hash input set */
11233 struct cmd_set_hash_input_set_result {
11234 cmdline_fixed_string_t set_hash_input_set;
11236 cmdline_fixed_string_t flow_type;
11237 cmdline_fixed_string_t inset_field;
11238 cmdline_fixed_string_t select;
11241 static enum rte_eth_input_set_field
11242 str2inset(char *string)
11246 static const struct {
11248 enum rte_eth_input_set_field inset;
11249 } inset_table[] = {
11250 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11251 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11252 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11253 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11254 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11255 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11256 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11257 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11258 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11259 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11260 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11261 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11262 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11263 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11264 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11265 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11266 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11267 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11268 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11269 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11270 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11271 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11272 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11273 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11274 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11275 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11276 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11277 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11278 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11279 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11280 {"none", RTE_ETH_INPUT_SET_NONE},
11283 for (i = 0; i < RTE_DIM(inset_table); i++) {
11284 if (!strcmp(string, inset_table[i].str))
11285 return inset_table[i].inset;
11288 return RTE_ETH_INPUT_SET_UNKNOWN;
11292 cmd_set_hash_input_set_parsed(void *parsed_result,
11293 __rte_unused struct cmdline *cl,
11294 __rte_unused void *data)
11296 struct cmd_set_hash_input_set_result *res = parsed_result;
11297 struct rte_eth_hash_filter_info info;
11299 memset(&info, 0, sizeof(info));
11300 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11301 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11302 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11303 info.info.input_set_conf.inset_size = 1;
11304 if (!strcmp(res->select, "select"))
11305 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11306 else if (!strcmp(res->select, "add"))
11307 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11308 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11309 RTE_ETH_FILTER_SET, &info);
11312 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11313 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11314 set_hash_input_set, "set_hash_input_set");
11315 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11316 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11318 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11319 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11321 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11322 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11324 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11325 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11326 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11327 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11328 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11330 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11331 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11332 select, "select#add");
11334 cmdline_parse_inst_t cmd_set_hash_input_set = {
11335 .f = cmd_set_hash_input_set_parsed,
11337 .help_str = "set_hash_input_set <port_id> "
11338 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11339 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11340 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11341 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11342 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11343 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11344 "fld-7th|fld-8th|none select|add",
11346 (void *)&cmd_set_hash_input_set_cmd,
11347 (void *)&cmd_set_hash_input_set_port_id,
11348 (void *)&cmd_set_hash_input_set_flow_type,
11349 (void *)&cmd_set_hash_input_set_field,
11350 (void *)&cmd_set_hash_input_set_select,
11355 /* Set flow director input set */
11356 struct cmd_set_fdir_input_set_result {
11357 cmdline_fixed_string_t set_fdir_input_set;
11359 cmdline_fixed_string_t flow_type;
11360 cmdline_fixed_string_t inset_field;
11361 cmdline_fixed_string_t select;
11365 cmd_set_fdir_input_set_parsed(void *parsed_result,
11366 __rte_unused struct cmdline *cl,
11367 __rte_unused void *data)
11369 struct cmd_set_fdir_input_set_result *res = parsed_result;
11370 struct rte_eth_fdir_filter_info info;
11372 memset(&info, 0, sizeof(info));
11373 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11374 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11375 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11376 info.info.input_set_conf.inset_size = 1;
11377 if (!strcmp(res->select, "select"))
11378 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11379 else if (!strcmp(res->select, "add"))
11380 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11381 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11382 RTE_ETH_FILTER_SET, &info);
11385 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11386 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11387 set_fdir_input_set, "set_fdir_input_set");
11388 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11389 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11391 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11392 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11394 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11395 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11396 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11397 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11399 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11400 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11401 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11402 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11403 "sctp-veri-tag#none");
11404 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11405 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11406 select, "select#add");
11408 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11409 .f = cmd_set_fdir_input_set_parsed,
11411 .help_str = "set_fdir_input_set <port_id> "
11412 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11413 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11414 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11415 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11416 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11417 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11418 "sctp-veri-tag|none select|add",
11420 (void *)&cmd_set_fdir_input_set_cmd,
11421 (void *)&cmd_set_fdir_input_set_port_id,
11422 (void *)&cmd_set_fdir_input_set_flow_type,
11423 (void *)&cmd_set_fdir_input_set_field,
11424 (void *)&cmd_set_fdir_input_set_select,
11429 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11430 struct cmd_mcast_addr_result {
11431 cmdline_fixed_string_t mcast_addr_cmd;
11432 cmdline_fixed_string_t what;
11434 struct ether_addr mc_addr;
11437 static void cmd_mcast_addr_parsed(void *parsed_result,
11438 __attribute__((unused)) struct cmdline *cl,
11439 __attribute__((unused)) void *data)
11441 struct cmd_mcast_addr_result *res = parsed_result;
11443 if (!is_multicast_ether_addr(&res->mc_addr)) {
11444 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11445 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11446 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11447 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11450 if (strcmp(res->what, "add") == 0)
11451 mcast_addr_add(res->port_num, &res->mc_addr);
11453 mcast_addr_remove(res->port_num, &res->mc_addr);
11456 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11457 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11458 mcast_addr_cmd, "mcast_addr");
11459 cmdline_parse_token_string_t cmd_mcast_addr_what =
11460 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11462 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11463 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11464 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11465 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11467 cmdline_parse_inst_t cmd_mcast_addr = {
11468 .f = cmd_mcast_addr_parsed,
11470 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11471 "Add/Remove multicast MAC address on port_id",
11473 (void *)&cmd_mcast_addr_cmd,
11474 (void *)&cmd_mcast_addr_what,
11475 (void *)&cmd_mcast_addr_portnum,
11476 (void *)&cmd_mcast_addr_addr,
11481 /* l2 tunnel config
11482 * only support E-tag now.
11485 /* Ether type config */
11486 struct cmd_config_l2_tunnel_eth_type_result {
11487 cmdline_fixed_string_t port;
11488 cmdline_fixed_string_t config;
11489 cmdline_fixed_string_t all;
11491 cmdline_fixed_string_t l2_tunnel;
11492 cmdline_fixed_string_t l2_tunnel_type;
11493 cmdline_fixed_string_t eth_type;
11494 uint16_t eth_type_val;
11497 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_config_l2_tunnel_eth_type_result,
11501 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_config_l2_tunnel_eth_type_result,
11505 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_config_l2_tunnel_eth_type_result,
11509 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11510 TOKEN_NUM_INITIALIZER
11511 (struct cmd_config_l2_tunnel_eth_type_result,
11513 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_config_l2_tunnel_eth_type_result,
11516 l2_tunnel, "l2-tunnel");
11517 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_config_l2_tunnel_eth_type_result,
11520 l2_tunnel_type, "E-tag");
11521 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_config_l2_tunnel_eth_type_result,
11524 eth_type, "ether-type");
11525 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11526 TOKEN_NUM_INITIALIZER
11527 (struct cmd_config_l2_tunnel_eth_type_result,
11528 eth_type_val, UINT16);
11530 static enum rte_eth_tunnel_type
11531 str2fdir_l2_tunnel_type(char *string)
11535 static const struct {
11537 enum rte_eth_tunnel_type type;
11538 } l2_tunnel_type_str[] = {
11539 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11542 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11543 if (!strcmp(l2_tunnel_type_str[i].str, string))
11544 return l2_tunnel_type_str[i].type;
11546 return RTE_TUNNEL_TYPE_NONE;
11549 /* ether type config for all ports */
11551 cmd_config_l2_tunnel_eth_type_all_parsed
11552 (void *parsed_result,
11553 __attribute__((unused)) struct cmdline *cl,
11554 __attribute__((unused)) void *data)
11556 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11557 struct rte_eth_l2_tunnel_conf entry;
11560 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11561 entry.ether_type = res->eth_type_val;
11563 RTE_ETH_FOREACH_DEV(pid) {
11564 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11568 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11569 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11571 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11573 (void *)&cmd_config_l2_tunnel_eth_type_port,
11574 (void *)&cmd_config_l2_tunnel_eth_type_config,
11575 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11576 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11577 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11578 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11579 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11584 /* ether type config for a specific port */
11586 cmd_config_l2_tunnel_eth_type_specific_parsed(
11587 void *parsed_result,
11588 __attribute__((unused)) struct cmdline *cl,
11589 __attribute__((unused)) void *data)
11591 struct cmd_config_l2_tunnel_eth_type_result *res =
11593 struct rte_eth_l2_tunnel_conf entry;
11595 if (port_id_is_invalid(res->id, ENABLED_WARN))
11598 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11599 entry.ether_type = res->eth_type_val;
11601 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11604 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11605 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11607 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11609 (void *)&cmd_config_l2_tunnel_eth_type_port,
11610 (void *)&cmd_config_l2_tunnel_eth_type_config,
11611 (void *)&cmd_config_l2_tunnel_eth_type_id,
11612 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11613 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11614 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11615 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11620 /* Enable/disable l2 tunnel */
11621 struct cmd_config_l2_tunnel_en_dis_result {
11622 cmdline_fixed_string_t port;
11623 cmdline_fixed_string_t config;
11624 cmdline_fixed_string_t all;
11626 cmdline_fixed_string_t l2_tunnel;
11627 cmdline_fixed_string_t l2_tunnel_type;
11628 cmdline_fixed_string_t en_dis;
11631 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11632 TOKEN_STRING_INITIALIZER
11633 (struct cmd_config_l2_tunnel_en_dis_result,
11635 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11636 TOKEN_STRING_INITIALIZER
11637 (struct cmd_config_l2_tunnel_en_dis_result,
11639 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_config_l2_tunnel_en_dis_result,
11643 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11644 TOKEN_NUM_INITIALIZER
11645 (struct cmd_config_l2_tunnel_en_dis_result,
11647 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_config_l2_tunnel_en_dis_result,
11650 l2_tunnel, "l2-tunnel");
11651 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11652 TOKEN_STRING_INITIALIZER
11653 (struct cmd_config_l2_tunnel_en_dis_result,
11654 l2_tunnel_type, "E-tag");
11655 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_config_l2_tunnel_en_dis_result,
11658 en_dis, "enable#disable");
11660 /* enable/disable l2 tunnel for all ports */
11662 cmd_config_l2_tunnel_en_dis_all_parsed(
11663 void *parsed_result,
11664 __attribute__((unused)) struct cmdline *cl,
11665 __attribute__((unused)) void *data)
11667 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11668 struct rte_eth_l2_tunnel_conf entry;
11672 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11674 if (!strcmp("enable", res->en_dis))
11679 RTE_ETH_FOREACH_DEV(pid) {
11680 rte_eth_dev_l2_tunnel_offload_set(pid,
11682 ETH_L2_TUNNEL_ENABLE_MASK,
11687 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11688 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11690 .help_str = "port config all l2-tunnel E-tag enable|disable",
11692 (void *)&cmd_config_l2_tunnel_en_dis_port,
11693 (void *)&cmd_config_l2_tunnel_en_dis_config,
11694 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11695 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11696 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11697 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11702 /* enable/disable l2 tunnel for a port */
11704 cmd_config_l2_tunnel_en_dis_specific_parsed(
11705 void *parsed_result,
11706 __attribute__((unused)) struct cmdline *cl,
11707 __attribute__((unused)) void *data)
11709 struct cmd_config_l2_tunnel_en_dis_result *res =
11711 struct rte_eth_l2_tunnel_conf entry;
11713 if (port_id_is_invalid(res->id, ENABLED_WARN))
11716 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11718 if (!strcmp("enable", res->en_dis))
11719 rte_eth_dev_l2_tunnel_offload_set(res->id,
11721 ETH_L2_TUNNEL_ENABLE_MASK,
11724 rte_eth_dev_l2_tunnel_offload_set(res->id,
11726 ETH_L2_TUNNEL_ENABLE_MASK,
11730 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11731 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11733 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11735 (void *)&cmd_config_l2_tunnel_en_dis_port,
11736 (void *)&cmd_config_l2_tunnel_en_dis_config,
11737 (void *)&cmd_config_l2_tunnel_en_dis_id,
11738 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11739 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11740 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11745 /* E-tag configuration */
11747 /* Common result structure for all E-tag configuration */
11748 struct cmd_config_e_tag_result {
11749 cmdline_fixed_string_t e_tag;
11750 cmdline_fixed_string_t set;
11751 cmdline_fixed_string_t insertion;
11752 cmdline_fixed_string_t stripping;
11753 cmdline_fixed_string_t forwarding;
11754 cmdline_fixed_string_t filter;
11755 cmdline_fixed_string_t add;
11756 cmdline_fixed_string_t del;
11757 cmdline_fixed_string_t on;
11758 cmdline_fixed_string_t off;
11759 cmdline_fixed_string_t on_off;
11760 cmdline_fixed_string_t port_tag_id;
11761 uint32_t port_tag_id_val;
11762 cmdline_fixed_string_t e_tag_id;
11763 uint16_t e_tag_id_val;
11764 cmdline_fixed_string_t dst_pool;
11765 uint8_t dst_pool_val;
11766 cmdline_fixed_string_t port;
11768 cmdline_fixed_string_t vf;
11772 /* Common CLI fields for all E-tag configuration */
11773 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11774 TOKEN_STRING_INITIALIZER
11775 (struct cmd_config_e_tag_result,
11777 cmdline_parse_token_string_t cmd_config_e_tag_set =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_config_e_tag_result,
11781 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_config_e_tag_result,
11784 insertion, "insertion");
11785 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_config_e_tag_result,
11788 stripping, "stripping");
11789 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_config_e_tag_result,
11792 forwarding, "forwarding");
11793 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_config_e_tag_result,
11797 cmdline_parse_token_string_t cmd_config_e_tag_add =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_config_e_tag_result,
11801 cmdline_parse_token_string_t cmd_config_e_tag_del =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_config_e_tag_result,
11805 cmdline_parse_token_string_t cmd_config_e_tag_on =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_config_e_tag_result,
11809 cmdline_parse_token_string_t cmd_config_e_tag_off =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_config_e_tag_result,
11813 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_config_e_tag_result,
11817 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_config_e_tag_result,
11820 port_tag_id, "port-tag-id");
11821 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11822 TOKEN_NUM_INITIALIZER
11823 (struct cmd_config_e_tag_result,
11824 port_tag_id_val, UINT32);
11825 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_config_e_tag_result,
11828 e_tag_id, "e-tag-id");
11829 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11830 TOKEN_NUM_INITIALIZER
11831 (struct cmd_config_e_tag_result,
11832 e_tag_id_val, UINT16);
11833 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11834 TOKEN_STRING_INITIALIZER
11835 (struct cmd_config_e_tag_result,
11836 dst_pool, "dst-pool");
11837 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11838 TOKEN_NUM_INITIALIZER
11839 (struct cmd_config_e_tag_result,
11840 dst_pool_val, UINT8);
11841 cmdline_parse_token_string_t cmd_config_e_tag_port =
11842 TOKEN_STRING_INITIALIZER
11843 (struct cmd_config_e_tag_result,
11845 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11846 TOKEN_NUM_INITIALIZER
11847 (struct cmd_config_e_tag_result,
11849 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_e_tag_result,
11853 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11854 TOKEN_NUM_INITIALIZER
11855 (struct cmd_config_e_tag_result,
11858 /* E-tag insertion configuration */
11860 cmd_config_e_tag_insertion_en_parsed(
11861 void *parsed_result,
11862 __attribute__((unused)) struct cmdline *cl,
11863 __attribute__((unused)) void *data)
11865 struct cmd_config_e_tag_result *res =
11867 struct rte_eth_l2_tunnel_conf entry;
11869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11872 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11873 entry.tunnel_id = res->port_tag_id_val;
11874 entry.vf_id = res->vf_id;
11875 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11877 ETH_L2_TUNNEL_INSERTION_MASK,
11882 cmd_config_e_tag_insertion_dis_parsed(
11883 void *parsed_result,
11884 __attribute__((unused)) struct cmdline *cl,
11885 __attribute__((unused)) void *data)
11887 struct cmd_config_e_tag_result *res =
11889 struct rte_eth_l2_tunnel_conf entry;
11891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11894 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11895 entry.vf_id = res->vf_id;
11897 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11899 ETH_L2_TUNNEL_INSERTION_MASK,
11903 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11904 .f = cmd_config_e_tag_insertion_en_parsed,
11906 .help_str = "E-tag ... : E-tag insertion enable",
11908 (void *)&cmd_config_e_tag_e_tag,
11909 (void *)&cmd_config_e_tag_set,
11910 (void *)&cmd_config_e_tag_insertion,
11911 (void *)&cmd_config_e_tag_on,
11912 (void *)&cmd_config_e_tag_port_tag_id,
11913 (void *)&cmd_config_e_tag_port_tag_id_val,
11914 (void *)&cmd_config_e_tag_port,
11915 (void *)&cmd_config_e_tag_port_id,
11916 (void *)&cmd_config_e_tag_vf,
11917 (void *)&cmd_config_e_tag_vf_id,
11922 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11923 .f = cmd_config_e_tag_insertion_dis_parsed,
11925 .help_str = "E-tag ... : E-tag insertion disable",
11927 (void *)&cmd_config_e_tag_e_tag,
11928 (void *)&cmd_config_e_tag_set,
11929 (void *)&cmd_config_e_tag_insertion,
11930 (void *)&cmd_config_e_tag_off,
11931 (void *)&cmd_config_e_tag_port,
11932 (void *)&cmd_config_e_tag_port_id,
11933 (void *)&cmd_config_e_tag_vf,
11934 (void *)&cmd_config_e_tag_vf_id,
11939 /* E-tag stripping configuration */
11941 cmd_config_e_tag_stripping_parsed(
11942 void *parsed_result,
11943 __attribute__((unused)) struct cmdline *cl,
11944 __attribute__((unused)) void *data)
11946 struct cmd_config_e_tag_result *res =
11948 struct rte_eth_l2_tunnel_conf entry;
11950 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11953 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11955 if (!strcmp(res->on_off, "on"))
11956 rte_eth_dev_l2_tunnel_offload_set
11959 ETH_L2_TUNNEL_STRIPPING_MASK,
11962 rte_eth_dev_l2_tunnel_offload_set
11965 ETH_L2_TUNNEL_STRIPPING_MASK,
11969 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11970 .f = cmd_config_e_tag_stripping_parsed,
11972 .help_str = "E-tag ... : E-tag stripping enable/disable",
11974 (void *)&cmd_config_e_tag_e_tag,
11975 (void *)&cmd_config_e_tag_set,
11976 (void *)&cmd_config_e_tag_stripping,
11977 (void *)&cmd_config_e_tag_on_off,
11978 (void *)&cmd_config_e_tag_port,
11979 (void *)&cmd_config_e_tag_port_id,
11984 /* E-tag forwarding configuration */
11986 cmd_config_e_tag_forwarding_parsed(
11987 void *parsed_result,
11988 __attribute__((unused)) struct cmdline *cl,
11989 __attribute__((unused)) void *data)
11991 struct cmd_config_e_tag_result *res = parsed_result;
11992 struct rte_eth_l2_tunnel_conf entry;
11994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11997 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11999 if (!strcmp(res->on_off, "on"))
12000 rte_eth_dev_l2_tunnel_offload_set
12003 ETH_L2_TUNNEL_FORWARDING_MASK,
12006 rte_eth_dev_l2_tunnel_offload_set
12009 ETH_L2_TUNNEL_FORWARDING_MASK,
12013 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12014 .f = cmd_config_e_tag_forwarding_parsed,
12016 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12018 (void *)&cmd_config_e_tag_e_tag,
12019 (void *)&cmd_config_e_tag_set,
12020 (void *)&cmd_config_e_tag_forwarding,
12021 (void *)&cmd_config_e_tag_on_off,
12022 (void *)&cmd_config_e_tag_port,
12023 (void *)&cmd_config_e_tag_port_id,
12028 /* E-tag filter configuration */
12030 cmd_config_e_tag_filter_add_parsed(
12031 void *parsed_result,
12032 __attribute__((unused)) struct cmdline *cl,
12033 __attribute__((unused)) void *data)
12035 struct cmd_config_e_tag_result *res = parsed_result;
12036 struct rte_eth_l2_tunnel_conf entry;
12039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12042 if (res->e_tag_id_val > 0x3fff) {
12043 printf("e-tag-id must be equal or less than 0x3fff.\n");
12047 ret = rte_eth_dev_filter_supported(res->port_id,
12048 RTE_ETH_FILTER_L2_TUNNEL);
12050 printf("E-tag filter is not supported on port %u.\n",
12055 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12056 entry.tunnel_id = res->e_tag_id_val;
12057 entry.pool = res->dst_pool_val;
12059 ret = rte_eth_dev_filter_ctrl(res->port_id,
12060 RTE_ETH_FILTER_L2_TUNNEL,
12061 RTE_ETH_FILTER_ADD,
12064 printf("E-tag filter programming error: (%s)\n",
12068 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12069 .f = cmd_config_e_tag_filter_add_parsed,
12071 .help_str = "E-tag ... : E-tag filter add",
12073 (void *)&cmd_config_e_tag_e_tag,
12074 (void *)&cmd_config_e_tag_set,
12075 (void *)&cmd_config_e_tag_filter,
12076 (void *)&cmd_config_e_tag_add,
12077 (void *)&cmd_config_e_tag_e_tag_id,
12078 (void *)&cmd_config_e_tag_e_tag_id_val,
12079 (void *)&cmd_config_e_tag_dst_pool,
12080 (void *)&cmd_config_e_tag_dst_pool_val,
12081 (void *)&cmd_config_e_tag_port,
12082 (void *)&cmd_config_e_tag_port_id,
12088 cmd_config_e_tag_filter_del_parsed(
12089 void *parsed_result,
12090 __attribute__((unused)) struct cmdline *cl,
12091 __attribute__((unused)) void *data)
12093 struct cmd_config_e_tag_result *res = parsed_result;
12094 struct rte_eth_l2_tunnel_conf entry;
12097 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12100 if (res->e_tag_id_val > 0x3fff) {
12101 printf("e-tag-id must be less than 0x3fff.\n");
12105 ret = rte_eth_dev_filter_supported(res->port_id,
12106 RTE_ETH_FILTER_L2_TUNNEL);
12108 printf("E-tag filter is not supported on port %u.\n",
12113 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12114 entry.tunnel_id = res->e_tag_id_val;
12116 ret = rte_eth_dev_filter_ctrl(res->port_id,
12117 RTE_ETH_FILTER_L2_TUNNEL,
12118 RTE_ETH_FILTER_DELETE,
12121 printf("E-tag filter programming error: (%s)\n",
12125 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12126 .f = cmd_config_e_tag_filter_del_parsed,
12128 .help_str = "E-tag ... : E-tag filter delete",
12130 (void *)&cmd_config_e_tag_e_tag,
12131 (void *)&cmd_config_e_tag_set,
12132 (void *)&cmd_config_e_tag_filter,
12133 (void *)&cmd_config_e_tag_del,
12134 (void *)&cmd_config_e_tag_e_tag_id,
12135 (void *)&cmd_config_e_tag_e_tag_id_val,
12136 (void *)&cmd_config_e_tag_port,
12137 (void *)&cmd_config_e_tag_port_id,
12142 /* vf vlan anti spoof configuration */
12144 /* Common result structure for vf vlan anti spoof */
12145 struct cmd_vf_vlan_anti_spoof_result {
12146 cmdline_fixed_string_t set;
12147 cmdline_fixed_string_t vf;
12148 cmdline_fixed_string_t vlan;
12149 cmdline_fixed_string_t antispoof;
12152 cmdline_fixed_string_t on_off;
12155 /* Common CLI fields for vf vlan anti spoof enable disable */
12156 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12157 TOKEN_STRING_INITIALIZER
12158 (struct cmd_vf_vlan_anti_spoof_result,
12160 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_vf_vlan_anti_spoof_result,
12164 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_vf_vlan_anti_spoof_result,
12168 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_vf_vlan_anti_spoof_result,
12171 antispoof, "antispoof");
12172 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12173 TOKEN_NUM_INITIALIZER
12174 (struct cmd_vf_vlan_anti_spoof_result,
12176 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12177 TOKEN_NUM_INITIALIZER
12178 (struct cmd_vf_vlan_anti_spoof_result,
12180 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12181 TOKEN_STRING_INITIALIZER
12182 (struct cmd_vf_vlan_anti_spoof_result,
12186 cmd_set_vf_vlan_anti_spoof_parsed(
12187 void *parsed_result,
12188 __attribute__((unused)) struct cmdline *cl,
12189 __attribute__((unused)) void *data)
12191 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12192 int ret = -ENOTSUP;
12194 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12199 #ifdef RTE_LIBRTE_IXGBE_PMD
12200 if (ret == -ENOTSUP)
12201 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12202 res->vf_id, is_on);
12204 #ifdef RTE_LIBRTE_I40E_PMD
12205 if (ret == -ENOTSUP)
12206 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12207 res->vf_id, is_on);
12209 #ifdef RTE_LIBRTE_BNXT_PMD
12210 if (ret == -ENOTSUP)
12211 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12212 res->vf_id, is_on);
12219 printf("invalid vf_id %d\n", res->vf_id);
12222 printf("invalid port_id %d\n", res->port_id);
12225 printf("function not implemented\n");
12228 printf("programming error: (%s)\n", strerror(-ret));
12232 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12233 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12235 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12237 (void *)&cmd_vf_vlan_anti_spoof_set,
12238 (void *)&cmd_vf_vlan_anti_spoof_vf,
12239 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12240 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12241 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12242 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12243 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12248 /* vf mac anti spoof configuration */
12250 /* Common result structure for vf mac anti spoof */
12251 struct cmd_vf_mac_anti_spoof_result {
12252 cmdline_fixed_string_t set;
12253 cmdline_fixed_string_t vf;
12254 cmdline_fixed_string_t mac;
12255 cmdline_fixed_string_t antispoof;
12258 cmdline_fixed_string_t on_off;
12261 /* Common CLI fields for vf mac anti spoof enable disable */
12262 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12263 TOKEN_STRING_INITIALIZER
12264 (struct cmd_vf_mac_anti_spoof_result,
12266 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12267 TOKEN_STRING_INITIALIZER
12268 (struct cmd_vf_mac_anti_spoof_result,
12270 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12271 TOKEN_STRING_INITIALIZER
12272 (struct cmd_vf_mac_anti_spoof_result,
12274 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12275 TOKEN_STRING_INITIALIZER
12276 (struct cmd_vf_mac_anti_spoof_result,
12277 antispoof, "antispoof");
12278 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12279 TOKEN_NUM_INITIALIZER
12280 (struct cmd_vf_mac_anti_spoof_result,
12282 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12283 TOKEN_NUM_INITIALIZER
12284 (struct cmd_vf_mac_anti_spoof_result,
12286 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_vf_mac_anti_spoof_result,
12292 cmd_set_vf_mac_anti_spoof_parsed(
12293 void *parsed_result,
12294 __attribute__((unused)) struct cmdline *cl,
12295 __attribute__((unused)) void *data)
12297 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12298 int ret = -ENOTSUP;
12300 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12305 #ifdef RTE_LIBRTE_IXGBE_PMD
12306 if (ret == -ENOTSUP)
12307 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12308 res->vf_id, is_on);
12310 #ifdef RTE_LIBRTE_I40E_PMD
12311 if (ret == -ENOTSUP)
12312 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12313 res->vf_id, is_on);
12315 #ifdef RTE_LIBRTE_BNXT_PMD
12316 if (ret == -ENOTSUP)
12317 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12318 res->vf_id, is_on);
12325 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12328 printf("invalid port_id %d\n", res->port_id);
12331 printf("function not implemented\n");
12334 printf("programming error: (%s)\n", strerror(-ret));
12338 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12339 .f = cmd_set_vf_mac_anti_spoof_parsed,
12341 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12343 (void *)&cmd_vf_mac_anti_spoof_set,
12344 (void *)&cmd_vf_mac_anti_spoof_vf,
12345 (void *)&cmd_vf_mac_anti_spoof_mac,
12346 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12347 (void *)&cmd_vf_mac_anti_spoof_port_id,
12348 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12349 (void *)&cmd_vf_mac_anti_spoof_on_off,
12354 /* vf vlan strip queue configuration */
12356 /* Common result structure for vf mac anti spoof */
12357 struct cmd_vf_vlan_stripq_result {
12358 cmdline_fixed_string_t set;
12359 cmdline_fixed_string_t vf;
12360 cmdline_fixed_string_t vlan;
12361 cmdline_fixed_string_t stripq;
12364 cmdline_fixed_string_t on_off;
12367 /* Common CLI fields for vf vlan strip enable disable */
12368 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_vf_vlan_stripq_result,
12372 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_vf_vlan_stripq_result,
12376 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_vf_vlan_stripq_result,
12380 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_vf_vlan_stripq_result,
12384 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12385 TOKEN_NUM_INITIALIZER
12386 (struct cmd_vf_vlan_stripq_result,
12388 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_vf_vlan_stripq_result,
12392 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12393 TOKEN_STRING_INITIALIZER
12394 (struct cmd_vf_vlan_stripq_result,
12398 cmd_set_vf_vlan_stripq_parsed(
12399 void *parsed_result,
12400 __attribute__((unused)) struct cmdline *cl,
12401 __attribute__((unused)) void *data)
12403 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12404 int ret = -ENOTSUP;
12406 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12411 #ifdef RTE_LIBRTE_IXGBE_PMD
12412 if (ret == -ENOTSUP)
12413 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12414 res->vf_id, is_on);
12416 #ifdef RTE_LIBRTE_I40E_PMD
12417 if (ret == -ENOTSUP)
12418 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12419 res->vf_id, is_on);
12421 #ifdef RTE_LIBRTE_BNXT_PMD
12422 if (ret == -ENOTSUP)
12423 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12424 res->vf_id, is_on);
12431 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12434 printf("invalid port_id %d\n", res->port_id);
12437 printf("function not implemented\n");
12440 printf("programming error: (%s)\n", strerror(-ret));
12444 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12445 .f = cmd_set_vf_vlan_stripq_parsed,
12447 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12449 (void *)&cmd_vf_vlan_stripq_set,
12450 (void *)&cmd_vf_vlan_stripq_vf,
12451 (void *)&cmd_vf_vlan_stripq_vlan,
12452 (void *)&cmd_vf_vlan_stripq_stripq,
12453 (void *)&cmd_vf_vlan_stripq_port_id,
12454 (void *)&cmd_vf_vlan_stripq_vf_id,
12455 (void *)&cmd_vf_vlan_stripq_on_off,
12460 /* vf vlan insert configuration */
12462 /* Common result structure for vf vlan insert */
12463 struct cmd_vf_vlan_insert_result {
12464 cmdline_fixed_string_t set;
12465 cmdline_fixed_string_t vf;
12466 cmdline_fixed_string_t vlan;
12467 cmdline_fixed_string_t insert;
12473 /* Common CLI fields for vf vlan insert enable disable */
12474 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_vf_vlan_insert_result,
12478 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_vf_vlan_insert_result,
12482 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_vlan_insert_result,
12486 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_vlan_insert_result,
12490 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12491 TOKEN_NUM_INITIALIZER
12492 (struct cmd_vf_vlan_insert_result,
12494 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12495 TOKEN_NUM_INITIALIZER
12496 (struct cmd_vf_vlan_insert_result,
12498 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_vlan_insert_result,
12504 cmd_set_vf_vlan_insert_parsed(
12505 void *parsed_result,
12506 __attribute__((unused)) struct cmdline *cl,
12507 __attribute__((unused)) void *data)
12509 struct cmd_vf_vlan_insert_result *res = parsed_result;
12510 int ret = -ENOTSUP;
12512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12515 #ifdef RTE_LIBRTE_IXGBE_PMD
12516 if (ret == -ENOTSUP)
12517 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12520 #ifdef RTE_LIBRTE_I40E_PMD
12521 if (ret == -ENOTSUP)
12522 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12525 #ifdef RTE_LIBRTE_BNXT_PMD
12526 if (ret == -ENOTSUP)
12527 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12535 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12538 printf("invalid port_id %d\n", res->port_id);
12541 printf("function not implemented\n");
12544 printf("programming error: (%s)\n", strerror(-ret));
12548 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12549 .f = cmd_set_vf_vlan_insert_parsed,
12551 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12553 (void *)&cmd_vf_vlan_insert_set,
12554 (void *)&cmd_vf_vlan_insert_vf,
12555 (void *)&cmd_vf_vlan_insert_vlan,
12556 (void *)&cmd_vf_vlan_insert_insert,
12557 (void *)&cmd_vf_vlan_insert_port_id,
12558 (void *)&cmd_vf_vlan_insert_vf_id,
12559 (void *)&cmd_vf_vlan_insert_vlan_id,
12564 /* tx loopback configuration */
12566 /* Common result structure for tx loopback */
12567 struct cmd_tx_loopback_result {
12568 cmdline_fixed_string_t set;
12569 cmdline_fixed_string_t tx;
12570 cmdline_fixed_string_t loopback;
12572 cmdline_fixed_string_t on_off;
12575 /* Common CLI fields for tx loopback enable disable */
12576 cmdline_parse_token_string_t cmd_tx_loopback_set =
12577 TOKEN_STRING_INITIALIZER
12578 (struct cmd_tx_loopback_result,
12580 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_tx_loopback_result,
12584 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_tx_loopback_result,
12587 loopback, "loopback");
12588 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12589 TOKEN_NUM_INITIALIZER
12590 (struct cmd_tx_loopback_result,
12592 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12593 TOKEN_STRING_INITIALIZER
12594 (struct cmd_tx_loopback_result,
12598 cmd_set_tx_loopback_parsed(
12599 void *parsed_result,
12600 __attribute__((unused)) struct cmdline *cl,
12601 __attribute__((unused)) void *data)
12603 struct cmd_tx_loopback_result *res = parsed_result;
12604 int ret = -ENOTSUP;
12606 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12608 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12611 #ifdef RTE_LIBRTE_IXGBE_PMD
12612 if (ret == -ENOTSUP)
12613 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12615 #ifdef RTE_LIBRTE_I40E_PMD
12616 if (ret == -ENOTSUP)
12617 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12619 #ifdef RTE_LIBRTE_BNXT_PMD
12620 if (ret == -ENOTSUP)
12621 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12628 printf("invalid is_on %d\n", is_on);
12631 printf("invalid port_id %d\n", res->port_id);
12634 printf("function not implemented\n");
12637 printf("programming error: (%s)\n", strerror(-ret));
12641 cmdline_parse_inst_t cmd_set_tx_loopback = {
12642 .f = cmd_set_tx_loopback_parsed,
12644 .help_str = "set tx loopback <port_id> on|off",
12646 (void *)&cmd_tx_loopback_set,
12647 (void *)&cmd_tx_loopback_tx,
12648 (void *)&cmd_tx_loopback_loopback,
12649 (void *)&cmd_tx_loopback_port_id,
12650 (void *)&cmd_tx_loopback_on_off,
12655 /* all queues drop enable configuration */
12657 /* Common result structure for all queues drop enable */
12658 struct cmd_all_queues_drop_en_result {
12659 cmdline_fixed_string_t set;
12660 cmdline_fixed_string_t all;
12661 cmdline_fixed_string_t queues;
12662 cmdline_fixed_string_t drop;
12664 cmdline_fixed_string_t on_off;
12667 /* Common CLI fields for tx loopback enable disable */
12668 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12669 TOKEN_STRING_INITIALIZER
12670 (struct cmd_all_queues_drop_en_result,
12672 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12673 TOKEN_STRING_INITIALIZER
12674 (struct cmd_all_queues_drop_en_result,
12676 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_all_queues_drop_en_result,
12680 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_all_queues_drop_en_result,
12684 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12685 TOKEN_NUM_INITIALIZER
12686 (struct cmd_all_queues_drop_en_result,
12688 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_all_queues_drop_en_result,
12694 cmd_set_all_queues_drop_en_parsed(
12695 void *parsed_result,
12696 __attribute__((unused)) struct cmdline *cl,
12697 __attribute__((unused)) void *data)
12699 struct cmd_all_queues_drop_en_result *res = parsed_result;
12700 int ret = -ENOTSUP;
12701 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12706 #ifdef RTE_LIBRTE_IXGBE_PMD
12707 if (ret == -ENOTSUP)
12708 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12710 #ifdef RTE_LIBRTE_BNXT_PMD
12711 if (ret == -ENOTSUP)
12712 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12718 printf("invalid is_on %d\n", is_on);
12721 printf("invalid port_id %d\n", res->port_id);
12724 printf("function not implemented\n");
12727 printf("programming error: (%s)\n", strerror(-ret));
12731 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12732 .f = cmd_set_all_queues_drop_en_parsed,
12734 .help_str = "set all queues drop <port_id> on|off",
12736 (void *)&cmd_all_queues_drop_en_set,
12737 (void *)&cmd_all_queues_drop_en_all,
12738 (void *)&cmd_all_queues_drop_en_queues,
12739 (void *)&cmd_all_queues_drop_en_drop,
12740 (void *)&cmd_all_queues_drop_en_port_id,
12741 (void *)&cmd_all_queues_drop_en_on_off,
12746 /* vf split drop enable configuration */
12748 /* Common result structure for vf split drop enable */
12749 struct cmd_vf_split_drop_en_result {
12750 cmdline_fixed_string_t set;
12751 cmdline_fixed_string_t vf;
12752 cmdline_fixed_string_t split;
12753 cmdline_fixed_string_t drop;
12756 cmdline_fixed_string_t on_off;
12759 /* Common CLI fields for vf split drop enable disable */
12760 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12761 TOKEN_STRING_INITIALIZER
12762 (struct cmd_vf_split_drop_en_result,
12764 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_vf_split_drop_en_result,
12768 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_vf_split_drop_en_result,
12772 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_vf_split_drop_en_result,
12776 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12777 TOKEN_NUM_INITIALIZER
12778 (struct cmd_vf_split_drop_en_result,
12780 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12781 TOKEN_NUM_INITIALIZER
12782 (struct cmd_vf_split_drop_en_result,
12784 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12785 TOKEN_STRING_INITIALIZER
12786 (struct cmd_vf_split_drop_en_result,
12790 cmd_set_vf_split_drop_en_parsed(
12791 void *parsed_result,
12792 __attribute__((unused)) struct cmdline *cl,
12793 __attribute__((unused)) void *data)
12795 struct cmd_vf_split_drop_en_result *res = parsed_result;
12796 int ret = -ENOTSUP;
12797 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12802 #ifdef RTE_LIBRTE_IXGBE_PMD
12803 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12810 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12813 printf("invalid port_id %d\n", res->port_id);
12816 printf("not supported on port %d\n", res->port_id);
12819 printf("programming error: (%s)\n", strerror(-ret));
12823 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12824 .f = cmd_set_vf_split_drop_en_parsed,
12826 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12828 (void *)&cmd_vf_split_drop_en_set,
12829 (void *)&cmd_vf_split_drop_en_vf,
12830 (void *)&cmd_vf_split_drop_en_split,
12831 (void *)&cmd_vf_split_drop_en_drop,
12832 (void *)&cmd_vf_split_drop_en_port_id,
12833 (void *)&cmd_vf_split_drop_en_vf_id,
12834 (void *)&cmd_vf_split_drop_en_on_off,
12839 /* vf mac address configuration */
12841 /* Common result structure for vf mac address */
12842 struct cmd_set_vf_mac_addr_result {
12843 cmdline_fixed_string_t set;
12844 cmdline_fixed_string_t vf;
12845 cmdline_fixed_string_t mac;
12846 cmdline_fixed_string_t addr;
12849 struct ether_addr mac_addr;
12853 /* Common CLI fields for vf split drop enable disable */
12854 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12855 TOKEN_STRING_INITIALIZER
12856 (struct cmd_set_vf_mac_addr_result,
12858 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_set_vf_mac_addr_result,
12862 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_set_vf_mac_addr_result,
12866 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_set_vf_mac_addr_result,
12870 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12871 TOKEN_NUM_INITIALIZER
12872 (struct cmd_set_vf_mac_addr_result,
12874 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_set_vf_mac_addr_result,
12878 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12879 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12883 cmd_set_vf_mac_addr_parsed(
12884 void *parsed_result,
12885 __attribute__((unused)) struct cmdline *cl,
12886 __attribute__((unused)) void *data)
12888 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12889 int ret = -ENOTSUP;
12891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12894 #ifdef RTE_LIBRTE_IXGBE_PMD
12895 if (ret == -ENOTSUP)
12896 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12899 #ifdef RTE_LIBRTE_I40E_PMD
12900 if (ret == -ENOTSUP)
12901 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12904 #ifdef RTE_LIBRTE_BNXT_PMD
12905 if (ret == -ENOTSUP)
12906 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12914 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12917 printf("invalid port_id %d\n", res->port_id);
12920 printf("function not implemented\n");
12923 printf("programming error: (%s)\n", strerror(-ret));
12927 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12928 .f = cmd_set_vf_mac_addr_parsed,
12930 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12932 (void *)&cmd_set_vf_mac_addr_set,
12933 (void *)&cmd_set_vf_mac_addr_vf,
12934 (void *)&cmd_set_vf_mac_addr_mac,
12935 (void *)&cmd_set_vf_mac_addr_addr,
12936 (void *)&cmd_set_vf_mac_addr_port_id,
12937 (void *)&cmd_set_vf_mac_addr_vf_id,
12938 (void *)&cmd_set_vf_mac_addr_mac_addr,
12943 /* MACsec configuration */
12945 /* Common result structure for MACsec offload enable */
12946 struct cmd_macsec_offload_on_result {
12947 cmdline_fixed_string_t set;
12948 cmdline_fixed_string_t macsec;
12949 cmdline_fixed_string_t offload;
12951 cmdline_fixed_string_t on;
12952 cmdline_fixed_string_t encrypt;
12953 cmdline_fixed_string_t en_on_off;
12954 cmdline_fixed_string_t replay_protect;
12955 cmdline_fixed_string_t rp_on_off;
12958 /* Common CLI fields for MACsec offload disable */
12959 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12960 TOKEN_STRING_INITIALIZER
12961 (struct cmd_macsec_offload_on_result,
12963 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_macsec_offload_on_result,
12967 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_macsec_offload_on_result,
12970 offload, "offload");
12971 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12972 TOKEN_NUM_INITIALIZER
12973 (struct cmd_macsec_offload_on_result,
12975 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_macsec_offload_on_result,
12979 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_macsec_offload_on_result,
12982 encrypt, "encrypt");
12983 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_macsec_offload_on_result,
12986 en_on_off, "on#off");
12987 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_macsec_offload_on_result,
12990 replay_protect, "replay-protect");
12991 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_macsec_offload_on_result,
12994 rp_on_off, "on#off");
12997 cmd_set_macsec_offload_on_parsed(
12998 void *parsed_result,
12999 __attribute__((unused)) struct cmdline *cl,
13000 __attribute__((unused)) void *data)
13002 struct cmd_macsec_offload_on_result *res = parsed_result;
13003 int ret = -ENOTSUP;
13004 portid_t port_id = res->port_id;
13005 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13006 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13008 if (port_id_is_invalid(port_id, ENABLED_WARN))
13011 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
13012 #ifdef RTE_LIBRTE_IXGBE_PMD
13013 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13022 printf("invalid port_id %d\n", port_id);
13025 printf("not supported on port %d\n", port_id);
13028 printf("programming error: (%s)\n", strerror(-ret));
13032 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13033 .f = cmd_set_macsec_offload_on_parsed,
13035 .help_str = "set macsec offload <port_id> on "
13036 "encrypt on|off replay-protect on|off",
13038 (void *)&cmd_macsec_offload_on_set,
13039 (void *)&cmd_macsec_offload_on_macsec,
13040 (void *)&cmd_macsec_offload_on_offload,
13041 (void *)&cmd_macsec_offload_on_port_id,
13042 (void *)&cmd_macsec_offload_on_on,
13043 (void *)&cmd_macsec_offload_on_encrypt,
13044 (void *)&cmd_macsec_offload_on_en_on_off,
13045 (void *)&cmd_macsec_offload_on_replay_protect,
13046 (void *)&cmd_macsec_offload_on_rp_on_off,
13051 /* Common result structure for MACsec offload disable */
13052 struct cmd_macsec_offload_off_result {
13053 cmdline_fixed_string_t set;
13054 cmdline_fixed_string_t macsec;
13055 cmdline_fixed_string_t offload;
13057 cmdline_fixed_string_t off;
13060 /* Common CLI fields for MACsec offload disable */
13061 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13062 TOKEN_STRING_INITIALIZER
13063 (struct cmd_macsec_offload_off_result,
13065 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_macsec_offload_off_result,
13069 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_macsec_offload_off_result,
13072 offload, "offload");
13073 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13074 TOKEN_NUM_INITIALIZER
13075 (struct cmd_macsec_offload_off_result,
13077 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_macsec_offload_off_result,
13083 cmd_set_macsec_offload_off_parsed(
13084 void *parsed_result,
13085 __attribute__((unused)) struct cmdline *cl,
13086 __attribute__((unused)) void *data)
13088 struct cmd_macsec_offload_off_result *res = parsed_result;
13089 int ret = -ENOTSUP;
13090 portid_t port_id = res->port_id;
13092 if (port_id_is_invalid(port_id, ENABLED_WARN))
13095 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13096 #ifdef RTE_LIBRTE_IXGBE_PMD
13097 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13104 printf("invalid port_id %d\n", port_id);
13107 printf("not supported on port %d\n", port_id);
13110 printf("programming error: (%s)\n", strerror(-ret));
13114 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13115 .f = cmd_set_macsec_offload_off_parsed,
13117 .help_str = "set macsec offload <port_id> off",
13119 (void *)&cmd_macsec_offload_off_set,
13120 (void *)&cmd_macsec_offload_off_macsec,
13121 (void *)&cmd_macsec_offload_off_offload,
13122 (void *)&cmd_macsec_offload_off_port_id,
13123 (void *)&cmd_macsec_offload_off_off,
13128 /* Common result structure for MACsec secure connection configure */
13129 struct cmd_macsec_sc_result {
13130 cmdline_fixed_string_t set;
13131 cmdline_fixed_string_t macsec;
13132 cmdline_fixed_string_t sc;
13133 cmdline_fixed_string_t tx_rx;
13135 struct ether_addr mac;
13139 /* Common CLI fields for MACsec secure connection configure */
13140 cmdline_parse_token_string_t cmd_macsec_sc_set =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_macsec_sc_result,
13144 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13145 TOKEN_STRING_INITIALIZER
13146 (struct cmd_macsec_sc_result,
13148 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_macsec_sc_result,
13152 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13153 TOKEN_STRING_INITIALIZER
13154 (struct cmd_macsec_sc_result,
13156 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13157 TOKEN_NUM_INITIALIZER
13158 (struct cmd_macsec_sc_result,
13160 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13161 TOKEN_ETHERADDR_INITIALIZER
13162 (struct cmd_macsec_sc_result,
13164 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13165 TOKEN_NUM_INITIALIZER
13166 (struct cmd_macsec_sc_result,
13170 cmd_set_macsec_sc_parsed(
13171 void *parsed_result,
13172 __attribute__((unused)) struct cmdline *cl,
13173 __attribute__((unused)) void *data)
13175 struct cmd_macsec_sc_result *res = parsed_result;
13176 int ret = -ENOTSUP;
13177 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13179 #ifdef RTE_LIBRTE_IXGBE_PMD
13181 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13182 res->mac.addr_bytes) :
13183 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13184 res->mac.addr_bytes, res->pi);
13186 RTE_SET_USED(is_tx);
13192 printf("invalid port_id %d\n", res->port_id);
13195 printf("not supported on port %d\n", res->port_id);
13198 printf("programming error: (%s)\n", strerror(-ret));
13202 cmdline_parse_inst_t cmd_set_macsec_sc = {
13203 .f = cmd_set_macsec_sc_parsed,
13205 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13207 (void *)&cmd_macsec_sc_set,
13208 (void *)&cmd_macsec_sc_macsec,
13209 (void *)&cmd_macsec_sc_sc,
13210 (void *)&cmd_macsec_sc_tx_rx,
13211 (void *)&cmd_macsec_sc_port_id,
13212 (void *)&cmd_macsec_sc_mac,
13213 (void *)&cmd_macsec_sc_pi,
13218 /* Common result structure for MACsec secure connection configure */
13219 struct cmd_macsec_sa_result {
13220 cmdline_fixed_string_t set;
13221 cmdline_fixed_string_t macsec;
13222 cmdline_fixed_string_t sa;
13223 cmdline_fixed_string_t tx_rx;
13228 cmdline_fixed_string_t key;
13231 /* Common CLI fields for MACsec secure connection configure */
13232 cmdline_parse_token_string_t cmd_macsec_sa_set =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_macsec_sa_result,
13236 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_macsec_sa_result,
13240 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13241 TOKEN_STRING_INITIALIZER
13242 (struct cmd_macsec_sa_result,
13244 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_macsec_sa_result,
13248 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13249 TOKEN_NUM_INITIALIZER
13250 (struct cmd_macsec_sa_result,
13252 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13253 TOKEN_NUM_INITIALIZER
13254 (struct cmd_macsec_sa_result,
13256 cmdline_parse_token_num_t cmd_macsec_sa_an =
13257 TOKEN_NUM_INITIALIZER
13258 (struct cmd_macsec_sa_result,
13260 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13261 TOKEN_NUM_INITIALIZER
13262 (struct cmd_macsec_sa_result,
13264 cmdline_parse_token_string_t cmd_macsec_sa_key =
13265 TOKEN_STRING_INITIALIZER
13266 (struct cmd_macsec_sa_result,
13270 cmd_set_macsec_sa_parsed(
13271 void *parsed_result,
13272 __attribute__((unused)) struct cmdline *cl,
13273 __attribute__((unused)) void *data)
13275 struct cmd_macsec_sa_result *res = parsed_result;
13276 int ret = -ENOTSUP;
13277 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13278 uint8_t key[16] = { 0 };
13284 key_len = strlen(res->key) / 2;
13288 for (i = 0; i < key_len; i++) {
13289 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13292 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13295 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13298 #ifdef RTE_LIBRTE_IXGBE_PMD
13300 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13301 res->idx, res->an, res->pn, key) :
13302 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13303 res->idx, res->an, res->pn, key);
13305 RTE_SET_USED(is_tx);
13312 printf("invalid idx %d or an %d\n", res->idx, res->an);
13315 printf("invalid port_id %d\n", res->port_id);
13318 printf("not supported on port %d\n", res->port_id);
13321 printf("programming error: (%s)\n", strerror(-ret));
13325 cmdline_parse_inst_t cmd_set_macsec_sa = {
13326 .f = cmd_set_macsec_sa_parsed,
13328 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13330 (void *)&cmd_macsec_sa_set,
13331 (void *)&cmd_macsec_sa_macsec,
13332 (void *)&cmd_macsec_sa_sa,
13333 (void *)&cmd_macsec_sa_tx_rx,
13334 (void *)&cmd_macsec_sa_port_id,
13335 (void *)&cmd_macsec_sa_idx,
13336 (void *)&cmd_macsec_sa_an,
13337 (void *)&cmd_macsec_sa_pn,
13338 (void *)&cmd_macsec_sa_key,
13343 /* VF unicast promiscuous mode configuration */
13345 /* Common result structure for VF unicast promiscuous mode */
13346 struct cmd_vf_promisc_result {
13347 cmdline_fixed_string_t set;
13348 cmdline_fixed_string_t vf;
13349 cmdline_fixed_string_t promisc;
13352 cmdline_fixed_string_t on_off;
13355 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13356 cmdline_parse_token_string_t cmd_vf_promisc_set =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_vf_promisc_result,
13360 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_promisc_result,
13364 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_promisc_result,
13367 promisc, "promisc");
13368 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13369 TOKEN_NUM_INITIALIZER
13370 (struct cmd_vf_promisc_result,
13372 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13373 TOKEN_NUM_INITIALIZER
13374 (struct cmd_vf_promisc_result,
13376 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_vf_promisc_result,
13382 cmd_set_vf_promisc_parsed(
13383 void *parsed_result,
13384 __attribute__((unused)) struct cmdline *cl,
13385 __attribute__((unused)) void *data)
13387 struct cmd_vf_promisc_result *res = parsed_result;
13388 int ret = -ENOTSUP;
13390 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13395 #ifdef RTE_LIBRTE_I40E_PMD
13396 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13397 res->vf_id, is_on);
13404 printf("invalid vf_id %d\n", res->vf_id);
13407 printf("invalid port_id %d\n", res->port_id);
13410 printf("function not implemented\n");
13413 printf("programming error: (%s)\n", strerror(-ret));
13417 cmdline_parse_inst_t cmd_set_vf_promisc = {
13418 .f = cmd_set_vf_promisc_parsed,
13420 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13421 "Set unicast promiscuous mode for a VF from the PF",
13423 (void *)&cmd_vf_promisc_set,
13424 (void *)&cmd_vf_promisc_vf,
13425 (void *)&cmd_vf_promisc_promisc,
13426 (void *)&cmd_vf_promisc_port_id,
13427 (void *)&cmd_vf_promisc_vf_id,
13428 (void *)&cmd_vf_promisc_on_off,
13433 /* VF multicast promiscuous mode configuration */
13435 /* Common result structure for VF multicast promiscuous mode */
13436 struct cmd_vf_allmulti_result {
13437 cmdline_fixed_string_t set;
13438 cmdline_fixed_string_t vf;
13439 cmdline_fixed_string_t allmulti;
13442 cmdline_fixed_string_t on_off;
13445 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13446 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13447 TOKEN_STRING_INITIALIZER
13448 (struct cmd_vf_allmulti_result,
13450 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13451 TOKEN_STRING_INITIALIZER
13452 (struct cmd_vf_allmulti_result,
13454 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13455 TOKEN_STRING_INITIALIZER
13456 (struct cmd_vf_allmulti_result,
13457 allmulti, "allmulti");
13458 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13459 TOKEN_NUM_INITIALIZER
13460 (struct cmd_vf_allmulti_result,
13462 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13463 TOKEN_NUM_INITIALIZER
13464 (struct cmd_vf_allmulti_result,
13466 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_allmulti_result,
13472 cmd_set_vf_allmulti_parsed(
13473 void *parsed_result,
13474 __attribute__((unused)) struct cmdline *cl,
13475 __attribute__((unused)) void *data)
13477 struct cmd_vf_allmulti_result *res = parsed_result;
13478 int ret = -ENOTSUP;
13480 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13485 #ifdef RTE_LIBRTE_I40E_PMD
13486 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13487 res->vf_id, is_on);
13494 printf("invalid vf_id %d\n", res->vf_id);
13497 printf("invalid port_id %d\n", res->port_id);
13500 printf("function not implemented\n");
13503 printf("programming error: (%s)\n", strerror(-ret));
13507 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13508 .f = cmd_set_vf_allmulti_parsed,
13510 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13511 "Set multicast promiscuous mode for a VF from the PF",
13513 (void *)&cmd_vf_allmulti_set,
13514 (void *)&cmd_vf_allmulti_vf,
13515 (void *)&cmd_vf_allmulti_allmulti,
13516 (void *)&cmd_vf_allmulti_port_id,
13517 (void *)&cmd_vf_allmulti_vf_id,
13518 (void *)&cmd_vf_allmulti_on_off,
13523 /* vf broadcast mode configuration */
13525 /* Common result structure for vf broadcast */
13526 struct cmd_set_vf_broadcast_result {
13527 cmdline_fixed_string_t set;
13528 cmdline_fixed_string_t vf;
13529 cmdline_fixed_string_t broadcast;
13532 cmdline_fixed_string_t on_off;
13535 /* Common CLI fields for vf broadcast enable disable */
13536 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13537 TOKEN_STRING_INITIALIZER
13538 (struct cmd_set_vf_broadcast_result,
13540 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13541 TOKEN_STRING_INITIALIZER
13542 (struct cmd_set_vf_broadcast_result,
13544 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_set_vf_broadcast_result,
13547 broadcast, "broadcast");
13548 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13549 TOKEN_NUM_INITIALIZER
13550 (struct cmd_set_vf_broadcast_result,
13552 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13553 TOKEN_NUM_INITIALIZER
13554 (struct cmd_set_vf_broadcast_result,
13556 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_set_vf_broadcast_result,
13562 cmd_set_vf_broadcast_parsed(
13563 void *parsed_result,
13564 __attribute__((unused)) struct cmdline *cl,
13565 __attribute__((unused)) void *data)
13567 struct cmd_set_vf_broadcast_result *res = parsed_result;
13568 int ret = -ENOTSUP;
13570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13575 #ifdef RTE_LIBRTE_I40E_PMD
13576 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13577 res->vf_id, is_on);
13584 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13587 printf("invalid port_id %d\n", res->port_id);
13590 printf("function not implemented\n");
13593 printf("programming error: (%s)\n", strerror(-ret));
13597 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13598 .f = cmd_set_vf_broadcast_parsed,
13600 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13602 (void *)&cmd_set_vf_broadcast_set,
13603 (void *)&cmd_set_vf_broadcast_vf,
13604 (void *)&cmd_set_vf_broadcast_broadcast,
13605 (void *)&cmd_set_vf_broadcast_port_id,
13606 (void *)&cmd_set_vf_broadcast_vf_id,
13607 (void *)&cmd_set_vf_broadcast_on_off,
13612 /* vf vlan tag configuration */
13614 /* Common result structure for vf vlan tag */
13615 struct cmd_set_vf_vlan_tag_result {
13616 cmdline_fixed_string_t set;
13617 cmdline_fixed_string_t vf;
13618 cmdline_fixed_string_t vlan;
13619 cmdline_fixed_string_t tag;
13622 cmdline_fixed_string_t on_off;
13625 /* Common CLI fields for vf vlan tag enable disable */
13626 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13627 TOKEN_STRING_INITIALIZER
13628 (struct cmd_set_vf_vlan_tag_result,
13630 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13631 TOKEN_STRING_INITIALIZER
13632 (struct cmd_set_vf_vlan_tag_result,
13634 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13635 TOKEN_STRING_INITIALIZER
13636 (struct cmd_set_vf_vlan_tag_result,
13638 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13639 TOKEN_STRING_INITIALIZER
13640 (struct cmd_set_vf_vlan_tag_result,
13642 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13643 TOKEN_NUM_INITIALIZER
13644 (struct cmd_set_vf_vlan_tag_result,
13646 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13647 TOKEN_NUM_INITIALIZER
13648 (struct cmd_set_vf_vlan_tag_result,
13650 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_set_vf_vlan_tag_result,
13656 cmd_set_vf_vlan_tag_parsed(
13657 void *parsed_result,
13658 __attribute__((unused)) struct cmdline *cl,
13659 __attribute__((unused)) void *data)
13661 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13662 int ret = -ENOTSUP;
13664 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13669 #ifdef RTE_LIBRTE_I40E_PMD
13670 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13671 res->vf_id, is_on);
13678 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13681 printf("invalid port_id %d\n", res->port_id);
13684 printf("function not implemented\n");
13687 printf("programming error: (%s)\n", strerror(-ret));
13691 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13692 .f = cmd_set_vf_vlan_tag_parsed,
13694 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13696 (void *)&cmd_set_vf_vlan_tag_set,
13697 (void *)&cmd_set_vf_vlan_tag_vf,
13698 (void *)&cmd_set_vf_vlan_tag_vlan,
13699 (void *)&cmd_set_vf_vlan_tag_tag,
13700 (void *)&cmd_set_vf_vlan_tag_port_id,
13701 (void *)&cmd_set_vf_vlan_tag_vf_id,
13702 (void *)&cmd_set_vf_vlan_tag_on_off,
13707 /* Common definition of VF and TC TX bandwidth configuration */
13708 struct cmd_vf_tc_bw_result {
13709 cmdline_fixed_string_t set;
13710 cmdline_fixed_string_t vf;
13711 cmdline_fixed_string_t tc;
13712 cmdline_fixed_string_t tx;
13713 cmdline_fixed_string_t min_bw;
13714 cmdline_fixed_string_t max_bw;
13715 cmdline_fixed_string_t strict_link_prio;
13720 cmdline_fixed_string_t bw_list;
13724 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13725 TOKEN_STRING_INITIALIZER
13726 (struct cmd_vf_tc_bw_result,
13728 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13729 TOKEN_STRING_INITIALIZER
13730 (struct cmd_vf_tc_bw_result,
13732 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13733 TOKEN_STRING_INITIALIZER
13734 (struct cmd_vf_tc_bw_result,
13736 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13737 TOKEN_STRING_INITIALIZER
13738 (struct cmd_vf_tc_bw_result,
13740 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13741 TOKEN_STRING_INITIALIZER
13742 (struct cmd_vf_tc_bw_result,
13743 strict_link_prio, "strict-link-priority");
13744 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_vf_tc_bw_result,
13747 min_bw, "min-bandwidth");
13748 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_vf_tc_bw_result,
13751 max_bw, "max-bandwidth");
13752 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13753 TOKEN_NUM_INITIALIZER
13754 (struct cmd_vf_tc_bw_result,
13756 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13757 TOKEN_NUM_INITIALIZER
13758 (struct cmd_vf_tc_bw_result,
13760 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13761 TOKEN_NUM_INITIALIZER
13762 (struct cmd_vf_tc_bw_result,
13764 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_vf_tc_bw_result,
13768 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13769 TOKEN_STRING_INITIALIZER
13770 (struct cmd_vf_tc_bw_result,
13772 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13773 TOKEN_NUM_INITIALIZER
13774 (struct cmd_vf_tc_bw_result,
13777 /* VF max bandwidth setting */
13779 cmd_vf_max_bw_parsed(
13780 void *parsed_result,
13781 __attribute__((unused)) struct cmdline *cl,
13782 __attribute__((unused)) void *data)
13784 struct cmd_vf_tc_bw_result *res = parsed_result;
13785 int ret = -ENOTSUP;
13787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13790 #ifdef RTE_LIBRTE_I40E_PMD
13791 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13792 res->vf_id, res->bw);
13799 printf("invalid vf_id %d or bandwidth %d\n",
13800 res->vf_id, res->bw);
13803 printf("invalid port_id %d\n", res->port_id);
13806 printf("function not implemented\n");
13809 printf("programming error: (%s)\n", strerror(-ret));
13813 cmdline_parse_inst_t cmd_vf_max_bw = {
13814 .f = cmd_vf_max_bw_parsed,
13816 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13818 (void *)&cmd_vf_tc_bw_set,
13819 (void *)&cmd_vf_tc_bw_vf,
13820 (void *)&cmd_vf_tc_bw_tx,
13821 (void *)&cmd_vf_tc_bw_max_bw,
13822 (void *)&cmd_vf_tc_bw_port_id,
13823 (void *)&cmd_vf_tc_bw_vf_id,
13824 (void *)&cmd_vf_tc_bw_bw,
13830 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13835 const char *p, *p0 = str;
13842 p = strchr(p0, '(');
13844 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13848 p0 = strchr(p, ')');
13850 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13854 if (size >= sizeof(s)) {
13855 printf("The string size exceeds the internal buffer size\n");
13858 snprintf(s, sizeof(s), "%.*s", size, p);
13859 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13861 printf("Failed to get the bandwidth list. ");
13865 for (i = 0; i < ret; i++)
13866 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13871 /* TC min bandwidth setting */
13873 cmd_vf_tc_min_bw_parsed(
13874 void *parsed_result,
13875 __attribute__((unused)) struct cmdline *cl,
13876 __attribute__((unused)) void *data)
13878 struct cmd_vf_tc_bw_result *res = parsed_result;
13881 int ret = -ENOTSUP;
13883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13886 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13890 #ifdef RTE_LIBRTE_I40E_PMD
13891 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13899 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13902 printf("invalid port_id %d\n", res->port_id);
13905 printf("function not implemented\n");
13908 printf("programming error: (%s)\n", strerror(-ret));
13912 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13913 .f = cmd_vf_tc_min_bw_parsed,
13915 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13916 " <bw1, bw2, ...>",
13918 (void *)&cmd_vf_tc_bw_set,
13919 (void *)&cmd_vf_tc_bw_vf,
13920 (void *)&cmd_vf_tc_bw_tc,
13921 (void *)&cmd_vf_tc_bw_tx,
13922 (void *)&cmd_vf_tc_bw_min_bw,
13923 (void *)&cmd_vf_tc_bw_port_id,
13924 (void *)&cmd_vf_tc_bw_vf_id,
13925 (void *)&cmd_vf_tc_bw_bw_list,
13931 cmd_tc_min_bw_parsed(
13932 void *parsed_result,
13933 __attribute__((unused)) struct cmdline *cl,
13934 __attribute__((unused)) void *data)
13936 struct cmd_vf_tc_bw_result *res = parsed_result;
13937 struct rte_port *port;
13940 int ret = -ENOTSUP;
13942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13945 port = &ports[res->port_id];
13946 /** Check if the port is not started **/
13947 if (port->port_status != RTE_PORT_STOPPED) {
13948 printf("Please stop port %d first\n", res->port_id);
13952 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13956 #ifdef RTE_LIBRTE_IXGBE_PMD
13957 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13964 printf("invalid bandwidth\n");
13967 printf("invalid port_id %d\n", res->port_id);
13970 printf("function not implemented\n");
13973 printf("programming error: (%s)\n", strerror(-ret));
13977 cmdline_parse_inst_t cmd_tc_min_bw = {
13978 .f = cmd_tc_min_bw_parsed,
13980 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13982 (void *)&cmd_vf_tc_bw_set,
13983 (void *)&cmd_vf_tc_bw_tc,
13984 (void *)&cmd_vf_tc_bw_tx,
13985 (void *)&cmd_vf_tc_bw_min_bw,
13986 (void *)&cmd_vf_tc_bw_port_id,
13987 (void *)&cmd_vf_tc_bw_bw_list,
13992 /* TC max bandwidth setting */
13994 cmd_vf_tc_max_bw_parsed(
13995 void *parsed_result,
13996 __attribute__((unused)) struct cmdline *cl,
13997 __attribute__((unused)) void *data)
13999 struct cmd_vf_tc_bw_result *res = parsed_result;
14000 int ret = -ENOTSUP;
14002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14005 #ifdef RTE_LIBRTE_I40E_PMD
14006 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14007 res->tc_no, res->bw);
14014 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14015 res->vf_id, res->tc_no, res->bw);
14018 printf("invalid port_id %d\n", res->port_id);
14021 printf("function not implemented\n");
14024 printf("programming error: (%s)\n", strerror(-ret));
14028 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14029 .f = cmd_vf_tc_max_bw_parsed,
14031 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14034 (void *)&cmd_vf_tc_bw_set,
14035 (void *)&cmd_vf_tc_bw_vf,
14036 (void *)&cmd_vf_tc_bw_tc,
14037 (void *)&cmd_vf_tc_bw_tx,
14038 (void *)&cmd_vf_tc_bw_max_bw,
14039 (void *)&cmd_vf_tc_bw_port_id,
14040 (void *)&cmd_vf_tc_bw_vf_id,
14041 (void *)&cmd_vf_tc_bw_tc_no,
14042 (void *)&cmd_vf_tc_bw_bw,
14048 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14050 /* *** Set Port default Traffic Management Hierarchy *** */
14051 struct cmd_set_port_tm_hierarchy_default_result {
14052 cmdline_fixed_string_t set;
14053 cmdline_fixed_string_t port;
14054 cmdline_fixed_string_t tm;
14055 cmdline_fixed_string_t hierarchy;
14056 cmdline_fixed_string_t def;
14060 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14061 TOKEN_STRING_INITIALIZER(
14062 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14063 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14064 TOKEN_STRING_INITIALIZER(
14065 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14066 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14067 TOKEN_STRING_INITIALIZER(
14068 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14069 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14070 TOKEN_STRING_INITIALIZER(
14071 struct cmd_set_port_tm_hierarchy_default_result,
14072 hierarchy, "hierarchy");
14073 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14074 TOKEN_STRING_INITIALIZER(
14075 struct cmd_set_port_tm_hierarchy_default_result,
14077 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14078 TOKEN_NUM_INITIALIZER(
14079 struct cmd_set_port_tm_hierarchy_default_result,
14082 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14083 __attribute__((unused)) struct cmdline *cl,
14084 __attribute__((unused)) void *data)
14086 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14087 struct rte_port *p;
14088 portid_t port_id = res->port_id;
14090 if (port_id_is_invalid(port_id, ENABLED_WARN))
14093 p = &ports[port_id];
14096 if (p->softport.tm_flag == 0) {
14097 printf(" tm not enabled on port %u (error)\n", port_id);
14101 /* Forward mode: tm */
14102 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14103 printf(" tm mode not enabled(error)\n");
14107 /* Set the default tm hierarchy */
14108 p->softport.tm.default_hierarchy_enable = 1;
14111 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14112 .f = cmd_set_port_tm_hierarchy_default_parsed,
14114 .help_str = "set port tm hierarchy default <port_id>",
14116 (void *)&cmd_set_port_tm_hierarchy_default_set,
14117 (void *)&cmd_set_port_tm_hierarchy_default_port,
14118 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14119 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14120 (void *)&cmd_set_port_tm_hierarchy_default_default,
14121 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14127 /* Strict link priority scheduling mode setting */
14129 cmd_strict_link_prio_parsed(
14130 void *parsed_result,
14131 __attribute__((unused)) struct cmdline *cl,
14132 __attribute__((unused)) void *data)
14134 struct cmd_vf_tc_bw_result *res = parsed_result;
14135 int ret = -ENOTSUP;
14137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14140 #ifdef RTE_LIBRTE_I40E_PMD
14141 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14148 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14151 printf("invalid port_id %d\n", res->port_id);
14154 printf("function not implemented\n");
14157 printf("programming error: (%s)\n", strerror(-ret));
14161 cmdline_parse_inst_t cmd_strict_link_prio = {
14162 .f = cmd_strict_link_prio_parsed,
14164 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14166 (void *)&cmd_vf_tc_bw_set,
14167 (void *)&cmd_vf_tc_bw_tx,
14168 (void *)&cmd_vf_tc_bw_strict_link_prio,
14169 (void *)&cmd_vf_tc_bw_port_id,
14170 (void *)&cmd_vf_tc_bw_tc_map,
14175 /* Load dynamic device personalization*/
14176 struct cmd_ddp_add_result {
14177 cmdline_fixed_string_t ddp;
14178 cmdline_fixed_string_t add;
14183 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14184 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14185 cmdline_parse_token_string_t cmd_ddp_add_add =
14186 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14187 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14188 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14189 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14190 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14193 cmd_ddp_add_parsed(
14194 void *parsed_result,
14195 __attribute__((unused)) struct cmdline *cl,
14196 __attribute__((unused)) void *data)
14198 struct cmd_ddp_add_result *res = parsed_result;
14204 int ret = -ENOTSUP;
14206 if (res->port_id > nb_ports) {
14207 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14211 if (!all_ports_stopped()) {
14212 printf("Please stop all ports first\n");
14216 filepath = strdup(res->filepath);
14217 if (filepath == NULL) {
14218 printf("Failed to allocate memory\n");
14221 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14223 buff = open_ddp_package_file(file_fld[0], &size);
14225 free((void *)filepath);
14229 #ifdef RTE_LIBRTE_I40E_PMD
14230 if (ret == -ENOTSUP)
14231 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14233 RTE_PMD_I40E_PKG_OP_WR_ADD);
14236 if (ret == -EEXIST)
14237 printf("Profile has already existed.\n");
14239 printf("Failed to load profile.\n");
14240 else if (file_num == 2)
14241 save_ddp_package_file(file_fld[1], buff, size);
14243 close_ddp_package_file(buff);
14244 free((void *)filepath);
14247 cmdline_parse_inst_t cmd_ddp_add = {
14248 .f = cmd_ddp_add_parsed,
14250 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14252 (void *)&cmd_ddp_add_ddp,
14253 (void *)&cmd_ddp_add_add,
14254 (void *)&cmd_ddp_add_port_id,
14255 (void *)&cmd_ddp_add_filepath,
14260 /* Delete dynamic device personalization*/
14261 struct cmd_ddp_del_result {
14262 cmdline_fixed_string_t ddp;
14263 cmdline_fixed_string_t del;
14268 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14270 cmdline_parse_token_string_t cmd_ddp_del_del =
14271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14272 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14273 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14274 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14275 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14278 cmd_ddp_del_parsed(
14279 void *parsed_result,
14280 __attribute__((unused)) struct cmdline *cl,
14281 __attribute__((unused)) void *data)
14283 struct cmd_ddp_del_result *res = parsed_result;
14286 int ret = -ENOTSUP;
14288 if (res->port_id > nb_ports) {
14289 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14293 if (!all_ports_stopped()) {
14294 printf("Please stop all ports first\n");
14298 buff = open_ddp_package_file(res->filepath, &size);
14302 #ifdef RTE_LIBRTE_I40E_PMD
14303 if (ret == -ENOTSUP)
14304 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14306 RTE_PMD_I40E_PKG_OP_WR_DEL);
14309 if (ret == -EACCES)
14310 printf("Profile does not exist.\n");
14312 printf("Failed to delete profile.\n");
14314 close_ddp_package_file(buff);
14317 cmdline_parse_inst_t cmd_ddp_del = {
14318 .f = cmd_ddp_del_parsed,
14320 .help_str = "ddp del <port_id> <profile_path>",
14322 (void *)&cmd_ddp_del_ddp,
14323 (void *)&cmd_ddp_del_del,
14324 (void *)&cmd_ddp_del_port_id,
14325 (void *)&cmd_ddp_del_filepath,
14330 /* Get dynamic device personalization profile info */
14331 struct cmd_ddp_info_result {
14332 cmdline_fixed_string_t ddp;
14333 cmdline_fixed_string_t get;
14334 cmdline_fixed_string_t info;
14338 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14339 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14340 cmdline_parse_token_string_t cmd_ddp_info_get =
14341 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14342 cmdline_parse_token_string_t cmd_ddp_info_info =
14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14344 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14345 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14348 cmd_ddp_info_parsed(
14349 void *parsed_result,
14350 __attribute__((unused)) struct cmdline *cl,
14351 __attribute__((unused)) void *data)
14353 struct cmd_ddp_info_result *res = parsed_result;
14356 int ret = -ENOTSUP;
14357 #ifdef RTE_LIBRTE_I40E_PMD
14360 uint32_t buff_size = 0;
14361 struct rte_pmd_i40e_profile_info info;
14362 uint32_t dev_num = 0;
14363 struct rte_pmd_i40e_ddp_device_id *devs;
14364 uint32_t proto_num = 0;
14365 struct rte_pmd_i40e_proto_info *proto = NULL;
14366 uint32_t pctype_num = 0;
14367 struct rte_pmd_i40e_ptype_info *pctype;
14368 uint32_t ptype_num = 0;
14369 struct rte_pmd_i40e_ptype_info *ptype;
14374 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14378 #ifdef RTE_LIBRTE_I40E_PMD
14379 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14380 (uint8_t *)&info, sizeof(info),
14381 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14383 printf("Global Track id: 0x%x\n", info.track_id);
14384 printf("Global Version: %d.%d.%d.%d\n",
14385 info.version.major,
14386 info.version.minor,
14387 info.version.update,
14388 info.version.draft);
14389 printf("Global Package name: %s\n\n", info.name);
14392 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14393 (uint8_t *)&info, sizeof(info),
14394 RTE_PMD_I40E_PKG_INFO_HEADER);
14396 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14397 printf("i40e Profile Version: %d.%d.%d.%d\n",
14398 info.version.major,
14399 info.version.minor,
14400 info.version.update,
14401 info.version.draft);
14402 printf("i40e Profile name: %s\n\n", info.name);
14405 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14406 (uint8_t *)&buff_size, sizeof(buff_size),
14407 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14408 if (!ret && buff_size) {
14409 buff = (uint8_t *)malloc(buff_size);
14411 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14413 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14415 printf("Package Notes:\n%s\n\n", buff);
14420 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14421 (uint8_t *)&dev_num, sizeof(dev_num),
14422 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14423 if (!ret && dev_num) {
14424 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14425 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14427 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14428 (uint8_t *)devs, buff_size,
14429 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14431 printf("List of supported devices:\n");
14432 for (i = 0; i < dev_num; i++) {
14433 printf(" %04X:%04X %04X:%04X\n",
14434 devs[i].vendor_dev_id >> 16,
14435 devs[i].vendor_dev_id & 0xFFFF,
14436 devs[i].sub_vendor_dev_id >> 16,
14437 devs[i].sub_vendor_dev_id & 0xFFFF);
14445 /* get information about protocols and packet types */
14446 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14447 (uint8_t *)&proto_num, sizeof(proto_num),
14448 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14449 if (ret || !proto_num)
14450 goto no_print_return;
14452 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14453 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14455 goto no_print_return;
14457 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14459 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14461 printf("List of used protocols:\n");
14462 for (i = 0; i < proto_num; i++)
14463 printf(" %2u: %s\n", proto[i].proto_id,
14467 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14468 (uint8_t *)&pctype_num, sizeof(pctype_num),
14469 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14470 if (ret || !pctype_num)
14471 goto no_print_pctypes;
14473 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14474 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14476 goto no_print_pctypes;
14478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14480 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14483 goto no_print_pctypes;
14486 printf("List of defined packet classification types:\n");
14487 for (i = 0; i < pctype_num; i++) {
14488 printf(" %2u:", pctype[i].ptype_id);
14489 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14490 proto_id = pctype[i].protocols[j];
14491 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14492 for (n = 0; n < proto_num; n++) {
14493 if (proto[n].proto_id == proto_id) {
14494 printf(" %s", proto[n].name);
14507 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14509 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14510 if (ret || !ptype_num)
14511 goto no_print_return;
14513 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14514 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14516 goto no_print_return;
14518 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14520 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14523 goto no_print_return;
14525 printf("List of defined packet types:\n");
14526 for (i = 0; i < ptype_num; i++) {
14527 printf(" %2u:", ptype[i].ptype_id);
14528 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14529 proto_id = ptype[i].protocols[j];
14530 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14531 for (n = 0; n < proto_num; n++) {
14532 if (proto[n].proto_id == proto_id) {
14533 printf(" %s", proto[n].name);
14549 if (ret == -ENOTSUP)
14550 printf("Function not supported in PMD driver\n");
14551 close_ddp_package_file(pkg);
14554 cmdline_parse_inst_t cmd_ddp_get_info = {
14555 .f = cmd_ddp_info_parsed,
14557 .help_str = "ddp get info <profile_path>",
14559 (void *)&cmd_ddp_info_ddp,
14560 (void *)&cmd_ddp_info_get,
14561 (void *)&cmd_ddp_info_info,
14562 (void *)&cmd_ddp_info_filepath,
14567 /* Get dynamic device personalization profile info list*/
14568 #define PROFILE_INFO_SIZE 48
14569 #define MAX_PROFILE_NUM 16
14571 struct cmd_ddp_get_list_result {
14572 cmdline_fixed_string_t ddp;
14573 cmdline_fixed_string_t get;
14574 cmdline_fixed_string_t list;
14578 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14579 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14580 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14581 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14582 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14583 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14584 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14585 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14588 cmd_ddp_get_list_parsed(
14589 void *parsed_result,
14590 __attribute__((unused)) struct cmdline *cl,
14591 __attribute__((unused)) void *data)
14593 struct cmd_ddp_get_list_result *res = parsed_result;
14594 #ifdef RTE_LIBRTE_I40E_PMD
14595 struct rte_pmd_i40e_profile_list *p_list;
14596 struct rte_pmd_i40e_profile_info *p_info;
14601 int ret = -ENOTSUP;
14603 if (res->port_id > nb_ports) {
14604 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14608 #ifdef RTE_LIBRTE_I40E_PMD
14609 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14610 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14612 printf("%s: Failed to malloc buffer\n", __func__);
14614 if (ret == -ENOTSUP)
14615 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14616 (uint8_t *)p_list, size);
14619 p_num = p_list->p_count;
14620 printf("Profile number is: %d\n\n", p_num);
14622 for (i = 0; i < p_num; i++) {
14623 p_info = &p_list->p_info[i];
14624 printf("Profile %d:\n", i);
14625 printf("Track id: 0x%x\n", p_info->track_id);
14626 printf("Version: %d.%d.%d.%d\n",
14627 p_info->version.major,
14628 p_info->version.minor,
14629 p_info->version.update,
14630 p_info->version.draft);
14631 printf("Profile name: %s\n\n", p_info->name);
14639 printf("Failed to get ddp list\n");
14642 cmdline_parse_inst_t cmd_ddp_get_list = {
14643 .f = cmd_ddp_get_list_parsed,
14645 .help_str = "ddp get list <port_id>",
14647 (void *)&cmd_ddp_get_list_ddp,
14648 (void *)&cmd_ddp_get_list_get,
14649 (void *)&cmd_ddp_get_list_list,
14650 (void *)&cmd_ddp_get_list_port_id,
14655 /* show vf stats */
14657 /* Common result structure for show vf stats */
14658 struct cmd_show_vf_stats_result {
14659 cmdline_fixed_string_t show;
14660 cmdline_fixed_string_t vf;
14661 cmdline_fixed_string_t stats;
14666 /* Common CLI fields show vf stats*/
14667 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14668 TOKEN_STRING_INITIALIZER
14669 (struct cmd_show_vf_stats_result,
14671 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_show_vf_stats_result,
14675 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14676 TOKEN_STRING_INITIALIZER
14677 (struct cmd_show_vf_stats_result,
14679 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14680 TOKEN_NUM_INITIALIZER
14681 (struct cmd_show_vf_stats_result,
14683 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14684 TOKEN_NUM_INITIALIZER
14685 (struct cmd_show_vf_stats_result,
14689 cmd_show_vf_stats_parsed(
14690 void *parsed_result,
14691 __attribute__((unused)) struct cmdline *cl,
14692 __attribute__((unused)) void *data)
14694 struct cmd_show_vf_stats_result *res = parsed_result;
14695 struct rte_eth_stats stats;
14696 int ret = -ENOTSUP;
14697 static const char *nic_stats_border = "########################";
14699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14702 memset(&stats, 0, sizeof(stats));
14704 #ifdef RTE_LIBRTE_I40E_PMD
14705 if (ret == -ENOTSUP)
14706 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14710 #ifdef RTE_LIBRTE_BNXT_PMD
14711 if (ret == -ENOTSUP)
14712 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14721 printf("invalid vf_id %d\n", res->vf_id);
14724 printf("invalid port_id %d\n", res->port_id);
14727 printf("function not implemented\n");
14730 printf("programming error: (%s)\n", strerror(-ret));
14733 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14734 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14736 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14738 stats.ipackets, stats.imissed, stats.ibytes);
14739 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14740 printf(" RX-nombuf: %-10"PRIu64"\n",
14742 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14744 stats.opackets, stats.oerrors, stats.obytes);
14746 printf(" %s############################%s\n",
14747 nic_stats_border, nic_stats_border);
14750 cmdline_parse_inst_t cmd_show_vf_stats = {
14751 .f = cmd_show_vf_stats_parsed,
14753 .help_str = "show vf stats <port_id> <vf_id>",
14755 (void *)&cmd_show_vf_stats_show,
14756 (void *)&cmd_show_vf_stats_vf,
14757 (void *)&cmd_show_vf_stats_stats,
14758 (void *)&cmd_show_vf_stats_port_id,
14759 (void *)&cmd_show_vf_stats_vf_id,
14764 /* clear vf stats */
14766 /* Common result structure for clear vf stats */
14767 struct cmd_clear_vf_stats_result {
14768 cmdline_fixed_string_t clear;
14769 cmdline_fixed_string_t vf;
14770 cmdline_fixed_string_t stats;
14775 /* Common CLI fields clear vf stats*/
14776 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14777 TOKEN_STRING_INITIALIZER
14778 (struct cmd_clear_vf_stats_result,
14780 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14781 TOKEN_STRING_INITIALIZER
14782 (struct cmd_clear_vf_stats_result,
14784 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14785 TOKEN_STRING_INITIALIZER
14786 (struct cmd_clear_vf_stats_result,
14788 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14789 TOKEN_NUM_INITIALIZER
14790 (struct cmd_clear_vf_stats_result,
14792 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14793 TOKEN_NUM_INITIALIZER
14794 (struct cmd_clear_vf_stats_result,
14798 cmd_clear_vf_stats_parsed(
14799 void *parsed_result,
14800 __attribute__((unused)) struct cmdline *cl,
14801 __attribute__((unused)) void *data)
14803 struct cmd_clear_vf_stats_result *res = parsed_result;
14804 int ret = -ENOTSUP;
14806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14809 #ifdef RTE_LIBRTE_I40E_PMD
14810 if (ret == -ENOTSUP)
14811 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14814 #ifdef RTE_LIBRTE_BNXT_PMD
14815 if (ret == -ENOTSUP)
14816 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14824 printf("invalid vf_id %d\n", res->vf_id);
14827 printf("invalid port_id %d\n", res->port_id);
14830 printf("function not implemented\n");
14833 printf("programming error: (%s)\n", strerror(-ret));
14837 cmdline_parse_inst_t cmd_clear_vf_stats = {
14838 .f = cmd_clear_vf_stats_parsed,
14840 .help_str = "clear vf stats <port_id> <vf_id>",
14842 (void *)&cmd_clear_vf_stats_clear,
14843 (void *)&cmd_clear_vf_stats_vf,
14844 (void *)&cmd_clear_vf_stats_stats,
14845 (void *)&cmd_clear_vf_stats_port_id,
14846 (void *)&cmd_clear_vf_stats_vf_id,
14851 /* port config pctype mapping reset */
14853 /* Common result structure for port config pctype mapping reset */
14854 struct cmd_pctype_mapping_reset_result {
14855 cmdline_fixed_string_t port;
14856 cmdline_fixed_string_t config;
14858 cmdline_fixed_string_t pctype;
14859 cmdline_fixed_string_t mapping;
14860 cmdline_fixed_string_t reset;
14863 /* Common CLI fields for port config pctype mapping reset*/
14864 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14865 TOKEN_STRING_INITIALIZER
14866 (struct cmd_pctype_mapping_reset_result,
14868 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14869 TOKEN_STRING_INITIALIZER
14870 (struct cmd_pctype_mapping_reset_result,
14872 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14873 TOKEN_NUM_INITIALIZER
14874 (struct cmd_pctype_mapping_reset_result,
14876 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14877 TOKEN_STRING_INITIALIZER
14878 (struct cmd_pctype_mapping_reset_result,
14880 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14881 TOKEN_STRING_INITIALIZER
14882 (struct cmd_pctype_mapping_reset_result,
14883 mapping, "mapping");
14884 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_pctype_mapping_reset_result,
14890 cmd_pctype_mapping_reset_parsed(
14891 void *parsed_result,
14892 __attribute__((unused)) struct cmdline *cl,
14893 __attribute__((unused)) void *data)
14895 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14896 int ret = -ENOTSUP;
14898 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14901 #ifdef RTE_LIBRTE_I40E_PMD
14902 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14909 printf("invalid port_id %d\n", res->port_id);
14912 printf("function not implemented\n");
14915 printf("programming error: (%s)\n", strerror(-ret));
14919 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14920 .f = cmd_pctype_mapping_reset_parsed,
14922 .help_str = "port config <port_id> pctype mapping reset",
14924 (void *)&cmd_pctype_mapping_reset_port,
14925 (void *)&cmd_pctype_mapping_reset_config,
14926 (void *)&cmd_pctype_mapping_reset_port_id,
14927 (void *)&cmd_pctype_mapping_reset_pctype,
14928 (void *)&cmd_pctype_mapping_reset_mapping,
14929 (void *)&cmd_pctype_mapping_reset_reset,
14934 /* show port pctype mapping */
14936 /* Common result structure for show port pctype mapping */
14937 struct cmd_pctype_mapping_get_result {
14938 cmdline_fixed_string_t show;
14939 cmdline_fixed_string_t port;
14941 cmdline_fixed_string_t pctype;
14942 cmdline_fixed_string_t mapping;
14945 /* Common CLI fields for pctype mapping get */
14946 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14947 TOKEN_STRING_INITIALIZER
14948 (struct cmd_pctype_mapping_get_result,
14950 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_pctype_mapping_get_result,
14954 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14955 TOKEN_NUM_INITIALIZER
14956 (struct cmd_pctype_mapping_get_result,
14958 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14959 TOKEN_STRING_INITIALIZER
14960 (struct cmd_pctype_mapping_get_result,
14962 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14963 TOKEN_STRING_INITIALIZER
14964 (struct cmd_pctype_mapping_get_result,
14965 mapping, "mapping");
14968 cmd_pctype_mapping_get_parsed(
14969 void *parsed_result,
14970 __attribute__((unused)) struct cmdline *cl,
14971 __attribute__((unused)) void *data)
14973 struct cmd_pctype_mapping_get_result *res = parsed_result;
14974 int ret = -ENOTSUP;
14975 #ifdef RTE_LIBRTE_I40E_PMD
14976 struct rte_pmd_i40e_flow_type_mapping
14977 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14978 int i, j, first_pctype;
14981 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14984 #ifdef RTE_LIBRTE_I40E_PMD
14985 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14992 printf("invalid port_id %d\n", res->port_id);
14995 printf("function not implemented\n");
14998 printf("programming error: (%s)\n", strerror(-ret));
15002 #ifdef RTE_LIBRTE_I40E_PMD
15003 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15004 if (mapping[i].pctype != 0ULL) {
15007 printf("pctype: ");
15008 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15009 if (mapping[i].pctype & (1ULL << j)) {
15010 printf(first_pctype ?
15011 "%02d" : ",%02d", j);
15015 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15021 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15022 .f = cmd_pctype_mapping_get_parsed,
15024 .help_str = "show port <port_id> pctype mapping",
15026 (void *)&cmd_pctype_mapping_get_show,
15027 (void *)&cmd_pctype_mapping_get_port,
15028 (void *)&cmd_pctype_mapping_get_port_id,
15029 (void *)&cmd_pctype_mapping_get_pctype,
15030 (void *)&cmd_pctype_mapping_get_mapping,
15035 /* port config pctype mapping update */
15037 /* Common result structure for port config pctype mapping update */
15038 struct cmd_pctype_mapping_update_result {
15039 cmdline_fixed_string_t port;
15040 cmdline_fixed_string_t config;
15042 cmdline_fixed_string_t pctype;
15043 cmdline_fixed_string_t mapping;
15044 cmdline_fixed_string_t update;
15045 cmdline_fixed_string_t pctype_list;
15046 uint16_t flow_type;
15049 /* Common CLI fields for pctype mapping update*/
15050 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15051 TOKEN_STRING_INITIALIZER
15052 (struct cmd_pctype_mapping_update_result,
15054 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15055 TOKEN_STRING_INITIALIZER
15056 (struct cmd_pctype_mapping_update_result,
15058 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15059 TOKEN_NUM_INITIALIZER
15060 (struct cmd_pctype_mapping_update_result,
15062 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15063 TOKEN_STRING_INITIALIZER
15064 (struct cmd_pctype_mapping_update_result,
15066 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15067 TOKEN_STRING_INITIALIZER
15068 (struct cmd_pctype_mapping_update_result,
15069 mapping, "mapping");
15070 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15071 TOKEN_STRING_INITIALIZER
15072 (struct cmd_pctype_mapping_update_result,
15074 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15075 TOKEN_STRING_INITIALIZER
15076 (struct cmd_pctype_mapping_update_result,
15077 pctype_list, NULL);
15078 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15079 TOKEN_NUM_INITIALIZER
15080 (struct cmd_pctype_mapping_update_result,
15081 flow_type, UINT16);
15084 cmd_pctype_mapping_update_parsed(
15085 void *parsed_result,
15086 __attribute__((unused)) struct cmdline *cl,
15087 __attribute__((unused)) void *data)
15089 struct cmd_pctype_mapping_update_result *res = parsed_result;
15090 int ret = -ENOTSUP;
15091 #ifdef RTE_LIBRTE_I40E_PMD
15092 struct rte_pmd_i40e_flow_type_mapping mapping;
15094 unsigned int nb_item;
15095 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15098 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15101 #ifdef RTE_LIBRTE_I40E_PMD
15102 nb_item = parse_item_list(res->pctype_list, "pctypes",
15103 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15104 mapping.flow_type = res->flow_type;
15105 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15106 mapping.pctype |= (1ULL << pctype_list[i]);
15107 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15117 printf("invalid pctype or flow type\n");
15120 printf("invalid port_id %d\n", res->port_id);
15123 printf("function not implemented\n");
15126 printf("programming error: (%s)\n", strerror(-ret));
15130 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15131 .f = cmd_pctype_mapping_update_parsed,
15133 .help_str = "port config <port_id> pctype mapping update"
15134 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15136 (void *)&cmd_pctype_mapping_update_port,
15137 (void *)&cmd_pctype_mapping_update_config,
15138 (void *)&cmd_pctype_mapping_update_port_id,
15139 (void *)&cmd_pctype_mapping_update_pctype,
15140 (void *)&cmd_pctype_mapping_update_mapping,
15141 (void *)&cmd_pctype_mapping_update_update,
15142 (void *)&cmd_pctype_mapping_update_pc_type,
15143 (void *)&cmd_pctype_mapping_update_flow_type,
15148 /* ptype mapping get */
15150 /* Common result structure for ptype mapping get */
15151 struct cmd_ptype_mapping_get_result {
15152 cmdline_fixed_string_t ptype;
15153 cmdline_fixed_string_t mapping;
15154 cmdline_fixed_string_t get;
15156 uint8_t valid_only;
15159 /* Common CLI fields for ptype mapping get */
15160 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15161 TOKEN_STRING_INITIALIZER
15162 (struct cmd_ptype_mapping_get_result,
15164 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15165 TOKEN_STRING_INITIALIZER
15166 (struct cmd_ptype_mapping_get_result,
15167 mapping, "mapping");
15168 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15169 TOKEN_STRING_INITIALIZER
15170 (struct cmd_ptype_mapping_get_result,
15172 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15173 TOKEN_NUM_INITIALIZER
15174 (struct cmd_ptype_mapping_get_result,
15176 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15177 TOKEN_NUM_INITIALIZER
15178 (struct cmd_ptype_mapping_get_result,
15179 valid_only, UINT8);
15182 cmd_ptype_mapping_get_parsed(
15183 void *parsed_result,
15184 __attribute__((unused)) struct cmdline *cl,
15185 __attribute__((unused)) void *data)
15187 struct cmd_ptype_mapping_get_result *res = parsed_result;
15188 int ret = -ENOTSUP;
15189 #ifdef RTE_LIBRTE_I40E_PMD
15190 int max_ptype_num = 256;
15191 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15199 #ifdef RTE_LIBRTE_I40E_PMD
15200 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15211 printf("invalid port_id %d\n", res->port_id);
15214 printf("function not implemented\n");
15217 printf("programming error: (%s)\n", strerror(-ret));
15220 #ifdef RTE_LIBRTE_I40E_PMD
15222 for (i = 0; i < count; i++)
15223 printf("%3d\t0x%08x\n",
15224 mapping[i].hw_ptype, mapping[i].sw_ptype);
15229 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15230 .f = cmd_ptype_mapping_get_parsed,
15232 .help_str = "ptype mapping get <port_id> <valid_only>",
15234 (void *)&cmd_ptype_mapping_get_ptype,
15235 (void *)&cmd_ptype_mapping_get_mapping,
15236 (void *)&cmd_ptype_mapping_get_get,
15237 (void *)&cmd_ptype_mapping_get_port_id,
15238 (void *)&cmd_ptype_mapping_get_valid_only,
15243 /* ptype mapping replace */
15245 /* Common result structure for ptype mapping replace */
15246 struct cmd_ptype_mapping_replace_result {
15247 cmdline_fixed_string_t ptype;
15248 cmdline_fixed_string_t mapping;
15249 cmdline_fixed_string_t replace;
15256 /* Common CLI fields for ptype mapping replace */
15257 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15258 TOKEN_STRING_INITIALIZER
15259 (struct cmd_ptype_mapping_replace_result,
15261 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15262 TOKEN_STRING_INITIALIZER
15263 (struct cmd_ptype_mapping_replace_result,
15264 mapping, "mapping");
15265 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_ptype_mapping_replace_result,
15268 replace, "replace");
15269 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15270 TOKEN_NUM_INITIALIZER
15271 (struct cmd_ptype_mapping_replace_result,
15273 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15274 TOKEN_NUM_INITIALIZER
15275 (struct cmd_ptype_mapping_replace_result,
15277 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15278 TOKEN_NUM_INITIALIZER
15279 (struct cmd_ptype_mapping_replace_result,
15281 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15282 TOKEN_NUM_INITIALIZER
15283 (struct cmd_ptype_mapping_replace_result,
15287 cmd_ptype_mapping_replace_parsed(
15288 void *parsed_result,
15289 __attribute__((unused)) struct cmdline *cl,
15290 __attribute__((unused)) void *data)
15292 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15293 int ret = -ENOTSUP;
15295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15298 #ifdef RTE_LIBRTE_I40E_PMD
15299 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15309 printf("invalid ptype 0x%8x or 0x%8x\n",
15310 res->target, res->pkt_type);
15313 printf("invalid port_id %d\n", res->port_id);
15316 printf("function not implemented\n");
15319 printf("programming error: (%s)\n", strerror(-ret));
15323 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15324 .f = cmd_ptype_mapping_replace_parsed,
15327 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15329 (void *)&cmd_ptype_mapping_replace_ptype,
15330 (void *)&cmd_ptype_mapping_replace_mapping,
15331 (void *)&cmd_ptype_mapping_replace_replace,
15332 (void *)&cmd_ptype_mapping_replace_port_id,
15333 (void *)&cmd_ptype_mapping_replace_target,
15334 (void *)&cmd_ptype_mapping_replace_mask,
15335 (void *)&cmd_ptype_mapping_replace_pkt_type,
15340 /* ptype mapping reset */
15342 /* Common result structure for ptype mapping reset */
15343 struct cmd_ptype_mapping_reset_result {
15344 cmdline_fixed_string_t ptype;
15345 cmdline_fixed_string_t mapping;
15346 cmdline_fixed_string_t reset;
15350 /* Common CLI fields for ptype mapping reset*/
15351 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15352 TOKEN_STRING_INITIALIZER
15353 (struct cmd_ptype_mapping_reset_result,
15355 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15356 TOKEN_STRING_INITIALIZER
15357 (struct cmd_ptype_mapping_reset_result,
15358 mapping, "mapping");
15359 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15360 TOKEN_STRING_INITIALIZER
15361 (struct cmd_ptype_mapping_reset_result,
15363 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15364 TOKEN_NUM_INITIALIZER
15365 (struct cmd_ptype_mapping_reset_result,
15369 cmd_ptype_mapping_reset_parsed(
15370 void *parsed_result,
15371 __attribute__((unused)) struct cmdline *cl,
15372 __attribute__((unused)) void *data)
15374 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15375 int ret = -ENOTSUP;
15377 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15380 #ifdef RTE_LIBRTE_I40E_PMD
15381 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15388 printf("invalid port_id %d\n", res->port_id);
15391 printf("function not implemented\n");
15394 printf("programming error: (%s)\n", strerror(-ret));
15398 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15399 .f = cmd_ptype_mapping_reset_parsed,
15401 .help_str = "ptype mapping reset <port_id>",
15403 (void *)&cmd_ptype_mapping_reset_ptype,
15404 (void *)&cmd_ptype_mapping_reset_mapping,
15405 (void *)&cmd_ptype_mapping_reset_reset,
15406 (void *)&cmd_ptype_mapping_reset_port_id,
15411 /* ptype mapping update */
15413 /* Common result structure for ptype mapping update */
15414 struct cmd_ptype_mapping_update_result {
15415 cmdline_fixed_string_t ptype;
15416 cmdline_fixed_string_t mapping;
15417 cmdline_fixed_string_t reset;
15423 /* Common CLI fields for ptype mapping update*/
15424 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15425 TOKEN_STRING_INITIALIZER
15426 (struct cmd_ptype_mapping_update_result,
15428 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15429 TOKEN_STRING_INITIALIZER
15430 (struct cmd_ptype_mapping_update_result,
15431 mapping, "mapping");
15432 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_ptype_mapping_update_result,
15436 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15437 TOKEN_NUM_INITIALIZER
15438 (struct cmd_ptype_mapping_update_result,
15440 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15441 TOKEN_NUM_INITIALIZER
15442 (struct cmd_ptype_mapping_update_result,
15444 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15445 TOKEN_NUM_INITIALIZER
15446 (struct cmd_ptype_mapping_update_result,
15450 cmd_ptype_mapping_update_parsed(
15451 void *parsed_result,
15452 __attribute__((unused)) struct cmdline *cl,
15453 __attribute__((unused)) void *data)
15455 struct cmd_ptype_mapping_update_result *res = parsed_result;
15456 int ret = -ENOTSUP;
15457 #ifdef RTE_LIBRTE_I40E_PMD
15458 struct rte_pmd_i40e_ptype_mapping mapping;
15460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15463 #ifdef RTE_LIBRTE_I40E_PMD
15464 mapping.hw_ptype = res->hw_ptype;
15465 mapping.sw_ptype = res->sw_ptype;
15466 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15476 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15479 printf("invalid port_id %d\n", res->port_id);
15482 printf("function not implemented\n");
15485 printf("programming error: (%s)\n", strerror(-ret));
15489 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15490 .f = cmd_ptype_mapping_update_parsed,
15492 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15494 (void *)&cmd_ptype_mapping_update_ptype,
15495 (void *)&cmd_ptype_mapping_update_mapping,
15496 (void *)&cmd_ptype_mapping_update_update,
15497 (void *)&cmd_ptype_mapping_update_port_id,
15498 (void *)&cmd_ptype_mapping_update_hw_ptype,
15499 (void *)&cmd_ptype_mapping_update_sw_ptype,
15504 /* Common result structure for file commands */
15505 struct cmd_cmdfile_result {
15506 cmdline_fixed_string_t load;
15507 cmdline_fixed_string_t filename;
15510 /* Common CLI fields for file commands */
15511 cmdline_parse_token_string_t cmd_load_cmdfile =
15512 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15513 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15514 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15517 cmd_load_from_file_parsed(
15518 void *parsed_result,
15519 __attribute__((unused)) struct cmdline *cl,
15520 __attribute__((unused)) void *data)
15522 struct cmd_cmdfile_result *res = parsed_result;
15524 cmdline_read_from_file(res->filename);
15527 cmdline_parse_inst_t cmd_load_from_file = {
15528 .f = cmd_load_from_file_parsed,
15530 .help_str = "load <filename>",
15532 (void *)&cmd_load_cmdfile,
15533 (void *)&cmd_load_cmdfile_filename,
15538 /* ******************************************************************************** */
15540 /* list of instructions */
15541 cmdline_parse_ctx_t main_ctx[] = {
15542 (cmdline_parse_inst_t *)&cmd_help_brief,
15543 (cmdline_parse_inst_t *)&cmd_help_long,
15544 (cmdline_parse_inst_t *)&cmd_quit,
15545 (cmdline_parse_inst_t *)&cmd_load_from_file,
15546 (cmdline_parse_inst_t *)&cmd_showport,
15547 (cmdline_parse_inst_t *)&cmd_showqueue,
15548 (cmdline_parse_inst_t *)&cmd_showportall,
15549 (cmdline_parse_inst_t *)&cmd_showcfg,
15550 (cmdline_parse_inst_t *)&cmd_start,
15551 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15552 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15553 (cmdline_parse_inst_t *)&cmd_set_link_up,
15554 (cmdline_parse_inst_t *)&cmd_set_link_down,
15555 (cmdline_parse_inst_t *)&cmd_reset,
15556 (cmdline_parse_inst_t *)&cmd_set_numbers,
15557 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15558 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15559 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15560 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15561 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15562 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15563 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15564 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15565 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15566 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15567 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15568 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15569 (cmdline_parse_inst_t *)&cmd_set_link_check,
15570 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15571 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15572 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15573 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15574 #ifdef RTE_LIBRTE_PMD_BOND
15575 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15576 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15577 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15578 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15579 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15580 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15581 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15582 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15583 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15584 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15585 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15587 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15588 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15589 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15590 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15591 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15592 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15593 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15594 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15595 (cmdline_parse_inst_t *)&cmd_csum_set,
15596 (cmdline_parse_inst_t *)&cmd_csum_show,
15597 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15598 (cmdline_parse_inst_t *)&cmd_tso_set,
15599 (cmdline_parse_inst_t *)&cmd_tso_show,
15600 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15601 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15602 (cmdline_parse_inst_t *)&cmd_gro_enable,
15603 (cmdline_parse_inst_t *)&cmd_gro_flush,
15604 (cmdline_parse_inst_t *)&cmd_gro_show,
15605 (cmdline_parse_inst_t *)&cmd_gso_enable,
15606 (cmdline_parse_inst_t *)&cmd_gso_size,
15607 (cmdline_parse_inst_t *)&cmd_gso_show,
15608 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15609 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15610 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15611 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15612 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15613 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15614 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15615 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15616 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15617 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15618 (cmdline_parse_inst_t *)&cmd_config_dcb,
15619 (cmdline_parse_inst_t *)&cmd_read_reg,
15620 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15621 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15622 (cmdline_parse_inst_t *)&cmd_write_reg,
15623 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15624 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15625 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15626 (cmdline_parse_inst_t *)&cmd_stop,
15627 (cmdline_parse_inst_t *)&cmd_mac_addr,
15628 (cmdline_parse_inst_t *)&cmd_set_qmap,
15629 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15630 (cmdline_parse_inst_t *)&cmd_operate_port,
15631 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15632 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15633 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15634 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15635 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15636 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15637 (cmdline_parse_inst_t *)&cmd_config_mtu,
15638 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15639 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15640 (cmdline_parse_inst_t *)&cmd_config_rss,
15641 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15642 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15643 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15644 (cmdline_parse_inst_t *)&cmd_showport_reta,
15645 (cmdline_parse_inst_t *)&cmd_config_burst,
15646 (cmdline_parse_inst_t *)&cmd_config_thresh,
15647 (cmdline_parse_inst_t *)&cmd_config_threshold,
15648 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15649 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15650 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15651 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15652 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15653 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15654 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15655 (cmdline_parse_inst_t *)&cmd_global_config,
15656 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15657 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15658 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15659 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15660 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15661 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15662 (cmdline_parse_inst_t *)&cmd_dump,
15663 (cmdline_parse_inst_t *)&cmd_dump_one,
15664 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15665 (cmdline_parse_inst_t *)&cmd_syn_filter,
15666 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15667 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15668 (cmdline_parse_inst_t *)&cmd_flex_filter,
15669 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15670 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15671 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15672 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15673 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15674 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15675 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15676 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15677 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15678 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15679 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15680 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15681 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15682 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15683 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15684 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15685 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15686 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15687 (cmdline_parse_inst_t *)&cmd_flow,
15688 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15689 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15690 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15691 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15692 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15693 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15694 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15695 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15696 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15697 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15698 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15699 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15700 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15701 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15702 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15703 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15704 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15705 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15706 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15707 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15708 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15709 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15710 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15711 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15712 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15713 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15714 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15715 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15716 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15717 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15718 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15719 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15720 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15721 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15722 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15723 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15724 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15725 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15726 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15727 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15728 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15729 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15730 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15731 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15732 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15733 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15734 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15736 (cmdline_parse_inst_t *)&cmd_ddp_add,
15737 (cmdline_parse_inst_t *)&cmd_ddp_del,
15738 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15739 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15740 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15741 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15742 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15743 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15744 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15745 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15747 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15748 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15749 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15750 (cmdline_parse_inst_t *)&cmd_queue_region,
15751 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15752 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15753 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15754 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15755 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15756 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15757 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15758 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15759 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15760 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15761 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15762 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15763 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15764 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15765 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15766 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15767 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15768 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15769 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15770 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15771 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15775 /* read cmdline commands from file */
15777 cmdline_read_from_file(const char *filename)
15779 struct cmdline *cl;
15781 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15783 printf("Failed to create file based cmdline context: %s\n",
15788 cmdline_interact(cl);
15793 printf("Read CLI commands from %s\n", filename);
15796 /* prompt function, called from main on MASTER lcore */
15800 /* initialize non-constant commands */
15801 cmd_set_fwd_mode_init();
15802 cmd_set_fwd_retry_mode_init();
15804 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15805 if (testpmd_cl == NULL)
15807 cmdline_interact(testpmd_cl);
15808 cmdline_stdin_exit(testpmd_cl);
15814 if (testpmd_cl != NULL)
15815 cmdline_quit(testpmd_cl);
15819 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15821 if (id == (portid_t)RTE_PORT_ALL) {
15824 RTE_ETH_FOREACH_DEV(pid) {
15825 /* check if need_reconfig has been set to 1 */
15826 if (ports[pid].need_reconfig == 0)
15827 ports[pid].need_reconfig = dev;
15828 /* check if need_reconfig_queues has been set to 1 */
15829 if (ports[pid].need_reconfig_queues == 0)
15830 ports[pid].need_reconfig_queues = queue;
15832 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15833 /* check if need_reconfig has been set to 1 */
15834 if (ports[id].need_reconfig == 0)
15835 ports[id].need_reconfig = dev;
15836 /* check if need_reconfig_queues has been set to 1 */
15837 if (ports[id].need_reconfig_queues == 0)
15838 ports[id].need_reconfig_queues = queue;