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 if (check_nb_rxq(res->value) != 0)
1506 nb_rxq = res->value;
1508 else if (!strcmp(res->name, "txq")) {
1509 if (!res->value && !nb_rxq) {
1510 printf("Warning: Either rx or tx queues should be non zero\n");
1513 if (check_nb_txq(res->value) != 0)
1515 nb_txq = res->value;
1517 else if (!strcmp(res->name, "rxd")) {
1518 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1519 printf("rxd %d invalid - must be > 0 && <= %d\n",
1520 res->value, RTE_TEST_RX_DESC_MAX);
1523 nb_rxd = res->value;
1524 } else if (!strcmp(res->name, "txd")) {
1525 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1526 printf("txd %d invalid - must be > 0 && <= %d\n",
1527 res->value, RTE_TEST_TX_DESC_MAX);
1530 nb_txd = res->value;
1532 printf("Unknown parameter\n");
1540 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1543 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1544 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1545 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1546 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1547 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1548 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1549 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1552 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1553 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1555 cmdline_parse_inst_t cmd_config_rx_tx = {
1556 .f = cmd_config_rx_tx_parsed,
1558 .help_str = "port config all rxq|txq|rxd|txd <value>",
1560 (void *)&cmd_config_rx_tx_port,
1561 (void *)&cmd_config_rx_tx_keyword,
1562 (void *)&cmd_config_rx_tx_all,
1563 (void *)&cmd_config_rx_tx_name,
1564 (void *)&cmd_config_rx_tx_value,
1569 /* *** config max packet length *** */
1570 struct cmd_config_max_pkt_len_result {
1571 cmdline_fixed_string_t port;
1572 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t all;
1574 cmdline_fixed_string_t name;
1579 cmd_config_max_pkt_len_parsed(void *parsed_result,
1580 __attribute__((unused)) struct cmdline *cl,
1581 __attribute__((unused)) void *data)
1583 struct cmd_config_max_pkt_len_result *res = parsed_result;
1585 if (!all_ports_stopped()) {
1586 printf("Please stop all ports first\n");
1590 if (!strcmp(res->name, "max-pkt-len")) {
1591 if (res->value < ETHER_MIN_LEN) {
1592 printf("max-pkt-len can not be less than %d\n",
1596 if (res->value == rx_mode.max_rx_pkt_len)
1599 rx_mode.max_rx_pkt_len = res->value;
1600 if (res->value > ETHER_MAX_LEN)
1601 rx_mode.jumbo_frame = 1;
1603 rx_mode.jumbo_frame = 0;
1605 printf("Unknown parameter\n");
1611 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1614 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1615 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1617 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1618 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1620 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1623 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1624 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1626 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1627 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1630 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1631 .f = cmd_config_max_pkt_len_parsed,
1633 .help_str = "port config all max-pkt-len <value>",
1635 (void *)&cmd_config_max_pkt_len_port,
1636 (void *)&cmd_config_max_pkt_len_keyword,
1637 (void *)&cmd_config_max_pkt_len_all,
1638 (void *)&cmd_config_max_pkt_len_name,
1639 (void *)&cmd_config_max_pkt_len_value,
1644 /* *** configure port MTU *** */
1645 struct cmd_config_mtu_result {
1646 cmdline_fixed_string_t port;
1647 cmdline_fixed_string_t keyword;
1648 cmdline_fixed_string_t mtu;
1654 cmd_config_mtu_parsed(void *parsed_result,
1655 __attribute__((unused)) struct cmdline *cl,
1656 __attribute__((unused)) void *data)
1658 struct cmd_config_mtu_result *res = parsed_result;
1660 if (res->value < ETHER_MIN_LEN) {
1661 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1664 port_mtu_set(res->port_id, res->value);
1667 cmdline_parse_token_string_t cmd_config_mtu_port =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1670 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1673 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1676 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1677 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1678 cmdline_parse_token_num_t cmd_config_mtu_value =
1679 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1681 cmdline_parse_inst_t cmd_config_mtu = {
1682 .f = cmd_config_mtu_parsed,
1684 .help_str = "port config mtu <port_id> <value>",
1686 (void *)&cmd_config_mtu_port,
1687 (void *)&cmd_config_mtu_keyword,
1688 (void *)&cmd_config_mtu_mtu,
1689 (void *)&cmd_config_mtu_port_id,
1690 (void *)&cmd_config_mtu_value,
1695 /* *** configure rx mode *** */
1696 struct cmd_config_rx_mode_flag {
1697 cmdline_fixed_string_t port;
1698 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t all;
1700 cmdline_fixed_string_t name;
1701 cmdline_fixed_string_t value;
1705 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_config_rx_mode_flag *res = parsed_result;
1711 if (!all_ports_stopped()) {
1712 printf("Please stop all ports first\n");
1716 if (!strcmp(res->name, "crc-strip")) {
1717 if (!strcmp(res->value, "on"))
1718 rx_mode.hw_strip_crc = 1;
1719 else if (!strcmp(res->value, "off"))
1720 rx_mode.hw_strip_crc = 0;
1722 printf("Unknown parameter\n");
1725 } else if (!strcmp(res->name, "scatter")) {
1726 if (!strcmp(res->value, "on"))
1727 rx_mode.enable_scatter = 1;
1728 else if (!strcmp(res->value, "off"))
1729 rx_mode.enable_scatter = 0;
1731 printf("Unknown parameter\n");
1734 } else if (!strcmp(res->name, "rx-cksum")) {
1735 if (!strcmp(res->value, "on"))
1736 rx_mode.hw_ip_checksum = 1;
1737 else if (!strcmp(res->value, "off"))
1738 rx_mode.hw_ip_checksum = 0;
1740 printf("Unknown parameter\n");
1743 } else if (!strcmp(res->name, "rx-timestamp")) {
1744 if (!strcmp(res->value, "on"))
1745 rx_mode.hw_timestamp = 1;
1746 else if (!strcmp(res->value, "off"))
1747 rx_mode.hw_timestamp = 0;
1749 printf("Unknown parameter\n");
1752 } else if (!strcmp(res->name, "hw-vlan")) {
1753 if (!strcmp(res->value, "on")) {
1754 rx_mode.hw_vlan_filter = 1;
1755 rx_mode.hw_vlan_strip = 1;
1757 else if (!strcmp(res->value, "off")) {
1758 rx_mode.hw_vlan_filter = 0;
1759 rx_mode.hw_vlan_strip = 0;
1762 printf("Unknown parameter\n");
1765 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1766 if (!strcmp(res->value, "on"))
1767 rx_mode.hw_vlan_filter = 1;
1768 else if (!strcmp(res->value, "off"))
1769 rx_mode.hw_vlan_filter = 0;
1771 printf("Unknown parameter\n");
1774 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1775 if (!strcmp(res->value, "on"))
1776 rx_mode.hw_vlan_strip = 1;
1777 else if (!strcmp(res->value, "off"))
1778 rx_mode.hw_vlan_strip = 0;
1780 printf("Unknown parameter\n");
1783 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1784 if (!strcmp(res->value, "on"))
1785 rx_mode.hw_vlan_extend = 1;
1786 else if (!strcmp(res->value, "off"))
1787 rx_mode.hw_vlan_extend = 0;
1789 printf("Unknown parameter\n");
1792 } else if (!strcmp(res->name, "drop-en")) {
1793 if (!strcmp(res->value, "on"))
1795 else if (!strcmp(res->value, "off"))
1798 printf("Unknown parameter\n");
1802 printf("Unknown parameter\n");
1808 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1811 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1812 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1813 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1814 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1816 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1817 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1818 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1819 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1820 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1821 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1822 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1826 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1827 .f = cmd_config_rx_mode_flag_parsed,
1829 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1830 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1832 (void *)&cmd_config_rx_mode_flag_port,
1833 (void *)&cmd_config_rx_mode_flag_keyword,
1834 (void *)&cmd_config_rx_mode_flag_all,
1835 (void *)&cmd_config_rx_mode_flag_name,
1836 (void *)&cmd_config_rx_mode_flag_value,
1841 /* *** configure rss *** */
1842 struct cmd_config_rss {
1843 cmdline_fixed_string_t port;
1844 cmdline_fixed_string_t keyword;
1845 cmdline_fixed_string_t all;
1846 cmdline_fixed_string_t name;
1847 cmdline_fixed_string_t value;
1851 cmd_config_rss_parsed(void *parsed_result,
1852 __attribute__((unused)) struct cmdline *cl,
1853 __attribute__((unused)) void *data)
1855 struct cmd_config_rss *res = parsed_result;
1856 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1860 if (!strcmp(res->value, "all"))
1861 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1862 ETH_RSS_UDP | ETH_RSS_SCTP |
1864 else if (!strcmp(res->value, "ip"))
1865 rss_conf.rss_hf = ETH_RSS_IP;
1866 else if (!strcmp(res->value, "udp"))
1867 rss_conf.rss_hf = ETH_RSS_UDP;
1868 else if (!strcmp(res->value, "tcp"))
1869 rss_conf.rss_hf = ETH_RSS_TCP;
1870 else if (!strcmp(res->value, "sctp"))
1871 rss_conf.rss_hf = ETH_RSS_SCTP;
1872 else if (!strcmp(res->value, "ether"))
1873 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1874 else if (!strcmp(res->value, "port"))
1875 rss_conf.rss_hf = ETH_RSS_PORT;
1876 else if (!strcmp(res->value, "vxlan"))
1877 rss_conf.rss_hf = ETH_RSS_VXLAN;
1878 else if (!strcmp(res->value, "geneve"))
1879 rss_conf.rss_hf = ETH_RSS_GENEVE;
1880 else if (!strcmp(res->value, "nvgre"))
1881 rss_conf.rss_hf = ETH_RSS_NVGRE;
1882 else if (!strcmp(res->value, "none"))
1883 rss_conf.rss_hf = 0;
1884 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1885 atoi(res->value) < 64)
1886 rss_conf.rss_hf = 1ULL << atoi(res->value);
1888 printf("Unknown parameter\n");
1891 rss_conf.rss_key = NULL;
1892 for (i = 0; i < rte_eth_dev_count(); i++) {
1893 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1895 printf("Configuration of RSS hash at ethernet port %d "
1896 "failed with error (%d): %s.\n",
1897 i, -diag, strerror(-diag));
1901 cmdline_parse_token_string_t cmd_config_rss_port =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1903 cmdline_parse_token_string_t cmd_config_rss_keyword =
1904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1905 cmdline_parse_token_string_t cmd_config_rss_all =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1907 cmdline_parse_token_string_t cmd_config_rss_name =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1909 cmdline_parse_token_string_t cmd_config_rss_value =
1910 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1912 cmdline_parse_inst_t cmd_config_rss = {
1913 .f = cmd_config_rss_parsed,
1915 .help_str = "port config all rss "
1916 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1918 (void *)&cmd_config_rss_port,
1919 (void *)&cmd_config_rss_keyword,
1920 (void *)&cmd_config_rss_all,
1921 (void *)&cmd_config_rss_name,
1922 (void *)&cmd_config_rss_value,
1927 /* *** configure rss hash key *** */
1928 struct cmd_config_rss_hash_key {
1929 cmdline_fixed_string_t port;
1930 cmdline_fixed_string_t config;
1932 cmdline_fixed_string_t rss_hash_key;
1933 cmdline_fixed_string_t rss_type;
1934 cmdline_fixed_string_t key;
1938 hexa_digit_to_value(char hexa_digit)
1940 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1941 return (uint8_t) (hexa_digit - '0');
1942 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1943 return (uint8_t) ((hexa_digit - 'a') + 10);
1944 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1945 return (uint8_t) ((hexa_digit - 'A') + 10);
1946 /* Invalid hexa digit */
1951 parse_and_check_key_hexa_digit(char *key, int idx)
1955 hexa_v = hexa_digit_to_value(key[idx]);
1957 printf("invalid key: character %c at position %d is not a "
1958 "valid hexa digit\n", key[idx], idx);
1963 cmd_config_rss_hash_key_parsed(void *parsed_result,
1964 __attribute__((unused)) struct cmdline *cl,
1965 __attribute__((unused)) void *data)
1967 struct cmd_config_rss_hash_key *res = parsed_result;
1968 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1972 struct rte_eth_dev_info dev_info;
1973 uint8_t hash_key_size;
1976 memset(&dev_info, 0, sizeof(dev_info));
1977 rte_eth_dev_info_get(res->port_id, &dev_info);
1978 if (dev_info.hash_key_size > 0 &&
1979 dev_info.hash_key_size <= sizeof(hash_key))
1980 hash_key_size = dev_info.hash_key_size;
1982 printf("dev_info did not provide a valid hash key size\n");
1985 /* Check the length of the RSS hash key */
1986 key_len = strlen(res->key);
1987 if (key_len != (hash_key_size * 2)) {
1988 printf("key length: %d invalid - key must be a string of %d"
1989 " hexa-decimal numbers\n",
1990 (int) key_len, hash_key_size * 2);
1993 /* Translate RSS hash key into binary representation */
1994 for (i = 0; i < hash_key_size; i++) {
1995 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1998 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2001 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2003 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2007 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2009 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2012 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2013 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2014 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2016 rss_hash_key, "rss-hash-key");
2017 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2019 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2020 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2021 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2022 "ipv6-tcp-ex#ipv6-udp-ex");
2023 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2026 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2027 .f = cmd_config_rss_hash_key_parsed,
2029 .help_str = "port config <port_id> rss-hash-key "
2030 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2031 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2032 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2033 "<string of hex digits (variable length, NIC dependent)>",
2035 (void *)&cmd_config_rss_hash_key_port,
2036 (void *)&cmd_config_rss_hash_key_config,
2037 (void *)&cmd_config_rss_hash_key_port_id,
2038 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2039 (void *)&cmd_config_rss_hash_key_rss_type,
2040 (void *)&cmd_config_rss_hash_key_value,
2045 /* *** configure port rxq/txq start/stop *** */
2046 struct cmd_config_rxtx_queue {
2047 cmdline_fixed_string_t port;
2049 cmdline_fixed_string_t rxtxq;
2051 cmdline_fixed_string_t opname;
2055 cmd_config_rxtx_queue_parsed(void *parsed_result,
2056 __attribute__((unused)) struct cmdline *cl,
2057 __attribute__((unused)) void *data)
2059 struct cmd_config_rxtx_queue *res = parsed_result;
2064 if (test_done == 0) {
2065 printf("Please stop forwarding first\n");
2069 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2072 if (port_is_started(res->portid) != 1) {
2073 printf("Please start port %u first\n", res->portid);
2077 if (!strcmp(res->rxtxq, "rxq"))
2079 else if (!strcmp(res->rxtxq, "txq"))
2082 printf("Unknown parameter\n");
2086 if (isrx && rx_queue_id_is_invalid(res->qid))
2088 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2091 if (!strcmp(res->opname, "start"))
2093 else if (!strcmp(res->opname, "stop"))
2096 printf("Unknown parameter\n");
2100 if (isstart && isrx)
2101 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2102 else if (!isstart && isrx)
2103 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2104 else if (isstart && !isrx)
2105 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2107 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2109 if (ret == -ENOTSUP)
2110 printf("Function not supported in PMD driver\n");
2113 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2115 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2116 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2117 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2119 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2120 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2121 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2125 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2126 .f = cmd_config_rxtx_queue_parsed,
2128 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2130 (void *)&cmd_config_speed_all_port,
2131 (void *)&cmd_config_rxtx_queue_portid,
2132 (void *)&cmd_config_rxtx_queue_rxtxq,
2133 (void *)&cmd_config_rxtx_queue_qid,
2134 (void *)&cmd_config_rxtx_queue_opname,
2139 /* *** Configure RSS RETA *** */
2140 struct cmd_config_rss_reta {
2141 cmdline_fixed_string_t port;
2142 cmdline_fixed_string_t keyword;
2144 cmdline_fixed_string_t name;
2145 cmdline_fixed_string_t list_name;
2146 cmdline_fixed_string_t list_of_items;
2150 parse_reta_config(const char *str,
2151 struct rte_eth_rss_reta_entry64 *reta_conf,
2152 uint16_t nb_entries)
2156 uint16_t hash_index, idx, shift;
2159 const char *p, *p0 = str;
2166 unsigned long int_fld[_NUM_FLD];
2167 char *str_fld[_NUM_FLD];
2169 while ((p = strchr(p0,'(')) != NULL) {
2171 if((p0 = strchr(p,')')) == NULL)
2175 if(size >= sizeof(s))
2178 snprintf(s, sizeof(s), "%.*s", size, p);
2179 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2181 for (i = 0; i < _NUM_FLD; i++) {
2183 int_fld[i] = strtoul(str_fld[i], &end, 0);
2184 if (errno != 0 || end == str_fld[i] ||
2189 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2190 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2192 if (hash_index >= nb_entries) {
2193 printf("Invalid RETA hash index=%d\n", hash_index);
2197 idx = hash_index / RTE_RETA_GROUP_SIZE;
2198 shift = hash_index % RTE_RETA_GROUP_SIZE;
2199 reta_conf[idx].mask |= (1ULL << shift);
2200 reta_conf[idx].reta[shift] = nb_queue;
2207 cmd_set_rss_reta_parsed(void *parsed_result,
2208 __attribute__((unused)) struct cmdline *cl,
2209 __attribute__((unused)) void *data)
2212 struct rte_eth_dev_info dev_info;
2213 struct rte_eth_rss_reta_entry64 reta_conf[8];
2214 struct cmd_config_rss_reta *res = parsed_result;
2216 memset(&dev_info, 0, sizeof(dev_info));
2217 rte_eth_dev_info_get(res->port_id, &dev_info);
2218 if (dev_info.reta_size == 0) {
2219 printf("Redirection table size is 0 which is "
2220 "invalid for RSS\n");
2223 printf("The reta size of port %d is %u\n",
2224 res->port_id, dev_info.reta_size);
2225 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2226 printf("Currently do not support more than %u entries of "
2227 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2231 memset(reta_conf, 0, sizeof(reta_conf));
2232 if (!strcmp(res->list_name, "reta")) {
2233 if (parse_reta_config(res->list_of_items, reta_conf,
2234 dev_info.reta_size)) {
2235 printf("Invalid RSS Redirection Table "
2236 "config entered\n");
2239 ret = rte_eth_dev_rss_reta_update(res->port_id,
2240 reta_conf, dev_info.reta_size);
2242 printf("Bad redirection table parameter, "
2243 "return code = %d \n", ret);
2247 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2249 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2251 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2252 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2253 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2255 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2257 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2260 cmdline_parse_inst_t cmd_config_rss_reta = {
2261 .f = cmd_set_rss_reta_parsed,
2263 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2265 (void *)&cmd_config_rss_reta_port,
2266 (void *)&cmd_config_rss_reta_keyword,
2267 (void *)&cmd_config_rss_reta_port_id,
2268 (void *)&cmd_config_rss_reta_name,
2269 (void *)&cmd_config_rss_reta_list_name,
2270 (void *)&cmd_config_rss_reta_list_of_items,
2275 /* *** SHOW PORT RETA INFO *** */
2276 struct cmd_showport_reta {
2277 cmdline_fixed_string_t show;
2278 cmdline_fixed_string_t port;
2280 cmdline_fixed_string_t rss;
2281 cmdline_fixed_string_t reta;
2283 cmdline_fixed_string_t list_of_items;
2287 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2288 uint16_t nb_entries,
2292 const char *p, *p0 = str;
2297 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2298 RTE_RETA_GROUP_SIZE;
2301 p = strchr(p0, '(');
2305 p0 = strchr(p, ')');
2309 if (size >= sizeof(s)) {
2310 printf("The string size exceeds the internal buffer size\n");
2313 snprintf(s, sizeof(s), "%.*s", size, p);
2314 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2315 if (ret <= 0 || ret != num) {
2316 printf("The bits of masks do not match the number of "
2317 "reta entries: %u\n", num);
2320 for (i = 0; i < ret; i++)
2321 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2327 cmd_showport_reta_parsed(void *parsed_result,
2328 __attribute__((unused)) struct cmdline *cl,
2329 __attribute__((unused)) void *data)
2331 struct cmd_showport_reta *res = parsed_result;
2332 struct rte_eth_rss_reta_entry64 reta_conf[8];
2333 struct rte_eth_dev_info dev_info;
2334 uint16_t max_reta_size;
2336 memset(&dev_info, 0, sizeof(dev_info));
2337 rte_eth_dev_info_get(res->port_id, &dev_info);
2338 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2339 if (res->size == 0 || res->size > max_reta_size) {
2340 printf("Invalid redirection table size: %u (1-%u)\n",
2341 res->size, max_reta_size);
2345 memset(reta_conf, 0, sizeof(reta_conf));
2346 if (showport_parse_reta_config(reta_conf, res->size,
2347 res->list_of_items) < 0) {
2348 printf("Invalid string: %s for reta masks\n",
2349 res->list_of_items);
2352 port_rss_reta_info(res->port_id, reta_conf, res->size);
2355 cmdline_parse_token_string_t cmd_showport_reta_show =
2356 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2357 cmdline_parse_token_string_t cmd_showport_reta_port =
2358 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2359 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2360 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2361 cmdline_parse_token_string_t cmd_showport_reta_rss =
2362 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2363 cmdline_parse_token_string_t cmd_showport_reta_reta =
2364 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2365 cmdline_parse_token_num_t cmd_showport_reta_size =
2366 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2367 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2368 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2369 list_of_items, NULL);
2371 cmdline_parse_inst_t cmd_showport_reta = {
2372 .f = cmd_showport_reta_parsed,
2374 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2376 (void *)&cmd_showport_reta_show,
2377 (void *)&cmd_showport_reta_port,
2378 (void *)&cmd_showport_reta_port_id,
2379 (void *)&cmd_showport_reta_rss,
2380 (void *)&cmd_showport_reta_reta,
2381 (void *)&cmd_showport_reta_size,
2382 (void *)&cmd_showport_reta_list_of_items,
2387 /* *** Show RSS hash configuration *** */
2388 struct cmd_showport_rss_hash {
2389 cmdline_fixed_string_t show;
2390 cmdline_fixed_string_t port;
2392 cmdline_fixed_string_t rss_hash;
2393 cmdline_fixed_string_t rss_type;
2394 cmdline_fixed_string_t key; /* optional argument */
2397 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2398 __attribute__((unused)) struct cmdline *cl,
2401 struct cmd_showport_rss_hash *res = parsed_result;
2403 port_rss_hash_conf_show(res->port_id, res->rss_type,
2404 show_rss_key != NULL);
2407 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2408 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2409 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2410 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2411 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2412 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2413 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2414 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2416 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2417 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2418 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2419 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2420 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2421 "ipv6-tcp-ex#ipv6-udp-ex");
2422 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2423 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2425 cmdline_parse_inst_t cmd_showport_rss_hash = {
2426 .f = cmd_showport_rss_hash_parsed,
2428 .help_str = "show port <port_id> rss-hash "
2429 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2430 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2431 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2433 (void *)&cmd_showport_rss_hash_show,
2434 (void *)&cmd_showport_rss_hash_port,
2435 (void *)&cmd_showport_rss_hash_port_id,
2436 (void *)&cmd_showport_rss_hash_rss_hash,
2437 (void *)&cmd_showport_rss_hash_rss_hash_info,
2442 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2443 .f = cmd_showport_rss_hash_parsed,
2445 .help_str = "show port <port_id> rss-hash "
2446 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2447 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2448 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2450 (void *)&cmd_showport_rss_hash_show,
2451 (void *)&cmd_showport_rss_hash_port,
2452 (void *)&cmd_showport_rss_hash_port_id,
2453 (void *)&cmd_showport_rss_hash_rss_hash,
2454 (void *)&cmd_showport_rss_hash_rss_hash_info,
2455 (void *)&cmd_showport_rss_hash_rss_key,
2460 /* *** Configure DCB *** */
2461 struct cmd_config_dcb {
2462 cmdline_fixed_string_t port;
2463 cmdline_fixed_string_t config;
2465 cmdline_fixed_string_t dcb;
2466 cmdline_fixed_string_t vt;
2467 cmdline_fixed_string_t vt_en;
2469 cmdline_fixed_string_t pfc;
2470 cmdline_fixed_string_t pfc_en;
2474 cmd_config_dcb_parsed(void *parsed_result,
2475 __attribute__((unused)) struct cmdline *cl,
2476 __attribute__((unused)) void *data)
2478 struct cmd_config_dcb *res = parsed_result;
2479 portid_t port_id = res->port_id;
2480 struct rte_port *port;
2484 port = &ports[port_id];
2485 /** Check if the port is not started **/
2486 if (port->port_status != RTE_PORT_STOPPED) {
2487 printf("Please stop port %d first\n", port_id);
2491 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2492 printf("The invalid number of traffic class,"
2493 " only 4 or 8 allowed.\n");
2497 if (nb_fwd_lcores < res->num_tcs) {
2498 printf("nb_cores shouldn't be less than number of TCs.\n");
2501 if (!strncmp(res->pfc_en, "on", 2))
2506 /* DCB in VT mode */
2507 if (!strncmp(res->vt_en, "on", 2))
2508 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2509 (enum rte_eth_nb_tcs)res->num_tcs,
2512 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2513 (enum rte_eth_nb_tcs)res->num_tcs,
2518 printf("Cannot initialize network ports.\n");
2522 cmd_reconfig_device_queue(port_id, 1, 1);
2525 cmdline_parse_token_string_t cmd_config_dcb_port =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2527 cmdline_parse_token_string_t cmd_config_dcb_config =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2529 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2530 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2531 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2532 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2533 cmdline_parse_token_string_t cmd_config_dcb_vt =
2534 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2535 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2536 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2537 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2538 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2539 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2540 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2541 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2542 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2544 cmdline_parse_inst_t cmd_config_dcb = {
2545 .f = cmd_config_dcb_parsed,
2547 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2549 (void *)&cmd_config_dcb_port,
2550 (void *)&cmd_config_dcb_config,
2551 (void *)&cmd_config_dcb_port_id,
2552 (void *)&cmd_config_dcb_dcb,
2553 (void *)&cmd_config_dcb_vt,
2554 (void *)&cmd_config_dcb_vt_en,
2555 (void *)&cmd_config_dcb_num_tcs,
2556 (void *)&cmd_config_dcb_pfc,
2557 (void *)&cmd_config_dcb_pfc_en,
2562 /* *** configure number of packets per burst *** */
2563 struct cmd_config_burst {
2564 cmdline_fixed_string_t port;
2565 cmdline_fixed_string_t keyword;
2566 cmdline_fixed_string_t all;
2567 cmdline_fixed_string_t name;
2572 cmd_config_burst_parsed(void *parsed_result,
2573 __attribute__((unused)) struct cmdline *cl,
2574 __attribute__((unused)) void *data)
2576 struct cmd_config_burst *res = parsed_result;
2578 if (!all_ports_stopped()) {
2579 printf("Please stop all ports first\n");
2583 if (!strcmp(res->name, "burst")) {
2584 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2585 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2588 nb_pkt_per_burst = res->value;
2590 printf("Unknown parameter\n");
2596 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2599 cmdline_parse_token_string_t cmd_config_burst_port =
2600 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2601 cmdline_parse_token_string_t cmd_config_burst_keyword =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2603 cmdline_parse_token_string_t cmd_config_burst_all =
2604 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2605 cmdline_parse_token_string_t cmd_config_burst_name =
2606 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2607 cmdline_parse_token_num_t cmd_config_burst_value =
2608 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2610 cmdline_parse_inst_t cmd_config_burst = {
2611 .f = cmd_config_burst_parsed,
2613 .help_str = "port config all burst <value>",
2615 (void *)&cmd_config_burst_port,
2616 (void *)&cmd_config_burst_keyword,
2617 (void *)&cmd_config_burst_all,
2618 (void *)&cmd_config_burst_name,
2619 (void *)&cmd_config_burst_value,
2624 /* *** configure rx/tx queues *** */
2625 struct cmd_config_thresh {
2626 cmdline_fixed_string_t port;
2627 cmdline_fixed_string_t keyword;
2628 cmdline_fixed_string_t all;
2629 cmdline_fixed_string_t name;
2634 cmd_config_thresh_parsed(void *parsed_result,
2635 __attribute__((unused)) struct cmdline *cl,
2636 __attribute__((unused)) void *data)
2638 struct cmd_config_thresh *res = parsed_result;
2640 if (!all_ports_stopped()) {
2641 printf("Please stop all ports first\n");
2645 if (!strcmp(res->name, "txpt"))
2646 tx_pthresh = res->value;
2647 else if(!strcmp(res->name, "txht"))
2648 tx_hthresh = res->value;
2649 else if(!strcmp(res->name, "txwt"))
2650 tx_wthresh = res->value;
2651 else if(!strcmp(res->name, "rxpt"))
2652 rx_pthresh = res->value;
2653 else if(!strcmp(res->name, "rxht"))
2654 rx_hthresh = res->value;
2655 else if(!strcmp(res->name, "rxwt"))
2656 rx_wthresh = res->value;
2658 printf("Unknown parameter\n");
2664 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2667 cmdline_parse_token_string_t cmd_config_thresh_port =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2669 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2671 cmdline_parse_token_string_t cmd_config_thresh_all =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2673 cmdline_parse_token_string_t cmd_config_thresh_name =
2674 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2675 "txpt#txht#txwt#rxpt#rxht#rxwt");
2676 cmdline_parse_token_num_t cmd_config_thresh_value =
2677 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2679 cmdline_parse_inst_t cmd_config_thresh = {
2680 .f = cmd_config_thresh_parsed,
2682 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2684 (void *)&cmd_config_thresh_port,
2685 (void *)&cmd_config_thresh_keyword,
2686 (void *)&cmd_config_thresh_all,
2687 (void *)&cmd_config_thresh_name,
2688 (void *)&cmd_config_thresh_value,
2693 /* *** configure free/rs threshold *** */
2694 struct cmd_config_threshold {
2695 cmdline_fixed_string_t port;
2696 cmdline_fixed_string_t keyword;
2697 cmdline_fixed_string_t all;
2698 cmdline_fixed_string_t name;
2703 cmd_config_threshold_parsed(void *parsed_result,
2704 __attribute__((unused)) struct cmdline *cl,
2705 __attribute__((unused)) void *data)
2707 struct cmd_config_threshold *res = parsed_result;
2709 if (!all_ports_stopped()) {
2710 printf("Please stop all ports first\n");
2714 if (!strcmp(res->name, "txfreet"))
2715 tx_free_thresh = res->value;
2716 else if (!strcmp(res->name, "txrst"))
2717 tx_rs_thresh = res->value;
2718 else if (!strcmp(res->name, "rxfreet"))
2719 rx_free_thresh = res->value;
2721 printf("Unknown parameter\n");
2727 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2730 cmdline_parse_token_string_t cmd_config_threshold_port =
2731 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2732 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2733 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2735 cmdline_parse_token_string_t cmd_config_threshold_all =
2736 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2737 cmdline_parse_token_string_t cmd_config_threshold_name =
2738 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2739 "txfreet#txrst#rxfreet");
2740 cmdline_parse_token_num_t cmd_config_threshold_value =
2741 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2743 cmdline_parse_inst_t cmd_config_threshold = {
2744 .f = cmd_config_threshold_parsed,
2746 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2748 (void *)&cmd_config_threshold_port,
2749 (void *)&cmd_config_threshold_keyword,
2750 (void *)&cmd_config_threshold_all,
2751 (void *)&cmd_config_threshold_name,
2752 (void *)&cmd_config_threshold_value,
2758 struct cmd_stop_result {
2759 cmdline_fixed_string_t stop;
2762 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2763 __attribute__((unused)) struct cmdline *cl,
2764 __attribute__((unused)) void *data)
2766 stop_packet_forwarding();
2769 cmdline_parse_token_string_t cmd_stop_stop =
2770 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2772 cmdline_parse_inst_t cmd_stop = {
2773 .f = cmd_stop_parsed,
2775 .help_str = "stop: Stop packet forwarding",
2777 (void *)&cmd_stop_stop,
2782 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2785 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2786 unsigned int *parsed_items, int check_unique_values)
2788 unsigned int nb_item;
2796 * First parse all items in the list and store their value.
2801 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2803 if ((c >= '0') && (c <= '9')) {
2804 value = (unsigned int) (value * 10 + (c - '0'));
2809 printf("character %c is not a decimal digit\n", c);
2813 printf("No valid value before comma\n");
2816 if (nb_item < max_items) {
2817 parsed_items[nb_item] = value;
2823 if (nb_item >= max_items) {
2824 printf("Number of %s = %u > %u (maximum items)\n",
2825 item_name, nb_item + 1, max_items);
2828 parsed_items[nb_item++] = value;
2829 if (! check_unique_values)
2833 * Then, check that all values in the list are differents.
2834 * No optimization here...
2836 for (i = 0; i < nb_item; i++) {
2837 for (j = i + 1; j < nb_item; j++) {
2838 if (parsed_items[j] == parsed_items[i]) {
2839 printf("duplicated %s %u at index %u and %u\n",
2840 item_name, parsed_items[i], i, j);
2848 struct cmd_set_list_result {
2849 cmdline_fixed_string_t cmd_keyword;
2850 cmdline_fixed_string_t list_name;
2851 cmdline_fixed_string_t list_of_items;
2854 static void cmd_set_list_parsed(void *parsed_result,
2855 __attribute__((unused)) struct cmdline *cl,
2856 __attribute__((unused)) void *data)
2858 struct cmd_set_list_result *res;
2860 unsigned int lcorelist[RTE_MAX_LCORE];
2861 unsigned int portlist[RTE_MAX_ETHPORTS];
2863 unsigned int nb_item;
2865 if (test_done == 0) {
2866 printf("Please stop forwarding first\n");
2870 res = parsed_result;
2871 if (!strcmp(res->list_name, "corelist")) {
2872 nb_item = parse_item_list(res->list_of_items, "core",
2874 parsed_items.lcorelist, 1);
2876 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2881 if (!strcmp(res->list_name, "portlist")) {
2882 nb_item = parse_item_list(res->list_of_items, "port",
2884 parsed_items.portlist, 1);
2886 set_fwd_ports_list(parsed_items.portlist, nb_item);
2892 cmdline_parse_token_string_t cmd_set_list_keyword =
2893 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2895 cmdline_parse_token_string_t cmd_set_list_name =
2896 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2897 "corelist#portlist");
2898 cmdline_parse_token_string_t cmd_set_list_of_items =
2899 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2902 cmdline_parse_inst_t cmd_set_fwd_list = {
2903 .f = cmd_set_list_parsed,
2905 .help_str = "set corelist|portlist <list0[,list1]*>",
2907 (void *)&cmd_set_list_keyword,
2908 (void *)&cmd_set_list_name,
2909 (void *)&cmd_set_list_of_items,
2914 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2916 struct cmd_setmask_result {
2917 cmdline_fixed_string_t set;
2918 cmdline_fixed_string_t mask;
2922 static void cmd_set_mask_parsed(void *parsed_result,
2923 __attribute__((unused)) struct cmdline *cl,
2924 __attribute__((unused)) void *data)
2926 struct cmd_setmask_result *res = parsed_result;
2928 if (test_done == 0) {
2929 printf("Please stop forwarding first\n");
2932 if (!strcmp(res->mask, "coremask")) {
2933 set_fwd_lcores_mask(res->hexavalue);
2935 } else if (!strcmp(res->mask, "portmask")) {
2936 set_fwd_ports_mask(res->hexavalue);
2941 cmdline_parse_token_string_t cmd_setmask_set =
2942 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2943 cmdline_parse_token_string_t cmd_setmask_mask =
2944 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2945 "coremask#portmask");
2946 cmdline_parse_token_num_t cmd_setmask_value =
2947 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2949 cmdline_parse_inst_t cmd_set_fwd_mask = {
2950 .f = cmd_set_mask_parsed,
2952 .help_str = "set coremask|portmask <hexadecimal value>",
2954 (void *)&cmd_setmask_set,
2955 (void *)&cmd_setmask_mask,
2956 (void *)&cmd_setmask_value,
2962 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2964 struct cmd_set_result {
2965 cmdline_fixed_string_t set;
2966 cmdline_fixed_string_t what;
2970 static void cmd_set_parsed(void *parsed_result,
2971 __attribute__((unused)) struct cmdline *cl,
2972 __attribute__((unused)) void *data)
2974 struct cmd_set_result *res = parsed_result;
2975 if (!strcmp(res->what, "nbport")) {
2976 set_fwd_ports_number(res->value);
2978 } else if (!strcmp(res->what, "nbcore")) {
2979 set_fwd_lcores_number(res->value);
2981 } else if (!strcmp(res->what, "burst"))
2982 set_nb_pkt_per_burst(res->value);
2983 else if (!strcmp(res->what, "verbose"))
2984 set_verbose_level(res->value);
2987 cmdline_parse_token_string_t cmd_set_set =
2988 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2989 cmdline_parse_token_string_t cmd_set_what =
2990 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2991 "nbport#nbcore#burst#verbose");
2992 cmdline_parse_token_num_t cmd_set_value =
2993 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2995 cmdline_parse_inst_t cmd_set_numbers = {
2996 .f = cmd_set_parsed,
2998 .help_str = "set nbport|nbcore|burst|verbose <value>",
3000 (void *)&cmd_set_set,
3001 (void *)&cmd_set_what,
3002 (void *)&cmd_set_value,
3007 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3009 struct cmd_set_txpkts_result {
3010 cmdline_fixed_string_t cmd_keyword;
3011 cmdline_fixed_string_t txpkts;
3012 cmdline_fixed_string_t seg_lengths;
3016 cmd_set_txpkts_parsed(void *parsed_result,
3017 __attribute__((unused)) struct cmdline *cl,
3018 __attribute__((unused)) void *data)
3020 struct cmd_set_txpkts_result *res;
3021 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3022 unsigned int nb_segs;
3024 res = parsed_result;
3025 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3026 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3028 set_tx_pkt_segments(seg_lengths, nb_segs);
3031 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3032 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3033 cmd_keyword, "set");
3034 cmdline_parse_token_string_t cmd_set_txpkts_name =
3035 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3037 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3038 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3041 cmdline_parse_inst_t cmd_set_txpkts = {
3042 .f = cmd_set_txpkts_parsed,
3044 .help_str = "set txpkts <len0[,len1]*>",
3046 (void *)&cmd_set_txpkts_keyword,
3047 (void *)&cmd_set_txpkts_name,
3048 (void *)&cmd_set_txpkts_lengths,
3053 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3055 struct cmd_set_txsplit_result {
3056 cmdline_fixed_string_t cmd_keyword;
3057 cmdline_fixed_string_t txsplit;
3058 cmdline_fixed_string_t mode;
3062 cmd_set_txsplit_parsed(void *parsed_result,
3063 __attribute__((unused)) struct cmdline *cl,
3064 __attribute__((unused)) void *data)
3066 struct cmd_set_txsplit_result *res;
3068 res = parsed_result;
3069 set_tx_pkt_split(res->mode);
3072 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3073 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3074 cmd_keyword, "set");
3075 cmdline_parse_token_string_t cmd_set_txsplit_name =
3076 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3077 txsplit, "txsplit");
3078 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3079 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3082 cmdline_parse_inst_t cmd_set_txsplit = {
3083 .f = cmd_set_txsplit_parsed,
3085 .help_str = "set txsplit on|off|rand",
3087 (void *)&cmd_set_txsplit_keyword,
3088 (void *)&cmd_set_txsplit_name,
3089 (void *)&cmd_set_txsplit_mode,
3094 /* *** CONFIG TX QUEUE FLAGS *** */
3096 struct cmd_config_txqflags_result {
3097 cmdline_fixed_string_t port;
3098 cmdline_fixed_string_t config;
3099 cmdline_fixed_string_t all;
3100 cmdline_fixed_string_t what;
3104 static void cmd_config_txqflags_parsed(void *parsed_result,
3105 __attribute__((unused)) struct cmdline *cl,
3106 __attribute__((unused)) void *data)
3108 struct cmd_config_txqflags_result *res = parsed_result;
3110 if (!all_ports_stopped()) {
3111 printf("Please stop all ports first\n");
3115 if (strcmp(res->what, "txqflags")) {
3116 printf("Unknown parameter\n");
3120 if (res->hexvalue >= 0) {
3121 txq_flags = res->hexvalue;
3123 printf("txqflags must be >= 0\n");
3129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3132 cmdline_parse_token_string_t cmd_config_txqflags_port =
3133 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3135 cmdline_parse_token_string_t cmd_config_txqflags_config =
3136 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3138 cmdline_parse_token_string_t cmd_config_txqflags_all =
3139 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3141 cmdline_parse_token_string_t cmd_config_txqflags_what =
3142 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3144 cmdline_parse_token_num_t cmd_config_txqflags_value =
3145 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3148 cmdline_parse_inst_t cmd_config_txqflags = {
3149 .f = cmd_config_txqflags_parsed,
3151 .help_str = "port config all txqflags <value>",
3153 (void *)&cmd_config_txqflags_port,
3154 (void *)&cmd_config_txqflags_config,
3155 (void *)&cmd_config_txqflags_all,
3156 (void *)&cmd_config_txqflags_what,
3157 (void *)&cmd_config_txqflags_value,
3162 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3163 struct cmd_rx_vlan_filter_all_result {
3164 cmdline_fixed_string_t rx_vlan;
3165 cmdline_fixed_string_t what;
3166 cmdline_fixed_string_t all;
3171 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3172 __attribute__((unused)) struct cmdline *cl,
3173 __attribute__((unused)) void *data)
3175 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3177 if (!strcmp(res->what, "add"))
3178 rx_vlan_all_filter_set(res->port_id, 1);
3180 rx_vlan_all_filter_set(res->port_id, 0);
3183 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3184 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3185 rx_vlan, "rx_vlan");
3186 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3187 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3189 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3190 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3192 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3193 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3196 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3197 .f = cmd_rx_vlan_filter_all_parsed,
3199 .help_str = "rx_vlan add|rm all <port_id>: "
3200 "Add/Remove all identifiers to/from the set of VLAN "
3201 "identifiers filtered by a port",
3203 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3204 (void *)&cmd_rx_vlan_filter_all_what,
3205 (void *)&cmd_rx_vlan_filter_all_all,
3206 (void *)&cmd_rx_vlan_filter_all_portid,
3211 /* *** VLAN OFFLOAD SET ON A PORT *** */
3212 struct cmd_vlan_offload_result {
3213 cmdline_fixed_string_t vlan;
3214 cmdline_fixed_string_t set;
3215 cmdline_fixed_string_t vlan_type;
3216 cmdline_fixed_string_t what;
3217 cmdline_fixed_string_t on;
3218 cmdline_fixed_string_t port_id;
3222 cmd_vlan_offload_parsed(void *parsed_result,
3223 __attribute__((unused)) struct cmdline *cl,
3224 __attribute__((unused)) void *data)
3227 struct cmd_vlan_offload_result *res = parsed_result;
3230 portid_t port_id = 0;
3234 len = strnlen(str, STR_TOKEN_SIZE);
3236 /* Get port_id first */
3244 tmp = strtoul(str, NULL, 0);
3245 /* If port_id greater that what portid_t can represent, return */
3246 if(tmp >= RTE_MAX_ETHPORTS)
3248 port_id = (portid_t)tmp;
3250 if (!strcmp(res->on, "on"))
3255 if (!strcmp(res->what, "strip"))
3256 rx_vlan_strip_set(port_id, on);
3257 else if(!strcmp(res->what, "stripq")){
3258 uint16_t queue_id = 0;
3260 /* No queue_id, return */
3262 printf("must specify (port,queue_id)\n");
3265 tmp = strtoul(str + i + 1, NULL, 0);
3266 /* If queue_id greater that what 16-bits can represent, return */
3270 queue_id = (uint16_t)tmp;
3271 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3273 else if (!strcmp(res->what, "filter"))
3274 rx_vlan_filter_set(port_id, on);
3276 vlan_extend_set(port_id, on);
3281 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3282 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3284 cmdline_parse_token_string_t cmd_vlan_offload_set =
3285 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3287 cmdline_parse_token_string_t cmd_vlan_offload_what =
3288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3289 what, "strip#filter#qinq#stripq");
3290 cmdline_parse_token_string_t cmd_vlan_offload_on =
3291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3293 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3297 cmdline_parse_inst_t cmd_vlan_offload = {
3298 .f = cmd_vlan_offload_parsed,
3300 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3301 "<port_id[,queue_id]>: "
3302 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3304 (void *)&cmd_vlan_offload_vlan,
3305 (void *)&cmd_vlan_offload_set,
3306 (void *)&cmd_vlan_offload_what,
3307 (void *)&cmd_vlan_offload_on,
3308 (void *)&cmd_vlan_offload_portid,
3313 /* *** VLAN TPID SET ON A PORT *** */
3314 struct cmd_vlan_tpid_result {
3315 cmdline_fixed_string_t vlan;
3316 cmdline_fixed_string_t set;
3317 cmdline_fixed_string_t vlan_type;
3318 cmdline_fixed_string_t what;
3324 cmd_vlan_tpid_parsed(void *parsed_result,
3325 __attribute__((unused)) struct cmdline *cl,
3326 __attribute__((unused)) void *data)
3328 struct cmd_vlan_tpid_result *res = parsed_result;
3329 enum rte_vlan_type vlan_type;
3331 if (!strcmp(res->vlan_type, "inner"))
3332 vlan_type = ETH_VLAN_TYPE_INNER;
3333 else if (!strcmp(res->vlan_type, "outer"))
3334 vlan_type = ETH_VLAN_TYPE_OUTER;
3336 printf("Unknown vlan type\n");
3339 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3342 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3343 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3345 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3346 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3348 cmdline_parse_token_string_t cmd_vlan_type =
3349 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3350 vlan_type, "inner#outer");
3351 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3352 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3354 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3355 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3357 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3358 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3361 cmdline_parse_inst_t cmd_vlan_tpid = {
3362 .f = cmd_vlan_tpid_parsed,
3364 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3365 "Set the VLAN Ether type",
3367 (void *)&cmd_vlan_tpid_vlan,
3368 (void *)&cmd_vlan_tpid_set,
3369 (void *)&cmd_vlan_type,
3370 (void *)&cmd_vlan_tpid_what,
3371 (void *)&cmd_vlan_tpid_tpid,
3372 (void *)&cmd_vlan_tpid_portid,
3377 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3378 struct cmd_rx_vlan_filter_result {
3379 cmdline_fixed_string_t rx_vlan;
3380 cmdline_fixed_string_t what;
3386 cmd_rx_vlan_filter_parsed(void *parsed_result,
3387 __attribute__((unused)) struct cmdline *cl,
3388 __attribute__((unused)) void *data)
3390 struct cmd_rx_vlan_filter_result *res = parsed_result;
3392 if (!strcmp(res->what, "add"))
3393 rx_vft_set(res->port_id, res->vlan_id, 1);
3395 rx_vft_set(res->port_id, res->vlan_id, 0);
3398 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3399 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3400 rx_vlan, "rx_vlan");
3401 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3402 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3404 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3405 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3407 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3408 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3411 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3412 .f = cmd_rx_vlan_filter_parsed,
3414 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3415 "Add/Remove a VLAN identifier to/from the set of VLAN "
3416 "identifiers filtered by a port",
3418 (void *)&cmd_rx_vlan_filter_rx_vlan,
3419 (void *)&cmd_rx_vlan_filter_what,
3420 (void *)&cmd_rx_vlan_filter_vlanid,
3421 (void *)&cmd_rx_vlan_filter_portid,
3426 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3427 struct cmd_tx_vlan_set_result {
3428 cmdline_fixed_string_t tx_vlan;
3429 cmdline_fixed_string_t set;
3435 cmd_tx_vlan_set_parsed(void *parsed_result,
3436 __attribute__((unused)) struct cmdline *cl,
3437 __attribute__((unused)) void *data)
3439 struct cmd_tx_vlan_set_result *res = parsed_result;
3441 tx_vlan_set(res->port_id, res->vlan_id);
3444 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3445 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3446 tx_vlan, "tx_vlan");
3447 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3448 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3450 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3451 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3453 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3454 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3457 cmdline_parse_inst_t cmd_tx_vlan_set = {
3458 .f = cmd_tx_vlan_set_parsed,
3460 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3461 "Enable hardware insertion of a single VLAN header "
3462 "with a given TAG Identifier in packets sent on a port",
3464 (void *)&cmd_tx_vlan_set_tx_vlan,
3465 (void *)&cmd_tx_vlan_set_set,
3466 (void *)&cmd_tx_vlan_set_portid,
3467 (void *)&cmd_tx_vlan_set_vlanid,
3472 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3473 struct cmd_tx_vlan_set_qinq_result {
3474 cmdline_fixed_string_t tx_vlan;
3475 cmdline_fixed_string_t set;
3478 uint16_t vlan_id_outer;
3482 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3483 __attribute__((unused)) struct cmdline *cl,
3484 __attribute__((unused)) void *data)
3486 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3488 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3491 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3492 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3493 tx_vlan, "tx_vlan");
3494 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3495 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3497 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3498 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3500 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3501 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3503 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3504 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3505 vlan_id_outer, UINT16);
3507 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3508 .f = cmd_tx_vlan_set_qinq_parsed,
3510 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3511 "Enable hardware insertion of double VLAN header "
3512 "with given TAG Identifiers in packets sent on a port",
3514 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3515 (void *)&cmd_tx_vlan_set_qinq_set,
3516 (void *)&cmd_tx_vlan_set_qinq_portid,
3517 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3518 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3523 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3524 struct cmd_tx_vlan_set_pvid_result {
3525 cmdline_fixed_string_t tx_vlan;
3526 cmdline_fixed_string_t set;
3527 cmdline_fixed_string_t pvid;
3530 cmdline_fixed_string_t mode;
3534 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3535 __attribute__((unused)) struct cmdline *cl,
3536 __attribute__((unused)) void *data)
3538 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3540 if (strcmp(res->mode, "on") == 0)
3541 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3543 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3546 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3547 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3548 tx_vlan, "tx_vlan");
3549 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3550 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3552 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3553 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3555 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3556 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3558 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3559 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3561 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3562 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3565 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3566 .f = cmd_tx_vlan_set_pvid_parsed,
3568 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3570 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3571 (void *)&cmd_tx_vlan_set_pvid_set,
3572 (void *)&cmd_tx_vlan_set_pvid_pvid,
3573 (void *)&cmd_tx_vlan_set_pvid_port_id,
3574 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3575 (void *)&cmd_tx_vlan_set_pvid_mode,
3580 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3581 struct cmd_tx_vlan_reset_result {
3582 cmdline_fixed_string_t tx_vlan;
3583 cmdline_fixed_string_t reset;
3588 cmd_tx_vlan_reset_parsed(void *parsed_result,
3589 __attribute__((unused)) struct cmdline *cl,
3590 __attribute__((unused)) void *data)
3592 struct cmd_tx_vlan_reset_result *res = parsed_result;
3594 tx_vlan_reset(res->port_id);
3597 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3598 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3599 tx_vlan, "tx_vlan");
3600 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3601 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3603 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3604 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3607 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3608 .f = cmd_tx_vlan_reset_parsed,
3610 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3611 "VLAN header in packets sent on a port",
3613 (void *)&cmd_tx_vlan_reset_tx_vlan,
3614 (void *)&cmd_tx_vlan_reset_reset,
3615 (void *)&cmd_tx_vlan_reset_portid,
3621 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3622 struct cmd_csum_result {
3623 cmdline_fixed_string_t csum;
3624 cmdline_fixed_string_t mode;
3625 cmdline_fixed_string_t proto;
3626 cmdline_fixed_string_t hwsw;
3631 csum_show(int port_id)
3633 struct rte_eth_dev_info dev_info;
3636 ol_flags = ports[port_id].tx_ol_flags;
3637 printf("Parse tunnel is %s\n",
3638 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3639 printf("IP checksum offload is %s\n",
3640 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3641 printf("UDP checksum offload is %s\n",
3642 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3643 printf("TCP checksum offload is %s\n",
3644 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3645 printf("SCTP checksum offload is %s\n",
3646 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3647 printf("Outer-Ip checksum offload is %s\n",
3648 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3650 /* display warnings if configuration is not supported by the NIC */
3651 rte_eth_dev_info_get(port_id, &dev_info);
3652 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3654 printf("Warning: hardware IP checksum enabled but not "
3655 "supported by port %d\n", port_id);
3657 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3658 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3659 printf("Warning: hardware UDP checksum enabled but not "
3660 "supported by port %d\n", port_id);
3662 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3663 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3664 printf("Warning: hardware TCP checksum enabled but not "
3665 "supported by port %d\n", port_id);
3667 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3668 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3669 printf("Warning: hardware SCTP checksum enabled but not "
3670 "supported by port %d\n", port_id);
3672 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3674 printf("Warning: hardware outer IP checksum enabled but not "
3675 "supported by port %d\n", port_id);
3680 cmd_csum_parsed(void *parsed_result,
3681 __attribute__((unused)) struct cmdline *cl,
3682 __attribute__((unused)) void *data)
3684 struct cmd_csum_result *res = parsed_result;
3688 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3689 printf("invalid port %d\n", res->port_id);
3693 if (!strcmp(res->mode, "set")) {
3695 if (!strcmp(res->hwsw, "hw"))
3698 if (!strcmp(res->proto, "ip")) {
3699 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3700 } else if (!strcmp(res->proto, "udp")) {
3701 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3702 } else if (!strcmp(res->proto, "tcp")) {
3703 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3704 } else if (!strcmp(res->proto, "sctp")) {
3705 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3706 } else if (!strcmp(res->proto, "outer-ip")) {
3707 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3711 ports[res->port_id].tx_ol_flags |= mask;
3713 ports[res->port_id].tx_ol_flags &= (~mask);
3715 csum_show(res->port_id);
3718 cmdline_parse_token_string_t cmd_csum_csum =
3719 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3721 cmdline_parse_token_string_t cmd_csum_mode =
3722 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3724 cmdline_parse_token_string_t cmd_csum_proto =
3725 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3726 proto, "ip#tcp#udp#sctp#outer-ip");
3727 cmdline_parse_token_string_t cmd_csum_hwsw =
3728 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3730 cmdline_parse_token_num_t cmd_csum_portid =
3731 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3734 cmdline_parse_inst_t cmd_csum_set = {
3735 .f = cmd_csum_parsed,
3737 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3738 "Enable/Disable hardware calculation of L3/L4 checksum when "
3739 "using csum forward engine",
3741 (void *)&cmd_csum_csum,
3742 (void *)&cmd_csum_mode,
3743 (void *)&cmd_csum_proto,
3744 (void *)&cmd_csum_hwsw,
3745 (void *)&cmd_csum_portid,
3750 cmdline_parse_token_string_t cmd_csum_mode_show =
3751 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3754 cmdline_parse_inst_t cmd_csum_show = {
3755 .f = cmd_csum_parsed,
3757 .help_str = "csum show <port_id>: Show checksum offload configuration",
3759 (void *)&cmd_csum_csum,
3760 (void *)&cmd_csum_mode_show,
3761 (void *)&cmd_csum_portid,
3766 /* Enable/disable tunnel parsing */
3767 struct cmd_csum_tunnel_result {
3768 cmdline_fixed_string_t csum;
3769 cmdline_fixed_string_t parse;
3770 cmdline_fixed_string_t onoff;
3775 cmd_csum_tunnel_parsed(void *parsed_result,
3776 __attribute__((unused)) struct cmdline *cl,
3777 __attribute__((unused)) void *data)
3779 struct cmd_csum_tunnel_result *res = parsed_result;
3781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3784 if (!strcmp(res->onoff, "on"))
3785 ports[res->port_id].tx_ol_flags |=
3786 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3788 ports[res->port_id].tx_ol_flags &=
3789 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3791 csum_show(res->port_id);
3794 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3795 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3797 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3798 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3799 parse, "parse_tunnel");
3800 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3801 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3803 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3804 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3807 cmdline_parse_inst_t cmd_csum_tunnel = {
3808 .f = cmd_csum_tunnel_parsed,
3810 .help_str = "csum parse_tunnel on|off <port_id>: "
3811 "Enable/Disable parsing of tunnels for csum engine",
3813 (void *)&cmd_csum_tunnel_csum,
3814 (void *)&cmd_csum_tunnel_parse,
3815 (void *)&cmd_csum_tunnel_onoff,
3816 (void *)&cmd_csum_tunnel_portid,
3821 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3822 struct cmd_tso_set_result {
3823 cmdline_fixed_string_t tso;
3824 cmdline_fixed_string_t mode;
3830 cmd_tso_set_parsed(void *parsed_result,
3831 __attribute__((unused)) struct cmdline *cl,
3832 __attribute__((unused)) void *data)
3834 struct cmd_tso_set_result *res = parsed_result;
3835 struct rte_eth_dev_info dev_info;
3837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3840 if (!strcmp(res->mode, "set"))
3841 ports[res->port_id].tso_segsz = res->tso_segsz;
3843 if (ports[res->port_id].tso_segsz == 0)
3844 printf("TSO for non-tunneled packets is disabled\n");
3846 printf("TSO segment size for non-tunneled packets is %d\n",
3847 ports[res->port_id].tso_segsz);
3849 /* display warnings if configuration is not supported by the NIC */
3850 rte_eth_dev_info_get(res->port_id, &dev_info);
3851 if ((ports[res->port_id].tso_segsz != 0) &&
3852 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3853 printf("Warning: TSO enabled but not "
3854 "supported by port %d\n", res->port_id);
3858 cmdline_parse_token_string_t cmd_tso_set_tso =
3859 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3861 cmdline_parse_token_string_t cmd_tso_set_mode =
3862 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3864 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3865 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3867 cmdline_parse_token_num_t cmd_tso_set_portid =
3868 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3871 cmdline_parse_inst_t cmd_tso_set = {
3872 .f = cmd_tso_set_parsed,
3874 .help_str = "tso set <tso_segsz> <port_id>: "
3875 "Set TSO segment size of non-tunneled packets for csum engine "
3878 (void *)&cmd_tso_set_tso,
3879 (void *)&cmd_tso_set_mode,
3880 (void *)&cmd_tso_set_tso_segsz,
3881 (void *)&cmd_tso_set_portid,
3886 cmdline_parse_token_string_t cmd_tso_show_mode =
3887 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3891 cmdline_parse_inst_t cmd_tso_show = {
3892 .f = cmd_tso_set_parsed,
3894 .help_str = "tso show <port_id>: "
3895 "Show TSO segment size of non-tunneled packets for csum engine",
3897 (void *)&cmd_tso_set_tso,
3898 (void *)&cmd_tso_show_mode,
3899 (void *)&cmd_tso_set_portid,
3904 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3905 struct cmd_tunnel_tso_set_result {
3906 cmdline_fixed_string_t tso;
3907 cmdline_fixed_string_t mode;
3913 check_tunnel_tso_nic_support(portid_t port_id)
3915 struct rte_eth_dev_info dev_info;
3917 rte_eth_dev_info_get(port_id, &dev_info);
3918 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3919 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3920 "supported by port %d\n", port_id);
3921 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3922 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3923 "supported by port %d\n", port_id);
3924 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3925 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3926 "supported by port %d\n", port_id);
3927 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3928 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3929 "supported by port %d\n", port_id);
3933 cmd_tunnel_tso_set_parsed(void *parsed_result,
3934 __attribute__((unused)) struct cmdline *cl,
3935 __attribute__((unused)) void *data)
3937 struct cmd_tunnel_tso_set_result *res = parsed_result;
3939 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3942 if (!strcmp(res->mode, "set"))
3943 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3945 if (ports[res->port_id].tunnel_tso_segsz == 0)
3946 printf("TSO for tunneled packets is disabled\n");
3948 printf("TSO segment size for tunneled packets is %d\n",
3949 ports[res->port_id].tunnel_tso_segsz);
3951 /* Below conditions are needed to make it work:
3952 * (1) tunnel TSO is supported by the NIC;
3953 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3955 * (3) for tunneled pkts with outer L3 of IPv4,
3956 * "csum set outer-ip" must be set to hw, because after tso,
3957 * total_len of outer IP header is changed, and the checksum
3958 * of outer IP header calculated by sw should be wrong; that
3959 * is not necessary for IPv6 tunneled pkts because there's no
3960 * checksum in IP header anymore.
3962 check_tunnel_tso_nic_support(res->port_id);
3964 if (!(ports[res->port_id].tx_ol_flags &
3965 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3966 printf("Warning: csum parse_tunnel must be set "
3967 "so that tunneled packets are recognized\n");
3968 if (!(ports[res->port_id].tx_ol_flags &
3969 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3970 printf("Warning: csum set outer-ip must be set to hw "
3971 "if outer L3 is IPv4; not necessary for IPv6\n");
3975 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3976 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3978 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3979 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3981 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3982 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3984 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3985 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3988 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3989 .f = cmd_tunnel_tso_set_parsed,
3991 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3992 "Set TSO segment size of tunneled packets for csum engine "
3995 (void *)&cmd_tunnel_tso_set_tso,
3996 (void *)&cmd_tunnel_tso_set_mode,
3997 (void *)&cmd_tunnel_tso_set_tso_segsz,
3998 (void *)&cmd_tunnel_tso_set_portid,
4003 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4004 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4008 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4009 .f = cmd_tunnel_tso_set_parsed,
4011 .help_str = "tunnel_tso show <port_id> "
4012 "Show TSO segment size of tunneled packets for csum engine",
4014 (void *)&cmd_tunnel_tso_set_tso,
4015 (void *)&cmd_tunnel_tso_show_mode,
4016 (void *)&cmd_tunnel_tso_set_portid,
4021 /* *** SET GRO FOR A PORT *** */
4022 struct cmd_gro_enable_result {
4023 cmdline_fixed_string_t cmd_set;
4024 cmdline_fixed_string_t cmd_port;
4025 cmdline_fixed_string_t cmd_keyword;
4026 cmdline_fixed_string_t cmd_onoff;
4031 cmd_gro_enable_parsed(void *parsed_result,
4032 __attribute__((unused)) struct cmdline *cl,
4033 __attribute__((unused)) void *data)
4035 struct cmd_gro_enable_result *res;
4037 res = parsed_result;
4038 if (!strcmp(res->cmd_keyword, "gro"))
4039 setup_gro(res->cmd_onoff, res->cmd_pid);
4042 cmdline_parse_token_string_t cmd_gro_enable_set =
4043 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4045 cmdline_parse_token_string_t cmd_gro_enable_port =
4046 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4047 cmd_keyword, "port");
4048 cmdline_parse_token_num_t cmd_gro_enable_pid =
4049 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4051 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4052 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4053 cmd_keyword, "gro");
4054 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4055 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4056 cmd_onoff, "on#off");
4058 cmdline_parse_inst_t cmd_gro_enable = {
4059 .f = cmd_gro_enable_parsed,
4061 .help_str = "set port <port_id> gro on|off",
4063 (void *)&cmd_gro_enable_set,
4064 (void *)&cmd_gro_enable_port,
4065 (void *)&cmd_gro_enable_pid,
4066 (void *)&cmd_gro_enable_keyword,
4067 (void *)&cmd_gro_enable_onoff,
4072 /* *** DISPLAY GRO CONFIGURATION *** */
4073 struct cmd_gro_show_result {
4074 cmdline_fixed_string_t cmd_show;
4075 cmdline_fixed_string_t cmd_port;
4076 cmdline_fixed_string_t cmd_keyword;
4081 cmd_gro_show_parsed(void *parsed_result,
4082 __attribute__((unused)) struct cmdline *cl,
4083 __attribute__((unused)) void *data)
4085 struct cmd_gro_show_result *res;
4087 res = parsed_result;
4088 if (!strcmp(res->cmd_keyword, "gro"))
4089 show_gro(res->cmd_pid);
4092 cmdline_parse_token_string_t cmd_gro_show_show =
4093 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4095 cmdline_parse_token_string_t cmd_gro_show_port =
4096 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4098 cmdline_parse_token_num_t cmd_gro_show_pid =
4099 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4101 cmdline_parse_token_string_t cmd_gro_show_keyword =
4102 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4103 cmd_keyword, "gro");
4105 cmdline_parse_inst_t cmd_gro_show = {
4106 .f = cmd_gro_show_parsed,
4108 .help_str = "show port <port_id> gro",
4110 (void *)&cmd_gro_show_show,
4111 (void *)&cmd_gro_show_port,
4112 (void *)&cmd_gro_show_pid,
4113 (void *)&cmd_gro_show_keyword,
4118 /* *** SET FLUSH CYCLES FOR GRO *** */
4119 struct cmd_gro_flush_result {
4120 cmdline_fixed_string_t cmd_set;
4121 cmdline_fixed_string_t cmd_keyword;
4122 cmdline_fixed_string_t cmd_flush;
4127 cmd_gro_flush_parsed(void *parsed_result,
4128 __attribute__((unused)) struct cmdline *cl,
4129 __attribute__((unused)) void *data)
4131 struct cmd_gro_flush_result *res;
4133 res = parsed_result;
4134 if ((!strcmp(res->cmd_keyword, "gro")) &&
4135 (!strcmp(res->cmd_flush, "flush")))
4136 setup_gro_flush_cycles(res->cmd_cycles);
4139 cmdline_parse_token_string_t cmd_gro_flush_set =
4140 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4142 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4143 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4144 cmd_keyword, "gro");
4145 cmdline_parse_token_string_t cmd_gro_flush_flush =
4146 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4147 cmd_flush, "flush");
4148 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4149 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4152 cmdline_parse_inst_t cmd_gro_flush = {
4153 .f = cmd_gro_flush_parsed,
4155 .help_str = "set gro flush <cycles>",
4157 (void *)&cmd_gro_flush_set,
4158 (void *)&cmd_gro_flush_keyword,
4159 (void *)&cmd_gro_flush_flush,
4160 (void *)&cmd_gro_flush_cycles,
4165 /* *** ENABLE/DISABLE GSO *** */
4166 struct cmd_gso_enable_result {
4167 cmdline_fixed_string_t cmd_set;
4168 cmdline_fixed_string_t cmd_port;
4169 cmdline_fixed_string_t cmd_keyword;
4170 cmdline_fixed_string_t cmd_mode;
4175 cmd_gso_enable_parsed(void *parsed_result,
4176 __attribute__((unused)) struct cmdline *cl,
4177 __attribute__((unused)) void *data)
4179 struct cmd_gso_enable_result *res;
4181 res = parsed_result;
4182 if (!strcmp(res->cmd_keyword, "gso"))
4183 setup_gso(res->cmd_mode, res->cmd_pid);
4186 cmdline_parse_token_string_t cmd_gso_enable_set =
4187 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4189 cmdline_parse_token_string_t cmd_gso_enable_port =
4190 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4192 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4193 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4194 cmd_keyword, "gso");
4195 cmdline_parse_token_string_t cmd_gso_enable_mode =
4196 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4197 cmd_mode, "on#off");
4198 cmdline_parse_token_num_t cmd_gso_enable_pid =
4199 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4202 cmdline_parse_inst_t cmd_gso_enable = {
4203 .f = cmd_gso_enable_parsed,
4205 .help_str = "set port <port_id> gso on|off",
4207 (void *)&cmd_gso_enable_set,
4208 (void *)&cmd_gso_enable_port,
4209 (void *)&cmd_gso_enable_pid,
4210 (void *)&cmd_gso_enable_keyword,
4211 (void *)&cmd_gso_enable_mode,
4216 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4217 struct cmd_gso_size_result {
4218 cmdline_fixed_string_t cmd_set;
4219 cmdline_fixed_string_t cmd_keyword;
4220 cmdline_fixed_string_t cmd_segsz;
4225 cmd_gso_size_parsed(void *parsed_result,
4226 __attribute__((unused)) struct cmdline *cl,
4227 __attribute__((unused)) void *data)
4229 struct cmd_gso_size_result *res = parsed_result;
4231 if (test_done == 0) {
4232 printf("Before setting GSO segsz, please first"
4233 " stop fowarding\n");
4237 if (!strcmp(res->cmd_keyword, "gso") &&
4238 !strcmp(res->cmd_segsz, "segsz")) {
4239 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4240 printf("gso_size should be larger than %zu."
4241 " Please input a legal value\n",
4242 RTE_GSO_SEG_SIZE_MIN);
4244 gso_max_segment_size = res->cmd_size;
4248 cmdline_parse_token_string_t cmd_gso_size_set =
4249 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4251 cmdline_parse_token_string_t cmd_gso_size_keyword =
4252 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4253 cmd_keyword, "gso");
4254 cmdline_parse_token_string_t cmd_gso_size_segsz =
4255 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4256 cmd_segsz, "segsz");
4257 cmdline_parse_token_num_t cmd_gso_size_size =
4258 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4261 cmdline_parse_inst_t cmd_gso_size = {
4262 .f = cmd_gso_size_parsed,
4264 .help_str = "set gso segsz <length>",
4266 (void *)&cmd_gso_size_set,
4267 (void *)&cmd_gso_size_keyword,
4268 (void *)&cmd_gso_size_segsz,
4269 (void *)&cmd_gso_size_size,
4274 /* *** SHOW GSO CONFIGURATION *** */
4275 struct cmd_gso_show_result {
4276 cmdline_fixed_string_t cmd_show;
4277 cmdline_fixed_string_t cmd_port;
4278 cmdline_fixed_string_t cmd_keyword;
4283 cmd_gso_show_parsed(void *parsed_result,
4284 __attribute__((unused)) struct cmdline *cl,
4285 __attribute__((unused)) void *data)
4287 struct cmd_gso_show_result *res = parsed_result;
4289 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4290 printf("invalid port id %u\n", res->cmd_pid);
4293 if (!strcmp(res->cmd_keyword, "gso")) {
4294 if (gso_ports[res->cmd_pid].enable) {
4295 printf("Max GSO'd packet size: %uB\n"
4296 "Supported GSO types: TCP/IPv4, "
4297 "VxLAN with inner TCP/IPv4 packet, "
4298 "GRE with inner TCP/IPv4 packet\n",
4299 gso_max_segment_size);
4301 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4305 cmdline_parse_token_string_t cmd_gso_show_show =
4306 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4308 cmdline_parse_token_string_t cmd_gso_show_port =
4309 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4311 cmdline_parse_token_string_t cmd_gso_show_keyword =
4312 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4313 cmd_keyword, "gso");
4314 cmdline_parse_token_num_t cmd_gso_show_pid =
4315 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4318 cmdline_parse_inst_t cmd_gso_show = {
4319 .f = cmd_gso_show_parsed,
4321 .help_str = "show port <port_id> gso",
4323 (void *)&cmd_gso_show_show,
4324 (void *)&cmd_gso_show_port,
4325 (void *)&cmd_gso_show_pid,
4326 (void *)&cmd_gso_show_keyword,
4331 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4332 struct cmd_set_flush_rx {
4333 cmdline_fixed_string_t set;
4334 cmdline_fixed_string_t flush_rx;
4335 cmdline_fixed_string_t mode;
4339 cmd_set_flush_rx_parsed(void *parsed_result,
4340 __attribute__((unused)) struct cmdline *cl,
4341 __attribute__((unused)) void *data)
4343 struct cmd_set_flush_rx *res = parsed_result;
4344 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4347 cmdline_parse_token_string_t cmd_setflushrx_set =
4348 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4350 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4351 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4352 flush_rx, "flush_rx");
4353 cmdline_parse_token_string_t cmd_setflushrx_mode =
4354 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4358 cmdline_parse_inst_t cmd_set_flush_rx = {
4359 .f = cmd_set_flush_rx_parsed,
4360 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4363 (void *)&cmd_setflushrx_set,
4364 (void *)&cmd_setflushrx_flush_rx,
4365 (void *)&cmd_setflushrx_mode,
4370 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4371 struct cmd_set_link_check {
4372 cmdline_fixed_string_t set;
4373 cmdline_fixed_string_t link_check;
4374 cmdline_fixed_string_t mode;
4378 cmd_set_link_check_parsed(void *parsed_result,
4379 __attribute__((unused)) struct cmdline *cl,
4380 __attribute__((unused)) void *data)
4382 struct cmd_set_link_check *res = parsed_result;
4383 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4386 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4387 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4389 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4391 link_check, "link_check");
4392 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4397 cmdline_parse_inst_t cmd_set_link_check = {
4398 .f = cmd_set_link_check_parsed,
4399 .help_str = "set link_check on|off: Enable/Disable link status check "
4400 "when starting/stopping a port",
4403 (void *)&cmd_setlinkcheck_set,
4404 (void *)&cmd_setlinkcheck_link_check,
4405 (void *)&cmd_setlinkcheck_mode,
4410 /* *** SET NIC BYPASS MODE *** */
4411 struct cmd_set_bypass_mode_result {
4412 cmdline_fixed_string_t set;
4413 cmdline_fixed_string_t bypass;
4414 cmdline_fixed_string_t mode;
4415 cmdline_fixed_string_t value;
4420 cmd_set_bypass_mode_parsed(void *parsed_result,
4421 __attribute__((unused)) struct cmdline *cl,
4422 __attribute__((unused)) void *data)
4424 struct cmd_set_bypass_mode_result *res = parsed_result;
4425 portid_t port_id = res->port_id;
4426 int32_t rc = -EINVAL;
4428 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4429 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4431 if (!strcmp(res->value, "bypass"))
4432 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4433 else if (!strcmp(res->value, "isolate"))
4434 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4436 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4438 /* Set the bypass mode for the relevant port. */
4439 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4442 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4445 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4448 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4451 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4454 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4456 value, "normal#bypass#isolate");
4457 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4458 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4461 cmdline_parse_inst_t cmd_set_bypass_mode = {
4462 .f = cmd_set_bypass_mode_parsed,
4463 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4464 "Set the NIC bypass mode for port_id",
4467 (void *)&cmd_setbypass_mode_set,
4468 (void *)&cmd_setbypass_mode_bypass,
4469 (void *)&cmd_setbypass_mode_mode,
4470 (void *)&cmd_setbypass_mode_value,
4471 (void *)&cmd_setbypass_mode_port,
4476 /* *** SET NIC BYPASS EVENT *** */
4477 struct cmd_set_bypass_event_result {
4478 cmdline_fixed_string_t set;
4479 cmdline_fixed_string_t bypass;
4480 cmdline_fixed_string_t event;
4481 cmdline_fixed_string_t event_value;
4482 cmdline_fixed_string_t mode;
4483 cmdline_fixed_string_t mode_value;
4488 cmd_set_bypass_event_parsed(void *parsed_result,
4489 __attribute__((unused)) struct cmdline *cl,
4490 __attribute__((unused)) void *data)
4492 int32_t rc = -EINVAL;
4493 struct cmd_set_bypass_event_result *res = parsed_result;
4494 portid_t port_id = res->port_id;
4496 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4497 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4498 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4500 if (!strcmp(res->event_value, "timeout"))
4501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4502 else if (!strcmp(res->event_value, "os_on"))
4503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4504 else if (!strcmp(res->event_value, "os_off"))
4505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4506 else if (!strcmp(res->event_value, "power_on"))
4507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4508 else if (!strcmp(res->event_value, "power_off"))
4509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4513 if (!strcmp(res->mode_value, "bypass"))
4514 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4515 else if (!strcmp(res->mode_value, "isolate"))
4516 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4520 /* Set the watchdog timeout. */
4521 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4524 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4525 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4529 printf("Failed to set timeout value %u "
4530 "for port %d, errto code: %d.\n",
4531 bypass_timeout, port_id, rc);
4535 /* Set the bypass event to transition to bypass mode. */
4536 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4541 printf("\t Failed to set bypass event for port = %d.\n",
4545 cmdline_parse_token_string_t cmd_setbypass_event_set =
4546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4548 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4551 cmdline_parse_token_string_t cmd_setbypass_event_event =
4552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4554 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4556 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4557 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4560 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4562 mode_value, "normal#bypass#isolate");
4563 cmdline_parse_token_num_t cmd_setbypass_event_port =
4564 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4567 cmdline_parse_inst_t cmd_set_bypass_event = {
4568 .f = cmd_set_bypass_event_parsed,
4569 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4570 "power_off mode normal|bypass|isolate <port_id>: "
4571 "Set the NIC bypass event mode for port_id",
4574 (void *)&cmd_setbypass_event_set,
4575 (void *)&cmd_setbypass_event_bypass,
4576 (void *)&cmd_setbypass_event_event,
4577 (void *)&cmd_setbypass_event_event_value,
4578 (void *)&cmd_setbypass_event_mode,
4579 (void *)&cmd_setbypass_event_mode_value,
4580 (void *)&cmd_setbypass_event_port,
4586 /* *** SET NIC BYPASS TIMEOUT *** */
4587 struct cmd_set_bypass_timeout_result {
4588 cmdline_fixed_string_t set;
4589 cmdline_fixed_string_t bypass;
4590 cmdline_fixed_string_t timeout;
4591 cmdline_fixed_string_t value;
4595 cmd_set_bypass_timeout_parsed(void *parsed_result,
4596 __attribute__((unused)) struct cmdline *cl,
4597 __attribute__((unused)) void *data)
4599 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4601 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4602 if (!strcmp(res->value, "1.5"))
4603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4604 else if (!strcmp(res->value, "2"))
4605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4606 else if (!strcmp(res->value, "3"))
4607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4608 else if (!strcmp(res->value, "4"))
4609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4610 else if (!strcmp(res->value, "8"))
4611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4612 else if (!strcmp(res->value, "16"))
4613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4614 else if (!strcmp(res->value, "32"))
4615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4621 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4624 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4625 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4627 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4628 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4629 timeout, "timeout");
4630 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4631 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4632 value, "0#1.5#2#3#4#8#16#32");
4634 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4635 .f = cmd_set_bypass_timeout_parsed,
4636 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4637 "Set the NIC bypass watchdog timeout in seconds",
4640 (void *)&cmd_setbypass_timeout_set,
4641 (void *)&cmd_setbypass_timeout_bypass,
4642 (void *)&cmd_setbypass_timeout_timeout,
4643 (void *)&cmd_setbypass_timeout_value,
4648 /* *** SHOW NIC BYPASS MODE *** */
4649 struct cmd_show_bypass_config_result {
4650 cmdline_fixed_string_t show;
4651 cmdline_fixed_string_t bypass;
4652 cmdline_fixed_string_t config;
4657 cmd_show_bypass_config_parsed(void *parsed_result,
4658 __attribute__((unused)) struct cmdline *cl,
4659 __attribute__((unused)) void *data)
4661 struct cmd_show_bypass_config_result *res = parsed_result;
4662 portid_t port_id = res->port_id;
4664 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4665 uint32_t event_mode;
4666 uint32_t bypass_mode;
4667 uint32_t timeout = bypass_timeout;
4670 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4671 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4672 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4673 {"UNKNOWN", "normal", "bypass", "isolate"};
4674 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4681 int num_events = (sizeof events) / (sizeof events[0]);
4683 /* Display the bypass mode.*/
4684 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4685 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4689 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4690 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4692 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4695 /* Display the bypass timeout.*/
4696 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4697 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4699 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4701 /* Display the bypass events and associated modes. */
4702 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4704 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4705 printf("\tFailed to get bypass mode for event = %s\n",
4708 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4709 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4711 printf("\tbypass event: %-16s = %s\n", events[i],
4717 printf("\tFailed to get bypass configuration for port = %d\n",
4721 cmdline_parse_token_string_t cmd_showbypass_config_show =
4722 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4724 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4725 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4727 cmdline_parse_token_string_t cmd_showbypass_config_config =
4728 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4730 cmdline_parse_token_num_t cmd_showbypass_config_port =
4731 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4734 cmdline_parse_inst_t cmd_show_bypass_config = {
4735 .f = cmd_show_bypass_config_parsed,
4736 .help_str = "show bypass config <port_id>: "
4737 "Show the NIC bypass config for port_id",
4740 (void *)&cmd_showbypass_config_show,
4741 (void *)&cmd_showbypass_config_bypass,
4742 (void *)&cmd_showbypass_config_config,
4743 (void *)&cmd_showbypass_config_port,
4748 #ifdef RTE_LIBRTE_PMD_BOND
4749 /* *** SET BONDING MODE *** */
4750 struct cmd_set_bonding_mode_result {
4751 cmdline_fixed_string_t set;
4752 cmdline_fixed_string_t bonding;
4753 cmdline_fixed_string_t mode;
4758 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4759 __attribute__((unused)) struct cmdline *cl,
4760 __attribute__((unused)) void *data)
4762 struct cmd_set_bonding_mode_result *res = parsed_result;
4763 portid_t port_id = res->port_id;
4765 /* Set the bonding mode for the relevant port. */
4766 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4767 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4770 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4771 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4773 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4774 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4775 bonding, "bonding");
4776 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4777 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4779 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4780 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4782 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4783 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4786 cmdline_parse_inst_t cmd_set_bonding_mode = {
4787 .f = cmd_set_bonding_mode_parsed,
4788 .help_str = "set bonding mode <mode_value> <port_id>: "
4789 "Set the bonding mode for port_id",
4792 (void *) &cmd_setbonding_mode_set,
4793 (void *) &cmd_setbonding_mode_bonding,
4794 (void *) &cmd_setbonding_mode_mode,
4795 (void *) &cmd_setbonding_mode_value,
4796 (void *) &cmd_setbonding_mode_port,
4801 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4802 struct cmd_set_bonding_lacp_dedicated_queues_result {
4803 cmdline_fixed_string_t set;
4804 cmdline_fixed_string_t bonding;
4805 cmdline_fixed_string_t lacp;
4806 cmdline_fixed_string_t dedicated_queues;
4808 cmdline_fixed_string_t mode;
4811 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4812 __attribute__((unused)) struct cmdline *cl,
4813 __attribute__((unused)) void *data)
4815 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4816 portid_t port_id = res->port_id;
4817 struct rte_port *port;
4819 port = &ports[port_id];
4821 /** Check if the port is not started **/
4822 if (port->port_status != RTE_PORT_STOPPED) {
4823 printf("Please stop port %d first\n", port_id);
4827 if (!strcmp(res->mode, "enable")) {
4828 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4829 printf("Dedicate queues for LACP control packets"
4832 printf("Enabling dedicate queues for LACP control "
4833 "packets on port %d failed\n", port_id);
4834 } else if (!strcmp(res->mode, "disable")) {
4835 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4836 printf("Dedicated queues for LACP control packets "
4839 printf("Disabling dedicated queues for LACP control "
4840 "traffic on port %d failed\n", port_id);
4844 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4845 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4847 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4849 bonding, "bonding");
4850 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4853 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4855 dedicated_queues, "dedicated_queues");
4856 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4857 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4859 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4861 mode, "enable#disable");
4863 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4864 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4865 .help_str = "set bonding lacp dedicated_queues <port_id> "
4867 "Enable/disable dedicated queues for LACP control traffic for port_id",
4870 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4871 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4872 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4873 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4874 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4875 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4880 /* *** SET BALANCE XMIT POLICY *** */
4881 struct cmd_set_bonding_balance_xmit_policy_result {
4882 cmdline_fixed_string_t set;
4883 cmdline_fixed_string_t bonding;
4884 cmdline_fixed_string_t balance_xmit_policy;
4886 cmdline_fixed_string_t policy;
4889 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4890 __attribute__((unused)) struct cmdline *cl,
4891 __attribute__((unused)) void *data)
4893 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4894 portid_t port_id = res->port_id;
4897 if (!strcmp(res->policy, "l2")) {
4898 policy = BALANCE_XMIT_POLICY_LAYER2;
4899 } else if (!strcmp(res->policy, "l23")) {
4900 policy = BALANCE_XMIT_POLICY_LAYER23;
4901 } else if (!strcmp(res->policy, "l34")) {
4902 policy = BALANCE_XMIT_POLICY_LAYER34;
4904 printf("\t Invalid xmit policy selection");
4908 /* Set the bonding mode for the relevant port. */
4909 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4910 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4915 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4916 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4918 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4919 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4920 bonding, "bonding");
4921 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4922 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4923 balance_xmit_policy, "balance_xmit_policy");
4924 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4925 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4927 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4929 policy, "l2#l23#l34");
4931 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4932 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4933 .help_str = "set bonding balance_xmit_policy <port_id> "
4935 "Set the bonding balance_xmit_policy for port_id",
4938 (void *)&cmd_setbonding_balance_xmit_policy_set,
4939 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4940 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4941 (void *)&cmd_setbonding_balance_xmit_policy_port,
4942 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4947 /* *** SHOW NIC BONDING CONFIGURATION *** */
4948 struct cmd_show_bonding_config_result {
4949 cmdline_fixed_string_t show;
4950 cmdline_fixed_string_t bonding;
4951 cmdline_fixed_string_t config;
4955 static void cmd_show_bonding_config_parsed(void *parsed_result,
4956 __attribute__((unused)) struct cmdline *cl,
4957 __attribute__((unused)) void *data)
4959 struct cmd_show_bonding_config_result *res = parsed_result;
4960 int bonding_mode, agg_mode;
4961 portid_t slaves[RTE_MAX_ETHPORTS];
4962 int num_slaves, num_active_slaves;
4965 portid_t port_id = res->port_id;
4967 /* Display the bonding mode.*/
4968 bonding_mode = rte_eth_bond_mode_get(port_id);
4969 if (bonding_mode < 0) {
4970 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4973 printf("\tBonding mode: %d\n", bonding_mode);
4975 if (bonding_mode == BONDING_MODE_BALANCE) {
4976 int balance_xmit_policy;
4978 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4979 if (balance_xmit_policy < 0) {
4980 printf("\tFailed to get balance xmit policy for port = %d\n",
4984 printf("\tBalance Xmit Policy: ");
4986 switch (balance_xmit_policy) {
4987 case BALANCE_XMIT_POLICY_LAYER2:
4988 printf("BALANCE_XMIT_POLICY_LAYER2");
4990 case BALANCE_XMIT_POLICY_LAYER23:
4991 printf("BALANCE_XMIT_POLICY_LAYER23");
4993 case BALANCE_XMIT_POLICY_LAYER34:
4994 printf("BALANCE_XMIT_POLICY_LAYER34");
5001 if (bonding_mode == BONDING_MODE_8023AD) {
5002 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5003 printf("\tIEEE802.3AD Aggregator Mode: ");
5006 printf("bandwidth");
5018 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5020 if (num_slaves < 0) {
5021 printf("\tFailed to get slave list for port = %d\n", port_id);
5024 if (num_slaves > 0) {
5025 printf("\tSlaves (%d): [", num_slaves);
5026 for (i = 0; i < num_slaves - 1; i++)
5027 printf("%d ", slaves[i]);
5029 printf("%d]\n", slaves[num_slaves - 1]);
5031 printf("\tSlaves: []\n");
5035 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5038 if (num_active_slaves < 0) {
5039 printf("\tFailed to get active slave list for port = %d\n", port_id);
5042 if (num_active_slaves > 0) {
5043 printf("\tActive Slaves (%d): [", num_active_slaves);
5044 for (i = 0; i < num_active_slaves - 1; i++)
5045 printf("%d ", slaves[i]);
5047 printf("%d]\n", slaves[num_active_slaves - 1]);
5050 printf("\tActive Slaves: []\n");
5054 primary_id = rte_eth_bond_primary_get(port_id);
5055 if (primary_id < 0) {
5056 printf("\tFailed to get primary slave for port = %d\n", port_id);
5059 printf("\tPrimary: [%d]\n", primary_id);
5063 cmdline_parse_token_string_t cmd_showbonding_config_show =
5064 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5066 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5067 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5068 bonding, "bonding");
5069 cmdline_parse_token_string_t cmd_showbonding_config_config =
5070 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5072 cmdline_parse_token_num_t cmd_showbonding_config_port =
5073 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5076 cmdline_parse_inst_t cmd_show_bonding_config = {
5077 .f = cmd_show_bonding_config_parsed,
5078 .help_str = "show bonding config <port_id>: "
5079 "Show the bonding config for port_id",
5082 (void *)&cmd_showbonding_config_show,
5083 (void *)&cmd_showbonding_config_bonding,
5084 (void *)&cmd_showbonding_config_config,
5085 (void *)&cmd_showbonding_config_port,
5090 /* *** SET BONDING PRIMARY *** */
5091 struct cmd_set_bonding_primary_result {
5092 cmdline_fixed_string_t set;
5093 cmdline_fixed_string_t bonding;
5094 cmdline_fixed_string_t primary;
5099 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5100 __attribute__((unused)) struct cmdline *cl,
5101 __attribute__((unused)) void *data)
5103 struct cmd_set_bonding_primary_result *res = parsed_result;
5104 portid_t master_port_id = res->port_id;
5105 portid_t slave_port_id = res->slave_id;
5107 /* Set the primary slave for a bonded device. */
5108 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5109 printf("\t Failed to set primary slave for port = %d.\n",
5116 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5117 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5119 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5121 bonding, "bonding");
5122 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5123 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5124 primary, "primary");
5125 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5126 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5128 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5129 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5132 cmdline_parse_inst_t cmd_set_bonding_primary = {
5133 .f = cmd_set_bonding_primary_parsed,
5134 .help_str = "set bonding primary <slave_id> <port_id>: "
5135 "Set the primary slave for port_id",
5138 (void *)&cmd_setbonding_primary_set,
5139 (void *)&cmd_setbonding_primary_bonding,
5140 (void *)&cmd_setbonding_primary_primary,
5141 (void *)&cmd_setbonding_primary_slave,
5142 (void *)&cmd_setbonding_primary_port,
5147 /* *** ADD SLAVE *** */
5148 struct cmd_add_bonding_slave_result {
5149 cmdline_fixed_string_t add;
5150 cmdline_fixed_string_t bonding;
5151 cmdline_fixed_string_t slave;
5156 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5157 __attribute__((unused)) struct cmdline *cl,
5158 __attribute__((unused)) void *data)
5160 struct cmd_add_bonding_slave_result *res = parsed_result;
5161 portid_t master_port_id = res->port_id;
5162 portid_t slave_port_id = res->slave_id;
5164 /* add the slave for a bonded device. */
5165 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5166 printf("\t Failed to add slave %d to master port = %d.\n",
5167 slave_port_id, master_port_id);
5171 set_port_slave_flag(slave_port_id);
5174 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5175 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5177 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5178 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5179 bonding, "bonding");
5180 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5181 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5183 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5184 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5186 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5187 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5190 cmdline_parse_inst_t cmd_add_bonding_slave = {
5191 .f = cmd_add_bonding_slave_parsed,
5192 .help_str = "add bonding slave <slave_id> <port_id>: "
5193 "Add a slave device to a bonded device",
5196 (void *)&cmd_addbonding_slave_add,
5197 (void *)&cmd_addbonding_slave_bonding,
5198 (void *)&cmd_addbonding_slave_slave,
5199 (void *)&cmd_addbonding_slave_slaveid,
5200 (void *)&cmd_addbonding_slave_port,
5205 /* *** REMOVE SLAVE *** */
5206 struct cmd_remove_bonding_slave_result {
5207 cmdline_fixed_string_t remove;
5208 cmdline_fixed_string_t bonding;
5209 cmdline_fixed_string_t slave;
5214 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5215 __attribute__((unused)) struct cmdline *cl,
5216 __attribute__((unused)) void *data)
5218 struct cmd_remove_bonding_slave_result *res = parsed_result;
5219 portid_t master_port_id = res->port_id;
5220 portid_t slave_port_id = res->slave_id;
5222 /* remove the slave from a bonded device. */
5223 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5224 printf("\t Failed to remove slave %d from master port = %d.\n",
5225 slave_port_id, master_port_id);
5229 clear_port_slave_flag(slave_port_id);
5232 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5233 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5235 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5236 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5237 bonding, "bonding");
5238 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5239 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5241 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5242 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5244 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5245 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5248 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5249 .f = cmd_remove_bonding_slave_parsed,
5250 .help_str = "remove bonding slave <slave_id> <port_id>: "
5251 "Remove a slave device from a bonded device",
5254 (void *)&cmd_removebonding_slave_remove,
5255 (void *)&cmd_removebonding_slave_bonding,
5256 (void *)&cmd_removebonding_slave_slave,
5257 (void *)&cmd_removebonding_slave_slaveid,
5258 (void *)&cmd_removebonding_slave_port,
5263 /* *** CREATE BONDED DEVICE *** */
5264 struct cmd_create_bonded_device_result {
5265 cmdline_fixed_string_t create;
5266 cmdline_fixed_string_t bonded;
5267 cmdline_fixed_string_t device;
5272 static int bond_dev_num = 0;
5274 static void cmd_create_bonded_device_parsed(void *parsed_result,
5275 __attribute__((unused)) struct cmdline *cl,
5276 __attribute__((unused)) void *data)
5278 struct cmd_create_bonded_device_result *res = parsed_result;
5279 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5282 if (test_done == 0) {
5283 printf("Please stop forwarding first\n");
5287 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5290 /* Create a new bonded device. */
5291 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5293 printf("\t Failed to create bonded device.\n");
5296 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5299 /* Update number of ports */
5300 nb_ports = rte_eth_dev_count();
5301 reconfig(port_id, res->socket);
5302 rte_eth_promiscuous_enable(port_id);
5307 cmdline_parse_token_string_t cmd_createbonded_device_create =
5308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5310 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5311 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5313 cmdline_parse_token_string_t cmd_createbonded_device_device =
5314 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5316 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5317 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5319 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5320 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5323 cmdline_parse_inst_t cmd_create_bonded_device = {
5324 .f = cmd_create_bonded_device_parsed,
5325 .help_str = "create bonded device <mode> <socket>: "
5326 "Create a new bonded device with specific bonding mode and socket",
5329 (void *)&cmd_createbonded_device_create,
5330 (void *)&cmd_createbonded_device_bonded,
5331 (void *)&cmd_createbonded_device_device,
5332 (void *)&cmd_createbonded_device_mode,
5333 (void *)&cmd_createbonded_device_socket,
5338 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5339 struct cmd_set_bond_mac_addr_result {
5340 cmdline_fixed_string_t set;
5341 cmdline_fixed_string_t bonding;
5342 cmdline_fixed_string_t mac_addr;
5344 struct ether_addr address;
5347 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5348 __attribute__((unused)) struct cmdline *cl,
5349 __attribute__((unused)) void *data)
5351 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5354 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5357 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5359 /* check the return value and print it if is < 0 */
5361 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5364 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5369 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5372 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5373 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5375 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5376 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5378 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5379 .f = cmd_set_bond_mac_addr_parsed,
5381 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5383 (void *)&cmd_set_bond_mac_addr_set,
5384 (void *)&cmd_set_bond_mac_addr_bonding,
5385 (void *)&cmd_set_bond_mac_addr_mac,
5386 (void *)&cmd_set_bond_mac_addr_portnum,
5387 (void *)&cmd_set_bond_mac_addr_addr,
5393 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5394 struct cmd_set_bond_mon_period_result {
5395 cmdline_fixed_string_t set;
5396 cmdline_fixed_string_t bonding;
5397 cmdline_fixed_string_t mon_period;
5402 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5403 __attribute__((unused)) struct cmdline *cl,
5404 __attribute__((unused)) void *data)
5406 struct cmd_set_bond_mon_period_result *res = parsed_result;
5409 if (res->port_num >= nb_ports) {
5410 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5414 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5416 /* check the return value and print it if is < 0 */
5418 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5421 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5424 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5426 bonding, "bonding");
5427 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5429 mon_period, "mon_period");
5430 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5431 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5433 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5434 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5437 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5438 .f = cmd_set_bond_mon_period_parsed,
5440 .help_str = "set bonding mon_period <port_id> <period_ms>",
5442 (void *)&cmd_set_bond_mon_period_set,
5443 (void *)&cmd_set_bond_mon_period_bonding,
5444 (void *)&cmd_set_bond_mon_period_mon_period,
5445 (void *)&cmd_set_bond_mon_period_portnum,
5446 (void *)&cmd_set_bond_mon_period_period_ms,
5453 struct cmd_set_bonding_agg_mode_policy_result {
5454 cmdline_fixed_string_t set;
5455 cmdline_fixed_string_t bonding;
5456 cmdline_fixed_string_t agg_mode;
5458 cmdline_fixed_string_t policy;
5463 cmd_set_bonding_agg_mode(void *parsed_result,
5464 __attribute__((unused)) struct cmdline *cl,
5465 __attribute__((unused)) void *data)
5467 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5468 uint8_t policy = AGG_BANDWIDTH;
5470 if (res->port_num >= nb_ports) {
5471 printf("Port id %d must be less than %d\n",
5472 res->port_num, nb_ports);
5476 if (!strcmp(res->policy, "bandwidth"))
5477 policy = AGG_BANDWIDTH;
5478 else if (!strcmp(res->policy, "stable"))
5479 policy = AGG_STABLE;
5480 else if (!strcmp(res->policy, "count"))
5483 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5487 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5490 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5492 bonding, "bonding");
5494 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5496 agg_mode, "agg_mode");
5498 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5499 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5502 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5503 TOKEN_STRING_INITIALIZER(
5504 struct cmd_set_bonding_balance_xmit_policy_result,
5505 policy, "stable#bandwidth#count");
5507 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5508 .f = cmd_set_bonding_agg_mode,
5510 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5512 (void *)&cmd_set_bonding_agg_mode_set,
5513 (void *)&cmd_set_bonding_agg_mode_bonding,
5514 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5515 (void *)&cmd_set_bonding_agg_mode_portnum,
5516 (void *)&cmd_set_bonding_agg_mode_policy_string,
5522 #endif /* RTE_LIBRTE_PMD_BOND */
5524 /* *** SET FORWARDING MODE *** */
5525 struct cmd_set_fwd_mode_result {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t fwd;
5528 cmdline_fixed_string_t mode;
5531 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5532 __attribute__((unused)) struct cmdline *cl,
5533 __attribute__((unused)) void *data)
5535 struct cmd_set_fwd_mode_result *res = parsed_result;
5538 set_pkt_forwarding_mode(res->mode);
5541 cmdline_parse_token_string_t cmd_setfwd_set =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5543 cmdline_parse_token_string_t cmd_setfwd_fwd =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5545 cmdline_parse_token_string_t cmd_setfwd_mode =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5547 "" /* defined at init */);
5549 cmdline_parse_inst_t cmd_set_fwd_mode = {
5550 .f = cmd_set_fwd_mode_parsed,
5552 .help_str = NULL, /* defined at init */
5554 (void *)&cmd_setfwd_set,
5555 (void *)&cmd_setfwd_fwd,
5556 (void *)&cmd_setfwd_mode,
5561 static void cmd_set_fwd_mode_init(void)
5564 static char token[128];
5565 static char help[256];
5566 cmdline_parse_token_string_t *token_struct;
5568 modes = list_pkt_forwarding_modes();
5569 snprintf(help, sizeof(help), "set fwd %s: "
5570 "Set packet forwarding mode", modes);
5571 cmd_set_fwd_mode.help_str = help;
5573 /* string token separator is # */
5574 for (c = token; *modes != '\0'; modes++)
5579 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5580 token_struct->string_data.str = token;
5583 /* *** SET RETRY FORWARDING MODE *** */
5584 struct cmd_set_fwd_retry_mode_result {
5585 cmdline_fixed_string_t set;
5586 cmdline_fixed_string_t fwd;
5587 cmdline_fixed_string_t mode;
5588 cmdline_fixed_string_t retry;
5591 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5592 __attribute__((unused)) struct cmdline *cl,
5593 __attribute__((unused)) void *data)
5595 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5598 set_pkt_forwarding_mode(res->mode);
5601 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5604 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5607 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5610 "" /* defined at init */);
5611 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5612 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5615 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5616 .f = cmd_set_fwd_retry_mode_parsed,
5618 .help_str = NULL, /* defined at init */
5620 (void *)&cmd_setfwd_retry_set,
5621 (void *)&cmd_setfwd_retry_fwd,
5622 (void *)&cmd_setfwd_retry_mode,
5623 (void *)&cmd_setfwd_retry_retry,
5628 static void cmd_set_fwd_retry_mode_init(void)
5631 static char token[128];
5632 static char help[256];
5633 cmdline_parse_token_string_t *token_struct;
5635 modes = list_pkt_forwarding_retry_modes();
5636 snprintf(help, sizeof(help), "set fwd %s retry: "
5637 "Set packet forwarding mode with retry", modes);
5638 cmd_set_fwd_retry_mode.help_str = help;
5640 /* string token separator is # */
5641 for (c = token; *modes != '\0'; modes++)
5646 token_struct = (cmdline_parse_token_string_t *)
5647 cmd_set_fwd_retry_mode.tokens[2];
5648 token_struct->string_data.str = token;
5651 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5652 struct cmd_set_burst_tx_retry_result {
5653 cmdline_fixed_string_t set;
5654 cmdline_fixed_string_t burst;
5655 cmdline_fixed_string_t tx;
5656 cmdline_fixed_string_t delay;
5658 cmdline_fixed_string_t retry;
5662 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5663 __attribute__((unused)) struct cmdline *cl,
5664 __attribute__((unused)) void *data)
5666 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5668 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5669 && !strcmp(res->tx, "tx")) {
5670 if (!strcmp(res->delay, "delay"))
5671 burst_tx_delay_time = res->time;
5672 if (!strcmp(res->retry, "retry"))
5673 burst_tx_retry_num = res->retry_num;
5678 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5679 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5680 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5681 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5683 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5685 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5687 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5688 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5689 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5691 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5694 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5695 .f = cmd_set_burst_tx_retry_parsed,
5696 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5698 (void *)&cmd_set_burst_tx_retry_set,
5699 (void *)&cmd_set_burst_tx_retry_burst,
5700 (void *)&cmd_set_burst_tx_retry_tx,
5701 (void *)&cmd_set_burst_tx_retry_delay,
5702 (void *)&cmd_set_burst_tx_retry_time,
5703 (void *)&cmd_set_burst_tx_retry_retry,
5704 (void *)&cmd_set_burst_tx_retry_retry_num,
5709 /* *** SET PROMISC MODE *** */
5710 struct cmd_set_promisc_mode_result {
5711 cmdline_fixed_string_t set;
5712 cmdline_fixed_string_t promisc;
5713 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5714 uint16_t port_num; /* valid if "allports" argument == 0 */
5715 cmdline_fixed_string_t mode;
5718 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5719 __attribute__((unused)) struct cmdline *cl,
5722 struct cmd_set_promisc_mode_result *res = parsed_result;
5726 if (!strcmp(res->mode, "on"))
5733 RTE_ETH_FOREACH_DEV(i) {
5735 rte_eth_promiscuous_enable(i);
5737 rte_eth_promiscuous_disable(i);
5742 rte_eth_promiscuous_enable(res->port_num);
5744 rte_eth_promiscuous_disable(res->port_num);
5748 cmdline_parse_token_string_t cmd_setpromisc_set =
5749 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5750 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5753 cmdline_parse_token_string_t cmd_setpromisc_portall =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5756 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5757 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5759 cmdline_parse_token_string_t cmd_setpromisc_mode =
5760 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5763 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5764 .f = cmd_set_promisc_mode_parsed,
5766 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5768 (void *)&cmd_setpromisc_set,
5769 (void *)&cmd_setpromisc_promisc,
5770 (void *)&cmd_setpromisc_portall,
5771 (void *)&cmd_setpromisc_mode,
5776 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5777 .f = cmd_set_promisc_mode_parsed,
5779 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5781 (void *)&cmd_setpromisc_set,
5782 (void *)&cmd_setpromisc_promisc,
5783 (void *)&cmd_setpromisc_portnum,
5784 (void *)&cmd_setpromisc_mode,
5789 /* *** SET ALLMULTI MODE *** */
5790 struct cmd_set_allmulti_mode_result {
5791 cmdline_fixed_string_t set;
5792 cmdline_fixed_string_t allmulti;
5793 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5794 uint16_t port_num; /* valid if "allports" argument == 0 */
5795 cmdline_fixed_string_t mode;
5798 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5799 __attribute__((unused)) struct cmdline *cl,
5802 struct cmd_set_allmulti_mode_result *res = parsed_result;
5806 if (!strcmp(res->mode, "on"))
5813 RTE_ETH_FOREACH_DEV(i) {
5815 rte_eth_allmulticast_enable(i);
5817 rte_eth_allmulticast_disable(i);
5822 rte_eth_allmulticast_enable(res->port_num);
5824 rte_eth_allmulticast_disable(res->port_num);
5828 cmdline_parse_token_string_t cmd_setallmulti_set =
5829 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5830 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5831 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5833 cmdline_parse_token_string_t cmd_setallmulti_portall =
5834 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5836 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5837 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5839 cmdline_parse_token_string_t cmd_setallmulti_mode =
5840 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5843 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5844 .f = cmd_set_allmulti_mode_parsed,
5846 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5848 (void *)&cmd_setallmulti_set,
5849 (void *)&cmd_setallmulti_allmulti,
5850 (void *)&cmd_setallmulti_portall,
5851 (void *)&cmd_setallmulti_mode,
5856 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5857 .f = cmd_set_allmulti_mode_parsed,
5859 .help_str = "set allmulti <port_id> on|off: "
5860 "Set allmulti mode on port_id",
5862 (void *)&cmd_setallmulti_set,
5863 (void *)&cmd_setallmulti_allmulti,
5864 (void *)&cmd_setallmulti_portnum,
5865 (void *)&cmd_setallmulti_mode,
5870 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5871 struct cmd_link_flow_ctrl_set_result {
5872 cmdline_fixed_string_t set;
5873 cmdline_fixed_string_t flow_ctrl;
5874 cmdline_fixed_string_t rx;
5875 cmdline_fixed_string_t rx_lfc_mode;
5876 cmdline_fixed_string_t tx;
5877 cmdline_fixed_string_t tx_lfc_mode;
5878 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5879 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5880 cmdline_fixed_string_t autoneg_str;
5881 cmdline_fixed_string_t autoneg;
5882 cmdline_fixed_string_t hw_str;
5883 uint32_t high_water;
5884 cmdline_fixed_string_t lw_str;
5886 cmdline_fixed_string_t pt_str;
5887 uint16_t pause_time;
5888 cmdline_fixed_string_t xon_str;
5893 cmdline_parse_token_string_t cmd_lfc_set_set =
5894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5896 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5897 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5898 flow_ctrl, "flow_ctrl");
5899 cmdline_parse_token_string_t cmd_lfc_set_rx =
5900 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5902 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5903 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5904 rx_lfc_mode, "on#off");
5905 cmdline_parse_token_string_t cmd_lfc_set_tx =
5906 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5908 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5909 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5910 tx_lfc_mode, "on#off");
5911 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5912 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5913 hw_str, "high_water");
5914 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5915 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5916 high_water, UINT32);
5917 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5918 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5919 lw_str, "low_water");
5920 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5921 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5923 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5924 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5925 pt_str, "pause_time");
5926 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5927 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5928 pause_time, UINT16);
5929 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5931 xon_str, "send_xon");
5932 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5933 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5935 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5936 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5937 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5938 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5939 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5940 mac_ctrl_frame_fwd_mode, "on#off");
5941 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5942 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5943 autoneg_str, "autoneg");
5944 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5945 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5947 cmdline_parse_token_num_t cmd_lfc_set_portid =
5948 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5951 /* forward declaration */
5953 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5956 cmdline_parse_inst_t cmd_link_flow_control_set = {
5957 .f = cmd_link_flow_ctrl_set_parsed,
5959 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5960 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5961 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5963 (void *)&cmd_lfc_set_set,
5964 (void *)&cmd_lfc_set_flow_ctrl,
5965 (void *)&cmd_lfc_set_rx,
5966 (void *)&cmd_lfc_set_rx_mode,
5967 (void *)&cmd_lfc_set_tx,
5968 (void *)&cmd_lfc_set_tx_mode,
5969 (void *)&cmd_lfc_set_high_water,
5970 (void *)&cmd_lfc_set_low_water,
5971 (void *)&cmd_lfc_set_pause_time,
5972 (void *)&cmd_lfc_set_send_xon,
5973 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5974 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5975 (void *)&cmd_lfc_set_autoneg_str,
5976 (void *)&cmd_lfc_set_autoneg,
5977 (void *)&cmd_lfc_set_portid,
5982 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5983 .f = cmd_link_flow_ctrl_set_parsed,
5984 .data = (void *)&cmd_link_flow_control_set_rx,
5985 .help_str = "set flow_ctrl rx on|off <port_id>: "
5986 "Change rx flow control parameter",
5988 (void *)&cmd_lfc_set_set,
5989 (void *)&cmd_lfc_set_flow_ctrl,
5990 (void *)&cmd_lfc_set_rx,
5991 (void *)&cmd_lfc_set_rx_mode,
5992 (void *)&cmd_lfc_set_portid,
5997 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5998 .f = cmd_link_flow_ctrl_set_parsed,
5999 .data = (void *)&cmd_link_flow_control_set_tx,
6000 .help_str = "set flow_ctrl tx on|off <port_id>: "
6001 "Change tx flow control parameter",
6003 (void *)&cmd_lfc_set_set,
6004 (void *)&cmd_lfc_set_flow_ctrl,
6005 (void *)&cmd_lfc_set_tx,
6006 (void *)&cmd_lfc_set_tx_mode,
6007 (void *)&cmd_lfc_set_portid,
6012 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6013 .f = cmd_link_flow_ctrl_set_parsed,
6014 .data = (void *)&cmd_link_flow_control_set_hw,
6015 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6016 "Change high water flow control parameter",
6018 (void *)&cmd_lfc_set_set,
6019 (void *)&cmd_lfc_set_flow_ctrl,
6020 (void *)&cmd_lfc_set_high_water_str,
6021 (void *)&cmd_lfc_set_high_water,
6022 (void *)&cmd_lfc_set_portid,
6027 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6028 .f = cmd_link_flow_ctrl_set_parsed,
6029 .data = (void *)&cmd_link_flow_control_set_lw,
6030 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6031 "Change low water flow control parameter",
6033 (void *)&cmd_lfc_set_set,
6034 (void *)&cmd_lfc_set_flow_ctrl,
6035 (void *)&cmd_lfc_set_low_water_str,
6036 (void *)&cmd_lfc_set_low_water,
6037 (void *)&cmd_lfc_set_portid,
6042 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6043 .f = cmd_link_flow_ctrl_set_parsed,
6044 .data = (void *)&cmd_link_flow_control_set_pt,
6045 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6046 "Change pause time flow control parameter",
6048 (void *)&cmd_lfc_set_set,
6049 (void *)&cmd_lfc_set_flow_ctrl,
6050 (void *)&cmd_lfc_set_pause_time_str,
6051 (void *)&cmd_lfc_set_pause_time,
6052 (void *)&cmd_lfc_set_portid,
6057 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6058 .f = cmd_link_flow_ctrl_set_parsed,
6059 .data = (void *)&cmd_link_flow_control_set_xon,
6060 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6061 "Change send_xon flow control parameter",
6063 (void *)&cmd_lfc_set_set,
6064 (void *)&cmd_lfc_set_flow_ctrl,
6065 (void *)&cmd_lfc_set_send_xon_str,
6066 (void *)&cmd_lfc_set_send_xon,
6067 (void *)&cmd_lfc_set_portid,
6072 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6073 .f = cmd_link_flow_ctrl_set_parsed,
6074 .data = (void *)&cmd_link_flow_control_set_macfwd,
6075 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6076 "Change mac ctrl fwd flow control parameter",
6078 (void *)&cmd_lfc_set_set,
6079 (void *)&cmd_lfc_set_flow_ctrl,
6080 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6081 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6082 (void *)&cmd_lfc_set_portid,
6087 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6088 .f = cmd_link_flow_ctrl_set_parsed,
6089 .data = (void *)&cmd_link_flow_control_set_autoneg,
6090 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6091 "Change autoneg flow control parameter",
6093 (void *)&cmd_lfc_set_set,
6094 (void *)&cmd_lfc_set_flow_ctrl,
6095 (void *)&cmd_lfc_set_autoneg_str,
6096 (void *)&cmd_lfc_set_autoneg,
6097 (void *)&cmd_lfc_set_portid,
6103 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6104 __attribute__((unused)) struct cmdline *cl,
6107 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6108 cmdline_parse_inst_t *cmd = data;
6109 struct rte_eth_fc_conf fc_conf;
6115 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6116 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6117 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6118 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6120 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6121 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6124 /* Partial command line, retrieve current configuration */
6126 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6128 printf("cannot get current flow ctrl parameters, return"
6129 "code = %d\n", ret);
6133 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6134 (fc_conf.mode == RTE_FC_FULL))
6136 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6137 (fc_conf.mode == RTE_FC_FULL))
6141 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6142 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6144 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6145 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6147 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6149 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6150 fc_conf.high_water = res->high_water;
6152 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6153 fc_conf.low_water = res->low_water;
6155 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6156 fc_conf.pause_time = res->pause_time;
6158 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6159 fc_conf.send_xon = res->send_xon;
6161 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6162 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6163 fc_conf.mac_ctrl_frame_fwd = 1;
6165 fc_conf.mac_ctrl_frame_fwd = 0;
6168 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6169 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6171 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6173 printf("bad flow contrl parameter, return code = %d \n", ret);
6176 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6177 struct cmd_priority_flow_ctrl_set_result {
6178 cmdline_fixed_string_t set;
6179 cmdline_fixed_string_t pfc_ctrl;
6180 cmdline_fixed_string_t rx;
6181 cmdline_fixed_string_t rx_pfc_mode;
6182 cmdline_fixed_string_t tx;
6183 cmdline_fixed_string_t tx_pfc_mode;
6184 uint32_t high_water;
6186 uint16_t pause_time;
6192 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6193 __attribute__((unused)) struct cmdline *cl,
6194 __attribute__((unused)) void *data)
6196 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6197 struct rte_eth_pfc_conf pfc_conf;
6198 int rx_fc_enable, tx_fc_enable;
6202 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6203 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6204 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6205 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6207 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6208 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6211 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6212 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6213 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6214 pfc_conf.fc.high_water = res->high_water;
6215 pfc_conf.fc.low_water = res->low_water;
6216 pfc_conf.fc.pause_time = res->pause_time;
6217 pfc_conf.priority = res->priority;
6219 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6221 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6224 cmdline_parse_token_string_t cmd_pfc_set_set =
6225 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6227 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6229 pfc_ctrl, "pfc_ctrl");
6230 cmdline_parse_token_string_t cmd_pfc_set_rx =
6231 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6233 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6235 rx_pfc_mode, "on#off");
6236 cmdline_parse_token_string_t cmd_pfc_set_tx =
6237 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6239 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6240 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6241 tx_pfc_mode, "on#off");
6242 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6244 high_water, UINT32);
6245 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6246 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6248 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6249 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6250 pause_time, UINT16);
6251 cmdline_parse_token_num_t cmd_pfc_set_priority =
6252 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6254 cmdline_parse_token_num_t cmd_pfc_set_portid =
6255 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6258 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6259 .f = cmd_priority_flow_ctrl_set_parsed,
6261 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6262 "<pause_time> <priority> <port_id>: "
6263 "Configure the Ethernet priority flow control",
6265 (void *)&cmd_pfc_set_set,
6266 (void *)&cmd_pfc_set_flow_ctrl,
6267 (void *)&cmd_pfc_set_rx,
6268 (void *)&cmd_pfc_set_rx_mode,
6269 (void *)&cmd_pfc_set_tx,
6270 (void *)&cmd_pfc_set_tx_mode,
6271 (void *)&cmd_pfc_set_high_water,
6272 (void *)&cmd_pfc_set_low_water,
6273 (void *)&cmd_pfc_set_pause_time,
6274 (void *)&cmd_pfc_set_priority,
6275 (void *)&cmd_pfc_set_portid,
6280 /* *** RESET CONFIGURATION *** */
6281 struct cmd_reset_result {
6282 cmdline_fixed_string_t reset;
6283 cmdline_fixed_string_t def;
6286 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6288 __attribute__((unused)) void *data)
6290 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6291 set_def_fwd_config();
6294 cmdline_parse_token_string_t cmd_reset_set =
6295 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6296 cmdline_parse_token_string_t cmd_reset_def =
6297 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6300 cmdline_parse_inst_t cmd_reset = {
6301 .f = cmd_reset_parsed,
6303 .help_str = "set default: Reset default forwarding configuration",
6305 (void *)&cmd_reset_set,
6306 (void *)&cmd_reset_def,
6311 /* *** START FORWARDING *** */
6312 struct cmd_start_result {
6313 cmdline_fixed_string_t start;
6316 cmdline_parse_token_string_t cmd_start_start =
6317 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6319 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6320 __attribute__((unused)) struct cmdline *cl,
6321 __attribute__((unused)) void *data)
6323 start_packet_forwarding(0);
6326 cmdline_parse_inst_t cmd_start = {
6327 .f = cmd_start_parsed,
6329 .help_str = "start: Start packet forwarding",
6331 (void *)&cmd_start_start,
6336 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6337 struct cmd_start_tx_first_result {
6338 cmdline_fixed_string_t start;
6339 cmdline_fixed_string_t tx_first;
6343 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6344 __attribute__((unused)) struct cmdline *cl,
6345 __attribute__((unused)) void *data)
6347 start_packet_forwarding(1);
6350 cmdline_parse_token_string_t cmd_start_tx_first_start =
6351 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6353 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6354 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6355 tx_first, "tx_first");
6357 cmdline_parse_inst_t cmd_start_tx_first = {
6358 .f = cmd_start_tx_first_parsed,
6360 .help_str = "start tx_first: Start packet forwarding, "
6361 "after sending 1 burst of packets",
6363 (void *)&cmd_start_tx_first_start,
6364 (void *)&cmd_start_tx_first_tx_first,
6369 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6370 struct cmd_start_tx_first_n_result {
6371 cmdline_fixed_string_t start;
6372 cmdline_fixed_string_t tx_first;
6377 cmd_start_tx_first_n_parsed(void *parsed_result,
6378 __attribute__((unused)) struct cmdline *cl,
6379 __attribute__((unused)) void *data)
6381 struct cmd_start_tx_first_n_result *res = parsed_result;
6383 start_packet_forwarding(res->tx_num);
6386 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6387 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6389 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6390 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6391 tx_first, "tx_first");
6392 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6393 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6396 cmdline_parse_inst_t cmd_start_tx_first_n = {
6397 .f = cmd_start_tx_first_n_parsed,
6399 .help_str = "start tx_first <num>: "
6400 "packet forwarding, after sending <num> bursts of packets",
6402 (void *)&cmd_start_tx_first_n_start,
6403 (void *)&cmd_start_tx_first_n_tx_first,
6404 (void *)&cmd_start_tx_first_n_tx_num,
6409 /* *** SET LINK UP *** */
6410 struct cmd_set_link_up_result {
6411 cmdline_fixed_string_t set;
6412 cmdline_fixed_string_t link_up;
6413 cmdline_fixed_string_t port;
6417 cmdline_parse_token_string_t cmd_set_link_up_set =
6418 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6419 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6422 cmdline_parse_token_string_t cmd_set_link_up_port =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6424 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6427 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6428 __attribute__((unused)) struct cmdline *cl,
6429 __attribute__((unused)) void *data)
6431 struct cmd_set_link_up_result *res = parsed_result;
6432 dev_set_link_up(res->port_id);
6435 cmdline_parse_inst_t cmd_set_link_up = {
6436 .f = cmd_set_link_up_parsed,
6438 .help_str = "set link-up port <port id>",
6440 (void *)&cmd_set_link_up_set,
6441 (void *)&cmd_set_link_up_link_up,
6442 (void *)&cmd_set_link_up_port,
6443 (void *)&cmd_set_link_up_port_id,
6448 /* *** SET LINK DOWN *** */
6449 struct cmd_set_link_down_result {
6450 cmdline_fixed_string_t set;
6451 cmdline_fixed_string_t link_down;
6452 cmdline_fixed_string_t port;
6456 cmdline_parse_token_string_t cmd_set_link_down_set =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6458 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6459 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6461 cmdline_parse_token_string_t cmd_set_link_down_port =
6462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6463 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6464 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6466 static void cmd_set_link_down_parsed(
6467 __attribute__((unused)) void *parsed_result,
6468 __attribute__((unused)) struct cmdline *cl,
6469 __attribute__((unused)) void *data)
6471 struct cmd_set_link_down_result *res = parsed_result;
6472 dev_set_link_down(res->port_id);
6475 cmdline_parse_inst_t cmd_set_link_down = {
6476 .f = cmd_set_link_down_parsed,
6478 .help_str = "set link-down port <port id>",
6480 (void *)&cmd_set_link_down_set,
6481 (void *)&cmd_set_link_down_link_down,
6482 (void *)&cmd_set_link_down_port,
6483 (void *)&cmd_set_link_down_port_id,
6488 /* *** SHOW CFG *** */
6489 struct cmd_showcfg_result {
6490 cmdline_fixed_string_t show;
6491 cmdline_fixed_string_t cfg;
6492 cmdline_fixed_string_t what;
6495 static void cmd_showcfg_parsed(void *parsed_result,
6496 __attribute__((unused)) struct cmdline *cl,
6497 __attribute__((unused)) void *data)
6499 struct cmd_showcfg_result *res = parsed_result;
6500 if (!strcmp(res->what, "rxtx"))
6501 rxtx_config_display();
6502 else if (!strcmp(res->what, "cores"))
6503 fwd_lcores_config_display();
6504 else if (!strcmp(res->what, "fwd"))
6505 pkt_fwd_config_display(&cur_fwd_config);
6506 else if (!strcmp(res->what, "txpkts"))
6507 show_tx_pkt_segments();
6510 cmdline_parse_token_string_t cmd_showcfg_show =
6511 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6512 cmdline_parse_token_string_t cmd_showcfg_port =
6513 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6514 cmdline_parse_token_string_t cmd_showcfg_what =
6515 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6516 "rxtx#cores#fwd#txpkts");
6518 cmdline_parse_inst_t cmd_showcfg = {
6519 .f = cmd_showcfg_parsed,
6521 .help_str = "show config rxtx|cores|fwd|txpkts",
6523 (void *)&cmd_showcfg_show,
6524 (void *)&cmd_showcfg_port,
6525 (void *)&cmd_showcfg_what,
6530 /* *** SHOW ALL PORT INFO *** */
6531 struct cmd_showportall_result {
6532 cmdline_fixed_string_t show;
6533 cmdline_fixed_string_t port;
6534 cmdline_fixed_string_t what;
6535 cmdline_fixed_string_t all;
6538 static void cmd_showportall_parsed(void *parsed_result,
6539 __attribute__((unused)) struct cmdline *cl,
6540 __attribute__((unused)) void *data)
6544 struct cmd_showportall_result *res = parsed_result;
6545 if (!strcmp(res->show, "clear")) {
6546 if (!strcmp(res->what, "stats"))
6547 RTE_ETH_FOREACH_DEV(i)
6549 else if (!strcmp(res->what, "xstats"))
6550 RTE_ETH_FOREACH_DEV(i)
6551 nic_xstats_clear(i);
6552 } else if (!strcmp(res->what, "info"))
6553 RTE_ETH_FOREACH_DEV(i)
6554 port_infos_display(i);
6555 else if (!strcmp(res->what, "stats"))
6556 RTE_ETH_FOREACH_DEV(i)
6557 nic_stats_display(i);
6558 else if (!strcmp(res->what, "xstats"))
6559 RTE_ETH_FOREACH_DEV(i)
6560 nic_xstats_display(i);
6561 else if (!strcmp(res->what, "fdir"))
6562 RTE_ETH_FOREACH_DEV(i)
6564 else if (!strcmp(res->what, "stat_qmap"))
6565 RTE_ETH_FOREACH_DEV(i)
6566 nic_stats_mapping_display(i);
6567 else if (!strcmp(res->what, "dcb_tc"))
6568 RTE_ETH_FOREACH_DEV(i)
6569 port_dcb_info_display(i);
6570 else if (!strcmp(res->what, "cap"))
6571 RTE_ETH_FOREACH_DEV(i)
6572 port_offload_cap_display(i);
6575 cmdline_parse_token_string_t cmd_showportall_show =
6576 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6578 cmdline_parse_token_string_t cmd_showportall_port =
6579 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6580 cmdline_parse_token_string_t cmd_showportall_what =
6581 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6582 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6583 cmdline_parse_token_string_t cmd_showportall_all =
6584 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6585 cmdline_parse_inst_t cmd_showportall = {
6586 .f = cmd_showportall_parsed,
6588 .help_str = "show|clear port "
6589 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6591 (void *)&cmd_showportall_show,
6592 (void *)&cmd_showportall_port,
6593 (void *)&cmd_showportall_what,
6594 (void *)&cmd_showportall_all,
6599 /* *** SHOW PORT INFO *** */
6600 struct cmd_showport_result {
6601 cmdline_fixed_string_t show;
6602 cmdline_fixed_string_t port;
6603 cmdline_fixed_string_t what;
6607 static void cmd_showport_parsed(void *parsed_result,
6608 __attribute__((unused)) struct cmdline *cl,
6609 __attribute__((unused)) void *data)
6611 struct cmd_showport_result *res = parsed_result;
6612 if (!strcmp(res->show, "clear")) {
6613 if (!strcmp(res->what, "stats"))
6614 nic_stats_clear(res->portnum);
6615 else if (!strcmp(res->what, "xstats"))
6616 nic_xstats_clear(res->portnum);
6617 } else if (!strcmp(res->what, "info"))
6618 port_infos_display(res->portnum);
6619 else if (!strcmp(res->what, "stats"))
6620 nic_stats_display(res->portnum);
6621 else if (!strcmp(res->what, "xstats"))
6622 nic_xstats_display(res->portnum);
6623 else if (!strcmp(res->what, "fdir"))
6624 fdir_get_infos(res->portnum);
6625 else if (!strcmp(res->what, "stat_qmap"))
6626 nic_stats_mapping_display(res->portnum);
6627 else if (!strcmp(res->what, "dcb_tc"))
6628 port_dcb_info_display(res->portnum);
6629 else if (!strcmp(res->what, "cap"))
6630 port_offload_cap_display(res->portnum);
6633 cmdline_parse_token_string_t cmd_showport_show =
6634 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6636 cmdline_parse_token_string_t cmd_showport_port =
6637 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6638 cmdline_parse_token_string_t cmd_showport_what =
6639 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6640 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6641 cmdline_parse_token_num_t cmd_showport_portnum =
6642 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6644 cmdline_parse_inst_t cmd_showport = {
6645 .f = cmd_showport_parsed,
6647 .help_str = "show|clear port "
6648 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6651 (void *)&cmd_showport_show,
6652 (void *)&cmd_showport_port,
6653 (void *)&cmd_showport_what,
6654 (void *)&cmd_showport_portnum,
6659 /* *** SHOW QUEUE INFO *** */
6660 struct cmd_showqueue_result {
6661 cmdline_fixed_string_t show;
6662 cmdline_fixed_string_t type;
6663 cmdline_fixed_string_t what;
6669 cmd_showqueue_parsed(void *parsed_result,
6670 __attribute__((unused)) struct cmdline *cl,
6671 __attribute__((unused)) void *data)
6673 struct cmd_showqueue_result *res = parsed_result;
6675 if (!strcmp(res->type, "rxq"))
6676 rx_queue_infos_display(res->portnum, res->queuenum);
6677 else if (!strcmp(res->type, "txq"))
6678 tx_queue_infos_display(res->portnum, res->queuenum);
6681 cmdline_parse_token_string_t cmd_showqueue_show =
6682 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6683 cmdline_parse_token_string_t cmd_showqueue_type =
6684 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6685 cmdline_parse_token_string_t cmd_showqueue_what =
6686 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6687 cmdline_parse_token_num_t cmd_showqueue_portnum =
6688 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6689 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6690 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6692 cmdline_parse_inst_t cmd_showqueue = {
6693 .f = cmd_showqueue_parsed,
6695 .help_str = "show rxq|txq info <port_id> <queue_id>",
6697 (void *)&cmd_showqueue_show,
6698 (void *)&cmd_showqueue_type,
6699 (void *)&cmd_showqueue_what,
6700 (void *)&cmd_showqueue_portnum,
6701 (void *)&cmd_showqueue_queuenum,
6706 /* *** READ PORT REGISTER *** */
6707 struct cmd_read_reg_result {
6708 cmdline_fixed_string_t read;
6709 cmdline_fixed_string_t reg;
6715 cmd_read_reg_parsed(void *parsed_result,
6716 __attribute__((unused)) struct cmdline *cl,
6717 __attribute__((unused)) void *data)
6719 struct cmd_read_reg_result *res = parsed_result;
6720 port_reg_display(res->port_id, res->reg_off);
6723 cmdline_parse_token_string_t cmd_read_reg_read =
6724 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6725 cmdline_parse_token_string_t cmd_read_reg_reg =
6726 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6727 cmdline_parse_token_num_t cmd_read_reg_port_id =
6728 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6729 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6730 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6732 cmdline_parse_inst_t cmd_read_reg = {
6733 .f = cmd_read_reg_parsed,
6735 .help_str = "read reg <port_id> <reg_off>",
6737 (void *)&cmd_read_reg_read,
6738 (void *)&cmd_read_reg_reg,
6739 (void *)&cmd_read_reg_port_id,
6740 (void *)&cmd_read_reg_reg_off,
6745 /* *** READ PORT REGISTER BIT FIELD *** */
6746 struct cmd_read_reg_bit_field_result {
6747 cmdline_fixed_string_t read;
6748 cmdline_fixed_string_t regfield;
6756 cmd_read_reg_bit_field_parsed(void *parsed_result,
6757 __attribute__((unused)) struct cmdline *cl,
6758 __attribute__((unused)) void *data)
6760 struct cmd_read_reg_bit_field_result *res = parsed_result;
6761 port_reg_bit_field_display(res->port_id, res->reg_off,
6762 res->bit1_pos, res->bit2_pos);
6765 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6766 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6768 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6769 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6770 regfield, "regfield");
6771 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6772 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6774 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6775 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6777 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6778 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6780 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6781 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6784 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6785 .f = cmd_read_reg_bit_field_parsed,
6787 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6788 "Read register bit field between bit_x and bit_y included",
6790 (void *)&cmd_read_reg_bit_field_read,
6791 (void *)&cmd_read_reg_bit_field_regfield,
6792 (void *)&cmd_read_reg_bit_field_port_id,
6793 (void *)&cmd_read_reg_bit_field_reg_off,
6794 (void *)&cmd_read_reg_bit_field_bit1_pos,
6795 (void *)&cmd_read_reg_bit_field_bit2_pos,
6800 /* *** READ PORT REGISTER BIT *** */
6801 struct cmd_read_reg_bit_result {
6802 cmdline_fixed_string_t read;
6803 cmdline_fixed_string_t regbit;
6810 cmd_read_reg_bit_parsed(void *parsed_result,
6811 __attribute__((unused)) struct cmdline *cl,
6812 __attribute__((unused)) void *data)
6814 struct cmd_read_reg_bit_result *res = parsed_result;
6815 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6818 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6819 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6820 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6821 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6823 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6824 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6825 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6826 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6827 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6828 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6830 cmdline_parse_inst_t cmd_read_reg_bit = {
6831 .f = cmd_read_reg_bit_parsed,
6833 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6835 (void *)&cmd_read_reg_bit_read,
6836 (void *)&cmd_read_reg_bit_regbit,
6837 (void *)&cmd_read_reg_bit_port_id,
6838 (void *)&cmd_read_reg_bit_reg_off,
6839 (void *)&cmd_read_reg_bit_bit_pos,
6844 /* *** WRITE PORT REGISTER *** */
6845 struct cmd_write_reg_result {
6846 cmdline_fixed_string_t write;
6847 cmdline_fixed_string_t reg;
6854 cmd_write_reg_parsed(void *parsed_result,
6855 __attribute__((unused)) struct cmdline *cl,
6856 __attribute__((unused)) void *data)
6858 struct cmd_write_reg_result *res = parsed_result;
6859 port_reg_set(res->port_id, res->reg_off, res->value);
6862 cmdline_parse_token_string_t cmd_write_reg_write =
6863 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6864 cmdline_parse_token_string_t cmd_write_reg_reg =
6865 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6866 cmdline_parse_token_num_t cmd_write_reg_port_id =
6867 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6868 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6869 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6870 cmdline_parse_token_num_t cmd_write_reg_value =
6871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6873 cmdline_parse_inst_t cmd_write_reg = {
6874 .f = cmd_write_reg_parsed,
6876 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6878 (void *)&cmd_write_reg_write,
6879 (void *)&cmd_write_reg_reg,
6880 (void *)&cmd_write_reg_port_id,
6881 (void *)&cmd_write_reg_reg_off,
6882 (void *)&cmd_write_reg_value,
6887 /* *** WRITE PORT REGISTER BIT FIELD *** */
6888 struct cmd_write_reg_bit_field_result {
6889 cmdline_fixed_string_t write;
6890 cmdline_fixed_string_t regfield;
6899 cmd_write_reg_bit_field_parsed(void *parsed_result,
6900 __attribute__((unused)) struct cmdline *cl,
6901 __attribute__((unused)) void *data)
6903 struct cmd_write_reg_bit_field_result *res = parsed_result;
6904 port_reg_bit_field_set(res->port_id, res->reg_off,
6905 res->bit1_pos, res->bit2_pos, res->value);
6908 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6909 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6911 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6912 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6913 regfield, "regfield");
6914 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6915 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6917 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6918 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6920 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6921 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6923 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6924 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6926 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6927 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6930 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6931 .f = cmd_write_reg_bit_field_parsed,
6933 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6935 "Set register bit field between bit_x and bit_y included",
6937 (void *)&cmd_write_reg_bit_field_write,
6938 (void *)&cmd_write_reg_bit_field_regfield,
6939 (void *)&cmd_write_reg_bit_field_port_id,
6940 (void *)&cmd_write_reg_bit_field_reg_off,
6941 (void *)&cmd_write_reg_bit_field_bit1_pos,
6942 (void *)&cmd_write_reg_bit_field_bit2_pos,
6943 (void *)&cmd_write_reg_bit_field_value,
6948 /* *** WRITE PORT REGISTER BIT *** */
6949 struct cmd_write_reg_bit_result {
6950 cmdline_fixed_string_t write;
6951 cmdline_fixed_string_t regbit;
6959 cmd_write_reg_bit_parsed(void *parsed_result,
6960 __attribute__((unused)) struct cmdline *cl,
6961 __attribute__((unused)) void *data)
6963 struct cmd_write_reg_bit_result *res = parsed_result;
6964 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6967 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6968 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6970 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6971 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6973 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6974 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6975 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6977 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6978 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6979 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6980 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6982 cmdline_parse_inst_t cmd_write_reg_bit = {
6983 .f = cmd_write_reg_bit_parsed,
6985 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6988 (void *)&cmd_write_reg_bit_write,
6989 (void *)&cmd_write_reg_bit_regbit,
6990 (void *)&cmd_write_reg_bit_port_id,
6991 (void *)&cmd_write_reg_bit_reg_off,
6992 (void *)&cmd_write_reg_bit_bit_pos,
6993 (void *)&cmd_write_reg_bit_value,
6998 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6999 struct cmd_read_rxd_txd_result {
7000 cmdline_fixed_string_t read;
7001 cmdline_fixed_string_t rxd_txd;
7008 cmd_read_rxd_txd_parsed(void *parsed_result,
7009 __attribute__((unused)) struct cmdline *cl,
7010 __attribute__((unused)) void *data)
7012 struct cmd_read_rxd_txd_result *res = parsed_result;
7014 if (!strcmp(res->rxd_txd, "rxd"))
7015 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7016 else if (!strcmp(res->rxd_txd, "txd"))
7017 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7020 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7021 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7022 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7023 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7025 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7026 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7027 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7028 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7029 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7030 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7032 cmdline_parse_inst_t cmd_read_rxd_txd = {
7033 .f = cmd_read_rxd_txd_parsed,
7035 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7037 (void *)&cmd_read_rxd_txd_read,
7038 (void *)&cmd_read_rxd_txd_rxd_txd,
7039 (void *)&cmd_read_rxd_txd_port_id,
7040 (void *)&cmd_read_rxd_txd_queue_id,
7041 (void *)&cmd_read_rxd_txd_desc_id,
7047 struct cmd_quit_result {
7048 cmdline_fixed_string_t quit;
7051 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7053 __attribute__((unused)) void *data)
7059 cmdline_parse_token_string_t cmd_quit_quit =
7060 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7062 cmdline_parse_inst_t cmd_quit = {
7063 .f = cmd_quit_parsed,
7065 .help_str = "quit: Exit application",
7067 (void *)&cmd_quit_quit,
7072 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7073 struct cmd_mac_addr_result {
7074 cmdline_fixed_string_t mac_addr_cmd;
7075 cmdline_fixed_string_t what;
7077 struct ether_addr address;
7080 static void cmd_mac_addr_parsed(void *parsed_result,
7081 __attribute__((unused)) struct cmdline *cl,
7082 __attribute__((unused)) void *data)
7084 struct cmd_mac_addr_result *res = parsed_result;
7087 if (strcmp(res->what, "add") == 0)
7088 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7089 else if (strcmp(res->what, "set") == 0)
7090 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7093 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7095 /* check the return value and print it if is < 0 */
7097 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7101 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7102 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7104 cmdline_parse_token_string_t cmd_mac_addr_what =
7105 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7107 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7108 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7110 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7111 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7113 cmdline_parse_inst_t cmd_mac_addr = {
7114 .f = cmd_mac_addr_parsed,
7116 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7117 "Add/Remove/Set MAC address on port_id",
7119 (void *)&cmd_mac_addr_cmd,
7120 (void *)&cmd_mac_addr_what,
7121 (void *)&cmd_mac_addr_portnum,
7122 (void *)&cmd_mac_addr_addr,
7128 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7129 struct cmd_set_qmap_result {
7130 cmdline_fixed_string_t set;
7131 cmdline_fixed_string_t qmap;
7132 cmdline_fixed_string_t what;
7139 cmd_set_qmap_parsed(void *parsed_result,
7140 __attribute__((unused)) struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_set_qmap_result *res = parsed_result;
7144 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7146 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7149 cmdline_parse_token_string_t cmd_setqmap_set =
7150 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7152 cmdline_parse_token_string_t cmd_setqmap_qmap =
7153 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7155 cmdline_parse_token_string_t cmd_setqmap_what =
7156 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7158 cmdline_parse_token_num_t cmd_setqmap_portid =
7159 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7161 cmdline_parse_token_num_t cmd_setqmap_queueid =
7162 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7164 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7165 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7168 cmdline_parse_inst_t cmd_set_qmap = {
7169 .f = cmd_set_qmap_parsed,
7171 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7172 "Set statistics mapping value on tx|rx queue_id of port_id",
7174 (void *)&cmd_setqmap_set,
7175 (void *)&cmd_setqmap_qmap,
7176 (void *)&cmd_setqmap_what,
7177 (void *)&cmd_setqmap_portid,
7178 (void *)&cmd_setqmap_queueid,
7179 (void *)&cmd_setqmap_mapvalue,
7184 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7185 struct cmd_set_xstats_hide_zero_result {
7186 cmdline_fixed_string_t keyword;
7187 cmdline_fixed_string_t name;
7188 cmdline_fixed_string_t on_off;
7192 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7193 __attribute__((unused)) struct cmdline *cl,
7194 __attribute__((unused)) void *data)
7196 struct cmd_set_xstats_hide_zero_result *res;
7197 uint16_t on_off = 0;
7199 res = parsed_result;
7200 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7201 set_xstats_hide_zero(on_off);
7204 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7205 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7207 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7209 name, "xstats-hide-zero");
7210 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7211 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7214 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7215 .f = cmd_set_xstats_hide_zero_parsed,
7217 .help_str = "set xstats-hide-zero on|off",
7219 (void *)&cmd_set_xstats_hide_zero_keyword,
7220 (void *)&cmd_set_xstats_hide_zero_name,
7221 (void *)&cmd_set_xstats_hide_zero_on_off,
7226 /* *** CONFIGURE UNICAST HASH TABLE *** */
7227 struct cmd_set_uc_hash_table {
7228 cmdline_fixed_string_t set;
7229 cmdline_fixed_string_t port;
7231 cmdline_fixed_string_t what;
7232 struct ether_addr address;
7233 cmdline_fixed_string_t mode;
7237 cmd_set_uc_hash_parsed(void *parsed_result,
7238 __attribute__((unused)) struct cmdline *cl,
7239 __attribute__((unused)) void *data)
7242 struct cmd_set_uc_hash_table *res = parsed_result;
7244 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7246 if (strcmp(res->what, "uta") == 0)
7247 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7248 &res->address,(uint8_t)is_on);
7250 printf("bad unicast hash table parameter, return code = %d \n", ret);
7254 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7257 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7258 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7260 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7261 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7263 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7264 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7266 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7267 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7269 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7270 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7273 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7274 .f = cmd_set_uc_hash_parsed,
7276 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7278 (void *)&cmd_set_uc_hash_set,
7279 (void *)&cmd_set_uc_hash_port,
7280 (void *)&cmd_set_uc_hash_portid,
7281 (void *)&cmd_set_uc_hash_what,
7282 (void *)&cmd_set_uc_hash_mac,
7283 (void *)&cmd_set_uc_hash_mode,
7288 struct cmd_set_uc_all_hash_table {
7289 cmdline_fixed_string_t set;
7290 cmdline_fixed_string_t port;
7292 cmdline_fixed_string_t what;
7293 cmdline_fixed_string_t value;
7294 cmdline_fixed_string_t mode;
7298 cmd_set_uc_all_hash_parsed(void *parsed_result,
7299 __attribute__((unused)) struct cmdline *cl,
7300 __attribute__((unused)) void *data)
7303 struct cmd_set_uc_all_hash_table *res = parsed_result;
7305 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7307 if ((strcmp(res->what, "uta") == 0) &&
7308 (strcmp(res->value, "all") == 0))
7309 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7311 printf("bad unicast hash table parameter,"
7312 "return code = %d \n", ret);
7315 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7316 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7318 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7321 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7322 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7324 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7325 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7327 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7328 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7330 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7334 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7335 .f = cmd_set_uc_all_hash_parsed,
7337 .help_str = "set port <port_id> uta all on|off",
7339 (void *)&cmd_set_uc_all_hash_set,
7340 (void *)&cmd_set_uc_all_hash_port,
7341 (void *)&cmd_set_uc_all_hash_portid,
7342 (void *)&cmd_set_uc_all_hash_what,
7343 (void *)&cmd_set_uc_all_hash_value,
7344 (void *)&cmd_set_uc_all_hash_mode,
7349 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7350 struct cmd_set_vf_macvlan_filter {
7351 cmdline_fixed_string_t set;
7352 cmdline_fixed_string_t port;
7354 cmdline_fixed_string_t vf;
7356 struct ether_addr address;
7357 cmdline_fixed_string_t filter_type;
7358 cmdline_fixed_string_t mode;
7362 cmd_set_vf_macvlan_parsed(void *parsed_result,
7363 __attribute__((unused)) struct cmdline *cl,
7364 __attribute__((unused)) void *data)
7367 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7368 struct rte_eth_mac_filter filter;
7370 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7372 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7374 /* set VF MAC filter */
7378 filter.dst_id = res->vf_id;
7380 if (!strcmp(res->filter_type, "exact-mac"))
7381 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7382 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7383 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7384 else if (!strcmp(res->filter_type, "hashmac"))
7385 filter.filter_type = RTE_MAC_HASH_MATCH;
7386 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7387 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7389 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7392 ret = rte_eth_dev_filter_ctrl(res->port_id,
7393 RTE_ETH_FILTER_MACVLAN,
7397 ret = rte_eth_dev_filter_ctrl(res->port_id,
7398 RTE_ETH_FILTER_MACVLAN,
7399 RTE_ETH_FILTER_DELETE,
7403 printf("bad set MAC hash parameter, return code = %d\n", ret);
7407 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7410 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7413 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7414 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7416 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7419 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7420 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7422 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7423 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7425 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7427 filter_type, "exact-mac#exact-mac-vlan"
7428 "#hashmac#hashmac-vlan");
7429 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7433 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7434 .f = cmd_set_vf_macvlan_parsed,
7436 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7437 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7438 "Exact match rule: exact match of MAC or MAC and VLAN; "
7439 "hash match rule: hash match of MAC and exact match of VLAN",
7441 (void *)&cmd_set_vf_macvlan_set,
7442 (void *)&cmd_set_vf_macvlan_port,
7443 (void *)&cmd_set_vf_macvlan_portid,
7444 (void *)&cmd_set_vf_macvlan_vf,
7445 (void *)&cmd_set_vf_macvlan_vf_id,
7446 (void *)&cmd_set_vf_macvlan_mac,
7447 (void *)&cmd_set_vf_macvlan_filter_type,
7448 (void *)&cmd_set_vf_macvlan_mode,
7453 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7454 struct cmd_set_vf_traffic {
7455 cmdline_fixed_string_t set;
7456 cmdline_fixed_string_t port;
7458 cmdline_fixed_string_t vf;
7460 cmdline_fixed_string_t what;
7461 cmdline_fixed_string_t mode;
7465 cmd_set_vf_traffic_parsed(void *parsed_result,
7466 __attribute__((unused)) struct cmdline *cl,
7467 __attribute__((unused)) void *data)
7469 struct cmd_set_vf_traffic *res = parsed_result;
7470 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7471 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7473 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7476 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7479 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7482 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7483 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7485 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7486 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7488 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7489 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7491 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7492 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7494 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7498 cmdline_parse_inst_t cmd_set_vf_traffic = {
7499 .f = cmd_set_vf_traffic_parsed,
7501 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7503 (void *)&cmd_setvf_traffic_set,
7504 (void *)&cmd_setvf_traffic_port,
7505 (void *)&cmd_setvf_traffic_portid,
7506 (void *)&cmd_setvf_traffic_vf,
7507 (void *)&cmd_setvf_traffic_vfid,
7508 (void *)&cmd_setvf_traffic_what,
7509 (void *)&cmd_setvf_traffic_mode,
7514 /* *** CONFIGURE VF RECEIVE MODE *** */
7515 struct cmd_set_vf_rxmode {
7516 cmdline_fixed_string_t set;
7517 cmdline_fixed_string_t port;
7519 cmdline_fixed_string_t vf;
7521 cmdline_fixed_string_t what;
7522 cmdline_fixed_string_t mode;
7523 cmdline_fixed_string_t on;
7527 cmd_set_vf_rxmode_parsed(void *parsed_result,
7528 __attribute__((unused)) struct cmdline *cl,
7529 __attribute__((unused)) void *data)
7532 uint16_t rx_mode = 0;
7533 struct cmd_set_vf_rxmode *res = parsed_result;
7535 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7536 if (!strcmp(res->what,"rxmode")) {
7537 if (!strcmp(res->mode, "AUPE"))
7538 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7539 else if (!strcmp(res->mode, "ROPE"))
7540 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7541 else if (!strcmp(res->mode, "BAM"))
7542 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7543 else if (!strncmp(res->mode, "MPE",3))
7544 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7547 RTE_SET_USED(is_on);
7549 #ifdef RTE_LIBRTE_IXGBE_PMD
7550 if (ret == -ENOTSUP)
7551 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7552 rx_mode, (uint8_t)is_on);
7554 #ifdef RTE_LIBRTE_BNXT_PMD
7555 if (ret == -ENOTSUP)
7556 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7557 rx_mode, (uint8_t)is_on);
7560 printf("bad VF receive mode parameter, return code = %d \n",
7564 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7565 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7567 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7568 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7570 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7571 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7573 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7574 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7576 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7577 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7579 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7582 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7584 mode, "AUPE#ROPE#BAM#MPE");
7585 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7589 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7590 .f = cmd_set_vf_rxmode_parsed,
7592 .help_str = "set port <port_id> vf <vf_id> rxmode "
7593 "AUPE|ROPE|BAM|MPE on|off",
7595 (void *)&cmd_set_vf_rxmode_set,
7596 (void *)&cmd_set_vf_rxmode_port,
7597 (void *)&cmd_set_vf_rxmode_portid,
7598 (void *)&cmd_set_vf_rxmode_vf,
7599 (void *)&cmd_set_vf_rxmode_vfid,
7600 (void *)&cmd_set_vf_rxmode_what,
7601 (void *)&cmd_set_vf_rxmode_mode,
7602 (void *)&cmd_set_vf_rxmode_on,
7607 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7608 struct cmd_vf_mac_addr_result {
7609 cmdline_fixed_string_t mac_addr_cmd;
7610 cmdline_fixed_string_t what;
7611 cmdline_fixed_string_t port;
7613 cmdline_fixed_string_t vf;
7615 struct ether_addr address;
7618 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7619 __attribute__((unused)) struct cmdline *cl,
7620 __attribute__((unused)) void *data)
7622 struct cmd_vf_mac_addr_result *res = parsed_result;
7625 if (strcmp(res->what, "add") != 0)
7628 #ifdef RTE_LIBRTE_I40E_PMD
7629 if (ret == -ENOTSUP)
7630 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7633 #ifdef RTE_LIBRTE_BNXT_PMD
7634 if (ret == -ENOTSUP)
7635 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7640 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7644 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7645 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7646 mac_addr_cmd,"mac_addr");
7647 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7648 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7650 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7651 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7653 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7654 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7656 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7657 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7659 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7660 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7662 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7666 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7667 .f = cmd_vf_mac_addr_parsed,
7669 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7670 "Add MAC address filtering for a VF on port_id",
7672 (void *)&cmd_vf_mac_addr_cmd,
7673 (void *)&cmd_vf_mac_addr_what,
7674 (void *)&cmd_vf_mac_addr_port,
7675 (void *)&cmd_vf_mac_addr_portnum,
7676 (void *)&cmd_vf_mac_addr_vf,
7677 (void *)&cmd_vf_mac_addr_vfnum,
7678 (void *)&cmd_vf_mac_addr_addr,
7683 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7684 struct cmd_vf_rx_vlan_filter {
7685 cmdline_fixed_string_t rx_vlan;
7686 cmdline_fixed_string_t what;
7688 cmdline_fixed_string_t port;
7690 cmdline_fixed_string_t vf;
7695 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7696 __attribute__((unused)) struct cmdline *cl,
7697 __attribute__((unused)) void *data)
7699 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7702 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7704 #ifdef RTE_LIBRTE_IXGBE_PMD
7705 if (ret == -ENOTSUP)
7706 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7707 res->vlan_id, res->vf_mask, is_add);
7709 #ifdef RTE_LIBRTE_I40E_PMD
7710 if (ret == -ENOTSUP)
7711 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7712 res->vlan_id, res->vf_mask, is_add);
7714 #ifdef RTE_LIBRTE_BNXT_PMD
7715 if (ret == -ENOTSUP)
7716 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7717 res->vlan_id, res->vf_mask, is_add);
7724 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7725 res->vlan_id, res->vf_mask);
7728 printf("invalid port_id %d\n", res->port_id);
7731 printf("function not implemented or supported\n");
7734 printf("programming error: (%s)\n", strerror(-ret));
7738 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7739 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7740 rx_vlan, "rx_vlan");
7741 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7742 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7744 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7745 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7747 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7748 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7750 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7751 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7753 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7754 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7756 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7757 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7760 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7761 .f = cmd_vf_rx_vlan_filter_parsed,
7763 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7764 "(vf_mask = hexadecimal VF mask)",
7766 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7767 (void *)&cmd_vf_rx_vlan_filter_what,
7768 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7769 (void *)&cmd_vf_rx_vlan_filter_port,
7770 (void *)&cmd_vf_rx_vlan_filter_portid,
7771 (void *)&cmd_vf_rx_vlan_filter_vf,
7772 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7777 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7778 struct cmd_queue_rate_limit_result {
7779 cmdline_fixed_string_t set;
7780 cmdline_fixed_string_t port;
7782 cmdline_fixed_string_t queue;
7784 cmdline_fixed_string_t rate;
7788 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7789 __attribute__((unused)) struct cmdline *cl,
7790 __attribute__((unused)) void *data)
7792 struct cmd_queue_rate_limit_result *res = parsed_result;
7795 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7796 && (strcmp(res->queue, "queue") == 0)
7797 && (strcmp(res->rate, "rate") == 0))
7798 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7801 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7805 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7806 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7808 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7809 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7811 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7812 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7814 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7815 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7817 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7818 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7820 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7821 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7823 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7824 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7827 cmdline_parse_inst_t cmd_queue_rate_limit = {
7828 .f = cmd_queue_rate_limit_parsed,
7830 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7831 "Set rate limit for a queue on port_id",
7833 (void *)&cmd_queue_rate_limit_set,
7834 (void *)&cmd_queue_rate_limit_port,
7835 (void *)&cmd_queue_rate_limit_portnum,
7836 (void *)&cmd_queue_rate_limit_queue,
7837 (void *)&cmd_queue_rate_limit_queuenum,
7838 (void *)&cmd_queue_rate_limit_rate,
7839 (void *)&cmd_queue_rate_limit_ratenum,
7844 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7845 struct cmd_vf_rate_limit_result {
7846 cmdline_fixed_string_t set;
7847 cmdline_fixed_string_t port;
7849 cmdline_fixed_string_t vf;
7851 cmdline_fixed_string_t rate;
7853 cmdline_fixed_string_t q_msk;
7857 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7858 __attribute__((unused)) struct cmdline *cl,
7859 __attribute__((unused)) void *data)
7861 struct cmd_vf_rate_limit_result *res = parsed_result;
7864 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7865 && (strcmp(res->vf, "vf") == 0)
7866 && (strcmp(res->rate, "rate") == 0)
7867 && (strcmp(res->q_msk, "queue_mask") == 0))
7868 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7869 res->rate_num, res->q_msk_val);
7871 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7875 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7876 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7878 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7879 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7881 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7882 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7884 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7885 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7887 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7888 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7890 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7891 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7893 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7894 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7896 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7898 q_msk, "queue_mask");
7899 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7900 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7903 cmdline_parse_inst_t cmd_vf_rate_limit = {
7904 .f = cmd_vf_rate_limit_parsed,
7906 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7907 "queue_mask <queue_mask_value>: "
7908 "Set rate limit for queues of VF on port_id",
7910 (void *)&cmd_vf_rate_limit_set,
7911 (void *)&cmd_vf_rate_limit_port,
7912 (void *)&cmd_vf_rate_limit_portnum,
7913 (void *)&cmd_vf_rate_limit_vf,
7914 (void *)&cmd_vf_rate_limit_vfnum,
7915 (void *)&cmd_vf_rate_limit_rate,
7916 (void *)&cmd_vf_rate_limit_ratenum,
7917 (void *)&cmd_vf_rate_limit_q_msk,
7918 (void *)&cmd_vf_rate_limit_q_msk_val,
7923 /* *** ADD TUNNEL FILTER OF A PORT *** */
7924 struct cmd_tunnel_filter_result {
7925 cmdline_fixed_string_t cmd;
7926 cmdline_fixed_string_t what;
7928 struct ether_addr outer_mac;
7929 struct ether_addr inner_mac;
7930 cmdline_ipaddr_t ip_value;
7931 uint16_t inner_vlan;
7932 cmdline_fixed_string_t tunnel_type;
7933 cmdline_fixed_string_t filter_type;
7939 cmd_tunnel_filter_parsed(void *parsed_result,
7940 __attribute__((unused)) struct cmdline *cl,
7941 __attribute__((unused)) void *data)
7943 struct cmd_tunnel_filter_result *res = parsed_result;
7944 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7947 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7949 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7950 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7951 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7953 if (res->ip_value.family == AF_INET) {
7954 tunnel_filter_conf.ip_addr.ipv4_addr =
7955 res->ip_value.addr.ipv4.s_addr;
7956 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7958 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7959 &(res->ip_value.addr.ipv6),
7960 sizeof(struct in6_addr));
7961 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7964 if (!strcmp(res->filter_type, "imac-ivlan"))
7965 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7966 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7967 tunnel_filter_conf.filter_type =
7968 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7969 else if (!strcmp(res->filter_type, "imac-tenid"))
7970 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7971 else if (!strcmp(res->filter_type, "imac"))
7972 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7973 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7974 tunnel_filter_conf.filter_type =
7975 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7976 else if (!strcmp(res->filter_type, "oip"))
7977 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7978 else if (!strcmp(res->filter_type, "iip"))
7979 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7981 printf("The filter type is not supported");
7985 if (!strcmp(res->tunnel_type, "vxlan"))
7986 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7987 else if (!strcmp(res->tunnel_type, "nvgre"))
7988 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7989 else if (!strcmp(res->tunnel_type, "ipingre"))
7990 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7992 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7996 tunnel_filter_conf.tenant_id = res->tenant_id;
7997 tunnel_filter_conf.queue_id = res->queue_num;
7998 if (!strcmp(res->what, "add"))
7999 ret = rte_eth_dev_filter_ctrl(res->port_id,
8000 RTE_ETH_FILTER_TUNNEL,
8002 &tunnel_filter_conf);
8004 ret = rte_eth_dev_filter_ctrl(res->port_id,
8005 RTE_ETH_FILTER_TUNNEL,
8006 RTE_ETH_FILTER_DELETE,
8007 &tunnel_filter_conf);
8009 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8013 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8014 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8015 cmd, "tunnel_filter");
8016 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8017 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8019 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8020 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8022 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8025 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8026 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8028 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8029 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8030 inner_vlan, UINT16);
8031 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8032 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8034 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8036 tunnel_type, "vxlan#nvgre#ipingre");
8038 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8039 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8040 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8041 "imac#omac-imac-tenid");
8042 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8043 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8045 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8046 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8049 cmdline_parse_inst_t cmd_tunnel_filter = {
8050 .f = cmd_tunnel_filter_parsed,
8052 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8053 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8054 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8055 "<queue_id>: Add/Rm tunnel filter of a port",
8057 (void *)&cmd_tunnel_filter_cmd,
8058 (void *)&cmd_tunnel_filter_what,
8059 (void *)&cmd_tunnel_filter_port_id,
8060 (void *)&cmd_tunnel_filter_outer_mac,
8061 (void *)&cmd_tunnel_filter_inner_mac,
8062 (void *)&cmd_tunnel_filter_ip_value,
8063 (void *)&cmd_tunnel_filter_innner_vlan,
8064 (void *)&cmd_tunnel_filter_tunnel_type,
8065 (void *)&cmd_tunnel_filter_filter_type,
8066 (void *)&cmd_tunnel_filter_tenant_id,
8067 (void *)&cmd_tunnel_filter_queue_num,
8072 /* *** CONFIGURE TUNNEL UDP PORT *** */
8073 struct cmd_tunnel_udp_config {
8074 cmdline_fixed_string_t cmd;
8075 cmdline_fixed_string_t what;
8081 cmd_tunnel_udp_config_parsed(void *parsed_result,
8082 __attribute__((unused)) struct cmdline *cl,
8083 __attribute__((unused)) void *data)
8085 struct cmd_tunnel_udp_config *res = parsed_result;
8086 struct rte_eth_udp_tunnel tunnel_udp;
8089 tunnel_udp.udp_port = res->udp_port;
8091 if (!strcmp(res->cmd, "rx_vxlan_port"))
8092 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8094 if (!strcmp(res->what, "add"))
8095 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8098 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8102 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8105 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8106 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8107 cmd, "rx_vxlan_port");
8108 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8111 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8112 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8114 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8115 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8118 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8119 .f = cmd_tunnel_udp_config_parsed,
8121 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8122 "Add/Remove a tunneling UDP port filter",
8124 (void *)&cmd_tunnel_udp_config_cmd,
8125 (void *)&cmd_tunnel_udp_config_what,
8126 (void *)&cmd_tunnel_udp_config_udp_port,
8127 (void *)&cmd_tunnel_udp_config_port_id,
8132 /* *** GLOBAL CONFIG *** */
8133 struct cmd_global_config_result {
8134 cmdline_fixed_string_t cmd;
8136 cmdline_fixed_string_t cfg_type;
8141 cmd_global_config_parsed(void *parsed_result,
8142 __attribute__((unused)) struct cmdline *cl,
8143 __attribute__((unused)) void *data)
8145 struct cmd_global_config_result *res = parsed_result;
8146 struct rte_eth_global_cfg conf;
8149 memset(&conf, 0, sizeof(conf));
8150 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8151 conf.cfg.gre_key_len = res->len;
8152 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8153 RTE_ETH_FILTER_SET, &conf);
8155 printf("Global config error\n");
8158 cmdline_parse_token_string_t cmd_global_config_cmd =
8159 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8161 cmdline_parse_token_num_t cmd_global_config_port_id =
8162 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8164 cmdline_parse_token_string_t cmd_global_config_type =
8165 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8166 cfg_type, "gre-key-len");
8167 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8168 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8171 cmdline_parse_inst_t cmd_global_config = {
8172 .f = cmd_global_config_parsed,
8173 .data = (void *)NULL,
8174 .help_str = "global_config <port_id> gre-key-len <key_len>",
8176 (void *)&cmd_global_config_cmd,
8177 (void *)&cmd_global_config_port_id,
8178 (void *)&cmd_global_config_type,
8179 (void *)&cmd_global_config_gre_key_len,
8184 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8185 struct cmd_set_mirror_mask_result {
8186 cmdline_fixed_string_t set;
8187 cmdline_fixed_string_t port;
8189 cmdline_fixed_string_t mirror;
8191 cmdline_fixed_string_t what;
8192 cmdline_fixed_string_t value;
8193 cmdline_fixed_string_t dstpool;
8195 cmdline_fixed_string_t on;
8198 cmdline_parse_token_string_t cmd_mirror_mask_set =
8199 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8201 cmdline_parse_token_string_t cmd_mirror_mask_port =
8202 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8204 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8205 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8207 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8208 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8209 mirror, "mirror-rule");
8210 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8211 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8213 cmdline_parse_token_string_t cmd_mirror_mask_what =
8214 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8215 what, "pool-mirror-up#pool-mirror-down"
8217 cmdline_parse_token_string_t cmd_mirror_mask_value =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8220 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8222 dstpool, "dst-pool");
8223 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8224 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8226 cmdline_parse_token_string_t cmd_mirror_mask_on =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8231 cmd_set_mirror_mask_parsed(void *parsed_result,
8232 __attribute__((unused)) struct cmdline *cl,
8233 __attribute__((unused)) void *data)
8236 struct cmd_set_mirror_mask_result *res = parsed_result;
8237 struct rte_eth_mirror_conf mr_conf;
8239 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8241 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8243 mr_conf.dst_pool = res->dstpool_id;
8245 if (!strcmp(res->what, "pool-mirror-up")) {
8246 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8247 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8248 } else if (!strcmp(res->what, "pool-mirror-down")) {
8249 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8250 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8251 } else if (!strcmp(res->what, "vlan-mirror")) {
8252 mr_conf.rule_type = ETH_MIRROR_VLAN;
8253 nb_item = parse_item_list(res->value, "vlan",
8254 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8258 for (i = 0; i < nb_item; i++) {
8259 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8260 printf("Invalid vlan_id: must be < 4096\n");
8264 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8265 mr_conf.vlan.vlan_mask |= 1ULL << i;
8269 if (!strcmp(res->on, "on"))
8270 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8273 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8276 printf("mirror rule add error: (%s)\n", strerror(-ret));
8279 cmdline_parse_inst_t cmd_set_mirror_mask = {
8280 .f = cmd_set_mirror_mask_parsed,
8282 .help_str = "set port <port_id> mirror-rule <rule_id> "
8283 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8284 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8286 (void *)&cmd_mirror_mask_set,
8287 (void *)&cmd_mirror_mask_port,
8288 (void *)&cmd_mirror_mask_portid,
8289 (void *)&cmd_mirror_mask_mirror,
8290 (void *)&cmd_mirror_mask_ruleid,
8291 (void *)&cmd_mirror_mask_what,
8292 (void *)&cmd_mirror_mask_value,
8293 (void *)&cmd_mirror_mask_dstpool,
8294 (void *)&cmd_mirror_mask_poolid,
8295 (void *)&cmd_mirror_mask_on,
8300 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8301 struct cmd_set_mirror_link_result {
8302 cmdline_fixed_string_t set;
8303 cmdline_fixed_string_t port;
8305 cmdline_fixed_string_t mirror;
8307 cmdline_fixed_string_t what;
8308 cmdline_fixed_string_t dstpool;
8310 cmdline_fixed_string_t on;
8313 cmdline_parse_token_string_t cmd_mirror_link_set =
8314 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8316 cmdline_parse_token_string_t cmd_mirror_link_port =
8317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8319 cmdline_parse_token_num_t cmd_mirror_link_portid =
8320 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8322 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8324 mirror, "mirror-rule");
8325 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8326 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8328 cmdline_parse_token_string_t cmd_mirror_link_what =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8330 what, "uplink-mirror#downlink-mirror");
8331 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8333 dstpool, "dst-pool");
8334 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8335 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8337 cmdline_parse_token_string_t cmd_mirror_link_on =
8338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8342 cmd_set_mirror_link_parsed(void *parsed_result,
8343 __attribute__((unused)) struct cmdline *cl,
8344 __attribute__((unused)) void *data)
8347 struct cmd_set_mirror_link_result *res = parsed_result;
8348 struct rte_eth_mirror_conf mr_conf;
8350 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8351 if (!strcmp(res->what, "uplink-mirror"))
8352 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8354 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8356 mr_conf.dst_pool = res->dstpool_id;
8358 if (!strcmp(res->on, "on"))
8359 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8362 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8365 /* check the return value and print it if is < 0 */
8367 printf("mirror rule add error: (%s)\n", strerror(-ret));
8371 cmdline_parse_inst_t cmd_set_mirror_link = {
8372 .f = cmd_set_mirror_link_parsed,
8374 .help_str = "set port <port_id> mirror-rule <rule_id> "
8375 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8377 (void *)&cmd_mirror_link_set,
8378 (void *)&cmd_mirror_link_port,
8379 (void *)&cmd_mirror_link_portid,
8380 (void *)&cmd_mirror_link_mirror,
8381 (void *)&cmd_mirror_link_ruleid,
8382 (void *)&cmd_mirror_link_what,
8383 (void *)&cmd_mirror_link_dstpool,
8384 (void *)&cmd_mirror_link_poolid,
8385 (void *)&cmd_mirror_link_on,
8390 /* *** RESET VM MIRROR RULE *** */
8391 struct cmd_rm_mirror_rule_result {
8392 cmdline_fixed_string_t reset;
8393 cmdline_fixed_string_t port;
8395 cmdline_fixed_string_t mirror;
8399 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8400 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8402 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8403 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8405 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8406 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8408 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8409 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8410 mirror, "mirror-rule");
8411 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8412 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8416 cmd_reset_mirror_rule_parsed(void *parsed_result,
8417 __attribute__((unused)) struct cmdline *cl,
8418 __attribute__((unused)) void *data)
8421 struct cmd_set_mirror_link_result *res = parsed_result;
8423 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8425 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8428 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8429 .f = cmd_reset_mirror_rule_parsed,
8431 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8433 (void *)&cmd_rm_mirror_rule_reset,
8434 (void *)&cmd_rm_mirror_rule_port,
8435 (void *)&cmd_rm_mirror_rule_portid,
8436 (void *)&cmd_rm_mirror_rule_mirror,
8437 (void *)&cmd_rm_mirror_rule_ruleid,
8442 /* ******************************************************************************** */
8444 struct cmd_dump_result {
8445 cmdline_fixed_string_t dump;
8449 dump_struct_sizes(void)
8451 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8452 DUMP_SIZE(struct rte_mbuf);
8453 DUMP_SIZE(struct rte_mempool);
8454 DUMP_SIZE(struct rte_ring);
8458 static void cmd_dump_parsed(void *parsed_result,
8459 __attribute__((unused)) struct cmdline *cl,
8460 __attribute__((unused)) void *data)
8462 struct cmd_dump_result *res = parsed_result;
8464 if (!strcmp(res->dump, "dump_physmem"))
8465 rte_dump_physmem_layout(stdout);
8466 else if (!strcmp(res->dump, "dump_memzone"))
8467 rte_memzone_dump(stdout);
8468 else if (!strcmp(res->dump, "dump_struct_sizes"))
8469 dump_struct_sizes();
8470 else if (!strcmp(res->dump, "dump_ring"))
8471 rte_ring_list_dump(stdout);
8472 else if (!strcmp(res->dump, "dump_mempool"))
8473 rte_mempool_list_dump(stdout);
8474 else if (!strcmp(res->dump, "dump_devargs"))
8475 rte_eal_devargs_dump(stdout);
8476 else if (!strcmp(res->dump, "dump_log_types"))
8477 rte_log_dump(stdout);
8480 cmdline_parse_token_string_t cmd_dump_dump =
8481 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8484 "dump_struct_sizes#"
8490 cmdline_parse_inst_t cmd_dump = {
8491 .f = cmd_dump_parsed, /* function to call */
8492 .data = NULL, /* 2nd arg of func */
8493 .help_str = "Dump status",
8494 .tokens = { /* token list, NULL terminated */
8495 (void *)&cmd_dump_dump,
8500 /* ******************************************************************************** */
8502 struct cmd_dump_one_result {
8503 cmdline_fixed_string_t dump;
8504 cmdline_fixed_string_t name;
8507 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8508 __attribute__((unused)) void *data)
8510 struct cmd_dump_one_result *res = parsed_result;
8512 if (!strcmp(res->dump, "dump_ring")) {
8514 r = rte_ring_lookup(res->name);
8516 cmdline_printf(cl, "Cannot find ring\n");
8519 rte_ring_dump(stdout, r);
8520 } else if (!strcmp(res->dump, "dump_mempool")) {
8521 struct rte_mempool *mp;
8522 mp = rte_mempool_lookup(res->name);
8524 cmdline_printf(cl, "Cannot find mempool\n");
8527 rte_mempool_dump(stdout, mp);
8531 cmdline_parse_token_string_t cmd_dump_one_dump =
8532 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8533 "dump_ring#dump_mempool");
8535 cmdline_parse_token_string_t cmd_dump_one_name =
8536 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8538 cmdline_parse_inst_t cmd_dump_one = {
8539 .f = cmd_dump_one_parsed, /* function to call */
8540 .data = NULL, /* 2nd arg of func */
8541 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8542 .tokens = { /* token list, NULL terminated */
8543 (void *)&cmd_dump_one_dump,
8544 (void *)&cmd_dump_one_name,
8549 /* *** Add/Del syn filter *** */
8550 struct cmd_syn_filter_result {
8551 cmdline_fixed_string_t filter;
8553 cmdline_fixed_string_t ops;
8554 cmdline_fixed_string_t priority;
8555 cmdline_fixed_string_t high;
8556 cmdline_fixed_string_t queue;
8561 cmd_syn_filter_parsed(void *parsed_result,
8562 __attribute__((unused)) struct cmdline *cl,
8563 __attribute__((unused)) void *data)
8565 struct cmd_syn_filter_result *res = parsed_result;
8566 struct rte_eth_syn_filter syn_filter;
8569 ret = rte_eth_dev_filter_supported(res->port_id,
8570 RTE_ETH_FILTER_SYN);
8572 printf("syn filter is not supported on port %u.\n",
8577 memset(&syn_filter, 0, sizeof(syn_filter));
8579 if (!strcmp(res->ops, "add")) {
8580 if (!strcmp(res->high, "high"))
8581 syn_filter.hig_pri = 1;
8583 syn_filter.hig_pri = 0;
8585 syn_filter.queue = res->queue_id;
8586 ret = rte_eth_dev_filter_ctrl(res->port_id,
8591 ret = rte_eth_dev_filter_ctrl(res->port_id,
8593 RTE_ETH_FILTER_DELETE,
8597 printf("syn filter programming error: (%s)\n",
8601 cmdline_parse_token_string_t cmd_syn_filter_filter =
8602 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8603 filter, "syn_filter");
8604 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8605 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8607 cmdline_parse_token_string_t cmd_syn_filter_ops =
8608 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8610 cmdline_parse_token_string_t cmd_syn_filter_priority =
8611 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8612 priority, "priority");
8613 cmdline_parse_token_string_t cmd_syn_filter_high =
8614 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8616 cmdline_parse_token_string_t cmd_syn_filter_queue =
8617 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8619 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8620 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8623 cmdline_parse_inst_t cmd_syn_filter = {
8624 .f = cmd_syn_filter_parsed,
8626 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8627 "<queue_id>: Add/Delete syn filter",
8629 (void *)&cmd_syn_filter_filter,
8630 (void *)&cmd_syn_filter_port_id,
8631 (void *)&cmd_syn_filter_ops,
8632 (void *)&cmd_syn_filter_priority,
8633 (void *)&cmd_syn_filter_high,
8634 (void *)&cmd_syn_filter_queue,
8635 (void *)&cmd_syn_filter_queue_id,
8640 /* *** queue region set *** */
8641 struct cmd_queue_region_result {
8642 cmdline_fixed_string_t set;
8643 cmdline_fixed_string_t port;
8645 cmdline_fixed_string_t cmd;
8646 cmdline_fixed_string_t region;
8648 cmdline_fixed_string_t queue_start_index;
8650 cmdline_fixed_string_t queue_num;
8651 uint8_t queue_num_value;
8655 cmd_queue_region_parsed(void *parsed_result,
8656 __attribute__((unused)) struct cmdline *cl,
8657 __attribute__((unused)) void *data)
8659 struct cmd_queue_region_result *res = parsed_result;
8661 #ifdef RTE_LIBRTE_I40E_PMD
8662 struct rte_pmd_i40e_queue_region_conf region_conf;
8663 enum rte_pmd_i40e_queue_region_op op_type;
8666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8669 #ifdef RTE_LIBRTE_I40E_PMD
8670 memset(®ion_conf, 0, sizeof(region_conf));
8671 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8672 region_conf.region_id = res->region_id;
8673 region_conf.queue_num = res->queue_num_value;
8674 region_conf.queue_start_index = res->queue_id;
8676 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8677 op_type, ®ion_conf);
8684 printf("function not implemented or supported\n");
8687 printf("queue region config error: (%s)\n", strerror(-ret));
8691 cmdline_parse_token_string_t cmd_queue_region_set =
8692 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8694 cmdline_parse_token_string_t cmd_queue_region_port =
8695 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8696 cmdline_parse_token_num_t cmd_queue_region_port_id =
8697 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8699 cmdline_parse_token_string_t cmd_queue_region_cmd =
8700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8701 cmd, "queue-region");
8702 cmdline_parse_token_string_t cmd_queue_region_id =
8703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8704 region, "region_id");
8705 cmdline_parse_token_num_t cmd_queue_region_index =
8706 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8708 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8709 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8710 queue_start_index, "queue_start_index");
8711 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8712 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8714 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8716 queue_num, "queue_num");
8717 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8719 queue_num_value, UINT8);
8721 cmdline_parse_inst_t cmd_queue_region = {
8722 .f = cmd_queue_region_parsed,
8724 .help_str = "set port <port_id> queue-region region_id <value> "
8725 "queue_start_index <value> queue_num <value>: Set a queue region",
8727 (void *)&cmd_queue_region_set,
8728 (void *)&cmd_queue_region_port,
8729 (void *)&cmd_queue_region_port_id,
8730 (void *)&cmd_queue_region_cmd,
8731 (void *)&cmd_queue_region_id,
8732 (void *)&cmd_queue_region_index,
8733 (void *)&cmd_queue_region_queue_start_index,
8734 (void *)&cmd_queue_region_queue_id,
8735 (void *)&cmd_queue_region_queue_num,
8736 (void *)&cmd_queue_region_queue_num_value,
8741 /* *** queue region and flowtype set *** */
8742 struct cmd_region_flowtype_result {
8743 cmdline_fixed_string_t set;
8744 cmdline_fixed_string_t port;
8746 cmdline_fixed_string_t cmd;
8747 cmdline_fixed_string_t region;
8749 cmdline_fixed_string_t flowtype;
8750 uint8_t flowtype_id;
8754 cmd_region_flowtype_parsed(void *parsed_result,
8755 __attribute__((unused)) struct cmdline *cl,
8756 __attribute__((unused)) void *data)
8758 struct cmd_region_flowtype_result *res = parsed_result;
8760 #ifdef RTE_LIBRTE_I40E_PMD
8761 struct rte_pmd_i40e_queue_region_conf region_conf;
8762 enum rte_pmd_i40e_queue_region_op op_type;
8765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8768 #ifdef RTE_LIBRTE_I40E_PMD
8769 memset(®ion_conf, 0, sizeof(region_conf));
8771 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8772 region_conf.region_id = res->region_id;
8773 region_conf.hw_flowtype = res->flowtype_id;
8775 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8776 op_type, ®ion_conf);
8783 printf("function not implemented or supported\n");
8786 printf("region flowtype config error: (%s)\n", strerror(-ret));
8790 cmdline_parse_token_string_t cmd_region_flowtype_set =
8791 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8793 cmdline_parse_token_string_t cmd_region_flowtype_port =
8794 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8796 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8797 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8799 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8800 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8801 cmd, "queue-region");
8802 cmdline_parse_token_string_t cmd_region_flowtype_index =
8803 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8804 region, "region_id");
8805 cmdline_parse_token_num_t cmd_region_flowtype_id =
8806 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8808 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8809 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8810 flowtype, "flowtype");
8811 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8812 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8813 flowtype_id, UINT8);
8814 cmdline_parse_inst_t cmd_region_flowtype = {
8815 .f = cmd_region_flowtype_parsed,
8817 .help_str = "set port <port_id> queue-region region_id <value> "
8818 "flowtype <value>: Set a flowtype region index",
8820 (void *)&cmd_region_flowtype_set,
8821 (void *)&cmd_region_flowtype_port,
8822 (void *)&cmd_region_flowtype_port_index,
8823 (void *)&cmd_region_flowtype_cmd,
8824 (void *)&cmd_region_flowtype_index,
8825 (void *)&cmd_region_flowtype_id,
8826 (void *)&cmd_region_flowtype_flow_index,
8827 (void *)&cmd_region_flowtype_flow_id,
8832 /* *** User Priority (UP) to queue region (region_id) set *** */
8833 struct cmd_user_priority_region_result {
8834 cmdline_fixed_string_t set;
8835 cmdline_fixed_string_t port;
8837 cmdline_fixed_string_t cmd;
8838 cmdline_fixed_string_t user_priority;
8839 uint8_t user_priority_id;
8840 cmdline_fixed_string_t region;
8845 cmd_user_priority_region_parsed(void *parsed_result,
8846 __attribute__((unused)) struct cmdline *cl,
8847 __attribute__((unused)) void *data)
8849 struct cmd_user_priority_region_result *res = parsed_result;
8851 #ifdef RTE_LIBRTE_I40E_PMD
8852 struct rte_pmd_i40e_queue_region_conf region_conf;
8853 enum rte_pmd_i40e_queue_region_op op_type;
8856 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8859 #ifdef RTE_LIBRTE_I40E_PMD
8860 memset(®ion_conf, 0, sizeof(region_conf));
8861 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8862 region_conf.user_priority = res->user_priority_id;
8863 region_conf.region_id = res->region_id;
8865 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8866 op_type, ®ion_conf);
8873 printf("function not implemented or supported\n");
8876 printf("user_priority region config error: (%s)\n",
8881 cmdline_parse_token_string_t cmd_user_priority_region_set =
8882 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8884 cmdline_parse_token_string_t cmd_user_priority_region_port =
8885 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8887 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8888 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8890 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8891 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8892 cmd, "queue-region");
8893 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8894 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8895 user_priority, "UP");
8896 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8897 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8898 user_priority_id, UINT8);
8899 cmdline_parse_token_string_t cmd_user_priority_region_region =
8900 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8901 region, "region_id");
8902 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8903 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8906 cmdline_parse_inst_t cmd_user_priority_region = {
8907 .f = cmd_user_priority_region_parsed,
8909 .help_str = "set port <port_id> queue-region UP <value> "
8910 "region_id <value>: Set the mapping of User Priority (UP) "
8911 "to queue region (region_id) ",
8913 (void *)&cmd_user_priority_region_set,
8914 (void *)&cmd_user_priority_region_port,
8915 (void *)&cmd_user_priority_region_port_index,
8916 (void *)&cmd_user_priority_region_cmd,
8917 (void *)&cmd_user_priority_region_UP,
8918 (void *)&cmd_user_priority_region_UP_id,
8919 (void *)&cmd_user_priority_region_region,
8920 (void *)&cmd_user_priority_region_region_id,
8925 /* *** flush all queue region related configuration *** */
8926 struct cmd_flush_queue_region_result {
8927 cmdline_fixed_string_t set;
8928 cmdline_fixed_string_t port;
8930 cmdline_fixed_string_t cmd;
8931 cmdline_fixed_string_t flush;
8932 cmdline_fixed_string_t what;
8936 cmd_flush_queue_region_parsed(void *parsed_result,
8937 __attribute__((unused)) struct cmdline *cl,
8938 __attribute__((unused)) void *data)
8940 struct cmd_flush_queue_region_result *res = parsed_result;
8942 #ifdef RTE_LIBRTE_I40E_PMD
8943 struct rte_pmd_i40e_queue_region_conf region_conf;
8944 enum rte_pmd_i40e_queue_region_op op_type;
8947 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8950 #ifdef RTE_LIBRTE_I40E_PMD
8951 memset(®ion_conf, 0, sizeof(region_conf));
8953 if (strcmp(res->what, "on") == 0)
8954 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8956 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8958 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8959 op_type, ®ion_conf);
8966 printf("function not implemented or supported\n");
8969 printf("queue region config flush error: (%s)\n",
8974 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8975 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8977 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8978 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8980 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8981 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8983 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8984 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8985 cmd, "queue-region");
8986 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8987 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8989 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8990 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8993 cmdline_parse_inst_t cmd_flush_queue_region = {
8994 .f = cmd_flush_queue_region_parsed,
8996 .help_str = "set port <port_id> queue-region flush on|off"
8997 ": flush all queue region related configuration",
8999 (void *)&cmd_flush_queue_region_set,
9000 (void *)&cmd_flush_queue_region_port,
9001 (void *)&cmd_flush_queue_region_port_index,
9002 (void *)&cmd_flush_queue_region_cmd,
9003 (void *)&cmd_flush_queue_region_flush,
9004 (void *)&cmd_flush_queue_region_what,
9009 /* *** get all queue region related configuration info *** */
9010 struct cmd_show_queue_region_info {
9011 cmdline_fixed_string_t show;
9012 cmdline_fixed_string_t port;
9014 cmdline_fixed_string_t cmd;
9018 cmd_show_queue_region_info_parsed(void *parsed_result,
9019 __attribute__((unused)) struct cmdline *cl,
9020 __attribute__((unused)) void *data)
9022 struct cmd_show_queue_region_info *res = parsed_result;
9024 #ifdef RTE_LIBRTE_I40E_PMD
9025 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9026 enum rte_pmd_i40e_queue_region_op op_type;
9029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9032 #ifdef RTE_LIBRTE_I40E_PMD
9033 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9035 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9037 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9038 op_type, &rte_pmd_regions);
9040 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9047 printf("function not implemented or supported\n");
9050 printf("queue region config info show error: (%s)\n",
9055 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9056 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9058 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9059 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9061 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9062 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9064 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9065 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9066 cmd, "queue-region");
9068 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9069 .f = cmd_show_queue_region_info_parsed,
9071 .help_str = "show port <port_id> queue-region"
9072 ": show all queue region related configuration info",
9074 (void *)&cmd_show_queue_region_info_get,
9075 (void *)&cmd_show_queue_region_info_port,
9076 (void *)&cmd_show_queue_region_info_port_index,
9077 (void *)&cmd_show_queue_region_info_cmd,
9082 /* *** ADD/REMOVE A 2tuple FILTER *** */
9083 struct cmd_2tuple_filter_result {
9084 cmdline_fixed_string_t filter;
9086 cmdline_fixed_string_t ops;
9087 cmdline_fixed_string_t dst_port;
9088 uint16_t dst_port_value;
9089 cmdline_fixed_string_t protocol;
9090 uint8_t protocol_value;
9091 cmdline_fixed_string_t mask;
9093 cmdline_fixed_string_t tcp_flags;
9094 uint8_t tcp_flags_value;
9095 cmdline_fixed_string_t priority;
9096 uint8_t priority_value;
9097 cmdline_fixed_string_t queue;
9102 cmd_2tuple_filter_parsed(void *parsed_result,
9103 __attribute__((unused)) struct cmdline *cl,
9104 __attribute__((unused)) void *data)
9106 struct rte_eth_ntuple_filter filter;
9107 struct cmd_2tuple_filter_result *res = parsed_result;
9110 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9112 printf("ntuple filter is not supported on port %u.\n",
9117 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9119 filter.flags = RTE_2TUPLE_FLAGS;
9120 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9121 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9122 filter.proto = res->protocol_value;
9123 filter.priority = res->priority_value;
9124 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9125 printf("nonzero tcp_flags is only meaningful"
9126 " when protocol is TCP.\n");
9129 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9130 printf("invalid TCP flags.\n");
9134 if (res->tcp_flags_value != 0) {
9135 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9136 filter.tcp_flags = res->tcp_flags_value;
9139 /* need convert to big endian. */
9140 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9141 filter.queue = res->queue_id;
9143 if (!strcmp(res->ops, "add"))
9144 ret = rte_eth_dev_filter_ctrl(res->port_id,
9145 RTE_ETH_FILTER_NTUPLE,
9149 ret = rte_eth_dev_filter_ctrl(res->port_id,
9150 RTE_ETH_FILTER_NTUPLE,
9151 RTE_ETH_FILTER_DELETE,
9154 printf("2tuple filter programming error: (%s)\n",
9159 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9160 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9161 filter, "2tuple_filter");
9162 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9163 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9165 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9166 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9168 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9169 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9170 dst_port, "dst_port");
9171 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9172 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9173 dst_port_value, UINT16);
9174 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9175 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9176 protocol, "protocol");
9177 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9178 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9179 protocol_value, UINT8);
9180 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9181 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9183 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9184 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9186 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9188 tcp_flags, "tcp_flags");
9189 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9191 tcp_flags_value, UINT8);
9192 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9194 priority, "priority");
9195 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9196 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9197 priority_value, UINT8);
9198 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9199 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9201 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9205 cmdline_parse_inst_t cmd_2tuple_filter = {
9206 .f = cmd_2tuple_filter_parsed,
9208 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9209 "<value> mask <value> tcp_flags <value> priority <value> queue "
9210 "<queue_id>: Add a 2tuple filter",
9212 (void *)&cmd_2tuple_filter_filter,
9213 (void *)&cmd_2tuple_filter_port_id,
9214 (void *)&cmd_2tuple_filter_ops,
9215 (void *)&cmd_2tuple_filter_dst_port,
9216 (void *)&cmd_2tuple_filter_dst_port_value,
9217 (void *)&cmd_2tuple_filter_protocol,
9218 (void *)&cmd_2tuple_filter_protocol_value,
9219 (void *)&cmd_2tuple_filter_mask,
9220 (void *)&cmd_2tuple_filter_mask_value,
9221 (void *)&cmd_2tuple_filter_tcp_flags,
9222 (void *)&cmd_2tuple_filter_tcp_flags_value,
9223 (void *)&cmd_2tuple_filter_priority,
9224 (void *)&cmd_2tuple_filter_priority_value,
9225 (void *)&cmd_2tuple_filter_queue,
9226 (void *)&cmd_2tuple_filter_queue_id,
9231 /* *** ADD/REMOVE A 5tuple FILTER *** */
9232 struct cmd_5tuple_filter_result {
9233 cmdline_fixed_string_t filter;
9235 cmdline_fixed_string_t ops;
9236 cmdline_fixed_string_t dst_ip;
9237 cmdline_ipaddr_t dst_ip_value;
9238 cmdline_fixed_string_t src_ip;
9239 cmdline_ipaddr_t src_ip_value;
9240 cmdline_fixed_string_t dst_port;
9241 uint16_t dst_port_value;
9242 cmdline_fixed_string_t src_port;
9243 uint16_t src_port_value;
9244 cmdline_fixed_string_t protocol;
9245 uint8_t protocol_value;
9246 cmdline_fixed_string_t mask;
9248 cmdline_fixed_string_t tcp_flags;
9249 uint8_t tcp_flags_value;
9250 cmdline_fixed_string_t priority;
9251 uint8_t priority_value;
9252 cmdline_fixed_string_t queue;
9257 cmd_5tuple_filter_parsed(void *parsed_result,
9258 __attribute__((unused)) struct cmdline *cl,
9259 __attribute__((unused)) void *data)
9261 struct rte_eth_ntuple_filter filter;
9262 struct cmd_5tuple_filter_result *res = parsed_result;
9265 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9267 printf("ntuple filter is not supported on port %u.\n",
9272 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9274 filter.flags = RTE_5TUPLE_FLAGS;
9275 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9276 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9277 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9278 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9279 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9280 filter.proto = res->protocol_value;
9281 filter.priority = res->priority_value;
9282 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9283 printf("nonzero tcp_flags is only meaningful"
9284 " when protocol is TCP.\n");
9287 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9288 printf("invalid TCP flags.\n");
9292 if (res->tcp_flags_value != 0) {
9293 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9294 filter.tcp_flags = res->tcp_flags_value;
9297 if (res->dst_ip_value.family == AF_INET)
9298 /* no need to convert, already big endian. */
9299 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9301 if (filter.dst_ip_mask == 0) {
9302 printf("can not support ipv6 involved compare.\n");
9308 if (res->src_ip_value.family == AF_INET)
9309 /* no need to convert, already big endian. */
9310 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9312 if (filter.src_ip_mask == 0) {
9313 printf("can not support ipv6 involved compare.\n");
9318 /* need convert to big endian. */
9319 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9320 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9321 filter.queue = res->queue_id;
9323 if (!strcmp(res->ops, "add"))
9324 ret = rte_eth_dev_filter_ctrl(res->port_id,
9325 RTE_ETH_FILTER_NTUPLE,
9329 ret = rte_eth_dev_filter_ctrl(res->port_id,
9330 RTE_ETH_FILTER_NTUPLE,
9331 RTE_ETH_FILTER_DELETE,
9334 printf("5tuple filter programming error: (%s)\n",
9338 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9339 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9340 filter, "5tuple_filter");
9341 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9342 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9344 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9345 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9347 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9348 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9350 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9351 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9353 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9354 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9356 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9357 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9359 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9360 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9361 dst_port, "dst_port");
9362 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9363 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9364 dst_port_value, UINT16);
9365 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9367 src_port, "src_port");
9368 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9369 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9370 src_port_value, UINT16);
9371 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9373 protocol, "protocol");
9374 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9375 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9376 protocol_value, UINT8);
9377 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9380 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9381 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9383 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9385 tcp_flags, "tcp_flags");
9386 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9388 tcp_flags_value, UINT8);
9389 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9391 priority, "priority");
9392 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9394 priority_value, UINT8);
9395 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9398 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9399 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9402 cmdline_parse_inst_t cmd_5tuple_filter = {
9403 .f = cmd_5tuple_filter_parsed,
9405 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9406 "src_ip <value> dst_port <value> src_port <value> "
9407 "protocol <value> mask <value> tcp_flags <value> "
9408 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9410 (void *)&cmd_5tuple_filter_filter,
9411 (void *)&cmd_5tuple_filter_port_id,
9412 (void *)&cmd_5tuple_filter_ops,
9413 (void *)&cmd_5tuple_filter_dst_ip,
9414 (void *)&cmd_5tuple_filter_dst_ip_value,
9415 (void *)&cmd_5tuple_filter_src_ip,
9416 (void *)&cmd_5tuple_filter_src_ip_value,
9417 (void *)&cmd_5tuple_filter_dst_port,
9418 (void *)&cmd_5tuple_filter_dst_port_value,
9419 (void *)&cmd_5tuple_filter_src_port,
9420 (void *)&cmd_5tuple_filter_src_port_value,
9421 (void *)&cmd_5tuple_filter_protocol,
9422 (void *)&cmd_5tuple_filter_protocol_value,
9423 (void *)&cmd_5tuple_filter_mask,
9424 (void *)&cmd_5tuple_filter_mask_value,
9425 (void *)&cmd_5tuple_filter_tcp_flags,
9426 (void *)&cmd_5tuple_filter_tcp_flags_value,
9427 (void *)&cmd_5tuple_filter_priority,
9428 (void *)&cmd_5tuple_filter_priority_value,
9429 (void *)&cmd_5tuple_filter_queue,
9430 (void *)&cmd_5tuple_filter_queue_id,
9435 /* *** ADD/REMOVE A flex FILTER *** */
9436 struct cmd_flex_filter_result {
9437 cmdline_fixed_string_t filter;
9438 cmdline_fixed_string_t ops;
9440 cmdline_fixed_string_t len;
9442 cmdline_fixed_string_t bytes;
9443 cmdline_fixed_string_t bytes_value;
9444 cmdline_fixed_string_t mask;
9445 cmdline_fixed_string_t mask_value;
9446 cmdline_fixed_string_t priority;
9447 uint8_t priority_value;
9448 cmdline_fixed_string_t queue;
9452 static int xdigit2val(unsigned char c)
9457 else if (isupper(c))
9465 cmd_flex_filter_parsed(void *parsed_result,
9466 __attribute__((unused)) struct cmdline *cl,
9467 __attribute__((unused)) void *data)
9470 struct rte_eth_flex_filter filter;
9471 struct cmd_flex_filter_result *res = parsed_result;
9472 char *bytes_ptr, *mask_ptr;
9473 uint16_t len, i, j = 0;
9478 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9479 printf("the len exceed the max length 128\n");
9482 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9483 filter.len = res->len_value;
9484 filter.priority = res->priority_value;
9485 filter.queue = res->queue_id;
9486 bytes_ptr = res->bytes_value;
9487 mask_ptr = res->mask_value;
9489 /* translate bytes string to array. */
9490 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9491 (bytes_ptr[1] == 'X')))
9493 len = strnlen(bytes_ptr, res->len_value * 2);
9494 if (len == 0 || (len % 8 != 0)) {
9495 printf("please check len and bytes input\n");
9498 for (i = 0; i < len; i++) {
9500 if (isxdigit(c) == 0) {
9501 /* invalid characters. */
9502 printf("invalid input\n");
9505 val = xdigit2val(c);
9508 filter.bytes[j] = byte;
9509 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9516 /* translate mask string to uint8_t array. */
9517 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9518 (mask_ptr[1] == 'X')))
9520 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9522 printf("invalid input\n");
9527 for (i = 0; i < len; i++) {
9529 if (isxdigit(c) == 0) {
9530 /* invalid characters. */
9531 printf("invalid input\n");
9534 val = xdigit2val(c);
9537 filter.mask[j] = byte;
9538 printf("mask[%d]:%02x ", j, filter.mask[j]);
9546 if (!strcmp(res->ops, "add"))
9547 ret = rte_eth_dev_filter_ctrl(res->port_id,
9548 RTE_ETH_FILTER_FLEXIBLE,
9552 ret = rte_eth_dev_filter_ctrl(res->port_id,
9553 RTE_ETH_FILTER_FLEXIBLE,
9554 RTE_ETH_FILTER_DELETE,
9558 printf("flex filter setting error: (%s)\n", strerror(-ret));
9561 cmdline_parse_token_string_t cmd_flex_filter_filter =
9562 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9563 filter, "flex_filter");
9564 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9565 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9567 cmdline_parse_token_string_t cmd_flex_filter_ops =
9568 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9570 cmdline_parse_token_string_t cmd_flex_filter_len =
9571 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9573 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9574 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9576 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9577 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9579 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9580 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9582 cmdline_parse_token_string_t cmd_flex_filter_mask =
9583 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9585 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9586 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9588 cmdline_parse_token_string_t cmd_flex_filter_priority =
9589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9590 priority, "priority");
9591 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9592 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9593 priority_value, UINT8);
9594 cmdline_parse_token_string_t cmd_flex_filter_queue =
9595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9597 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9598 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9600 cmdline_parse_inst_t cmd_flex_filter = {
9601 .f = cmd_flex_filter_parsed,
9603 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9604 "<value> mask <value> priority <value> queue <queue_id>: "
9605 "Add/Del a flex filter",
9607 (void *)&cmd_flex_filter_filter,
9608 (void *)&cmd_flex_filter_port_id,
9609 (void *)&cmd_flex_filter_ops,
9610 (void *)&cmd_flex_filter_len,
9611 (void *)&cmd_flex_filter_len_value,
9612 (void *)&cmd_flex_filter_bytes,
9613 (void *)&cmd_flex_filter_bytes_value,
9614 (void *)&cmd_flex_filter_mask,
9615 (void *)&cmd_flex_filter_mask_value,
9616 (void *)&cmd_flex_filter_priority,
9617 (void *)&cmd_flex_filter_priority_value,
9618 (void *)&cmd_flex_filter_queue,
9619 (void *)&cmd_flex_filter_queue_id,
9624 /* *** Filters Control *** */
9626 /* *** deal with ethertype filter *** */
9627 struct cmd_ethertype_filter_result {
9628 cmdline_fixed_string_t filter;
9630 cmdline_fixed_string_t ops;
9631 cmdline_fixed_string_t mac;
9632 struct ether_addr mac_addr;
9633 cmdline_fixed_string_t ethertype;
9634 uint16_t ethertype_value;
9635 cmdline_fixed_string_t drop;
9636 cmdline_fixed_string_t queue;
9640 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9641 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9642 filter, "ethertype_filter");
9643 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9644 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9646 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9647 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9649 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9650 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9651 mac, "mac_addr#mac_ignr");
9652 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9653 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9655 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9656 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9657 ethertype, "ethertype");
9658 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9659 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9660 ethertype_value, UINT16);
9661 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9662 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9664 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9665 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9667 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9668 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9672 cmd_ethertype_filter_parsed(void *parsed_result,
9673 __attribute__((unused)) struct cmdline *cl,
9674 __attribute__((unused)) void *data)
9676 struct cmd_ethertype_filter_result *res = parsed_result;
9677 struct rte_eth_ethertype_filter filter;
9680 ret = rte_eth_dev_filter_supported(res->port_id,
9681 RTE_ETH_FILTER_ETHERTYPE);
9683 printf("ethertype filter is not supported on port %u.\n",
9688 memset(&filter, 0, sizeof(filter));
9689 if (!strcmp(res->mac, "mac_addr")) {
9690 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9691 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9692 sizeof(struct ether_addr));
9694 if (!strcmp(res->drop, "drop"))
9695 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9696 filter.ether_type = res->ethertype_value;
9697 filter.queue = res->queue_id;
9699 if (!strcmp(res->ops, "add"))
9700 ret = rte_eth_dev_filter_ctrl(res->port_id,
9701 RTE_ETH_FILTER_ETHERTYPE,
9705 ret = rte_eth_dev_filter_ctrl(res->port_id,
9706 RTE_ETH_FILTER_ETHERTYPE,
9707 RTE_ETH_FILTER_DELETE,
9710 printf("ethertype filter programming error: (%s)\n",
9714 cmdline_parse_inst_t cmd_ethertype_filter = {
9715 .f = cmd_ethertype_filter_parsed,
9717 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9718 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9719 "Add or delete an ethertype filter entry",
9721 (void *)&cmd_ethertype_filter_filter,
9722 (void *)&cmd_ethertype_filter_port_id,
9723 (void *)&cmd_ethertype_filter_ops,
9724 (void *)&cmd_ethertype_filter_mac,
9725 (void *)&cmd_ethertype_filter_mac_addr,
9726 (void *)&cmd_ethertype_filter_ethertype,
9727 (void *)&cmd_ethertype_filter_ethertype_value,
9728 (void *)&cmd_ethertype_filter_drop,
9729 (void *)&cmd_ethertype_filter_queue,
9730 (void *)&cmd_ethertype_filter_queue_id,
9735 /* *** deal with flow director filter *** */
9736 struct cmd_flow_director_result {
9737 cmdline_fixed_string_t flow_director_filter;
9739 cmdline_fixed_string_t mode;
9740 cmdline_fixed_string_t mode_value;
9741 cmdline_fixed_string_t ops;
9742 cmdline_fixed_string_t flow;
9743 cmdline_fixed_string_t flow_type;
9744 cmdline_fixed_string_t ether;
9745 uint16_t ether_type;
9746 cmdline_fixed_string_t src;
9747 cmdline_ipaddr_t ip_src;
9749 cmdline_fixed_string_t dst;
9750 cmdline_ipaddr_t ip_dst;
9752 cmdline_fixed_string_t verify_tag;
9753 uint32_t verify_tag_value;
9754 cmdline_fixed_string_t tos;
9756 cmdline_fixed_string_t proto;
9757 uint8_t proto_value;
9758 cmdline_fixed_string_t ttl;
9760 cmdline_fixed_string_t vlan;
9761 uint16_t vlan_value;
9762 cmdline_fixed_string_t flexbytes;
9763 cmdline_fixed_string_t flexbytes_value;
9764 cmdline_fixed_string_t pf_vf;
9765 cmdline_fixed_string_t drop;
9766 cmdline_fixed_string_t queue;
9768 cmdline_fixed_string_t fd_id;
9769 uint32_t fd_id_value;
9770 cmdline_fixed_string_t mac;
9771 struct ether_addr mac_addr;
9772 cmdline_fixed_string_t tunnel;
9773 cmdline_fixed_string_t tunnel_type;
9774 cmdline_fixed_string_t tunnel_id;
9775 uint32_t tunnel_id_value;
9779 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9782 const char *p, *p0 = q_arg;
9784 unsigned long int_fld;
9785 char *str_fld[max_num];
9790 p = strchr(p0, '(');
9794 p0 = strchr(p, ')');
9799 if (size >= sizeof(s))
9802 snprintf(s, sizeof(s), "%.*s", size, p);
9803 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9804 if (ret < 0 || ret > max_num)
9806 for (i = 0; i < ret; i++) {
9808 int_fld = strtoul(str_fld[i], &end, 0);
9809 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9811 flexbytes[i] = (uint8_t)int_fld;
9817 str2flowtype(char *string)
9820 static const struct {
9823 } flowtype_str[] = {
9824 {"raw", RTE_ETH_FLOW_RAW},
9825 {"ipv4", RTE_ETH_FLOW_IPV4},
9826 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9827 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9828 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9829 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9830 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9831 {"ipv6", RTE_ETH_FLOW_IPV6},
9832 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9833 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9834 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9835 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9836 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9837 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9840 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9841 if (!strcmp(flowtype_str[i].str, string))
9842 return flowtype_str[i].type;
9845 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9846 return (uint16_t)atoi(string);
9848 return RTE_ETH_FLOW_UNKNOWN;
9851 static enum rte_eth_fdir_tunnel_type
9852 str2fdir_tunneltype(char *string)
9856 static const struct {
9858 enum rte_eth_fdir_tunnel_type type;
9859 } tunneltype_str[] = {
9860 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9861 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9864 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9865 if (!strcmp(tunneltype_str[i].str, string))
9866 return tunneltype_str[i].type;
9868 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9871 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9873 if ((ip_addr).family == AF_INET) \
9874 (ip) = (ip_addr).addr.ipv4.s_addr; \
9876 printf("invalid parameter.\n"); \
9881 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9883 if ((ip_addr).family == AF_INET6) \
9885 &((ip_addr).addr.ipv6), \
9886 sizeof(struct in6_addr)); \
9888 printf("invalid parameter.\n"); \
9894 cmd_flow_director_filter_parsed(void *parsed_result,
9895 __attribute__((unused)) struct cmdline *cl,
9896 __attribute__((unused)) void *data)
9898 struct cmd_flow_director_result *res = parsed_result;
9899 struct rte_eth_fdir_filter entry;
9900 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9902 unsigned long vf_id;
9905 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9907 printf("flow director is not supported on port %u.\n",
9911 memset(flexbytes, 0, sizeof(flexbytes));
9912 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9914 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9915 if (strcmp(res->mode_value, "MAC-VLAN")) {
9916 printf("Please set mode to MAC-VLAN.\n");
9919 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9920 if (strcmp(res->mode_value, "Tunnel")) {
9921 printf("Please set mode to Tunnel.\n");
9925 if (strcmp(res->mode_value, "IP")) {
9926 printf("Please set mode to IP.\n");
9929 entry.input.flow_type = str2flowtype(res->flow_type);
9932 ret = parse_flexbytes(res->flexbytes_value,
9934 RTE_ETH_FDIR_MAX_FLEXLEN);
9936 printf("error: Cannot parse flexbytes input.\n");
9940 switch (entry.input.flow_type) {
9941 case RTE_ETH_FLOW_FRAG_IPV4:
9942 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9943 entry.input.flow.ip4_flow.proto = res->proto_value;
9945 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9946 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9947 IPV4_ADDR_TO_UINT(res->ip_dst,
9948 entry.input.flow.ip4_flow.dst_ip);
9949 IPV4_ADDR_TO_UINT(res->ip_src,
9950 entry.input.flow.ip4_flow.src_ip);
9951 entry.input.flow.ip4_flow.tos = res->tos_value;
9952 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9953 /* need convert to big endian. */
9954 entry.input.flow.udp4_flow.dst_port =
9955 rte_cpu_to_be_16(res->port_dst);
9956 entry.input.flow.udp4_flow.src_port =
9957 rte_cpu_to_be_16(res->port_src);
9959 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9960 IPV4_ADDR_TO_UINT(res->ip_dst,
9961 entry.input.flow.sctp4_flow.ip.dst_ip);
9962 IPV4_ADDR_TO_UINT(res->ip_src,
9963 entry.input.flow.sctp4_flow.ip.src_ip);
9964 entry.input.flow.ip4_flow.tos = res->tos_value;
9965 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9966 /* need convert to big endian. */
9967 entry.input.flow.sctp4_flow.dst_port =
9968 rte_cpu_to_be_16(res->port_dst);
9969 entry.input.flow.sctp4_flow.src_port =
9970 rte_cpu_to_be_16(res->port_src);
9971 entry.input.flow.sctp4_flow.verify_tag =
9972 rte_cpu_to_be_32(res->verify_tag_value);
9974 case RTE_ETH_FLOW_FRAG_IPV6:
9975 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9976 entry.input.flow.ipv6_flow.proto = res->proto_value;
9978 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9979 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9980 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9981 entry.input.flow.ipv6_flow.dst_ip);
9982 IPV6_ADDR_TO_ARRAY(res->ip_src,
9983 entry.input.flow.ipv6_flow.src_ip);
9984 entry.input.flow.ipv6_flow.tc = res->tos_value;
9985 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9986 /* need convert to big endian. */
9987 entry.input.flow.udp6_flow.dst_port =
9988 rte_cpu_to_be_16(res->port_dst);
9989 entry.input.flow.udp6_flow.src_port =
9990 rte_cpu_to_be_16(res->port_src);
9992 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9993 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9994 entry.input.flow.sctp6_flow.ip.dst_ip);
9995 IPV6_ADDR_TO_ARRAY(res->ip_src,
9996 entry.input.flow.sctp6_flow.ip.src_ip);
9997 entry.input.flow.ipv6_flow.tc = res->tos_value;
9998 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9999 /* need convert to big endian. */
10000 entry.input.flow.sctp6_flow.dst_port =
10001 rte_cpu_to_be_16(res->port_dst);
10002 entry.input.flow.sctp6_flow.src_port =
10003 rte_cpu_to_be_16(res->port_src);
10004 entry.input.flow.sctp6_flow.verify_tag =
10005 rte_cpu_to_be_32(res->verify_tag_value);
10007 case RTE_ETH_FLOW_L2_PAYLOAD:
10008 entry.input.flow.l2_flow.ether_type =
10009 rte_cpu_to_be_16(res->ether_type);
10015 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10016 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10018 sizeof(struct ether_addr));
10020 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10021 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10023 sizeof(struct ether_addr));
10024 entry.input.flow.tunnel_flow.tunnel_type =
10025 str2fdir_tunneltype(res->tunnel_type);
10026 entry.input.flow.tunnel_flow.tunnel_id =
10027 rte_cpu_to_be_32(res->tunnel_id_value);
10030 rte_memcpy(entry.input.flow_ext.flexbytes,
10032 RTE_ETH_FDIR_MAX_FLEXLEN);
10034 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10036 entry.action.flex_off = 0; /*use 0 by default */
10037 if (!strcmp(res->drop, "drop"))
10038 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10040 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10042 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10043 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10044 if (!strcmp(res->pf_vf, "pf"))
10045 entry.input.flow_ext.is_vf = 0;
10046 else if (!strncmp(res->pf_vf, "vf", 2)) {
10047 struct rte_eth_dev_info dev_info;
10049 memset(&dev_info, 0, sizeof(dev_info));
10050 rte_eth_dev_info_get(res->port_id, &dev_info);
10052 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10053 if (errno != 0 || *end != '\0' ||
10054 vf_id >= dev_info.max_vfs) {
10055 printf("invalid parameter %s.\n", res->pf_vf);
10058 entry.input.flow_ext.is_vf = 1;
10059 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10061 printf("invalid parameter %s.\n", res->pf_vf);
10066 /* set to report FD ID by default */
10067 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10068 entry.action.rx_queue = res->queue_id;
10069 entry.soft_id = res->fd_id_value;
10070 if (!strcmp(res->ops, "add"))
10071 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10072 RTE_ETH_FILTER_ADD, &entry);
10073 else if (!strcmp(res->ops, "del"))
10074 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10075 RTE_ETH_FILTER_DELETE, &entry);
10077 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10078 RTE_ETH_FILTER_UPDATE, &entry);
10080 printf("flow director programming error: (%s)\n",
10084 cmdline_parse_token_string_t cmd_flow_director_filter =
10085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10086 flow_director_filter, "flow_director_filter");
10087 cmdline_parse_token_num_t cmd_flow_director_port_id =
10088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10090 cmdline_parse_token_string_t cmd_flow_director_ops =
10091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10092 ops, "add#del#update");
10093 cmdline_parse_token_string_t cmd_flow_director_flow =
10094 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10096 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10098 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10099 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10100 cmdline_parse_token_string_t cmd_flow_director_ether =
10101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10103 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10104 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10105 ether_type, UINT16);
10106 cmdline_parse_token_string_t cmd_flow_director_src =
10107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10109 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10110 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10112 cmdline_parse_token_num_t cmd_flow_director_port_src =
10113 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10115 cmdline_parse_token_string_t cmd_flow_director_dst =
10116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10118 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10119 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10121 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10124 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10126 verify_tag, "verify_tag");
10127 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10128 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10129 verify_tag_value, UINT32);
10130 cmdline_parse_token_string_t cmd_flow_director_tos =
10131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10133 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10134 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10136 cmdline_parse_token_string_t cmd_flow_director_proto =
10137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10139 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10140 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10141 proto_value, UINT8);
10142 cmdline_parse_token_string_t cmd_flow_director_ttl =
10143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10145 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10148 cmdline_parse_token_string_t cmd_flow_director_vlan =
10149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10151 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10153 vlan_value, UINT16);
10154 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10156 flexbytes, "flexbytes");
10157 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10159 flexbytes_value, NULL);
10160 cmdline_parse_token_string_t cmd_flow_director_drop =
10161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10163 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10166 cmdline_parse_token_string_t cmd_flow_director_queue =
10167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10169 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10170 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10172 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10175 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10177 fd_id_value, UINT32);
10179 cmdline_parse_token_string_t cmd_flow_director_mode =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10182 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10185 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10187 mode_value, "MAC-VLAN");
10188 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10190 mode_value, "Tunnel");
10191 cmdline_parse_token_string_t cmd_flow_director_mac =
10192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10194 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10197 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10200 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10202 tunnel_type, "NVGRE#VxLAN");
10203 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10205 tunnel_id, "tunnel-id");
10206 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10207 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10208 tunnel_id_value, UINT32);
10210 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10211 .f = cmd_flow_director_filter_parsed,
10213 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10214 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10215 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10216 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10217 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10218 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10219 "fd_id <fd_id_value>: "
10220 "Add or delete an ip flow director entry on NIC",
10222 (void *)&cmd_flow_director_filter,
10223 (void *)&cmd_flow_director_port_id,
10224 (void *)&cmd_flow_director_mode,
10225 (void *)&cmd_flow_director_mode_ip,
10226 (void *)&cmd_flow_director_ops,
10227 (void *)&cmd_flow_director_flow,
10228 (void *)&cmd_flow_director_flow_type,
10229 (void *)&cmd_flow_director_src,
10230 (void *)&cmd_flow_director_ip_src,
10231 (void *)&cmd_flow_director_dst,
10232 (void *)&cmd_flow_director_ip_dst,
10233 (void *)&cmd_flow_director_tos,
10234 (void *)&cmd_flow_director_tos_value,
10235 (void *)&cmd_flow_director_proto,
10236 (void *)&cmd_flow_director_proto_value,
10237 (void *)&cmd_flow_director_ttl,
10238 (void *)&cmd_flow_director_ttl_value,
10239 (void *)&cmd_flow_director_vlan,
10240 (void *)&cmd_flow_director_vlan_value,
10241 (void *)&cmd_flow_director_flexbytes,
10242 (void *)&cmd_flow_director_flexbytes_value,
10243 (void *)&cmd_flow_director_drop,
10244 (void *)&cmd_flow_director_pf_vf,
10245 (void *)&cmd_flow_director_queue,
10246 (void *)&cmd_flow_director_queue_id,
10247 (void *)&cmd_flow_director_fd_id,
10248 (void *)&cmd_flow_director_fd_id_value,
10253 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10254 .f = cmd_flow_director_filter_parsed,
10256 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10257 "director entry on NIC",
10259 (void *)&cmd_flow_director_filter,
10260 (void *)&cmd_flow_director_port_id,
10261 (void *)&cmd_flow_director_mode,
10262 (void *)&cmd_flow_director_mode_ip,
10263 (void *)&cmd_flow_director_ops,
10264 (void *)&cmd_flow_director_flow,
10265 (void *)&cmd_flow_director_flow_type,
10266 (void *)&cmd_flow_director_src,
10267 (void *)&cmd_flow_director_ip_src,
10268 (void *)&cmd_flow_director_port_src,
10269 (void *)&cmd_flow_director_dst,
10270 (void *)&cmd_flow_director_ip_dst,
10271 (void *)&cmd_flow_director_port_dst,
10272 (void *)&cmd_flow_director_tos,
10273 (void *)&cmd_flow_director_tos_value,
10274 (void *)&cmd_flow_director_ttl,
10275 (void *)&cmd_flow_director_ttl_value,
10276 (void *)&cmd_flow_director_vlan,
10277 (void *)&cmd_flow_director_vlan_value,
10278 (void *)&cmd_flow_director_flexbytes,
10279 (void *)&cmd_flow_director_flexbytes_value,
10280 (void *)&cmd_flow_director_drop,
10281 (void *)&cmd_flow_director_pf_vf,
10282 (void *)&cmd_flow_director_queue,
10283 (void *)&cmd_flow_director_queue_id,
10284 (void *)&cmd_flow_director_fd_id,
10285 (void *)&cmd_flow_director_fd_id_value,
10290 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10291 .f = cmd_flow_director_filter_parsed,
10293 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10294 "director entry on NIC",
10296 (void *)&cmd_flow_director_filter,
10297 (void *)&cmd_flow_director_port_id,
10298 (void *)&cmd_flow_director_mode,
10299 (void *)&cmd_flow_director_mode_ip,
10300 (void *)&cmd_flow_director_ops,
10301 (void *)&cmd_flow_director_flow,
10302 (void *)&cmd_flow_director_flow_type,
10303 (void *)&cmd_flow_director_src,
10304 (void *)&cmd_flow_director_ip_src,
10305 (void *)&cmd_flow_director_port_src,
10306 (void *)&cmd_flow_director_dst,
10307 (void *)&cmd_flow_director_ip_dst,
10308 (void *)&cmd_flow_director_port_dst,
10309 (void *)&cmd_flow_director_verify_tag,
10310 (void *)&cmd_flow_director_verify_tag_value,
10311 (void *)&cmd_flow_director_tos,
10312 (void *)&cmd_flow_director_tos_value,
10313 (void *)&cmd_flow_director_ttl,
10314 (void *)&cmd_flow_director_ttl_value,
10315 (void *)&cmd_flow_director_vlan,
10316 (void *)&cmd_flow_director_vlan_value,
10317 (void *)&cmd_flow_director_flexbytes,
10318 (void *)&cmd_flow_director_flexbytes_value,
10319 (void *)&cmd_flow_director_drop,
10320 (void *)&cmd_flow_director_pf_vf,
10321 (void *)&cmd_flow_director_queue,
10322 (void *)&cmd_flow_director_queue_id,
10323 (void *)&cmd_flow_director_fd_id,
10324 (void *)&cmd_flow_director_fd_id_value,
10329 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10330 .f = cmd_flow_director_filter_parsed,
10332 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10333 "director entry on NIC",
10335 (void *)&cmd_flow_director_filter,
10336 (void *)&cmd_flow_director_port_id,
10337 (void *)&cmd_flow_director_mode,
10338 (void *)&cmd_flow_director_mode_ip,
10339 (void *)&cmd_flow_director_ops,
10340 (void *)&cmd_flow_director_flow,
10341 (void *)&cmd_flow_director_flow_type,
10342 (void *)&cmd_flow_director_ether,
10343 (void *)&cmd_flow_director_ether_type,
10344 (void *)&cmd_flow_director_flexbytes,
10345 (void *)&cmd_flow_director_flexbytes_value,
10346 (void *)&cmd_flow_director_drop,
10347 (void *)&cmd_flow_director_pf_vf,
10348 (void *)&cmd_flow_director_queue,
10349 (void *)&cmd_flow_director_queue_id,
10350 (void *)&cmd_flow_director_fd_id,
10351 (void *)&cmd_flow_director_fd_id_value,
10356 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10357 .f = cmd_flow_director_filter_parsed,
10359 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10360 "director entry on NIC",
10362 (void *)&cmd_flow_director_filter,
10363 (void *)&cmd_flow_director_port_id,
10364 (void *)&cmd_flow_director_mode,
10365 (void *)&cmd_flow_director_mode_mac_vlan,
10366 (void *)&cmd_flow_director_ops,
10367 (void *)&cmd_flow_director_mac,
10368 (void *)&cmd_flow_director_mac_addr,
10369 (void *)&cmd_flow_director_vlan,
10370 (void *)&cmd_flow_director_vlan_value,
10371 (void *)&cmd_flow_director_flexbytes,
10372 (void *)&cmd_flow_director_flexbytes_value,
10373 (void *)&cmd_flow_director_drop,
10374 (void *)&cmd_flow_director_queue,
10375 (void *)&cmd_flow_director_queue_id,
10376 (void *)&cmd_flow_director_fd_id,
10377 (void *)&cmd_flow_director_fd_id_value,
10382 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10383 .f = cmd_flow_director_filter_parsed,
10385 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10386 "director entry on NIC",
10388 (void *)&cmd_flow_director_filter,
10389 (void *)&cmd_flow_director_port_id,
10390 (void *)&cmd_flow_director_mode,
10391 (void *)&cmd_flow_director_mode_tunnel,
10392 (void *)&cmd_flow_director_ops,
10393 (void *)&cmd_flow_director_mac,
10394 (void *)&cmd_flow_director_mac_addr,
10395 (void *)&cmd_flow_director_vlan,
10396 (void *)&cmd_flow_director_vlan_value,
10397 (void *)&cmd_flow_director_tunnel,
10398 (void *)&cmd_flow_director_tunnel_type,
10399 (void *)&cmd_flow_director_tunnel_id,
10400 (void *)&cmd_flow_director_tunnel_id_value,
10401 (void *)&cmd_flow_director_flexbytes,
10402 (void *)&cmd_flow_director_flexbytes_value,
10403 (void *)&cmd_flow_director_drop,
10404 (void *)&cmd_flow_director_queue,
10405 (void *)&cmd_flow_director_queue_id,
10406 (void *)&cmd_flow_director_fd_id,
10407 (void *)&cmd_flow_director_fd_id_value,
10412 struct cmd_flush_flow_director_result {
10413 cmdline_fixed_string_t flush_flow_director;
10417 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10419 flush_flow_director, "flush_flow_director");
10420 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10421 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10425 cmd_flush_flow_director_parsed(void *parsed_result,
10426 __attribute__((unused)) struct cmdline *cl,
10427 __attribute__((unused)) void *data)
10429 struct cmd_flow_director_result *res = parsed_result;
10432 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10434 printf("flow director is not supported on port %u.\n",
10439 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10440 RTE_ETH_FILTER_FLUSH, NULL);
10442 printf("flow director table flushing error: (%s)\n",
10446 cmdline_parse_inst_t cmd_flush_flow_director = {
10447 .f = cmd_flush_flow_director_parsed,
10449 .help_str = "flush_flow_director <port_id>: "
10450 "Flush all flow director entries of a device on NIC",
10452 (void *)&cmd_flush_flow_director_flush,
10453 (void *)&cmd_flush_flow_director_port_id,
10458 /* *** deal with flow director mask *** */
10459 struct cmd_flow_director_mask_result {
10460 cmdline_fixed_string_t flow_director_mask;
10462 cmdline_fixed_string_t mode;
10463 cmdline_fixed_string_t mode_value;
10464 cmdline_fixed_string_t vlan;
10465 uint16_t vlan_mask;
10466 cmdline_fixed_string_t src_mask;
10467 cmdline_ipaddr_t ipv4_src;
10468 cmdline_ipaddr_t ipv6_src;
10470 cmdline_fixed_string_t dst_mask;
10471 cmdline_ipaddr_t ipv4_dst;
10472 cmdline_ipaddr_t ipv6_dst;
10474 cmdline_fixed_string_t mac;
10475 uint8_t mac_addr_byte_mask;
10476 cmdline_fixed_string_t tunnel_id;
10477 uint32_t tunnel_id_mask;
10478 cmdline_fixed_string_t tunnel_type;
10479 uint8_t tunnel_type_mask;
10483 cmd_flow_director_mask_parsed(void *parsed_result,
10484 __attribute__((unused)) struct cmdline *cl,
10485 __attribute__((unused)) void *data)
10487 struct cmd_flow_director_mask_result *res = parsed_result;
10488 struct rte_eth_fdir_masks *mask;
10489 struct rte_port *port;
10491 if (res->port_id > nb_ports) {
10492 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10496 port = &ports[res->port_id];
10497 /** Check if the port is not started **/
10498 if (port->port_status != RTE_PORT_STOPPED) {
10499 printf("Please stop port %d first\n", res->port_id);
10503 mask = &port->dev_conf.fdir_conf.mask;
10505 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10506 if (strcmp(res->mode_value, "MAC-VLAN")) {
10507 printf("Please set mode to MAC-VLAN.\n");
10511 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10512 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10513 if (strcmp(res->mode_value, "Tunnel")) {
10514 printf("Please set mode to Tunnel.\n");
10518 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10519 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10520 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10521 mask->tunnel_type_mask = res->tunnel_type_mask;
10523 if (strcmp(res->mode_value, "IP")) {
10524 printf("Please set mode to IP.\n");
10528 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10529 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10530 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10531 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10532 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10533 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10534 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10537 cmd_reconfig_device_queue(res->port_id, 1, 1);
10540 cmdline_parse_token_string_t cmd_flow_director_mask =
10541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10542 flow_director_mask, "flow_director_mask");
10543 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10544 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10546 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10549 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10551 vlan_mask, UINT16);
10552 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10553 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10554 src_mask, "src_mask");
10555 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10556 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10558 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10559 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10561 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10562 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10564 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10566 dst_mask, "dst_mask");
10567 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10568 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10570 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10571 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10573 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10574 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10577 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10578 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10580 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10583 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10585 mode_value, "MAC-VLAN");
10586 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10588 mode_value, "Tunnel");
10589 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10592 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10594 mac_addr_byte_mask, UINT8);
10595 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10597 tunnel_type, "tunnel-type");
10598 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10600 tunnel_type_mask, UINT8);
10601 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10603 tunnel_id, "tunnel-id");
10604 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10606 tunnel_id_mask, UINT32);
10608 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10609 .f = cmd_flow_director_mask_parsed,
10611 .help_str = "flow_director_mask ... : "
10612 "Set IP mode flow director's mask on NIC",
10614 (void *)&cmd_flow_director_mask,
10615 (void *)&cmd_flow_director_mask_port_id,
10616 (void *)&cmd_flow_director_mask_mode,
10617 (void *)&cmd_flow_director_mask_mode_ip,
10618 (void *)&cmd_flow_director_mask_vlan,
10619 (void *)&cmd_flow_director_mask_vlan_value,
10620 (void *)&cmd_flow_director_mask_src,
10621 (void *)&cmd_flow_director_mask_ipv4_src,
10622 (void *)&cmd_flow_director_mask_ipv6_src,
10623 (void *)&cmd_flow_director_mask_port_src,
10624 (void *)&cmd_flow_director_mask_dst,
10625 (void *)&cmd_flow_director_mask_ipv4_dst,
10626 (void *)&cmd_flow_director_mask_ipv6_dst,
10627 (void *)&cmd_flow_director_mask_port_dst,
10632 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10633 .f = cmd_flow_director_mask_parsed,
10635 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10636 "flow director's mask on NIC",
10638 (void *)&cmd_flow_director_mask,
10639 (void *)&cmd_flow_director_mask_port_id,
10640 (void *)&cmd_flow_director_mask_mode,
10641 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10642 (void *)&cmd_flow_director_mask_vlan,
10643 (void *)&cmd_flow_director_mask_vlan_value,
10648 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10649 .f = cmd_flow_director_mask_parsed,
10651 .help_str = "flow_director_mask ... : Set tunnel mode "
10652 "flow director's mask on NIC",
10654 (void *)&cmd_flow_director_mask,
10655 (void *)&cmd_flow_director_mask_port_id,
10656 (void *)&cmd_flow_director_mask_mode,
10657 (void *)&cmd_flow_director_mask_mode_tunnel,
10658 (void *)&cmd_flow_director_mask_vlan,
10659 (void *)&cmd_flow_director_mask_vlan_value,
10660 (void *)&cmd_flow_director_mask_mac,
10661 (void *)&cmd_flow_director_mask_mac_value,
10662 (void *)&cmd_flow_director_mask_tunnel_type,
10663 (void *)&cmd_flow_director_mask_tunnel_type_value,
10664 (void *)&cmd_flow_director_mask_tunnel_id,
10665 (void *)&cmd_flow_director_mask_tunnel_id_value,
10670 /* *** deal with flow director mask on flexible payload *** */
10671 struct cmd_flow_director_flex_mask_result {
10672 cmdline_fixed_string_t flow_director_flexmask;
10674 cmdline_fixed_string_t flow;
10675 cmdline_fixed_string_t flow_type;
10676 cmdline_fixed_string_t mask;
10680 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10681 __attribute__((unused)) struct cmdline *cl,
10682 __attribute__((unused)) void *data)
10684 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10685 struct rte_eth_fdir_info fdir_info;
10686 struct rte_eth_fdir_flex_mask flex_mask;
10687 struct rte_port *port;
10688 uint32_t flow_type_mask;
10692 if (res->port_id > nb_ports) {
10693 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10697 port = &ports[res->port_id];
10698 /** Check if the port is not started **/
10699 if (port->port_status != RTE_PORT_STOPPED) {
10700 printf("Please stop port %d first\n", res->port_id);
10704 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10705 ret = parse_flexbytes(res->mask,
10707 RTE_ETH_FDIR_MAX_FLEXLEN);
10709 printf("error: Cannot parse mask input.\n");
10713 memset(&fdir_info, 0, sizeof(fdir_info));
10714 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10715 RTE_ETH_FILTER_INFO, &fdir_info);
10717 printf("Cannot get FDir filter info\n");
10721 if (!strcmp(res->flow_type, "none")) {
10722 /* means don't specify the flow type */
10723 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10724 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10725 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10726 0, sizeof(struct rte_eth_fdir_flex_mask));
10727 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10728 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10730 sizeof(struct rte_eth_fdir_flex_mask));
10731 cmd_reconfig_device_queue(res->port_id, 1, 1);
10734 flow_type_mask = fdir_info.flow_types_mask[0];
10735 if (!strcmp(res->flow_type, "all")) {
10736 if (!flow_type_mask) {
10737 printf("No flow type supported\n");
10740 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10741 if (flow_type_mask & (1 << i)) {
10742 flex_mask.flow_type = i;
10743 fdir_set_flex_mask(res->port_id, &flex_mask);
10746 cmd_reconfig_device_queue(res->port_id, 1, 1);
10749 flex_mask.flow_type = str2flowtype(res->flow_type);
10750 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10751 printf("Flow type %s not supported on port %d\n",
10752 res->flow_type, res->port_id);
10755 fdir_set_flex_mask(res->port_id, &flex_mask);
10756 cmd_reconfig_device_queue(res->port_id, 1, 1);
10759 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10761 flow_director_flexmask,
10762 "flow_director_flex_mask");
10763 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10764 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10766 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10769 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10771 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10772 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10773 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10777 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10778 .f = cmd_flow_director_flex_mask_parsed,
10780 .help_str = "flow_director_flex_mask ... : "
10781 "Set flow director's flex mask on NIC",
10783 (void *)&cmd_flow_director_flexmask,
10784 (void *)&cmd_flow_director_flexmask_port_id,
10785 (void *)&cmd_flow_director_flexmask_flow,
10786 (void *)&cmd_flow_director_flexmask_flow_type,
10787 (void *)&cmd_flow_director_flexmask_mask,
10792 /* *** deal with flow director flexible payload configuration *** */
10793 struct cmd_flow_director_flexpayload_result {
10794 cmdline_fixed_string_t flow_director_flexpayload;
10796 cmdline_fixed_string_t payload_layer;
10797 cmdline_fixed_string_t payload_cfg;
10801 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10804 const char *p, *p0 = q_arg;
10806 unsigned long int_fld;
10807 char *str_fld[max_num];
10812 p = strchr(p0, '(');
10816 p0 = strchr(p, ')');
10821 if (size >= sizeof(s))
10824 snprintf(s, sizeof(s), "%.*s", size, p);
10825 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10826 if (ret < 0 || ret > max_num)
10828 for (i = 0; i < ret; i++) {
10830 int_fld = strtoul(str_fld[i], &end, 0);
10831 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10833 offsets[i] = (uint16_t)int_fld;
10839 cmd_flow_director_flxpld_parsed(void *parsed_result,
10840 __attribute__((unused)) struct cmdline *cl,
10841 __attribute__((unused)) void *data)
10843 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10844 struct rte_eth_flex_payload_cfg flex_cfg;
10845 struct rte_port *port;
10848 if (res->port_id > nb_ports) {
10849 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10853 port = &ports[res->port_id];
10854 /** Check if the port is not started **/
10855 if (port->port_status != RTE_PORT_STOPPED) {
10856 printf("Please stop port %d first\n", res->port_id);
10860 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10862 if (!strcmp(res->payload_layer, "raw"))
10863 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10864 else if (!strcmp(res->payload_layer, "l2"))
10865 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10866 else if (!strcmp(res->payload_layer, "l3"))
10867 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10868 else if (!strcmp(res->payload_layer, "l4"))
10869 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10871 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10872 RTE_ETH_FDIR_MAX_FLEXLEN);
10874 printf("error: Cannot parse flex payload input.\n");
10878 fdir_set_flex_payload(res->port_id, &flex_cfg);
10879 cmd_reconfig_device_queue(res->port_id, 1, 1);
10882 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10884 flow_director_flexpayload,
10885 "flow_director_flex_payload");
10886 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10887 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10889 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10890 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10891 payload_layer, "raw#l2#l3#l4");
10892 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10893 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10894 payload_cfg, NULL);
10896 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10897 .f = cmd_flow_director_flxpld_parsed,
10899 .help_str = "flow_director_flexpayload ... : "
10900 "Set flow director's flex payload on NIC",
10902 (void *)&cmd_flow_director_flexpayload,
10903 (void *)&cmd_flow_director_flexpayload_port_id,
10904 (void *)&cmd_flow_director_flexpayload_payload_layer,
10905 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10910 /* Generic flow interface command. */
10911 extern cmdline_parse_inst_t cmd_flow;
10913 /* *** Classification Filters Control *** */
10914 /* *** Get symmetric hash enable per port *** */
10915 struct cmd_get_sym_hash_ena_per_port_result {
10916 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10921 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10922 __rte_unused struct cmdline *cl,
10923 __rte_unused void *data)
10925 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10926 struct rte_eth_hash_filter_info info;
10929 if (rte_eth_dev_filter_supported(res->port_id,
10930 RTE_ETH_FILTER_HASH) < 0) {
10931 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10936 memset(&info, 0, sizeof(info));
10937 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10938 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10939 RTE_ETH_FILTER_GET, &info);
10942 printf("Cannot get symmetric hash enable per port "
10943 "on port %u\n", res->port_id);
10947 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10948 "enabled" : "disabled", res->port_id);
10951 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10952 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10953 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10954 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10955 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10958 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10959 .f = cmd_get_sym_hash_per_port_parsed,
10961 .help_str = "get_sym_hash_ena_per_port <port_id>",
10963 (void *)&cmd_get_sym_hash_ena_per_port_all,
10964 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10969 /* *** Set symmetric hash enable per port *** */
10970 struct cmd_set_sym_hash_ena_per_port_result {
10971 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10972 cmdline_fixed_string_t enable;
10977 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10978 __rte_unused struct cmdline *cl,
10979 __rte_unused void *data)
10981 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10982 struct rte_eth_hash_filter_info info;
10985 if (rte_eth_dev_filter_supported(res->port_id,
10986 RTE_ETH_FILTER_HASH) < 0) {
10987 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10992 memset(&info, 0, sizeof(info));
10993 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10994 if (!strcmp(res->enable, "enable"))
10995 info.info.enable = 1;
10996 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10997 RTE_ETH_FILTER_SET, &info);
10999 printf("Cannot set symmetric hash enable per port on "
11000 "port %u\n", res->port_id);
11003 printf("Symmetric hash has been set to %s on port %u\n",
11004 res->enable, res->port_id);
11007 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11008 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11009 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11010 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11011 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11013 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11014 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11015 enable, "enable#disable");
11017 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11018 .f = cmd_set_sym_hash_per_port_parsed,
11020 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11022 (void *)&cmd_set_sym_hash_ena_per_port_all,
11023 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11024 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11029 /* Get global config of hash function */
11030 struct cmd_get_hash_global_config_result {
11031 cmdline_fixed_string_t get_hash_global_config;
11036 flowtype_to_str(uint16_t ftype)
11042 } ftype_table[] = {
11043 {"ipv4", RTE_ETH_FLOW_IPV4},
11044 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11045 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11046 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11047 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11048 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11049 {"ipv6", RTE_ETH_FLOW_IPV6},
11050 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11051 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11052 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11053 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11054 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11055 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11056 {"port", RTE_ETH_FLOW_PORT},
11057 {"vxlan", RTE_ETH_FLOW_VXLAN},
11058 {"geneve", RTE_ETH_FLOW_GENEVE},
11059 {"nvgre", RTE_ETH_FLOW_NVGRE},
11062 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11063 if (ftype_table[i].ftype == ftype)
11064 return ftype_table[i].str;
11071 cmd_get_hash_global_config_parsed(void *parsed_result,
11072 __rte_unused struct cmdline *cl,
11073 __rte_unused void *data)
11075 struct cmd_get_hash_global_config_result *res = parsed_result;
11076 struct rte_eth_hash_filter_info info;
11077 uint32_t idx, offset;
11082 if (rte_eth_dev_filter_supported(res->port_id,
11083 RTE_ETH_FILTER_HASH) < 0) {
11084 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11089 memset(&info, 0, sizeof(info));
11090 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11091 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11092 RTE_ETH_FILTER_GET, &info);
11094 printf("Cannot get hash global configurations by port %d\n",
11099 switch (info.info.global_conf.hash_func) {
11100 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11101 printf("Hash function is Toeplitz\n");
11103 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11104 printf("Hash function is Simple XOR\n");
11107 printf("Unknown hash function\n");
11111 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11112 idx = i / UINT32_BIT;
11113 offset = i % UINT32_BIT;
11114 if (!(info.info.global_conf.valid_bit_mask[idx] &
11117 str = flowtype_to_str(i);
11120 printf("Symmetric hash is %s globally for flow type %s "
11122 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11123 (1UL << offset)) ? "enabled" : "disabled"), str,
11128 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11129 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11130 get_hash_global_config, "get_hash_global_config");
11131 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11132 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11135 cmdline_parse_inst_t cmd_get_hash_global_config = {
11136 .f = cmd_get_hash_global_config_parsed,
11138 .help_str = "get_hash_global_config <port_id>",
11140 (void *)&cmd_get_hash_global_config_all,
11141 (void *)&cmd_get_hash_global_config_port_id,
11146 /* Set global config of hash function */
11147 struct cmd_set_hash_global_config_result {
11148 cmdline_fixed_string_t set_hash_global_config;
11150 cmdline_fixed_string_t hash_func;
11151 cmdline_fixed_string_t flow_type;
11152 cmdline_fixed_string_t enable;
11156 cmd_set_hash_global_config_parsed(void *parsed_result,
11157 __rte_unused struct cmdline *cl,
11158 __rte_unused void *data)
11160 struct cmd_set_hash_global_config_result *res = parsed_result;
11161 struct rte_eth_hash_filter_info info;
11162 uint32_t ftype, idx, offset;
11165 if (rte_eth_dev_filter_supported(res->port_id,
11166 RTE_ETH_FILTER_HASH) < 0) {
11167 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11171 memset(&info, 0, sizeof(info));
11172 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11173 if (!strcmp(res->hash_func, "toeplitz"))
11174 info.info.global_conf.hash_func =
11175 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11176 else if (!strcmp(res->hash_func, "simple_xor"))
11177 info.info.global_conf.hash_func =
11178 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11179 else if (!strcmp(res->hash_func, "default"))
11180 info.info.global_conf.hash_func =
11181 RTE_ETH_HASH_FUNCTION_DEFAULT;
11183 ftype = str2flowtype(res->flow_type);
11184 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11185 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11186 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11187 if (!strcmp(res->enable, "enable"))
11188 info.info.global_conf.sym_hash_enable_mask[idx] |=
11190 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11191 RTE_ETH_FILTER_SET, &info);
11193 printf("Cannot set global hash configurations by port %d\n",
11196 printf("Global hash configurations have been set "
11197 "succcessfully by port %d\n", res->port_id);
11200 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11201 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11202 set_hash_global_config, "set_hash_global_config");
11203 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11204 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11206 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11207 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11208 hash_func, "toeplitz#simple_xor#default");
11209 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11210 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11212 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11213 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11214 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11215 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11216 enable, "enable#disable");
11218 cmdline_parse_inst_t cmd_set_hash_global_config = {
11219 .f = cmd_set_hash_global_config_parsed,
11221 .help_str = "set_hash_global_config <port_id> "
11222 "toeplitz|simple_xor|default "
11223 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11224 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11225 "l2_payload enable|disable",
11227 (void *)&cmd_set_hash_global_config_all,
11228 (void *)&cmd_set_hash_global_config_port_id,
11229 (void *)&cmd_set_hash_global_config_hash_func,
11230 (void *)&cmd_set_hash_global_config_flow_type,
11231 (void *)&cmd_set_hash_global_config_enable,
11236 /* Set hash input set */
11237 struct cmd_set_hash_input_set_result {
11238 cmdline_fixed_string_t set_hash_input_set;
11240 cmdline_fixed_string_t flow_type;
11241 cmdline_fixed_string_t inset_field;
11242 cmdline_fixed_string_t select;
11245 static enum rte_eth_input_set_field
11246 str2inset(char *string)
11250 static const struct {
11252 enum rte_eth_input_set_field inset;
11253 } inset_table[] = {
11254 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11255 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11256 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11257 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11258 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11259 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11260 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11261 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11262 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11263 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11264 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11265 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11266 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11267 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11268 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11269 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11270 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11271 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11272 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11273 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11274 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11275 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11276 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11277 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11278 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11279 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11280 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11281 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11282 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11283 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11284 {"none", RTE_ETH_INPUT_SET_NONE},
11287 for (i = 0; i < RTE_DIM(inset_table); i++) {
11288 if (!strcmp(string, inset_table[i].str))
11289 return inset_table[i].inset;
11292 return RTE_ETH_INPUT_SET_UNKNOWN;
11296 cmd_set_hash_input_set_parsed(void *parsed_result,
11297 __rte_unused struct cmdline *cl,
11298 __rte_unused void *data)
11300 struct cmd_set_hash_input_set_result *res = parsed_result;
11301 struct rte_eth_hash_filter_info info;
11303 memset(&info, 0, sizeof(info));
11304 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11305 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11306 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11307 info.info.input_set_conf.inset_size = 1;
11308 if (!strcmp(res->select, "select"))
11309 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11310 else if (!strcmp(res->select, "add"))
11311 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11312 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11313 RTE_ETH_FILTER_SET, &info);
11316 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11317 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11318 set_hash_input_set, "set_hash_input_set");
11319 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11320 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11322 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11323 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11325 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11326 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11328 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11329 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11330 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11331 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11332 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11334 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11335 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11336 select, "select#add");
11338 cmdline_parse_inst_t cmd_set_hash_input_set = {
11339 .f = cmd_set_hash_input_set_parsed,
11341 .help_str = "set_hash_input_set <port_id> "
11342 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11343 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11344 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11345 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11346 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11347 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11348 "fld-7th|fld-8th|none select|add",
11350 (void *)&cmd_set_hash_input_set_cmd,
11351 (void *)&cmd_set_hash_input_set_port_id,
11352 (void *)&cmd_set_hash_input_set_flow_type,
11353 (void *)&cmd_set_hash_input_set_field,
11354 (void *)&cmd_set_hash_input_set_select,
11359 /* Set flow director input set */
11360 struct cmd_set_fdir_input_set_result {
11361 cmdline_fixed_string_t set_fdir_input_set;
11363 cmdline_fixed_string_t flow_type;
11364 cmdline_fixed_string_t inset_field;
11365 cmdline_fixed_string_t select;
11369 cmd_set_fdir_input_set_parsed(void *parsed_result,
11370 __rte_unused struct cmdline *cl,
11371 __rte_unused void *data)
11373 struct cmd_set_fdir_input_set_result *res = parsed_result;
11374 struct rte_eth_fdir_filter_info info;
11376 memset(&info, 0, sizeof(info));
11377 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11378 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11379 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11380 info.info.input_set_conf.inset_size = 1;
11381 if (!strcmp(res->select, "select"))
11382 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11383 else if (!strcmp(res->select, "add"))
11384 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11385 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11386 RTE_ETH_FILTER_SET, &info);
11389 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11390 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11391 set_fdir_input_set, "set_fdir_input_set");
11392 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11393 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11395 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11396 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11398 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11399 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11400 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11401 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11403 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11404 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11405 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11406 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11407 "sctp-veri-tag#none");
11408 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11409 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11410 select, "select#add");
11412 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11413 .f = cmd_set_fdir_input_set_parsed,
11415 .help_str = "set_fdir_input_set <port_id> "
11416 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11417 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11418 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11419 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11420 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11421 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11422 "sctp-veri-tag|none select|add",
11424 (void *)&cmd_set_fdir_input_set_cmd,
11425 (void *)&cmd_set_fdir_input_set_port_id,
11426 (void *)&cmd_set_fdir_input_set_flow_type,
11427 (void *)&cmd_set_fdir_input_set_field,
11428 (void *)&cmd_set_fdir_input_set_select,
11433 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11434 struct cmd_mcast_addr_result {
11435 cmdline_fixed_string_t mcast_addr_cmd;
11436 cmdline_fixed_string_t what;
11438 struct ether_addr mc_addr;
11441 static void cmd_mcast_addr_parsed(void *parsed_result,
11442 __attribute__((unused)) struct cmdline *cl,
11443 __attribute__((unused)) void *data)
11445 struct cmd_mcast_addr_result *res = parsed_result;
11447 if (!is_multicast_ether_addr(&res->mc_addr)) {
11448 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11449 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11450 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11451 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11454 if (strcmp(res->what, "add") == 0)
11455 mcast_addr_add(res->port_num, &res->mc_addr);
11457 mcast_addr_remove(res->port_num, &res->mc_addr);
11460 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11461 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11462 mcast_addr_cmd, "mcast_addr");
11463 cmdline_parse_token_string_t cmd_mcast_addr_what =
11464 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11466 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11467 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11468 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11469 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11471 cmdline_parse_inst_t cmd_mcast_addr = {
11472 .f = cmd_mcast_addr_parsed,
11474 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11475 "Add/Remove multicast MAC address on port_id",
11477 (void *)&cmd_mcast_addr_cmd,
11478 (void *)&cmd_mcast_addr_what,
11479 (void *)&cmd_mcast_addr_portnum,
11480 (void *)&cmd_mcast_addr_addr,
11485 /* l2 tunnel config
11486 * only support E-tag now.
11489 /* Ether type config */
11490 struct cmd_config_l2_tunnel_eth_type_result {
11491 cmdline_fixed_string_t port;
11492 cmdline_fixed_string_t config;
11493 cmdline_fixed_string_t all;
11495 cmdline_fixed_string_t l2_tunnel;
11496 cmdline_fixed_string_t l2_tunnel_type;
11497 cmdline_fixed_string_t eth_type;
11498 uint16_t eth_type_val;
11501 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
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_config =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_config_l2_tunnel_eth_type_result,
11509 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_config_l2_tunnel_eth_type_result,
11513 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11514 TOKEN_NUM_INITIALIZER
11515 (struct cmd_config_l2_tunnel_eth_type_result,
11517 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_config_l2_tunnel_eth_type_result,
11520 l2_tunnel, "l2-tunnel");
11521 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_config_l2_tunnel_eth_type_result,
11524 l2_tunnel_type, "E-tag");
11525 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_config_l2_tunnel_eth_type_result,
11528 eth_type, "ether-type");
11529 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11530 TOKEN_NUM_INITIALIZER
11531 (struct cmd_config_l2_tunnel_eth_type_result,
11532 eth_type_val, UINT16);
11534 static enum rte_eth_tunnel_type
11535 str2fdir_l2_tunnel_type(char *string)
11539 static const struct {
11541 enum rte_eth_tunnel_type type;
11542 } l2_tunnel_type_str[] = {
11543 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11546 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11547 if (!strcmp(l2_tunnel_type_str[i].str, string))
11548 return l2_tunnel_type_str[i].type;
11550 return RTE_TUNNEL_TYPE_NONE;
11553 /* ether type config for all ports */
11555 cmd_config_l2_tunnel_eth_type_all_parsed
11556 (void *parsed_result,
11557 __attribute__((unused)) struct cmdline *cl,
11558 __attribute__((unused)) void *data)
11560 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11561 struct rte_eth_l2_tunnel_conf entry;
11564 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11565 entry.ether_type = res->eth_type_val;
11567 RTE_ETH_FOREACH_DEV(pid) {
11568 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11572 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11573 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11575 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11577 (void *)&cmd_config_l2_tunnel_eth_type_port,
11578 (void *)&cmd_config_l2_tunnel_eth_type_config,
11579 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11580 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11581 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11582 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11583 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11588 /* ether type config for a specific port */
11590 cmd_config_l2_tunnel_eth_type_specific_parsed(
11591 void *parsed_result,
11592 __attribute__((unused)) struct cmdline *cl,
11593 __attribute__((unused)) void *data)
11595 struct cmd_config_l2_tunnel_eth_type_result *res =
11597 struct rte_eth_l2_tunnel_conf entry;
11599 if (port_id_is_invalid(res->id, ENABLED_WARN))
11602 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11603 entry.ether_type = res->eth_type_val;
11605 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11608 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11609 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11611 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11613 (void *)&cmd_config_l2_tunnel_eth_type_port,
11614 (void *)&cmd_config_l2_tunnel_eth_type_config,
11615 (void *)&cmd_config_l2_tunnel_eth_type_id,
11616 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11617 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11618 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11619 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11624 /* Enable/disable l2 tunnel */
11625 struct cmd_config_l2_tunnel_en_dis_result {
11626 cmdline_fixed_string_t port;
11627 cmdline_fixed_string_t config;
11628 cmdline_fixed_string_t all;
11630 cmdline_fixed_string_t l2_tunnel;
11631 cmdline_fixed_string_t l2_tunnel_type;
11632 cmdline_fixed_string_t en_dis;
11635 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
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_config =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_config_l2_tunnel_en_dis_result,
11643 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_config_l2_tunnel_en_dis_result,
11647 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11648 TOKEN_NUM_INITIALIZER
11649 (struct cmd_config_l2_tunnel_en_dis_result,
11651 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11652 TOKEN_STRING_INITIALIZER
11653 (struct cmd_config_l2_tunnel_en_dis_result,
11654 l2_tunnel, "l2-tunnel");
11655 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_config_l2_tunnel_en_dis_result,
11658 l2_tunnel_type, "E-tag");
11659 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_config_l2_tunnel_en_dis_result,
11662 en_dis, "enable#disable");
11664 /* enable/disable l2 tunnel for all ports */
11666 cmd_config_l2_tunnel_en_dis_all_parsed(
11667 void *parsed_result,
11668 __attribute__((unused)) struct cmdline *cl,
11669 __attribute__((unused)) void *data)
11671 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11672 struct rte_eth_l2_tunnel_conf entry;
11676 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11678 if (!strcmp("enable", res->en_dis))
11683 RTE_ETH_FOREACH_DEV(pid) {
11684 rte_eth_dev_l2_tunnel_offload_set(pid,
11686 ETH_L2_TUNNEL_ENABLE_MASK,
11691 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11692 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11694 .help_str = "port config all l2-tunnel E-tag enable|disable",
11696 (void *)&cmd_config_l2_tunnel_en_dis_port,
11697 (void *)&cmd_config_l2_tunnel_en_dis_config,
11698 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11699 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11700 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11701 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11706 /* enable/disable l2 tunnel for a port */
11708 cmd_config_l2_tunnel_en_dis_specific_parsed(
11709 void *parsed_result,
11710 __attribute__((unused)) struct cmdline *cl,
11711 __attribute__((unused)) void *data)
11713 struct cmd_config_l2_tunnel_en_dis_result *res =
11715 struct rte_eth_l2_tunnel_conf entry;
11717 if (port_id_is_invalid(res->id, ENABLED_WARN))
11720 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11722 if (!strcmp("enable", res->en_dis))
11723 rte_eth_dev_l2_tunnel_offload_set(res->id,
11725 ETH_L2_TUNNEL_ENABLE_MASK,
11728 rte_eth_dev_l2_tunnel_offload_set(res->id,
11730 ETH_L2_TUNNEL_ENABLE_MASK,
11734 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11735 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11737 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11739 (void *)&cmd_config_l2_tunnel_en_dis_port,
11740 (void *)&cmd_config_l2_tunnel_en_dis_config,
11741 (void *)&cmd_config_l2_tunnel_en_dis_id,
11742 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11743 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11744 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11749 /* E-tag configuration */
11751 /* Common result structure for all E-tag configuration */
11752 struct cmd_config_e_tag_result {
11753 cmdline_fixed_string_t e_tag;
11754 cmdline_fixed_string_t set;
11755 cmdline_fixed_string_t insertion;
11756 cmdline_fixed_string_t stripping;
11757 cmdline_fixed_string_t forwarding;
11758 cmdline_fixed_string_t filter;
11759 cmdline_fixed_string_t add;
11760 cmdline_fixed_string_t del;
11761 cmdline_fixed_string_t on;
11762 cmdline_fixed_string_t off;
11763 cmdline_fixed_string_t on_off;
11764 cmdline_fixed_string_t port_tag_id;
11765 uint32_t port_tag_id_val;
11766 cmdline_fixed_string_t e_tag_id;
11767 uint16_t e_tag_id_val;
11768 cmdline_fixed_string_t dst_pool;
11769 uint8_t dst_pool_val;
11770 cmdline_fixed_string_t port;
11772 cmdline_fixed_string_t vf;
11776 /* Common CLI fields for all E-tag configuration */
11777 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_config_e_tag_result,
11781 cmdline_parse_token_string_t cmd_config_e_tag_set =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_config_e_tag_result,
11785 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_config_e_tag_result,
11788 insertion, "insertion");
11789 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_config_e_tag_result,
11792 stripping, "stripping");
11793 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_config_e_tag_result,
11796 forwarding, "forwarding");
11797 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_config_e_tag_result,
11801 cmdline_parse_token_string_t cmd_config_e_tag_add =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_config_e_tag_result,
11805 cmdline_parse_token_string_t cmd_config_e_tag_del =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_config_e_tag_result,
11809 cmdline_parse_token_string_t cmd_config_e_tag_on =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_config_e_tag_result,
11813 cmdline_parse_token_string_t cmd_config_e_tag_off =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_config_e_tag_result,
11817 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_config_e_tag_result,
11821 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_config_e_tag_result,
11824 port_tag_id, "port-tag-id");
11825 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11826 TOKEN_NUM_INITIALIZER
11827 (struct cmd_config_e_tag_result,
11828 port_tag_id_val, UINT32);
11829 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11830 TOKEN_STRING_INITIALIZER
11831 (struct cmd_config_e_tag_result,
11832 e_tag_id, "e-tag-id");
11833 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11834 TOKEN_NUM_INITIALIZER
11835 (struct cmd_config_e_tag_result,
11836 e_tag_id_val, UINT16);
11837 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11838 TOKEN_STRING_INITIALIZER
11839 (struct cmd_config_e_tag_result,
11840 dst_pool, "dst-pool");
11841 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11842 TOKEN_NUM_INITIALIZER
11843 (struct cmd_config_e_tag_result,
11844 dst_pool_val, UINT8);
11845 cmdline_parse_token_string_t cmd_config_e_tag_port =
11846 TOKEN_STRING_INITIALIZER
11847 (struct cmd_config_e_tag_result,
11849 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11850 TOKEN_NUM_INITIALIZER
11851 (struct cmd_config_e_tag_result,
11853 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_config_e_tag_result,
11857 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11858 TOKEN_NUM_INITIALIZER
11859 (struct cmd_config_e_tag_result,
11862 /* E-tag insertion configuration */
11864 cmd_config_e_tag_insertion_en_parsed(
11865 void *parsed_result,
11866 __attribute__((unused)) struct cmdline *cl,
11867 __attribute__((unused)) void *data)
11869 struct cmd_config_e_tag_result *res =
11871 struct rte_eth_l2_tunnel_conf entry;
11873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11876 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11877 entry.tunnel_id = res->port_tag_id_val;
11878 entry.vf_id = res->vf_id;
11879 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11881 ETH_L2_TUNNEL_INSERTION_MASK,
11886 cmd_config_e_tag_insertion_dis_parsed(
11887 void *parsed_result,
11888 __attribute__((unused)) struct cmdline *cl,
11889 __attribute__((unused)) void *data)
11891 struct cmd_config_e_tag_result *res =
11893 struct rte_eth_l2_tunnel_conf entry;
11895 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11898 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11899 entry.vf_id = res->vf_id;
11901 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11903 ETH_L2_TUNNEL_INSERTION_MASK,
11907 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11908 .f = cmd_config_e_tag_insertion_en_parsed,
11910 .help_str = "E-tag ... : E-tag insertion enable",
11912 (void *)&cmd_config_e_tag_e_tag,
11913 (void *)&cmd_config_e_tag_set,
11914 (void *)&cmd_config_e_tag_insertion,
11915 (void *)&cmd_config_e_tag_on,
11916 (void *)&cmd_config_e_tag_port_tag_id,
11917 (void *)&cmd_config_e_tag_port_tag_id_val,
11918 (void *)&cmd_config_e_tag_port,
11919 (void *)&cmd_config_e_tag_port_id,
11920 (void *)&cmd_config_e_tag_vf,
11921 (void *)&cmd_config_e_tag_vf_id,
11926 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11927 .f = cmd_config_e_tag_insertion_dis_parsed,
11929 .help_str = "E-tag ... : E-tag insertion disable",
11931 (void *)&cmd_config_e_tag_e_tag,
11932 (void *)&cmd_config_e_tag_set,
11933 (void *)&cmd_config_e_tag_insertion,
11934 (void *)&cmd_config_e_tag_off,
11935 (void *)&cmd_config_e_tag_port,
11936 (void *)&cmd_config_e_tag_port_id,
11937 (void *)&cmd_config_e_tag_vf,
11938 (void *)&cmd_config_e_tag_vf_id,
11943 /* E-tag stripping configuration */
11945 cmd_config_e_tag_stripping_parsed(
11946 void *parsed_result,
11947 __attribute__((unused)) struct cmdline *cl,
11948 __attribute__((unused)) void *data)
11950 struct cmd_config_e_tag_result *res =
11952 struct rte_eth_l2_tunnel_conf entry;
11954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11957 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11959 if (!strcmp(res->on_off, "on"))
11960 rte_eth_dev_l2_tunnel_offload_set
11963 ETH_L2_TUNNEL_STRIPPING_MASK,
11966 rte_eth_dev_l2_tunnel_offload_set
11969 ETH_L2_TUNNEL_STRIPPING_MASK,
11973 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11974 .f = cmd_config_e_tag_stripping_parsed,
11976 .help_str = "E-tag ... : E-tag stripping enable/disable",
11978 (void *)&cmd_config_e_tag_e_tag,
11979 (void *)&cmd_config_e_tag_set,
11980 (void *)&cmd_config_e_tag_stripping,
11981 (void *)&cmd_config_e_tag_on_off,
11982 (void *)&cmd_config_e_tag_port,
11983 (void *)&cmd_config_e_tag_port_id,
11988 /* E-tag forwarding configuration */
11990 cmd_config_e_tag_forwarding_parsed(
11991 void *parsed_result,
11992 __attribute__((unused)) struct cmdline *cl,
11993 __attribute__((unused)) void *data)
11995 struct cmd_config_e_tag_result *res = parsed_result;
11996 struct rte_eth_l2_tunnel_conf entry;
11998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12001 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12003 if (!strcmp(res->on_off, "on"))
12004 rte_eth_dev_l2_tunnel_offload_set
12007 ETH_L2_TUNNEL_FORWARDING_MASK,
12010 rte_eth_dev_l2_tunnel_offload_set
12013 ETH_L2_TUNNEL_FORWARDING_MASK,
12017 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12018 .f = cmd_config_e_tag_forwarding_parsed,
12020 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12022 (void *)&cmd_config_e_tag_e_tag,
12023 (void *)&cmd_config_e_tag_set,
12024 (void *)&cmd_config_e_tag_forwarding,
12025 (void *)&cmd_config_e_tag_on_off,
12026 (void *)&cmd_config_e_tag_port,
12027 (void *)&cmd_config_e_tag_port_id,
12032 /* E-tag filter configuration */
12034 cmd_config_e_tag_filter_add_parsed(
12035 void *parsed_result,
12036 __attribute__((unused)) struct cmdline *cl,
12037 __attribute__((unused)) void *data)
12039 struct cmd_config_e_tag_result *res = parsed_result;
12040 struct rte_eth_l2_tunnel_conf entry;
12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 if (res->e_tag_id_val > 0x3fff) {
12047 printf("e-tag-id must be equal or less than 0x3fff.\n");
12051 ret = rte_eth_dev_filter_supported(res->port_id,
12052 RTE_ETH_FILTER_L2_TUNNEL);
12054 printf("E-tag filter is not supported on port %u.\n",
12059 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12060 entry.tunnel_id = res->e_tag_id_val;
12061 entry.pool = res->dst_pool_val;
12063 ret = rte_eth_dev_filter_ctrl(res->port_id,
12064 RTE_ETH_FILTER_L2_TUNNEL,
12065 RTE_ETH_FILTER_ADD,
12068 printf("E-tag filter programming error: (%s)\n",
12072 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12073 .f = cmd_config_e_tag_filter_add_parsed,
12075 .help_str = "E-tag ... : E-tag filter add",
12077 (void *)&cmd_config_e_tag_e_tag,
12078 (void *)&cmd_config_e_tag_set,
12079 (void *)&cmd_config_e_tag_filter,
12080 (void *)&cmd_config_e_tag_add,
12081 (void *)&cmd_config_e_tag_e_tag_id,
12082 (void *)&cmd_config_e_tag_e_tag_id_val,
12083 (void *)&cmd_config_e_tag_dst_pool,
12084 (void *)&cmd_config_e_tag_dst_pool_val,
12085 (void *)&cmd_config_e_tag_port,
12086 (void *)&cmd_config_e_tag_port_id,
12092 cmd_config_e_tag_filter_del_parsed(
12093 void *parsed_result,
12094 __attribute__((unused)) struct cmdline *cl,
12095 __attribute__((unused)) void *data)
12097 struct cmd_config_e_tag_result *res = parsed_result;
12098 struct rte_eth_l2_tunnel_conf entry;
12101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12104 if (res->e_tag_id_val > 0x3fff) {
12105 printf("e-tag-id must be less than 0x3fff.\n");
12109 ret = rte_eth_dev_filter_supported(res->port_id,
12110 RTE_ETH_FILTER_L2_TUNNEL);
12112 printf("E-tag filter is not supported on port %u.\n",
12117 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12118 entry.tunnel_id = res->e_tag_id_val;
12120 ret = rte_eth_dev_filter_ctrl(res->port_id,
12121 RTE_ETH_FILTER_L2_TUNNEL,
12122 RTE_ETH_FILTER_DELETE,
12125 printf("E-tag filter programming error: (%s)\n",
12129 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12130 .f = cmd_config_e_tag_filter_del_parsed,
12132 .help_str = "E-tag ... : E-tag filter delete",
12134 (void *)&cmd_config_e_tag_e_tag,
12135 (void *)&cmd_config_e_tag_set,
12136 (void *)&cmd_config_e_tag_filter,
12137 (void *)&cmd_config_e_tag_del,
12138 (void *)&cmd_config_e_tag_e_tag_id,
12139 (void *)&cmd_config_e_tag_e_tag_id_val,
12140 (void *)&cmd_config_e_tag_port,
12141 (void *)&cmd_config_e_tag_port_id,
12146 /* vf vlan anti spoof configuration */
12148 /* Common result structure for vf vlan anti spoof */
12149 struct cmd_vf_vlan_anti_spoof_result {
12150 cmdline_fixed_string_t set;
12151 cmdline_fixed_string_t vf;
12152 cmdline_fixed_string_t vlan;
12153 cmdline_fixed_string_t antispoof;
12156 cmdline_fixed_string_t on_off;
12159 /* Common CLI fields for vf vlan anti spoof enable disable */
12160 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12161 TOKEN_STRING_INITIALIZER
12162 (struct cmd_vf_vlan_anti_spoof_result,
12164 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_vf_vlan_anti_spoof_result,
12168 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_vf_vlan_anti_spoof_result,
12172 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_vf_vlan_anti_spoof_result,
12175 antispoof, "antispoof");
12176 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12177 TOKEN_NUM_INITIALIZER
12178 (struct cmd_vf_vlan_anti_spoof_result,
12180 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12181 TOKEN_NUM_INITIALIZER
12182 (struct cmd_vf_vlan_anti_spoof_result,
12184 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12185 TOKEN_STRING_INITIALIZER
12186 (struct cmd_vf_vlan_anti_spoof_result,
12190 cmd_set_vf_vlan_anti_spoof_parsed(
12191 void *parsed_result,
12192 __attribute__((unused)) struct cmdline *cl,
12193 __attribute__((unused)) void *data)
12195 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12196 int ret = -ENOTSUP;
12198 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12200 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12203 #ifdef RTE_LIBRTE_IXGBE_PMD
12204 if (ret == -ENOTSUP)
12205 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12206 res->vf_id, is_on);
12208 #ifdef RTE_LIBRTE_I40E_PMD
12209 if (ret == -ENOTSUP)
12210 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12211 res->vf_id, is_on);
12213 #ifdef RTE_LIBRTE_BNXT_PMD
12214 if (ret == -ENOTSUP)
12215 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12216 res->vf_id, is_on);
12223 printf("invalid vf_id %d\n", res->vf_id);
12226 printf("invalid port_id %d\n", res->port_id);
12229 printf("function not implemented\n");
12232 printf("programming error: (%s)\n", strerror(-ret));
12236 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12237 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12239 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12241 (void *)&cmd_vf_vlan_anti_spoof_set,
12242 (void *)&cmd_vf_vlan_anti_spoof_vf,
12243 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12244 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12245 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12246 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12247 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12252 /* vf mac anti spoof configuration */
12254 /* Common result structure for vf mac anti spoof */
12255 struct cmd_vf_mac_anti_spoof_result {
12256 cmdline_fixed_string_t set;
12257 cmdline_fixed_string_t vf;
12258 cmdline_fixed_string_t mac;
12259 cmdline_fixed_string_t antispoof;
12262 cmdline_fixed_string_t on_off;
12265 /* Common CLI fields for vf mac anti spoof enable disable */
12266 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12267 TOKEN_STRING_INITIALIZER
12268 (struct cmd_vf_mac_anti_spoof_result,
12270 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12271 TOKEN_STRING_INITIALIZER
12272 (struct cmd_vf_mac_anti_spoof_result,
12274 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12275 TOKEN_STRING_INITIALIZER
12276 (struct cmd_vf_mac_anti_spoof_result,
12278 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_vf_mac_anti_spoof_result,
12281 antispoof, "antispoof");
12282 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12283 TOKEN_NUM_INITIALIZER
12284 (struct cmd_vf_mac_anti_spoof_result,
12286 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12287 TOKEN_NUM_INITIALIZER
12288 (struct cmd_vf_mac_anti_spoof_result,
12290 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_vf_mac_anti_spoof_result,
12296 cmd_set_vf_mac_anti_spoof_parsed(
12297 void *parsed_result,
12298 __attribute__((unused)) struct cmdline *cl,
12299 __attribute__((unused)) void *data)
12301 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12302 int ret = -ENOTSUP;
12304 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12309 #ifdef RTE_LIBRTE_IXGBE_PMD
12310 if (ret == -ENOTSUP)
12311 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12312 res->vf_id, is_on);
12314 #ifdef RTE_LIBRTE_I40E_PMD
12315 if (ret == -ENOTSUP)
12316 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12317 res->vf_id, is_on);
12319 #ifdef RTE_LIBRTE_BNXT_PMD
12320 if (ret == -ENOTSUP)
12321 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12322 res->vf_id, is_on);
12329 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12332 printf("invalid port_id %d\n", res->port_id);
12335 printf("function not implemented\n");
12338 printf("programming error: (%s)\n", strerror(-ret));
12342 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12343 .f = cmd_set_vf_mac_anti_spoof_parsed,
12345 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12347 (void *)&cmd_vf_mac_anti_spoof_set,
12348 (void *)&cmd_vf_mac_anti_spoof_vf,
12349 (void *)&cmd_vf_mac_anti_spoof_mac,
12350 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12351 (void *)&cmd_vf_mac_anti_spoof_port_id,
12352 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12353 (void *)&cmd_vf_mac_anti_spoof_on_off,
12358 /* vf vlan strip queue configuration */
12360 /* Common result structure for vf mac anti spoof */
12361 struct cmd_vf_vlan_stripq_result {
12362 cmdline_fixed_string_t set;
12363 cmdline_fixed_string_t vf;
12364 cmdline_fixed_string_t vlan;
12365 cmdline_fixed_string_t stripq;
12368 cmdline_fixed_string_t on_off;
12371 /* Common CLI fields for vf vlan strip enable disable */
12372 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_vf_vlan_stripq_result,
12376 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_vf_vlan_stripq_result,
12380 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_vf_vlan_stripq_result,
12384 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_vf_vlan_stripq_result,
12388 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12389 TOKEN_NUM_INITIALIZER
12390 (struct cmd_vf_vlan_stripq_result,
12392 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12393 TOKEN_NUM_INITIALIZER
12394 (struct cmd_vf_vlan_stripq_result,
12396 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_vf_vlan_stripq_result,
12402 cmd_set_vf_vlan_stripq_parsed(
12403 void *parsed_result,
12404 __attribute__((unused)) struct cmdline *cl,
12405 __attribute__((unused)) void *data)
12407 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12408 int ret = -ENOTSUP;
12410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12415 #ifdef RTE_LIBRTE_IXGBE_PMD
12416 if (ret == -ENOTSUP)
12417 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12418 res->vf_id, is_on);
12420 #ifdef RTE_LIBRTE_I40E_PMD
12421 if (ret == -ENOTSUP)
12422 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12423 res->vf_id, is_on);
12425 #ifdef RTE_LIBRTE_BNXT_PMD
12426 if (ret == -ENOTSUP)
12427 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12428 res->vf_id, is_on);
12435 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12438 printf("invalid port_id %d\n", res->port_id);
12441 printf("function not implemented\n");
12444 printf("programming error: (%s)\n", strerror(-ret));
12448 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12449 .f = cmd_set_vf_vlan_stripq_parsed,
12451 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12453 (void *)&cmd_vf_vlan_stripq_set,
12454 (void *)&cmd_vf_vlan_stripq_vf,
12455 (void *)&cmd_vf_vlan_stripq_vlan,
12456 (void *)&cmd_vf_vlan_stripq_stripq,
12457 (void *)&cmd_vf_vlan_stripq_port_id,
12458 (void *)&cmd_vf_vlan_stripq_vf_id,
12459 (void *)&cmd_vf_vlan_stripq_on_off,
12464 /* vf vlan insert configuration */
12466 /* Common result structure for vf vlan insert */
12467 struct cmd_vf_vlan_insert_result {
12468 cmdline_fixed_string_t set;
12469 cmdline_fixed_string_t vf;
12470 cmdline_fixed_string_t vlan;
12471 cmdline_fixed_string_t insert;
12477 /* Common CLI fields for vf vlan insert enable disable */
12478 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_vf_vlan_insert_result,
12482 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_vlan_insert_result,
12486 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_vlan_insert_result,
12490 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_vf_vlan_insert_result,
12494 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12495 TOKEN_NUM_INITIALIZER
12496 (struct cmd_vf_vlan_insert_result,
12498 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_vlan_insert_result,
12502 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12503 TOKEN_NUM_INITIALIZER
12504 (struct cmd_vf_vlan_insert_result,
12508 cmd_set_vf_vlan_insert_parsed(
12509 void *parsed_result,
12510 __attribute__((unused)) struct cmdline *cl,
12511 __attribute__((unused)) void *data)
12513 struct cmd_vf_vlan_insert_result *res = parsed_result;
12514 int ret = -ENOTSUP;
12516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12519 #ifdef RTE_LIBRTE_IXGBE_PMD
12520 if (ret == -ENOTSUP)
12521 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12524 #ifdef RTE_LIBRTE_I40E_PMD
12525 if (ret == -ENOTSUP)
12526 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12529 #ifdef RTE_LIBRTE_BNXT_PMD
12530 if (ret == -ENOTSUP)
12531 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12539 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12542 printf("invalid port_id %d\n", res->port_id);
12545 printf("function not implemented\n");
12548 printf("programming error: (%s)\n", strerror(-ret));
12552 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12553 .f = cmd_set_vf_vlan_insert_parsed,
12555 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12557 (void *)&cmd_vf_vlan_insert_set,
12558 (void *)&cmd_vf_vlan_insert_vf,
12559 (void *)&cmd_vf_vlan_insert_vlan,
12560 (void *)&cmd_vf_vlan_insert_insert,
12561 (void *)&cmd_vf_vlan_insert_port_id,
12562 (void *)&cmd_vf_vlan_insert_vf_id,
12563 (void *)&cmd_vf_vlan_insert_vlan_id,
12568 /* tx loopback configuration */
12570 /* Common result structure for tx loopback */
12571 struct cmd_tx_loopback_result {
12572 cmdline_fixed_string_t set;
12573 cmdline_fixed_string_t tx;
12574 cmdline_fixed_string_t loopback;
12576 cmdline_fixed_string_t on_off;
12579 /* Common CLI fields for tx loopback enable disable */
12580 cmdline_parse_token_string_t cmd_tx_loopback_set =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_tx_loopback_result,
12584 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_tx_loopback_result,
12588 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_tx_loopback_result,
12591 loopback, "loopback");
12592 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12593 TOKEN_NUM_INITIALIZER
12594 (struct cmd_tx_loopback_result,
12596 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12597 TOKEN_STRING_INITIALIZER
12598 (struct cmd_tx_loopback_result,
12602 cmd_set_tx_loopback_parsed(
12603 void *parsed_result,
12604 __attribute__((unused)) struct cmdline *cl,
12605 __attribute__((unused)) void *data)
12607 struct cmd_tx_loopback_result *res = parsed_result;
12608 int ret = -ENOTSUP;
12610 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12612 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12615 #ifdef RTE_LIBRTE_IXGBE_PMD
12616 if (ret == -ENOTSUP)
12617 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12619 #ifdef RTE_LIBRTE_I40E_PMD
12620 if (ret == -ENOTSUP)
12621 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12623 #ifdef RTE_LIBRTE_BNXT_PMD
12624 if (ret == -ENOTSUP)
12625 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12632 printf("invalid is_on %d\n", is_on);
12635 printf("invalid port_id %d\n", res->port_id);
12638 printf("function not implemented\n");
12641 printf("programming error: (%s)\n", strerror(-ret));
12645 cmdline_parse_inst_t cmd_set_tx_loopback = {
12646 .f = cmd_set_tx_loopback_parsed,
12648 .help_str = "set tx loopback <port_id> on|off",
12650 (void *)&cmd_tx_loopback_set,
12651 (void *)&cmd_tx_loopback_tx,
12652 (void *)&cmd_tx_loopback_loopback,
12653 (void *)&cmd_tx_loopback_port_id,
12654 (void *)&cmd_tx_loopback_on_off,
12659 /* all queues drop enable configuration */
12661 /* Common result structure for all queues drop enable */
12662 struct cmd_all_queues_drop_en_result {
12663 cmdline_fixed_string_t set;
12664 cmdline_fixed_string_t all;
12665 cmdline_fixed_string_t queues;
12666 cmdline_fixed_string_t drop;
12668 cmdline_fixed_string_t on_off;
12671 /* Common CLI fields for tx loopback enable disable */
12672 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12673 TOKEN_STRING_INITIALIZER
12674 (struct cmd_all_queues_drop_en_result,
12676 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_all_queues_drop_en_result,
12680 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_all_queues_drop_en_result,
12684 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12685 TOKEN_STRING_INITIALIZER
12686 (struct cmd_all_queues_drop_en_result,
12688 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12689 TOKEN_NUM_INITIALIZER
12690 (struct cmd_all_queues_drop_en_result,
12692 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12693 TOKEN_STRING_INITIALIZER
12694 (struct cmd_all_queues_drop_en_result,
12698 cmd_set_all_queues_drop_en_parsed(
12699 void *parsed_result,
12700 __attribute__((unused)) struct cmdline *cl,
12701 __attribute__((unused)) void *data)
12703 struct cmd_all_queues_drop_en_result *res = parsed_result;
12704 int ret = -ENOTSUP;
12705 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12710 #ifdef RTE_LIBRTE_IXGBE_PMD
12711 if (ret == -ENOTSUP)
12712 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12714 #ifdef RTE_LIBRTE_BNXT_PMD
12715 if (ret == -ENOTSUP)
12716 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12722 printf("invalid is_on %d\n", is_on);
12725 printf("invalid port_id %d\n", res->port_id);
12728 printf("function not implemented\n");
12731 printf("programming error: (%s)\n", strerror(-ret));
12735 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12736 .f = cmd_set_all_queues_drop_en_parsed,
12738 .help_str = "set all queues drop <port_id> on|off",
12740 (void *)&cmd_all_queues_drop_en_set,
12741 (void *)&cmd_all_queues_drop_en_all,
12742 (void *)&cmd_all_queues_drop_en_queues,
12743 (void *)&cmd_all_queues_drop_en_drop,
12744 (void *)&cmd_all_queues_drop_en_port_id,
12745 (void *)&cmd_all_queues_drop_en_on_off,
12750 /* vf split drop enable configuration */
12752 /* Common result structure for vf split drop enable */
12753 struct cmd_vf_split_drop_en_result {
12754 cmdline_fixed_string_t set;
12755 cmdline_fixed_string_t vf;
12756 cmdline_fixed_string_t split;
12757 cmdline_fixed_string_t drop;
12760 cmdline_fixed_string_t on_off;
12763 /* Common CLI fields for vf split drop enable disable */
12764 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_vf_split_drop_en_result,
12768 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_vf_split_drop_en_result,
12772 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_vf_split_drop_en_result,
12776 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_vf_split_drop_en_result,
12780 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12781 TOKEN_NUM_INITIALIZER
12782 (struct cmd_vf_split_drop_en_result,
12784 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12785 TOKEN_NUM_INITIALIZER
12786 (struct cmd_vf_split_drop_en_result,
12788 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_vf_split_drop_en_result,
12794 cmd_set_vf_split_drop_en_parsed(
12795 void *parsed_result,
12796 __attribute__((unused)) struct cmdline *cl,
12797 __attribute__((unused)) void *data)
12799 struct cmd_vf_split_drop_en_result *res = parsed_result;
12800 int ret = -ENOTSUP;
12801 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12806 #ifdef RTE_LIBRTE_IXGBE_PMD
12807 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12814 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12817 printf("invalid port_id %d\n", res->port_id);
12820 printf("not supported on port %d\n", res->port_id);
12823 printf("programming error: (%s)\n", strerror(-ret));
12827 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12828 .f = cmd_set_vf_split_drop_en_parsed,
12830 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12832 (void *)&cmd_vf_split_drop_en_set,
12833 (void *)&cmd_vf_split_drop_en_vf,
12834 (void *)&cmd_vf_split_drop_en_split,
12835 (void *)&cmd_vf_split_drop_en_drop,
12836 (void *)&cmd_vf_split_drop_en_port_id,
12837 (void *)&cmd_vf_split_drop_en_vf_id,
12838 (void *)&cmd_vf_split_drop_en_on_off,
12843 /* vf mac address configuration */
12845 /* Common result structure for vf mac address */
12846 struct cmd_set_vf_mac_addr_result {
12847 cmdline_fixed_string_t set;
12848 cmdline_fixed_string_t vf;
12849 cmdline_fixed_string_t mac;
12850 cmdline_fixed_string_t addr;
12853 struct ether_addr mac_addr;
12857 /* Common CLI fields for vf split drop enable disable */
12858 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12859 TOKEN_STRING_INITIALIZER
12860 (struct cmd_set_vf_mac_addr_result,
12862 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_set_vf_mac_addr_result,
12866 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_set_vf_mac_addr_result,
12870 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_set_vf_mac_addr_result,
12874 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_set_vf_mac_addr_result,
12878 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12879 TOKEN_NUM_INITIALIZER
12880 (struct cmd_set_vf_mac_addr_result,
12882 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12883 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12887 cmd_set_vf_mac_addr_parsed(
12888 void *parsed_result,
12889 __attribute__((unused)) struct cmdline *cl,
12890 __attribute__((unused)) void *data)
12892 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12893 int ret = -ENOTSUP;
12895 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12898 #ifdef RTE_LIBRTE_IXGBE_PMD
12899 if (ret == -ENOTSUP)
12900 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12903 #ifdef RTE_LIBRTE_I40E_PMD
12904 if (ret == -ENOTSUP)
12905 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12908 #ifdef RTE_LIBRTE_BNXT_PMD
12909 if (ret == -ENOTSUP)
12910 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12918 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12921 printf("invalid port_id %d\n", res->port_id);
12924 printf("function not implemented\n");
12927 printf("programming error: (%s)\n", strerror(-ret));
12931 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12932 .f = cmd_set_vf_mac_addr_parsed,
12934 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12936 (void *)&cmd_set_vf_mac_addr_set,
12937 (void *)&cmd_set_vf_mac_addr_vf,
12938 (void *)&cmd_set_vf_mac_addr_mac,
12939 (void *)&cmd_set_vf_mac_addr_addr,
12940 (void *)&cmd_set_vf_mac_addr_port_id,
12941 (void *)&cmd_set_vf_mac_addr_vf_id,
12942 (void *)&cmd_set_vf_mac_addr_mac_addr,
12947 /* MACsec configuration */
12949 /* Common result structure for MACsec offload enable */
12950 struct cmd_macsec_offload_on_result {
12951 cmdline_fixed_string_t set;
12952 cmdline_fixed_string_t macsec;
12953 cmdline_fixed_string_t offload;
12955 cmdline_fixed_string_t on;
12956 cmdline_fixed_string_t encrypt;
12957 cmdline_fixed_string_t en_on_off;
12958 cmdline_fixed_string_t replay_protect;
12959 cmdline_fixed_string_t rp_on_off;
12962 /* Common CLI fields for MACsec offload disable */
12963 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_macsec_offload_on_result,
12967 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_macsec_offload_on_result,
12971 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_macsec_offload_on_result,
12974 offload, "offload");
12975 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12976 TOKEN_NUM_INITIALIZER
12977 (struct cmd_macsec_offload_on_result,
12979 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_macsec_offload_on_result,
12983 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_macsec_offload_on_result,
12986 encrypt, "encrypt");
12987 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_macsec_offload_on_result,
12990 en_on_off, "on#off");
12991 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_macsec_offload_on_result,
12994 replay_protect, "replay-protect");
12995 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_macsec_offload_on_result,
12998 rp_on_off, "on#off");
13001 cmd_set_macsec_offload_on_parsed(
13002 void *parsed_result,
13003 __attribute__((unused)) struct cmdline *cl,
13004 __attribute__((unused)) void *data)
13006 struct cmd_macsec_offload_on_result *res = parsed_result;
13007 int ret = -ENOTSUP;
13008 portid_t port_id = res->port_id;
13009 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13010 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13012 if (port_id_is_invalid(port_id, ENABLED_WARN))
13015 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
13016 #ifdef RTE_LIBRTE_IXGBE_PMD
13017 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13026 printf("invalid port_id %d\n", port_id);
13029 printf("not supported on port %d\n", port_id);
13032 printf("programming error: (%s)\n", strerror(-ret));
13036 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13037 .f = cmd_set_macsec_offload_on_parsed,
13039 .help_str = "set macsec offload <port_id> on "
13040 "encrypt on|off replay-protect on|off",
13042 (void *)&cmd_macsec_offload_on_set,
13043 (void *)&cmd_macsec_offload_on_macsec,
13044 (void *)&cmd_macsec_offload_on_offload,
13045 (void *)&cmd_macsec_offload_on_port_id,
13046 (void *)&cmd_macsec_offload_on_on,
13047 (void *)&cmd_macsec_offload_on_encrypt,
13048 (void *)&cmd_macsec_offload_on_en_on_off,
13049 (void *)&cmd_macsec_offload_on_replay_protect,
13050 (void *)&cmd_macsec_offload_on_rp_on_off,
13055 /* Common result structure for MACsec offload disable */
13056 struct cmd_macsec_offload_off_result {
13057 cmdline_fixed_string_t set;
13058 cmdline_fixed_string_t macsec;
13059 cmdline_fixed_string_t offload;
13061 cmdline_fixed_string_t off;
13064 /* Common CLI fields for MACsec offload disable */
13065 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_macsec_offload_off_result,
13069 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_macsec_offload_off_result,
13073 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_macsec_offload_off_result,
13076 offload, "offload");
13077 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13078 TOKEN_NUM_INITIALIZER
13079 (struct cmd_macsec_offload_off_result,
13081 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_macsec_offload_off_result,
13087 cmd_set_macsec_offload_off_parsed(
13088 void *parsed_result,
13089 __attribute__((unused)) struct cmdline *cl,
13090 __attribute__((unused)) void *data)
13092 struct cmd_macsec_offload_off_result *res = parsed_result;
13093 int ret = -ENOTSUP;
13094 portid_t port_id = res->port_id;
13096 if (port_id_is_invalid(port_id, ENABLED_WARN))
13099 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13100 #ifdef RTE_LIBRTE_IXGBE_PMD
13101 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13108 printf("invalid port_id %d\n", port_id);
13111 printf("not supported on port %d\n", port_id);
13114 printf("programming error: (%s)\n", strerror(-ret));
13118 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13119 .f = cmd_set_macsec_offload_off_parsed,
13121 .help_str = "set macsec offload <port_id> off",
13123 (void *)&cmd_macsec_offload_off_set,
13124 (void *)&cmd_macsec_offload_off_macsec,
13125 (void *)&cmd_macsec_offload_off_offload,
13126 (void *)&cmd_macsec_offload_off_port_id,
13127 (void *)&cmd_macsec_offload_off_off,
13132 /* Common result structure for MACsec secure connection configure */
13133 struct cmd_macsec_sc_result {
13134 cmdline_fixed_string_t set;
13135 cmdline_fixed_string_t macsec;
13136 cmdline_fixed_string_t sc;
13137 cmdline_fixed_string_t tx_rx;
13139 struct ether_addr mac;
13143 /* Common CLI fields for MACsec secure connection configure */
13144 cmdline_parse_token_string_t cmd_macsec_sc_set =
13145 TOKEN_STRING_INITIALIZER
13146 (struct cmd_macsec_sc_result,
13148 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_macsec_sc_result,
13152 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13153 TOKEN_STRING_INITIALIZER
13154 (struct cmd_macsec_sc_result,
13156 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13157 TOKEN_STRING_INITIALIZER
13158 (struct cmd_macsec_sc_result,
13160 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13161 TOKEN_NUM_INITIALIZER
13162 (struct cmd_macsec_sc_result,
13164 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13165 TOKEN_ETHERADDR_INITIALIZER
13166 (struct cmd_macsec_sc_result,
13168 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13169 TOKEN_NUM_INITIALIZER
13170 (struct cmd_macsec_sc_result,
13174 cmd_set_macsec_sc_parsed(
13175 void *parsed_result,
13176 __attribute__((unused)) struct cmdline *cl,
13177 __attribute__((unused)) void *data)
13179 struct cmd_macsec_sc_result *res = parsed_result;
13180 int ret = -ENOTSUP;
13181 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13183 #ifdef RTE_LIBRTE_IXGBE_PMD
13185 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13186 res->mac.addr_bytes) :
13187 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13188 res->mac.addr_bytes, res->pi);
13190 RTE_SET_USED(is_tx);
13196 printf("invalid port_id %d\n", res->port_id);
13199 printf("not supported on port %d\n", res->port_id);
13202 printf("programming error: (%s)\n", strerror(-ret));
13206 cmdline_parse_inst_t cmd_set_macsec_sc = {
13207 .f = cmd_set_macsec_sc_parsed,
13209 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13211 (void *)&cmd_macsec_sc_set,
13212 (void *)&cmd_macsec_sc_macsec,
13213 (void *)&cmd_macsec_sc_sc,
13214 (void *)&cmd_macsec_sc_tx_rx,
13215 (void *)&cmd_macsec_sc_port_id,
13216 (void *)&cmd_macsec_sc_mac,
13217 (void *)&cmd_macsec_sc_pi,
13222 /* Common result structure for MACsec secure connection configure */
13223 struct cmd_macsec_sa_result {
13224 cmdline_fixed_string_t set;
13225 cmdline_fixed_string_t macsec;
13226 cmdline_fixed_string_t sa;
13227 cmdline_fixed_string_t tx_rx;
13232 cmdline_fixed_string_t key;
13235 /* Common CLI fields for MACsec secure connection configure */
13236 cmdline_parse_token_string_t cmd_macsec_sa_set =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_macsec_sa_result,
13240 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13241 TOKEN_STRING_INITIALIZER
13242 (struct cmd_macsec_sa_result,
13244 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_macsec_sa_result,
13248 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13249 TOKEN_STRING_INITIALIZER
13250 (struct cmd_macsec_sa_result,
13252 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13253 TOKEN_NUM_INITIALIZER
13254 (struct cmd_macsec_sa_result,
13256 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13257 TOKEN_NUM_INITIALIZER
13258 (struct cmd_macsec_sa_result,
13260 cmdline_parse_token_num_t cmd_macsec_sa_an =
13261 TOKEN_NUM_INITIALIZER
13262 (struct cmd_macsec_sa_result,
13264 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13265 TOKEN_NUM_INITIALIZER
13266 (struct cmd_macsec_sa_result,
13268 cmdline_parse_token_string_t cmd_macsec_sa_key =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_macsec_sa_result,
13274 cmd_set_macsec_sa_parsed(
13275 void *parsed_result,
13276 __attribute__((unused)) struct cmdline *cl,
13277 __attribute__((unused)) void *data)
13279 struct cmd_macsec_sa_result *res = parsed_result;
13280 int ret = -ENOTSUP;
13281 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13282 uint8_t key[16] = { 0 };
13288 key_len = strlen(res->key) / 2;
13292 for (i = 0; i < key_len; i++) {
13293 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13296 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13299 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13302 #ifdef RTE_LIBRTE_IXGBE_PMD
13304 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13305 res->idx, res->an, res->pn, key) :
13306 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13307 res->idx, res->an, res->pn, key);
13309 RTE_SET_USED(is_tx);
13316 printf("invalid idx %d or an %d\n", res->idx, res->an);
13319 printf("invalid port_id %d\n", res->port_id);
13322 printf("not supported on port %d\n", res->port_id);
13325 printf("programming error: (%s)\n", strerror(-ret));
13329 cmdline_parse_inst_t cmd_set_macsec_sa = {
13330 .f = cmd_set_macsec_sa_parsed,
13332 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13334 (void *)&cmd_macsec_sa_set,
13335 (void *)&cmd_macsec_sa_macsec,
13336 (void *)&cmd_macsec_sa_sa,
13337 (void *)&cmd_macsec_sa_tx_rx,
13338 (void *)&cmd_macsec_sa_port_id,
13339 (void *)&cmd_macsec_sa_idx,
13340 (void *)&cmd_macsec_sa_an,
13341 (void *)&cmd_macsec_sa_pn,
13342 (void *)&cmd_macsec_sa_key,
13347 /* VF unicast promiscuous mode configuration */
13349 /* Common result structure for VF unicast promiscuous mode */
13350 struct cmd_vf_promisc_result {
13351 cmdline_fixed_string_t set;
13352 cmdline_fixed_string_t vf;
13353 cmdline_fixed_string_t promisc;
13356 cmdline_fixed_string_t on_off;
13359 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13360 cmdline_parse_token_string_t cmd_vf_promisc_set =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_promisc_result,
13364 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_promisc_result,
13368 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_vf_promisc_result,
13371 promisc, "promisc");
13372 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13373 TOKEN_NUM_INITIALIZER
13374 (struct cmd_vf_promisc_result,
13376 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13377 TOKEN_NUM_INITIALIZER
13378 (struct cmd_vf_promisc_result,
13380 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_vf_promisc_result,
13386 cmd_set_vf_promisc_parsed(
13387 void *parsed_result,
13388 __attribute__((unused)) struct cmdline *cl,
13389 __attribute__((unused)) void *data)
13391 struct cmd_vf_promisc_result *res = parsed_result;
13392 int ret = -ENOTSUP;
13394 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13399 #ifdef RTE_LIBRTE_I40E_PMD
13400 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13401 res->vf_id, is_on);
13408 printf("invalid vf_id %d\n", res->vf_id);
13411 printf("invalid port_id %d\n", res->port_id);
13414 printf("function not implemented\n");
13417 printf("programming error: (%s)\n", strerror(-ret));
13421 cmdline_parse_inst_t cmd_set_vf_promisc = {
13422 .f = cmd_set_vf_promisc_parsed,
13424 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13425 "Set unicast promiscuous mode for a VF from the PF",
13427 (void *)&cmd_vf_promisc_set,
13428 (void *)&cmd_vf_promisc_vf,
13429 (void *)&cmd_vf_promisc_promisc,
13430 (void *)&cmd_vf_promisc_port_id,
13431 (void *)&cmd_vf_promisc_vf_id,
13432 (void *)&cmd_vf_promisc_on_off,
13437 /* VF multicast promiscuous mode configuration */
13439 /* Common result structure for VF multicast promiscuous mode */
13440 struct cmd_vf_allmulti_result {
13441 cmdline_fixed_string_t set;
13442 cmdline_fixed_string_t vf;
13443 cmdline_fixed_string_t allmulti;
13446 cmdline_fixed_string_t on_off;
13449 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13450 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13451 TOKEN_STRING_INITIALIZER
13452 (struct cmd_vf_allmulti_result,
13454 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13455 TOKEN_STRING_INITIALIZER
13456 (struct cmd_vf_allmulti_result,
13458 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_vf_allmulti_result,
13461 allmulti, "allmulti");
13462 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13463 TOKEN_NUM_INITIALIZER
13464 (struct cmd_vf_allmulti_result,
13466 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13467 TOKEN_NUM_INITIALIZER
13468 (struct cmd_vf_allmulti_result,
13470 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_vf_allmulti_result,
13476 cmd_set_vf_allmulti_parsed(
13477 void *parsed_result,
13478 __attribute__((unused)) struct cmdline *cl,
13479 __attribute__((unused)) void *data)
13481 struct cmd_vf_allmulti_result *res = parsed_result;
13482 int ret = -ENOTSUP;
13484 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13486 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13489 #ifdef RTE_LIBRTE_I40E_PMD
13490 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13491 res->vf_id, is_on);
13498 printf("invalid vf_id %d\n", res->vf_id);
13501 printf("invalid port_id %d\n", res->port_id);
13504 printf("function not implemented\n");
13507 printf("programming error: (%s)\n", strerror(-ret));
13511 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13512 .f = cmd_set_vf_allmulti_parsed,
13514 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13515 "Set multicast promiscuous mode for a VF from the PF",
13517 (void *)&cmd_vf_allmulti_set,
13518 (void *)&cmd_vf_allmulti_vf,
13519 (void *)&cmd_vf_allmulti_allmulti,
13520 (void *)&cmd_vf_allmulti_port_id,
13521 (void *)&cmd_vf_allmulti_vf_id,
13522 (void *)&cmd_vf_allmulti_on_off,
13527 /* vf broadcast mode configuration */
13529 /* Common result structure for vf broadcast */
13530 struct cmd_set_vf_broadcast_result {
13531 cmdline_fixed_string_t set;
13532 cmdline_fixed_string_t vf;
13533 cmdline_fixed_string_t broadcast;
13536 cmdline_fixed_string_t on_off;
13539 /* Common CLI fields for vf broadcast enable disable */
13540 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13541 TOKEN_STRING_INITIALIZER
13542 (struct cmd_set_vf_broadcast_result,
13544 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_set_vf_broadcast_result,
13548 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_set_vf_broadcast_result,
13551 broadcast, "broadcast");
13552 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13553 TOKEN_NUM_INITIALIZER
13554 (struct cmd_set_vf_broadcast_result,
13556 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13557 TOKEN_NUM_INITIALIZER
13558 (struct cmd_set_vf_broadcast_result,
13560 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_set_vf_broadcast_result,
13566 cmd_set_vf_broadcast_parsed(
13567 void *parsed_result,
13568 __attribute__((unused)) struct cmdline *cl,
13569 __attribute__((unused)) void *data)
13571 struct cmd_set_vf_broadcast_result *res = parsed_result;
13572 int ret = -ENOTSUP;
13574 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13576 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13579 #ifdef RTE_LIBRTE_I40E_PMD
13580 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13581 res->vf_id, is_on);
13588 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13591 printf("invalid port_id %d\n", res->port_id);
13594 printf("function not implemented\n");
13597 printf("programming error: (%s)\n", strerror(-ret));
13601 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13602 .f = cmd_set_vf_broadcast_parsed,
13604 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13606 (void *)&cmd_set_vf_broadcast_set,
13607 (void *)&cmd_set_vf_broadcast_vf,
13608 (void *)&cmd_set_vf_broadcast_broadcast,
13609 (void *)&cmd_set_vf_broadcast_port_id,
13610 (void *)&cmd_set_vf_broadcast_vf_id,
13611 (void *)&cmd_set_vf_broadcast_on_off,
13616 /* vf vlan tag configuration */
13618 /* Common result structure for vf vlan tag */
13619 struct cmd_set_vf_vlan_tag_result {
13620 cmdline_fixed_string_t set;
13621 cmdline_fixed_string_t vf;
13622 cmdline_fixed_string_t vlan;
13623 cmdline_fixed_string_t tag;
13626 cmdline_fixed_string_t on_off;
13629 /* Common CLI fields for vf vlan tag enable disable */
13630 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13631 TOKEN_STRING_INITIALIZER
13632 (struct cmd_set_vf_vlan_tag_result,
13634 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13635 TOKEN_STRING_INITIALIZER
13636 (struct cmd_set_vf_vlan_tag_result,
13638 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13639 TOKEN_STRING_INITIALIZER
13640 (struct cmd_set_vf_vlan_tag_result,
13642 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13643 TOKEN_STRING_INITIALIZER
13644 (struct cmd_set_vf_vlan_tag_result,
13646 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13647 TOKEN_NUM_INITIALIZER
13648 (struct cmd_set_vf_vlan_tag_result,
13650 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13651 TOKEN_NUM_INITIALIZER
13652 (struct cmd_set_vf_vlan_tag_result,
13654 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_set_vf_vlan_tag_result,
13660 cmd_set_vf_vlan_tag_parsed(
13661 void *parsed_result,
13662 __attribute__((unused)) struct cmdline *cl,
13663 __attribute__((unused)) void *data)
13665 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13666 int ret = -ENOTSUP;
13668 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13673 #ifdef RTE_LIBRTE_I40E_PMD
13674 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13675 res->vf_id, is_on);
13682 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13685 printf("invalid port_id %d\n", res->port_id);
13688 printf("function not implemented\n");
13691 printf("programming error: (%s)\n", strerror(-ret));
13695 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13696 .f = cmd_set_vf_vlan_tag_parsed,
13698 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13700 (void *)&cmd_set_vf_vlan_tag_set,
13701 (void *)&cmd_set_vf_vlan_tag_vf,
13702 (void *)&cmd_set_vf_vlan_tag_vlan,
13703 (void *)&cmd_set_vf_vlan_tag_tag,
13704 (void *)&cmd_set_vf_vlan_tag_port_id,
13705 (void *)&cmd_set_vf_vlan_tag_vf_id,
13706 (void *)&cmd_set_vf_vlan_tag_on_off,
13711 /* Common definition of VF and TC TX bandwidth configuration */
13712 struct cmd_vf_tc_bw_result {
13713 cmdline_fixed_string_t set;
13714 cmdline_fixed_string_t vf;
13715 cmdline_fixed_string_t tc;
13716 cmdline_fixed_string_t tx;
13717 cmdline_fixed_string_t min_bw;
13718 cmdline_fixed_string_t max_bw;
13719 cmdline_fixed_string_t strict_link_prio;
13724 cmdline_fixed_string_t bw_list;
13728 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13729 TOKEN_STRING_INITIALIZER
13730 (struct cmd_vf_tc_bw_result,
13732 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13733 TOKEN_STRING_INITIALIZER
13734 (struct cmd_vf_tc_bw_result,
13736 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13737 TOKEN_STRING_INITIALIZER
13738 (struct cmd_vf_tc_bw_result,
13740 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13741 TOKEN_STRING_INITIALIZER
13742 (struct cmd_vf_tc_bw_result,
13744 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_vf_tc_bw_result,
13747 strict_link_prio, "strict-link-priority");
13748 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_vf_tc_bw_result,
13751 min_bw, "min-bandwidth");
13752 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_vf_tc_bw_result,
13755 max_bw, "max-bandwidth");
13756 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13757 TOKEN_NUM_INITIALIZER
13758 (struct cmd_vf_tc_bw_result,
13760 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13761 TOKEN_NUM_INITIALIZER
13762 (struct cmd_vf_tc_bw_result,
13764 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_vf_tc_bw_result,
13768 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13769 TOKEN_NUM_INITIALIZER
13770 (struct cmd_vf_tc_bw_result,
13772 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13773 TOKEN_STRING_INITIALIZER
13774 (struct cmd_vf_tc_bw_result,
13776 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13777 TOKEN_NUM_INITIALIZER
13778 (struct cmd_vf_tc_bw_result,
13781 /* VF max bandwidth setting */
13783 cmd_vf_max_bw_parsed(
13784 void *parsed_result,
13785 __attribute__((unused)) struct cmdline *cl,
13786 __attribute__((unused)) void *data)
13788 struct cmd_vf_tc_bw_result *res = parsed_result;
13789 int ret = -ENOTSUP;
13791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13794 #ifdef RTE_LIBRTE_I40E_PMD
13795 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13796 res->vf_id, res->bw);
13803 printf("invalid vf_id %d or bandwidth %d\n",
13804 res->vf_id, res->bw);
13807 printf("invalid port_id %d\n", res->port_id);
13810 printf("function not implemented\n");
13813 printf("programming error: (%s)\n", strerror(-ret));
13817 cmdline_parse_inst_t cmd_vf_max_bw = {
13818 .f = cmd_vf_max_bw_parsed,
13820 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13822 (void *)&cmd_vf_tc_bw_set,
13823 (void *)&cmd_vf_tc_bw_vf,
13824 (void *)&cmd_vf_tc_bw_tx,
13825 (void *)&cmd_vf_tc_bw_max_bw,
13826 (void *)&cmd_vf_tc_bw_port_id,
13827 (void *)&cmd_vf_tc_bw_vf_id,
13828 (void *)&cmd_vf_tc_bw_bw,
13834 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13839 const char *p, *p0 = str;
13846 p = strchr(p0, '(');
13848 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13852 p0 = strchr(p, ')');
13854 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13858 if (size >= sizeof(s)) {
13859 printf("The string size exceeds the internal buffer size\n");
13862 snprintf(s, sizeof(s), "%.*s", size, p);
13863 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13865 printf("Failed to get the bandwidth list. ");
13869 for (i = 0; i < ret; i++)
13870 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13875 /* TC min bandwidth setting */
13877 cmd_vf_tc_min_bw_parsed(
13878 void *parsed_result,
13879 __attribute__((unused)) struct cmdline *cl,
13880 __attribute__((unused)) void *data)
13882 struct cmd_vf_tc_bw_result *res = parsed_result;
13885 int ret = -ENOTSUP;
13887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13890 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13894 #ifdef RTE_LIBRTE_I40E_PMD
13895 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13903 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13906 printf("invalid port_id %d\n", res->port_id);
13909 printf("function not implemented\n");
13912 printf("programming error: (%s)\n", strerror(-ret));
13916 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13917 .f = cmd_vf_tc_min_bw_parsed,
13919 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13920 " <bw1, bw2, ...>",
13922 (void *)&cmd_vf_tc_bw_set,
13923 (void *)&cmd_vf_tc_bw_vf,
13924 (void *)&cmd_vf_tc_bw_tc,
13925 (void *)&cmd_vf_tc_bw_tx,
13926 (void *)&cmd_vf_tc_bw_min_bw,
13927 (void *)&cmd_vf_tc_bw_port_id,
13928 (void *)&cmd_vf_tc_bw_vf_id,
13929 (void *)&cmd_vf_tc_bw_bw_list,
13935 cmd_tc_min_bw_parsed(
13936 void *parsed_result,
13937 __attribute__((unused)) struct cmdline *cl,
13938 __attribute__((unused)) void *data)
13940 struct cmd_vf_tc_bw_result *res = parsed_result;
13941 struct rte_port *port;
13944 int ret = -ENOTSUP;
13946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13949 port = &ports[res->port_id];
13950 /** Check if the port is not started **/
13951 if (port->port_status != RTE_PORT_STOPPED) {
13952 printf("Please stop port %d first\n", res->port_id);
13956 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13960 #ifdef RTE_LIBRTE_IXGBE_PMD
13961 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13968 printf("invalid bandwidth\n");
13971 printf("invalid port_id %d\n", res->port_id);
13974 printf("function not implemented\n");
13977 printf("programming error: (%s)\n", strerror(-ret));
13981 cmdline_parse_inst_t cmd_tc_min_bw = {
13982 .f = cmd_tc_min_bw_parsed,
13984 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13986 (void *)&cmd_vf_tc_bw_set,
13987 (void *)&cmd_vf_tc_bw_tc,
13988 (void *)&cmd_vf_tc_bw_tx,
13989 (void *)&cmd_vf_tc_bw_min_bw,
13990 (void *)&cmd_vf_tc_bw_port_id,
13991 (void *)&cmd_vf_tc_bw_bw_list,
13996 /* TC max bandwidth setting */
13998 cmd_vf_tc_max_bw_parsed(
13999 void *parsed_result,
14000 __attribute__((unused)) struct cmdline *cl,
14001 __attribute__((unused)) void *data)
14003 struct cmd_vf_tc_bw_result *res = parsed_result;
14004 int ret = -ENOTSUP;
14006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14009 #ifdef RTE_LIBRTE_I40E_PMD
14010 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14011 res->tc_no, res->bw);
14018 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14019 res->vf_id, res->tc_no, res->bw);
14022 printf("invalid port_id %d\n", res->port_id);
14025 printf("function not implemented\n");
14028 printf("programming error: (%s)\n", strerror(-ret));
14032 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14033 .f = cmd_vf_tc_max_bw_parsed,
14035 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14038 (void *)&cmd_vf_tc_bw_set,
14039 (void *)&cmd_vf_tc_bw_vf,
14040 (void *)&cmd_vf_tc_bw_tc,
14041 (void *)&cmd_vf_tc_bw_tx,
14042 (void *)&cmd_vf_tc_bw_max_bw,
14043 (void *)&cmd_vf_tc_bw_port_id,
14044 (void *)&cmd_vf_tc_bw_vf_id,
14045 (void *)&cmd_vf_tc_bw_tc_no,
14046 (void *)&cmd_vf_tc_bw_bw,
14052 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14054 /* *** Set Port default Traffic Management Hierarchy *** */
14055 struct cmd_set_port_tm_hierarchy_default_result {
14056 cmdline_fixed_string_t set;
14057 cmdline_fixed_string_t port;
14058 cmdline_fixed_string_t tm;
14059 cmdline_fixed_string_t hierarchy;
14060 cmdline_fixed_string_t def;
14064 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14065 TOKEN_STRING_INITIALIZER(
14066 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14067 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14068 TOKEN_STRING_INITIALIZER(
14069 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14070 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14071 TOKEN_STRING_INITIALIZER(
14072 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14073 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14074 TOKEN_STRING_INITIALIZER(
14075 struct cmd_set_port_tm_hierarchy_default_result,
14076 hierarchy, "hierarchy");
14077 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14078 TOKEN_STRING_INITIALIZER(
14079 struct cmd_set_port_tm_hierarchy_default_result,
14081 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14082 TOKEN_NUM_INITIALIZER(
14083 struct cmd_set_port_tm_hierarchy_default_result,
14086 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14087 __attribute__((unused)) struct cmdline *cl,
14088 __attribute__((unused)) void *data)
14090 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14091 struct rte_port *p;
14092 portid_t port_id = res->port_id;
14094 if (port_id_is_invalid(port_id, ENABLED_WARN))
14097 p = &ports[port_id];
14100 if (p->softport.tm_flag == 0) {
14101 printf(" tm not enabled on port %u (error)\n", port_id);
14105 /* Forward mode: tm */
14106 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14107 printf(" tm mode not enabled(error)\n");
14111 /* Set the default tm hierarchy */
14112 p->softport.tm.default_hierarchy_enable = 1;
14115 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14116 .f = cmd_set_port_tm_hierarchy_default_parsed,
14118 .help_str = "set port tm hierarchy default <port_id>",
14120 (void *)&cmd_set_port_tm_hierarchy_default_set,
14121 (void *)&cmd_set_port_tm_hierarchy_default_port,
14122 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14123 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14124 (void *)&cmd_set_port_tm_hierarchy_default_default,
14125 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14131 /* Strict link priority scheduling mode setting */
14133 cmd_strict_link_prio_parsed(
14134 void *parsed_result,
14135 __attribute__((unused)) struct cmdline *cl,
14136 __attribute__((unused)) void *data)
14138 struct cmd_vf_tc_bw_result *res = parsed_result;
14139 int ret = -ENOTSUP;
14141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14144 #ifdef RTE_LIBRTE_I40E_PMD
14145 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14152 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14155 printf("invalid port_id %d\n", res->port_id);
14158 printf("function not implemented\n");
14161 printf("programming error: (%s)\n", strerror(-ret));
14165 cmdline_parse_inst_t cmd_strict_link_prio = {
14166 .f = cmd_strict_link_prio_parsed,
14168 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14170 (void *)&cmd_vf_tc_bw_set,
14171 (void *)&cmd_vf_tc_bw_tx,
14172 (void *)&cmd_vf_tc_bw_strict_link_prio,
14173 (void *)&cmd_vf_tc_bw_port_id,
14174 (void *)&cmd_vf_tc_bw_tc_map,
14179 /* Load dynamic device personalization*/
14180 struct cmd_ddp_add_result {
14181 cmdline_fixed_string_t ddp;
14182 cmdline_fixed_string_t add;
14187 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14188 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14189 cmdline_parse_token_string_t cmd_ddp_add_add =
14190 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14191 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14192 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14193 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14194 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14197 cmd_ddp_add_parsed(
14198 void *parsed_result,
14199 __attribute__((unused)) struct cmdline *cl,
14200 __attribute__((unused)) void *data)
14202 struct cmd_ddp_add_result *res = parsed_result;
14208 int ret = -ENOTSUP;
14210 if (res->port_id > nb_ports) {
14211 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14215 if (!all_ports_stopped()) {
14216 printf("Please stop all ports first\n");
14220 filepath = strdup(res->filepath);
14221 if (filepath == NULL) {
14222 printf("Failed to allocate memory\n");
14225 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14227 buff = open_ddp_package_file(file_fld[0], &size);
14229 free((void *)filepath);
14233 #ifdef RTE_LIBRTE_I40E_PMD
14234 if (ret == -ENOTSUP)
14235 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14237 RTE_PMD_I40E_PKG_OP_WR_ADD);
14240 if (ret == -EEXIST)
14241 printf("Profile has already existed.\n");
14243 printf("Failed to load profile.\n");
14244 else if (file_num == 2)
14245 save_ddp_package_file(file_fld[1], buff, size);
14247 close_ddp_package_file(buff);
14248 free((void *)filepath);
14251 cmdline_parse_inst_t cmd_ddp_add = {
14252 .f = cmd_ddp_add_parsed,
14254 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14256 (void *)&cmd_ddp_add_ddp,
14257 (void *)&cmd_ddp_add_add,
14258 (void *)&cmd_ddp_add_port_id,
14259 (void *)&cmd_ddp_add_filepath,
14264 /* Delete dynamic device personalization*/
14265 struct cmd_ddp_del_result {
14266 cmdline_fixed_string_t ddp;
14267 cmdline_fixed_string_t del;
14272 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14274 cmdline_parse_token_string_t cmd_ddp_del_del =
14275 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14276 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14277 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14278 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14279 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14282 cmd_ddp_del_parsed(
14283 void *parsed_result,
14284 __attribute__((unused)) struct cmdline *cl,
14285 __attribute__((unused)) void *data)
14287 struct cmd_ddp_del_result *res = parsed_result;
14290 int ret = -ENOTSUP;
14292 if (res->port_id > nb_ports) {
14293 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14297 if (!all_ports_stopped()) {
14298 printf("Please stop all ports first\n");
14302 buff = open_ddp_package_file(res->filepath, &size);
14306 #ifdef RTE_LIBRTE_I40E_PMD
14307 if (ret == -ENOTSUP)
14308 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14310 RTE_PMD_I40E_PKG_OP_WR_DEL);
14313 if (ret == -EACCES)
14314 printf("Profile does not exist.\n");
14316 printf("Failed to delete profile.\n");
14318 close_ddp_package_file(buff);
14321 cmdline_parse_inst_t cmd_ddp_del = {
14322 .f = cmd_ddp_del_parsed,
14324 .help_str = "ddp del <port_id> <profile_path>",
14326 (void *)&cmd_ddp_del_ddp,
14327 (void *)&cmd_ddp_del_del,
14328 (void *)&cmd_ddp_del_port_id,
14329 (void *)&cmd_ddp_del_filepath,
14334 /* Get dynamic device personalization profile info */
14335 struct cmd_ddp_info_result {
14336 cmdline_fixed_string_t ddp;
14337 cmdline_fixed_string_t get;
14338 cmdline_fixed_string_t info;
14342 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14344 cmdline_parse_token_string_t cmd_ddp_info_get =
14345 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14346 cmdline_parse_token_string_t cmd_ddp_info_info =
14347 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14348 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14349 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14352 cmd_ddp_info_parsed(
14353 void *parsed_result,
14354 __attribute__((unused)) struct cmdline *cl,
14355 __attribute__((unused)) void *data)
14357 struct cmd_ddp_info_result *res = parsed_result;
14360 int ret = -ENOTSUP;
14361 #ifdef RTE_LIBRTE_I40E_PMD
14364 uint32_t buff_size = 0;
14365 struct rte_pmd_i40e_profile_info info;
14366 uint32_t dev_num = 0;
14367 struct rte_pmd_i40e_ddp_device_id *devs;
14368 uint32_t proto_num = 0;
14369 struct rte_pmd_i40e_proto_info *proto = NULL;
14370 uint32_t pctype_num = 0;
14371 struct rte_pmd_i40e_ptype_info *pctype;
14372 uint32_t ptype_num = 0;
14373 struct rte_pmd_i40e_ptype_info *ptype;
14378 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14382 #ifdef RTE_LIBRTE_I40E_PMD
14383 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14384 (uint8_t *)&info, sizeof(info),
14385 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14387 printf("Global Track id: 0x%x\n", info.track_id);
14388 printf("Global Version: %d.%d.%d.%d\n",
14389 info.version.major,
14390 info.version.minor,
14391 info.version.update,
14392 info.version.draft);
14393 printf("Global Package name: %s\n\n", info.name);
14396 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14397 (uint8_t *)&info, sizeof(info),
14398 RTE_PMD_I40E_PKG_INFO_HEADER);
14400 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14401 printf("i40e Profile Version: %d.%d.%d.%d\n",
14402 info.version.major,
14403 info.version.minor,
14404 info.version.update,
14405 info.version.draft);
14406 printf("i40e Profile name: %s\n\n", info.name);
14409 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14410 (uint8_t *)&buff_size, sizeof(buff_size),
14411 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14412 if (!ret && buff_size) {
14413 buff = (uint8_t *)malloc(buff_size);
14415 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14417 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14419 printf("Package Notes:\n%s\n\n", buff);
14424 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14425 (uint8_t *)&dev_num, sizeof(dev_num),
14426 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14427 if (!ret && dev_num) {
14428 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14429 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14431 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14432 (uint8_t *)devs, buff_size,
14433 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14435 printf("List of supported devices:\n");
14436 for (i = 0; i < dev_num; i++) {
14437 printf(" %04X:%04X %04X:%04X\n",
14438 devs[i].vendor_dev_id >> 16,
14439 devs[i].vendor_dev_id & 0xFFFF,
14440 devs[i].sub_vendor_dev_id >> 16,
14441 devs[i].sub_vendor_dev_id & 0xFFFF);
14449 /* get information about protocols and packet types */
14450 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14451 (uint8_t *)&proto_num, sizeof(proto_num),
14452 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14453 if (ret || !proto_num)
14454 goto no_print_return;
14456 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14457 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14459 goto no_print_return;
14461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14463 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14465 printf("List of used protocols:\n");
14466 for (i = 0; i < proto_num; i++)
14467 printf(" %2u: %s\n", proto[i].proto_id,
14471 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14472 (uint8_t *)&pctype_num, sizeof(pctype_num),
14473 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14474 if (ret || !pctype_num)
14475 goto no_print_pctypes;
14477 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14478 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14480 goto no_print_pctypes;
14482 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14484 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14487 goto no_print_pctypes;
14490 printf("List of defined packet classification types:\n");
14491 for (i = 0; i < pctype_num; i++) {
14492 printf(" %2u:", pctype[i].ptype_id);
14493 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14494 proto_id = pctype[i].protocols[j];
14495 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14496 for (n = 0; n < proto_num; n++) {
14497 if (proto[n].proto_id == proto_id) {
14498 printf(" %s", proto[n].name);
14511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14513 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14514 if (ret || !ptype_num)
14515 goto no_print_return;
14517 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14518 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14520 goto no_print_return;
14522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14524 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14527 goto no_print_return;
14529 printf("List of defined packet types:\n");
14530 for (i = 0; i < ptype_num; i++) {
14531 printf(" %2u:", ptype[i].ptype_id);
14532 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14533 proto_id = ptype[i].protocols[j];
14534 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14535 for (n = 0; n < proto_num; n++) {
14536 if (proto[n].proto_id == proto_id) {
14537 printf(" %s", proto[n].name);
14553 if (ret == -ENOTSUP)
14554 printf("Function not supported in PMD driver\n");
14555 close_ddp_package_file(pkg);
14558 cmdline_parse_inst_t cmd_ddp_get_info = {
14559 .f = cmd_ddp_info_parsed,
14561 .help_str = "ddp get info <profile_path>",
14563 (void *)&cmd_ddp_info_ddp,
14564 (void *)&cmd_ddp_info_get,
14565 (void *)&cmd_ddp_info_info,
14566 (void *)&cmd_ddp_info_filepath,
14571 /* Get dynamic device personalization profile info list*/
14572 #define PROFILE_INFO_SIZE 48
14573 #define MAX_PROFILE_NUM 16
14575 struct cmd_ddp_get_list_result {
14576 cmdline_fixed_string_t ddp;
14577 cmdline_fixed_string_t get;
14578 cmdline_fixed_string_t list;
14582 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14583 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14584 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14585 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14586 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14587 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14588 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14589 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14592 cmd_ddp_get_list_parsed(
14593 void *parsed_result,
14594 __attribute__((unused)) struct cmdline *cl,
14595 __attribute__((unused)) void *data)
14597 struct cmd_ddp_get_list_result *res = parsed_result;
14598 #ifdef RTE_LIBRTE_I40E_PMD
14599 struct rte_pmd_i40e_profile_list *p_list;
14600 struct rte_pmd_i40e_profile_info *p_info;
14605 int ret = -ENOTSUP;
14607 if (res->port_id > nb_ports) {
14608 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14612 #ifdef RTE_LIBRTE_I40E_PMD
14613 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14614 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14616 printf("%s: Failed to malloc buffer\n", __func__);
14618 if (ret == -ENOTSUP)
14619 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14620 (uint8_t *)p_list, size);
14623 p_num = p_list->p_count;
14624 printf("Profile number is: %d\n\n", p_num);
14626 for (i = 0; i < p_num; i++) {
14627 p_info = &p_list->p_info[i];
14628 printf("Profile %d:\n", i);
14629 printf("Track id: 0x%x\n", p_info->track_id);
14630 printf("Version: %d.%d.%d.%d\n",
14631 p_info->version.major,
14632 p_info->version.minor,
14633 p_info->version.update,
14634 p_info->version.draft);
14635 printf("Profile name: %s\n\n", p_info->name);
14643 printf("Failed to get ddp list\n");
14646 cmdline_parse_inst_t cmd_ddp_get_list = {
14647 .f = cmd_ddp_get_list_parsed,
14649 .help_str = "ddp get list <port_id>",
14651 (void *)&cmd_ddp_get_list_ddp,
14652 (void *)&cmd_ddp_get_list_get,
14653 (void *)&cmd_ddp_get_list_list,
14654 (void *)&cmd_ddp_get_list_port_id,
14659 /* show vf stats */
14661 /* Common result structure for show vf stats */
14662 struct cmd_show_vf_stats_result {
14663 cmdline_fixed_string_t show;
14664 cmdline_fixed_string_t vf;
14665 cmdline_fixed_string_t stats;
14670 /* Common CLI fields show vf stats*/
14671 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_show_vf_stats_result,
14675 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14676 TOKEN_STRING_INITIALIZER
14677 (struct cmd_show_vf_stats_result,
14679 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14680 TOKEN_STRING_INITIALIZER
14681 (struct cmd_show_vf_stats_result,
14683 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14684 TOKEN_NUM_INITIALIZER
14685 (struct cmd_show_vf_stats_result,
14687 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14688 TOKEN_NUM_INITIALIZER
14689 (struct cmd_show_vf_stats_result,
14693 cmd_show_vf_stats_parsed(
14694 void *parsed_result,
14695 __attribute__((unused)) struct cmdline *cl,
14696 __attribute__((unused)) void *data)
14698 struct cmd_show_vf_stats_result *res = parsed_result;
14699 struct rte_eth_stats stats;
14700 int ret = -ENOTSUP;
14701 static const char *nic_stats_border = "########################";
14703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14706 memset(&stats, 0, sizeof(stats));
14708 #ifdef RTE_LIBRTE_I40E_PMD
14709 if (ret == -ENOTSUP)
14710 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14714 #ifdef RTE_LIBRTE_BNXT_PMD
14715 if (ret == -ENOTSUP)
14716 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14725 printf("invalid vf_id %d\n", res->vf_id);
14728 printf("invalid port_id %d\n", res->port_id);
14731 printf("function not implemented\n");
14734 printf("programming error: (%s)\n", strerror(-ret));
14737 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14738 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14740 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14742 stats.ipackets, stats.imissed, stats.ibytes);
14743 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14744 printf(" RX-nombuf: %-10"PRIu64"\n",
14746 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14748 stats.opackets, stats.oerrors, stats.obytes);
14750 printf(" %s############################%s\n",
14751 nic_stats_border, nic_stats_border);
14754 cmdline_parse_inst_t cmd_show_vf_stats = {
14755 .f = cmd_show_vf_stats_parsed,
14757 .help_str = "show vf stats <port_id> <vf_id>",
14759 (void *)&cmd_show_vf_stats_show,
14760 (void *)&cmd_show_vf_stats_vf,
14761 (void *)&cmd_show_vf_stats_stats,
14762 (void *)&cmd_show_vf_stats_port_id,
14763 (void *)&cmd_show_vf_stats_vf_id,
14768 /* clear vf stats */
14770 /* Common result structure for clear vf stats */
14771 struct cmd_clear_vf_stats_result {
14772 cmdline_fixed_string_t clear;
14773 cmdline_fixed_string_t vf;
14774 cmdline_fixed_string_t stats;
14779 /* Common CLI fields clear vf stats*/
14780 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14781 TOKEN_STRING_INITIALIZER
14782 (struct cmd_clear_vf_stats_result,
14784 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14785 TOKEN_STRING_INITIALIZER
14786 (struct cmd_clear_vf_stats_result,
14788 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14789 TOKEN_STRING_INITIALIZER
14790 (struct cmd_clear_vf_stats_result,
14792 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14793 TOKEN_NUM_INITIALIZER
14794 (struct cmd_clear_vf_stats_result,
14796 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14797 TOKEN_NUM_INITIALIZER
14798 (struct cmd_clear_vf_stats_result,
14802 cmd_clear_vf_stats_parsed(
14803 void *parsed_result,
14804 __attribute__((unused)) struct cmdline *cl,
14805 __attribute__((unused)) void *data)
14807 struct cmd_clear_vf_stats_result *res = parsed_result;
14808 int ret = -ENOTSUP;
14810 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14813 #ifdef RTE_LIBRTE_I40E_PMD
14814 if (ret == -ENOTSUP)
14815 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14818 #ifdef RTE_LIBRTE_BNXT_PMD
14819 if (ret == -ENOTSUP)
14820 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14828 printf("invalid vf_id %d\n", res->vf_id);
14831 printf("invalid port_id %d\n", res->port_id);
14834 printf("function not implemented\n");
14837 printf("programming error: (%s)\n", strerror(-ret));
14841 cmdline_parse_inst_t cmd_clear_vf_stats = {
14842 .f = cmd_clear_vf_stats_parsed,
14844 .help_str = "clear vf stats <port_id> <vf_id>",
14846 (void *)&cmd_clear_vf_stats_clear,
14847 (void *)&cmd_clear_vf_stats_vf,
14848 (void *)&cmd_clear_vf_stats_stats,
14849 (void *)&cmd_clear_vf_stats_port_id,
14850 (void *)&cmd_clear_vf_stats_vf_id,
14855 /* port config pctype mapping reset */
14857 /* Common result structure for port config pctype mapping reset */
14858 struct cmd_pctype_mapping_reset_result {
14859 cmdline_fixed_string_t port;
14860 cmdline_fixed_string_t config;
14862 cmdline_fixed_string_t pctype;
14863 cmdline_fixed_string_t mapping;
14864 cmdline_fixed_string_t reset;
14867 /* Common CLI fields for port config pctype mapping reset*/
14868 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14869 TOKEN_STRING_INITIALIZER
14870 (struct cmd_pctype_mapping_reset_result,
14872 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14873 TOKEN_STRING_INITIALIZER
14874 (struct cmd_pctype_mapping_reset_result,
14876 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14877 TOKEN_NUM_INITIALIZER
14878 (struct cmd_pctype_mapping_reset_result,
14880 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14881 TOKEN_STRING_INITIALIZER
14882 (struct cmd_pctype_mapping_reset_result,
14884 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_pctype_mapping_reset_result,
14887 mapping, "mapping");
14888 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14889 TOKEN_STRING_INITIALIZER
14890 (struct cmd_pctype_mapping_reset_result,
14894 cmd_pctype_mapping_reset_parsed(
14895 void *parsed_result,
14896 __attribute__((unused)) struct cmdline *cl,
14897 __attribute__((unused)) void *data)
14899 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14900 int ret = -ENOTSUP;
14902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14905 #ifdef RTE_LIBRTE_I40E_PMD
14906 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14913 printf("invalid port_id %d\n", res->port_id);
14916 printf("function not implemented\n");
14919 printf("programming error: (%s)\n", strerror(-ret));
14923 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14924 .f = cmd_pctype_mapping_reset_parsed,
14926 .help_str = "port config <port_id> pctype mapping reset",
14928 (void *)&cmd_pctype_mapping_reset_port,
14929 (void *)&cmd_pctype_mapping_reset_config,
14930 (void *)&cmd_pctype_mapping_reset_port_id,
14931 (void *)&cmd_pctype_mapping_reset_pctype,
14932 (void *)&cmd_pctype_mapping_reset_mapping,
14933 (void *)&cmd_pctype_mapping_reset_reset,
14938 /* show port pctype mapping */
14940 /* Common result structure for show port pctype mapping */
14941 struct cmd_pctype_mapping_get_result {
14942 cmdline_fixed_string_t show;
14943 cmdline_fixed_string_t port;
14945 cmdline_fixed_string_t pctype;
14946 cmdline_fixed_string_t mapping;
14949 /* Common CLI fields for pctype mapping get */
14950 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_pctype_mapping_get_result,
14954 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14955 TOKEN_STRING_INITIALIZER
14956 (struct cmd_pctype_mapping_get_result,
14958 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14959 TOKEN_NUM_INITIALIZER
14960 (struct cmd_pctype_mapping_get_result,
14962 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14963 TOKEN_STRING_INITIALIZER
14964 (struct cmd_pctype_mapping_get_result,
14966 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14967 TOKEN_STRING_INITIALIZER
14968 (struct cmd_pctype_mapping_get_result,
14969 mapping, "mapping");
14972 cmd_pctype_mapping_get_parsed(
14973 void *parsed_result,
14974 __attribute__((unused)) struct cmdline *cl,
14975 __attribute__((unused)) void *data)
14977 struct cmd_pctype_mapping_get_result *res = parsed_result;
14978 int ret = -ENOTSUP;
14979 #ifdef RTE_LIBRTE_I40E_PMD
14980 struct rte_pmd_i40e_flow_type_mapping
14981 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14982 int i, j, first_pctype;
14985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14988 #ifdef RTE_LIBRTE_I40E_PMD
14989 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14996 printf("invalid port_id %d\n", res->port_id);
14999 printf("function not implemented\n");
15002 printf("programming error: (%s)\n", strerror(-ret));
15006 #ifdef RTE_LIBRTE_I40E_PMD
15007 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15008 if (mapping[i].pctype != 0ULL) {
15011 printf("pctype: ");
15012 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15013 if (mapping[i].pctype & (1ULL << j)) {
15014 printf(first_pctype ?
15015 "%02d" : ",%02d", j);
15019 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15025 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15026 .f = cmd_pctype_mapping_get_parsed,
15028 .help_str = "show port <port_id> pctype mapping",
15030 (void *)&cmd_pctype_mapping_get_show,
15031 (void *)&cmd_pctype_mapping_get_port,
15032 (void *)&cmd_pctype_mapping_get_port_id,
15033 (void *)&cmd_pctype_mapping_get_pctype,
15034 (void *)&cmd_pctype_mapping_get_mapping,
15039 /* port config pctype mapping update */
15041 /* Common result structure for port config pctype mapping update */
15042 struct cmd_pctype_mapping_update_result {
15043 cmdline_fixed_string_t port;
15044 cmdline_fixed_string_t config;
15046 cmdline_fixed_string_t pctype;
15047 cmdline_fixed_string_t mapping;
15048 cmdline_fixed_string_t update;
15049 cmdline_fixed_string_t pctype_list;
15050 uint16_t flow_type;
15053 /* Common CLI fields for pctype mapping update*/
15054 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15055 TOKEN_STRING_INITIALIZER
15056 (struct cmd_pctype_mapping_update_result,
15058 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15059 TOKEN_STRING_INITIALIZER
15060 (struct cmd_pctype_mapping_update_result,
15062 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15063 TOKEN_NUM_INITIALIZER
15064 (struct cmd_pctype_mapping_update_result,
15066 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15067 TOKEN_STRING_INITIALIZER
15068 (struct cmd_pctype_mapping_update_result,
15070 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15071 TOKEN_STRING_INITIALIZER
15072 (struct cmd_pctype_mapping_update_result,
15073 mapping, "mapping");
15074 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15075 TOKEN_STRING_INITIALIZER
15076 (struct cmd_pctype_mapping_update_result,
15078 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15079 TOKEN_STRING_INITIALIZER
15080 (struct cmd_pctype_mapping_update_result,
15081 pctype_list, NULL);
15082 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15083 TOKEN_NUM_INITIALIZER
15084 (struct cmd_pctype_mapping_update_result,
15085 flow_type, UINT16);
15088 cmd_pctype_mapping_update_parsed(
15089 void *parsed_result,
15090 __attribute__((unused)) struct cmdline *cl,
15091 __attribute__((unused)) void *data)
15093 struct cmd_pctype_mapping_update_result *res = parsed_result;
15094 int ret = -ENOTSUP;
15095 #ifdef RTE_LIBRTE_I40E_PMD
15096 struct rte_pmd_i40e_flow_type_mapping mapping;
15098 unsigned int nb_item;
15099 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15105 #ifdef RTE_LIBRTE_I40E_PMD
15106 nb_item = parse_item_list(res->pctype_list, "pctypes",
15107 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15108 mapping.flow_type = res->flow_type;
15109 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15110 mapping.pctype |= (1ULL << pctype_list[i]);
15111 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15121 printf("invalid pctype or flow type\n");
15124 printf("invalid port_id %d\n", res->port_id);
15127 printf("function not implemented\n");
15130 printf("programming error: (%s)\n", strerror(-ret));
15134 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15135 .f = cmd_pctype_mapping_update_parsed,
15137 .help_str = "port config <port_id> pctype mapping update"
15138 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15140 (void *)&cmd_pctype_mapping_update_port,
15141 (void *)&cmd_pctype_mapping_update_config,
15142 (void *)&cmd_pctype_mapping_update_port_id,
15143 (void *)&cmd_pctype_mapping_update_pctype,
15144 (void *)&cmd_pctype_mapping_update_mapping,
15145 (void *)&cmd_pctype_mapping_update_update,
15146 (void *)&cmd_pctype_mapping_update_pc_type,
15147 (void *)&cmd_pctype_mapping_update_flow_type,
15152 /* ptype mapping get */
15154 /* Common result structure for ptype mapping get */
15155 struct cmd_ptype_mapping_get_result {
15156 cmdline_fixed_string_t ptype;
15157 cmdline_fixed_string_t mapping;
15158 cmdline_fixed_string_t get;
15160 uint8_t valid_only;
15163 /* Common CLI fields for ptype mapping get */
15164 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15165 TOKEN_STRING_INITIALIZER
15166 (struct cmd_ptype_mapping_get_result,
15168 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15169 TOKEN_STRING_INITIALIZER
15170 (struct cmd_ptype_mapping_get_result,
15171 mapping, "mapping");
15172 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15173 TOKEN_STRING_INITIALIZER
15174 (struct cmd_ptype_mapping_get_result,
15176 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15177 TOKEN_NUM_INITIALIZER
15178 (struct cmd_ptype_mapping_get_result,
15180 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15181 TOKEN_NUM_INITIALIZER
15182 (struct cmd_ptype_mapping_get_result,
15183 valid_only, UINT8);
15186 cmd_ptype_mapping_get_parsed(
15187 void *parsed_result,
15188 __attribute__((unused)) struct cmdline *cl,
15189 __attribute__((unused)) void *data)
15191 struct cmd_ptype_mapping_get_result *res = parsed_result;
15192 int ret = -ENOTSUP;
15193 #ifdef RTE_LIBRTE_I40E_PMD
15194 int max_ptype_num = 256;
15195 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15200 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15203 #ifdef RTE_LIBRTE_I40E_PMD
15204 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15215 printf("invalid port_id %d\n", res->port_id);
15218 printf("function not implemented\n");
15221 printf("programming error: (%s)\n", strerror(-ret));
15224 #ifdef RTE_LIBRTE_I40E_PMD
15226 for (i = 0; i < count; i++)
15227 printf("%3d\t0x%08x\n",
15228 mapping[i].hw_ptype, mapping[i].sw_ptype);
15233 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15234 .f = cmd_ptype_mapping_get_parsed,
15236 .help_str = "ptype mapping get <port_id> <valid_only>",
15238 (void *)&cmd_ptype_mapping_get_ptype,
15239 (void *)&cmd_ptype_mapping_get_mapping,
15240 (void *)&cmd_ptype_mapping_get_get,
15241 (void *)&cmd_ptype_mapping_get_port_id,
15242 (void *)&cmd_ptype_mapping_get_valid_only,
15247 /* ptype mapping replace */
15249 /* Common result structure for ptype mapping replace */
15250 struct cmd_ptype_mapping_replace_result {
15251 cmdline_fixed_string_t ptype;
15252 cmdline_fixed_string_t mapping;
15253 cmdline_fixed_string_t replace;
15260 /* Common CLI fields for ptype mapping replace */
15261 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15262 TOKEN_STRING_INITIALIZER
15263 (struct cmd_ptype_mapping_replace_result,
15265 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_ptype_mapping_replace_result,
15268 mapping, "mapping");
15269 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15270 TOKEN_STRING_INITIALIZER
15271 (struct cmd_ptype_mapping_replace_result,
15272 replace, "replace");
15273 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15274 TOKEN_NUM_INITIALIZER
15275 (struct cmd_ptype_mapping_replace_result,
15277 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15278 TOKEN_NUM_INITIALIZER
15279 (struct cmd_ptype_mapping_replace_result,
15281 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15282 TOKEN_NUM_INITIALIZER
15283 (struct cmd_ptype_mapping_replace_result,
15285 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15286 TOKEN_NUM_INITIALIZER
15287 (struct cmd_ptype_mapping_replace_result,
15291 cmd_ptype_mapping_replace_parsed(
15292 void *parsed_result,
15293 __attribute__((unused)) struct cmdline *cl,
15294 __attribute__((unused)) void *data)
15296 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15297 int ret = -ENOTSUP;
15299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15302 #ifdef RTE_LIBRTE_I40E_PMD
15303 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15313 printf("invalid ptype 0x%8x or 0x%8x\n",
15314 res->target, res->pkt_type);
15317 printf("invalid port_id %d\n", res->port_id);
15320 printf("function not implemented\n");
15323 printf("programming error: (%s)\n", strerror(-ret));
15327 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15328 .f = cmd_ptype_mapping_replace_parsed,
15331 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15333 (void *)&cmd_ptype_mapping_replace_ptype,
15334 (void *)&cmd_ptype_mapping_replace_mapping,
15335 (void *)&cmd_ptype_mapping_replace_replace,
15336 (void *)&cmd_ptype_mapping_replace_port_id,
15337 (void *)&cmd_ptype_mapping_replace_target,
15338 (void *)&cmd_ptype_mapping_replace_mask,
15339 (void *)&cmd_ptype_mapping_replace_pkt_type,
15344 /* ptype mapping reset */
15346 /* Common result structure for ptype mapping reset */
15347 struct cmd_ptype_mapping_reset_result {
15348 cmdline_fixed_string_t ptype;
15349 cmdline_fixed_string_t mapping;
15350 cmdline_fixed_string_t reset;
15354 /* Common CLI fields for ptype mapping reset*/
15355 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15356 TOKEN_STRING_INITIALIZER
15357 (struct cmd_ptype_mapping_reset_result,
15359 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15360 TOKEN_STRING_INITIALIZER
15361 (struct cmd_ptype_mapping_reset_result,
15362 mapping, "mapping");
15363 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15364 TOKEN_STRING_INITIALIZER
15365 (struct cmd_ptype_mapping_reset_result,
15367 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15368 TOKEN_NUM_INITIALIZER
15369 (struct cmd_ptype_mapping_reset_result,
15373 cmd_ptype_mapping_reset_parsed(
15374 void *parsed_result,
15375 __attribute__((unused)) struct cmdline *cl,
15376 __attribute__((unused)) void *data)
15378 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15379 int ret = -ENOTSUP;
15381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15384 #ifdef RTE_LIBRTE_I40E_PMD
15385 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15392 printf("invalid port_id %d\n", res->port_id);
15395 printf("function not implemented\n");
15398 printf("programming error: (%s)\n", strerror(-ret));
15402 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15403 .f = cmd_ptype_mapping_reset_parsed,
15405 .help_str = "ptype mapping reset <port_id>",
15407 (void *)&cmd_ptype_mapping_reset_ptype,
15408 (void *)&cmd_ptype_mapping_reset_mapping,
15409 (void *)&cmd_ptype_mapping_reset_reset,
15410 (void *)&cmd_ptype_mapping_reset_port_id,
15415 /* ptype mapping update */
15417 /* Common result structure for ptype mapping update */
15418 struct cmd_ptype_mapping_update_result {
15419 cmdline_fixed_string_t ptype;
15420 cmdline_fixed_string_t mapping;
15421 cmdline_fixed_string_t reset;
15427 /* Common CLI fields for ptype mapping update*/
15428 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15429 TOKEN_STRING_INITIALIZER
15430 (struct cmd_ptype_mapping_update_result,
15432 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_ptype_mapping_update_result,
15435 mapping, "mapping");
15436 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15437 TOKEN_STRING_INITIALIZER
15438 (struct cmd_ptype_mapping_update_result,
15440 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15441 TOKEN_NUM_INITIALIZER
15442 (struct cmd_ptype_mapping_update_result,
15444 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15445 TOKEN_NUM_INITIALIZER
15446 (struct cmd_ptype_mapping_update_result,
15448 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15449 TOKEN_NUM_INITIALIZER
15450 (struct cmd_ptype_mapping_update_result,
15454 cmd_ptype_mapping_update_parsed(
15455 void *parsed_result,
15456 __attribute__((unused)) struct cmdline *cl,
15457 __attribute__((unused)) void *data)
15459 struct cmd_ptype_mapping_update_result *res = parsed_result;
15460 int ret = -ENOTSUP;
15461 #ifdef RTE_LIBRTE_I40E_PMD
15462 struct rte_pmd_i40e_ptype_mapping mapping;
15464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15467 #ifdef RTE_LIBRTE_I40E_PMD
15468 mapping.hw_ptype = res->hw_ptype;
15469 mapping.sw_ptype = res->sw_ptype;
15470 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15480 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15483 printf("invalid port_id %d\n", res->port_id);
15486 printf("function not implemented\n");
15489 printf("programming error: (%s)\n", strerror(-ret));
15493 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15494 .f = cmd_ptype_mapping_update_parsed,
15496 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15498 (void *)&cmd_ptype_mapping_update_ptype,
15499 (void *)&cmd_ptype_mapping_update_mapping,
15500 (void *)&cmd_ptype_mapping_update_update,
15501 (void *)&cmd_ptype_mapping_update_port_id,
15502 (void *)&cmd_ptype_mapping_update_hw_ptype,
15503 (void *)&cmd_ptype_mapping_update_sw_ptype,
15508 /* Common result structure for file commands */
15509 struct cmd_cmdfile_result {
15510 cmdline_fixed_string_t load;
15511 cmdline_fixed_string_t filename;
15514 /* Common CLI fields for file commands */
15515 cmdline_parse_token_string_t cmd_load_cmdfile =
15516 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15517 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15518 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15521 cmd_load_from_file_parsed(
15522 void *parsed_result,
15523 __attribute__((unused)) struct cmdline *cl,
15524 __attribute__((unused)) void *data)
15526 struct cmd_cmdfile_result *res = parsed_result;
15528 cmdline_read_from_file(res->filename);
15531 cmdline_parse_inst_t cmd_load_from_file = {
15532 .f = cmd_load_from_file_parsed,
15534 .help_str = "load <filename>",
15536 (void *)&cmd_load_cmdfile,
15537 (void *)&cmd_load_cmdfile_filename,
15542 /* ******************************************************************************** */
15544 /* list of instructions */
15545 cmdline_parse_ctx_t main_ctx[] = {
15546 (cmdline_parse_inst_t *)&cmd_help_brief,
15547 (cmdline_parse_inst_t *)&cmd_help_long,
15548 (cmdline_parse_inst_t *)&cmd_quit,
15549 (cmdline_parse_inst_t *)&cmd_load_from_file,
15550 (cmdline_parse_inst_t *)&cmd_showport,
15551 (cmdline_parse_inst_t *)&cmd_showqueue,
15552 (cmdline_parse_inst_t *)&cmd_showportall,
15553 (cmdline_parse_inst_t *)&cmd_showcfg,
15554 (cmdline_parse_inst_t *)&cmd_start,
15555 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15556 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15557 (cmdline_parse_inst_t *)&cmd_set_link_up,
15558 (cmdline_parse_inst_t *)&cmd_set_link_down,
15559 (cmdline_parse_inst_t *)&cmd_reset,
15560 (cmdline_parse_inst_t *)&cmd_set_numbers,
15561 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15562 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15563 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15564 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15565 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15566 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15567 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15568 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15569 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15570 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15571 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15572 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15573 (cmdline_parse_inst_t *)&cmd_set_link_check,
15574 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15575 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15576 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15577 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15578 #ifdef RTE_LIBRTE_PMD_BOND
15579 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15580 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15581 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15582 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15583 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15584 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15585 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15586 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15587 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15588 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15589 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15591 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15592 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15593 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15594 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15595 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15596 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15597 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15598 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15599 (cmdline_parse_inst_t *)&cmd_csum_set,
15600 (cmdline_parse_inst_t *)&cmd_csum_show,
15601 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15602 (cmdline_parse_inst_t *)&cmd_tso_set,
15603 (cmdline_parse_inst_t *)&cmd_tso_show,
15604 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15605 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15606 (cmdline_parse_inst_t *)&cmd_gro_enable,
15607 (cmdline_parse_inst_t *)&cmd_gro_flush,
15608 (cmdline_parse_inst_t *)&cmd_gro_show,
15609 (cmdline_parse_inst_t *)&cmd_gso_enable,
15610 (cmdline_parse_inst_t *)&cmd_gso_size,
15611 (cmdline_parse_inst_t *)&cmd_gso_show,
15612 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15613 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15614 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15615 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15616 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15617 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15618 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15619 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15620 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15621 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15622 (cmdline_parse_inst_t *)&cmd_config_dcb,
15623 (cmdline_parse_inst_t *)&cmd_read_reg,
15624 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15625 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15626 (cmdline_parse_inst_t *)&cmd_write_reg,
15627 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15628 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15629 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15630 (cmdline_parse_inst_t *)&cmd_stop,
15631 (cmdline_parse_inst_t *)&cmd_mac_addr,
15632 (cmdline_parse_inst_t *)&cmd_set_qmap,
15633 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15634 (cmdline_parse_inst_t *)&cmd_operate_port,
15635 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15636 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15637 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15638 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15639 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15640 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15641 (cmdline_parse_inst_t *)&cmd_config_mtu,
15642 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15643 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15644 (cmdline_parse_inst_t *)&cmd_config_rss,
15645 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15646 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15647 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15648 (cmdline_parse_inst_t *)&cmd_showport_reta,
15649 (cmdline_parse_inst_t *)&cmd_config_burst,
15650 (cmdline_parse_inst_t *)&cmd_config_thresh,
15651 (cmdline_parse_inst_t *)&cmd_config_threshold,
15652 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15653 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15654 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15655 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15656 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15657 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15658 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15659 (cmdline_parse_inst_t *)&cmd_global_config,
15660 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15661 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15662 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15663 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15664 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15665 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15666 (cmdline_parse_inst_t *)&cmd_dump,
15667 (cmdline_parse_inst_t *)&cmd_dump_one,
15668 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15669 (cmdline_parse_inst_t *)&cmd_syn_filter,
15670 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15671 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15672 (cmdline_parse_inst_t *)&cmd_flex_filter,
15673 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15674 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15675 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15676 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15677 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15678 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15679 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15680 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15681 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15682 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15683 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15684 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15685 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15686 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15687 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15688 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15689 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15690 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15691 (cmdline_parse_inst_t *)&cmd_flow,
15692 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15693 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15694 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15695 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15696 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15697 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15698 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15699 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15700 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15701 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15702 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15703 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15704 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15705 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15706 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15707 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15708 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15709 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15710 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15711 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15712 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15713 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15714 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15715 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15716 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15717 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15718 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15719 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15720 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15721 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15722 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15723 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15724 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15725 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15726 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15727 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15728 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15729 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15730 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15731 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15732 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15733 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15734 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15735 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15736 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15737 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15738 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15740 (cmdline_parse_inst_t *)&cmd_ddp_add,
15741 (cmdline_parse_inst_t *)&cmd_ddp_del,
15742 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15743 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15744 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15745 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15746 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15747 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15748 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15749 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15751 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15752 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15753 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15754 (cmdline_parse_inst_t *)&cmd_queue_region,
15755 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15756 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15757 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15758 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15759 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15760 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15761 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15762 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15763 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15764 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15765 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15766 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15767 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15768 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15769 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15770 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15771 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15772 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15773 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15774 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15775 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15779 /* read cmdline commands from file */
15781 cmdline_read_from_file(const char *filename)
15783 struct cmdline *cl;
15785 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15787 printf("Failed to create file based cmdline context: %s\n",
15792 cmdline_interact(cl);
15797 printf("Read CLI commands from %s\n", filename);
15800 /* prompt function, called from main on MASTER lcore */
15804 /* initialize non-constant commands */
15805 cmd_set_fwd_mode_init();
15806 cmd_set_fwd_retry_mode_init();
15808 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15809 if (testpmd_cl == NULL)
15811 cmdline_interact(testpmd_cl);
15812 cmdline_stdin_exit(testpmd_cl);
15818 if (testpmd_cl != NULL)
15819 cmdline_quit(testpmd_cl);
15823 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15825 if (id == (portid_t)RTE_PORT_ALL) {
15828 RTE_ETH_FOREACH_DEV(pid) {
15829 /* check if need_reconfig has been set to 1 */
15830 if (ports[pid].need_reconfig == 0)
15831 ports[pid].need_reconfig = dev;
15832 /* check if need_reconfig_queues has been set to 1 */
15833 if (ports[pid].need_reconfig_queues == 0)
15834 ports[pid].need_reconfig_queues = queue;
15836 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15837 /* check if need_reconfig has been set to 1 */
15838 if (ports[id].need_reconfig == 0)
15839 ports[id].need_reconfig = dev;
15840 /* check if need_reconfig_queues has been set to 1 */
15841 if (ports[id].need_reconfig_queues == 0)
15842 ports[id].need_reconfig_queues = queue;