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 "show port meter cap (port_id)\n"
702 " Show port meter capability information\n\n"
704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 " meter profile add - srtcm rfc 2697\n\n"
707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 " meter profile add - trtcm rfc 2698\n\n"
710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 " meter profile add - trtcm rfc 4115\n\n"
713 "del port meter profile (port_id) (profile_id)\n"
714 " meter profile delete\n\n"
716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 "(dscp_tbl_entry63)]\n"
722 "enable port meter (port_id) (mtr_id)\n"
725 "disable port meter (port_id) (mtr_id)\n"
728 "del port meter (port_id) (mtr_id)\n"
731 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 " meter update meter profile\n\n"
734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 " update meter dscp table entries\n\n"
738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 "(action0) [(action1) (action2)]\n"
740 " meter update policer action\n\n"
742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 " meter update stats\n\n"
745 "show port (port_id) queue-region\n"
746 " show all queue region related configuration info\n\n"
748 "add port tm node shaper profile (port_id) (shaper_profile_id)"
749 " (tb_rate) (tb_size) (packet_length_adjust)\n"
750 " Add port tm node private shaper profile.\n\n"
752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
753 " Delete port tm node private shaper profile.\n\n"
755 "add port tm node shared shaper (port_id) (shared_shaper_id)"
756 " (shaper_profile_id)\n"
757 " Add/update port tm node shared shaper.\n\n"
759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
760 " Delete port tm node shared shaper.\n\n"
762 "set port tm node shaper profile (port_id) (node_id)"
763 " (shaper_profile_id)\n"
764 " Set port tm node shaper profile.\n\n"
766 "add port tm node wred profile (port_id) (wred_profile_id)"
767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
770 " Add port tm node wred profile.\n\n"
772 "del port tm node wred profile (port_id) (wred_profile_id)\n"
773 " Delete port tm node wred profile.\n\n"
775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
776 " (priority) (weight) (level_id) (shaper_profile_id)"
777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
779 " Add port tm nonleaf node.\n\n"
781 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm leaf node.\n\n"
787 "del port tm node (port_id) (node_id)\n"
788 " Delete port tm node.\n\n"
790 "set port tm node parent (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight)\n"
792 " Set port tm node parent.\n\n"
794 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
795 " Commit tm hierarchy.\n\n"
797 , list_pkt_forwarding_modes()
801 if (show_all || !strcmp(res->section, "ports")) {
807 "----------------\n\n"
809 "port start (port_id|all)\n"
810 " Start all ports or port_id.\n\n"
812 "port stop (port_id|all)\n"
813 " Stop all ports or port_id.\n\n"
815 "port close (port_id|all)\n"
816 " Close all ports or port_id.\n\n"
818 "port attach (ident)\n"
819 " Attach physical or virtual dev by pci address or virtual device name\n\n"
821 "port detach (port_id)\n"
822 " Detach physical or virtual dev by port_id\n\n"
824 "port config (port_id|all)"
825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
826 " duplex (half|full|auto)\n"
827 " Set speed and duplex for all ports or port_id\n\n"
829 "port config all (rxq|txq|rxd|txd) (value)\n"
830 " Set number for rxq/txq/rxd/txd.\n\n"
832 "port config all max-pkt-len (value)\n"
833 " Set the max packet length.\n\n"
835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
836 "hw-vlan-strip|hw-vlan-extend|drop-en)"
838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
842 "geneve|nvgre|none|<flowtype_id>)\n"
843 " Set the RSS mode.\n\n"
845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
846 " Set the RSS redirection table.\n\n"
848 "port config (port_id) dcb vt (on|off) (traffic_class)"
850 " Set the DCB mode.\n\n"
852 "port config all burst (value)\n"
853 " Set the number of packets per burst.\n\n"
855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
857 " Set the ring prefetch/host/writeback threshold"
858 " for tx/rx queue.\n\n"
860 "port config all (txfreet|txrst|rxfreet) (value)\n"
861 " Set free threshold for rx/tx, or set"
862 " tx rs bit threshold.\n\n"
863 "port config mtu X value\n"
864 " Set the MTU of port X to a given value\n\n"
866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
867 " Start/stop a rx/tx queue of port X. Only take effect"
868 " when port X is started\n\n"
870 "port config (port_id|all) l2-tunnel E-tag ether-type"
872 " Set the value of E-tag ether-type.\n\n"
874 "port config (port_id|all) l2-tunnel E-tag"
875 " (enable|disable)\n"
876 " Enable/disable the E-tag support.\n\n"
878 "port config (port_id) pctype mapping reset\n"
879 " Reset flow type to pctype mapping on a port\n\n"
881 "port config (port_id) pctype mapping update"
882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
883 " Update a flow type to pctype mapping item on a port\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure txq/rxq, txd/rxd *** */
1497 struct cmd_config_rx_tx {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_rx_tx_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_rx_tx *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1516 if (!strcmp(res->name, "rxq")) {
1517 if (!res->value && !nb_txq) {
1518 printf("Warning: Either rx or tx queues should be non zero\n");
1521 nb_rxq = res->value;
1523 else if (!strcmp(res->name, "txq")) {
1524 if (!res->value && !nb_rxq) {
1525 printf("Warning: Either rx or tx queues should be non zero\n");
1528 nb_txq = res->value;
1530 else if (!strcmp(res->name, "rxd")) {
1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1532 printf("rxd %d invalid - must be > 0 && <= %d\n",
1533 res->value, RTE_TEST_RX_DESC_MAX);
1536 nb_rxd = res->value;
1537 } else if (!strcmp(res->name, "txd")) {
1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1539 printf("txd %d invalid - must be > 0 && <= %d\n",
1540 res->value, RTE_TEST_TX_DESC_MAX);
1543 nb_txd = res->value;
1545 printf("Unknown parameter\n");
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1565 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1568 cmdline_parse_inst_t cmd_config_rx_tx = {
1569 .f = cmd_config_rx_tx_parsed,
1571 .help_str = "port config all rxq|txq|rxd|txd <value>",
1573 (void *)&cmd_config_rx_tx_port,
1574 (void *)&cmd_config_rx_tx_keyword,
1575 (void *)&cmd_config_rx_tx_all,
1576 (void *)&cmd_config_rx_tx_name,
1577 (void *)&cmd_config_rx_tx_value,
1582 /* *** config max packet length *** */
1583 struct cmd_config_max_pkt_len_result {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1592 cmd_config_max_pkt_len_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_max_pkt_len_result *res = parsed_result;
1598 if (!all_ports_stopped()) {
1599 printf("Please stop all ports first\n");
1603 if (!strcmp(res->name, "max-pkt-len")) {
1604 if (res->value < ETHER_MIN_LEN) {
1605 printf("max-pkt-len can not be less than %d\n",
1609 if (res->value == rx_mode.max_rx_pkt_len)
1612 rx_mode.max_rx_pkt_len = res->value;
1613 if (res->value > ETHER_MAX_LEN)
1614 rx_mode.jumbo_frame = 1;
1616 rx_mode.jumbo_frame = 0;
1618 printf("Unknown parameter\n");
1624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1627 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1639 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1640 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1643 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1644 .f = cmd_config_max_pkt_len_parsed,
1646 .help_str = "port config all max-pkt-len <value>",
1648 (void *)&cmd_config_max_pkt_len_port,
1649 (void *)&cmd_config_max_pkt_len_keyword,
1650 (void *)&cmd_config_max_pkt_len_all,
1651 (void *)&cmd_config_max_pkt_len_name,
1652 (void *)&cmd_config_max_pkt_len_value,
1657 /* *** configure port MTU *** */
1658 struct cmd_config_mtu_result {
1659 cmdline_fixed_string_t port;
1660 cmdline_fixed_string_t keyword;
1661 cmdline_fixed_string_t mtu;
1667 cmd_config_mtu_parsed(void *parsed_result,
1668 __attribute__((unused)) struct cmdline *cl,
1669 __attribute__((unused)) void *data)
1671 struct cmd_config_mtu_result *res = parsed_result;
1673 if (res->value < ETHER_MIN_LEN) {
1674 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1677 port_mtu_set(res->port_id, res->value);
1680 cmdline_parse_token_string_t cmd_config_mtu_port =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1683 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1686 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1689 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1690 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1691 cmdline_parse_token_num_t cmd_config_mtu_value =
1692 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1694 cmdline_parse_inst_t cmd_config_mtu = {
1695 .f = cmd_config_mtu_parsed,
1697 .help_str = "port config mtu <port_id> <value>",
1699 (void *)&cmd_config_mtu_port,
1700 (void *)&cmd_config_mtu_keyword,
1701 (void *)&cmd_config_mtu_mtu,
1702 (void *)&cmd_config_mtu_port_id,
1703 (void *)&cmd_config_mtu_value,
1708 /* *** configure rx mode *** */
1709 struct cmd_config_rx_mode_flag {
1710 cmdline_fixed_string_t port;
1711 cmdline_fixed_string_t keyword;
1712 cmdline_fixed_string_t all;
1713 cmdline_fixed_string_t name;
1714 cmdline_fixed_string_t value;
1718 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1719 __attribute__((unused)) struct cmdline *cl,
1720 __attribute__((unused)) void *data)
1722 struct cmd_config_rx_mode_flag *res = parsed_result;
1724 if (!all_ports_stopped()) {
1725 printf("Please stop all ports first\n");
1729 if (!strcmp(res->name, "crc-strip")) {
1730 if (!strcmp(res->value, "on"))
1731 rx_mode.hw_strip_crc = 1;
1732 else if (!strcmp(res->value, "off"))
1733 rx_mode.hw_strip_crc = 0;
1735 printf("Unknown parameter\n");
1738 } else if (!strcmp(res->name, "scatter")) {
1739 if (!strcmp(res->value, "on"))
1740 rx_mode.enable_scatter = 1;
1741 else if (!strcmp(res->value, "off"))
1742 rx_mode.enable_scatter = 0;
1744 printf("Unknown parameter\n");
1747 } else if (!strcmp(res->name, "rx-cksum")) {
1748 if (!strcmp(res->value, "on"))
1749 rx_mode.hw_ip_checksum = 1;
1750 else if (!strcmp(res->value, "off"))
1751 rx_mode.hw_ip_checksum = 0;
1753 printf("Unknown parameter\n");
1756 } else if (!strcmp(res->name, "rx-timestamp")) {
1757 if (!strcmp(res->value, "on"))
1758 rx_mode.hw_timestamp = 1;
1759 else if (!strcmp(res->value, "off"))
1760 rx_mode.hw_timestamp = 0;
1762 printf("Unknown parameter\n");
1765 } else if (!strcmp(res->name, "hw-vlan")) {
1766 if (!strcmp(res->value, "on")) {
1767 rx_mode.hw_vlan_filter = 1;
1768 rx_mode.hw_vlan_strip = 1;
1770 else if (!strcmp(res->value, "off")) {
1771 rx_mode.hw_vlan_filter = 0;
1772 rx_mode.hw_vlan_strip = 0;
1775 printf("Unknown parameter\n");
1778 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1779 if (!strcmp(res->value, "on"))
1780 rx_mode.hw_vlan_filter = 1;
1781 else if (!strcmp(res->value, "off"))
1782 rx_mode.hw_vlan_filter = 0;
1784 printf("Unknown parameter\n");
1787 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1788 if (!strcmp(res->value, "on"))
1789 rx_mode.hw_vlan_strip = 1;
1790 else if (!strcmp(res->value, "off"))
1791 rx_mode.hw_vlan_strip = 0;
1793 printf("Unknown parameter\n");
1796 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1797 if (!strcmp(res->value, "on"))
1798 rx_mode.hw_vlan_extend = 1;
1799 else if (!strcmp(res->value, "off"))
1800 rx_mode.hw_vlan_extend = 0;
1802 printf("Unknown parameter\n");
1805 } else if (!strcmp(res->name, "drop-en")) {
1806 if (!strcmp(res->value, "on"))
1808 else if (!strcmp(res->value, "off"))
1811 printf("Unknown parameter\n");
1815 printf("Unknown parameter\n");
1821 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1824 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1826 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1827 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1833 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1834 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1835 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1836 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1839 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1840 .f = cmd_config_rx_mode_flag_parsed,
1842 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1843 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1845 (void *)&cmd_config_rx_mode_flag_port,
1846 (void *)&cmd_config_rx_mode_flag_keyword,
1847 (void *)&cmd_config_rx_mode_flag_all,
1848 (void *)&cmd_config_rx_mode_flag_name,
1849 (void *)&cmd_config_rx_mode_flag_value,
1854 /* *** configure rss *** */
1855 struct cmd_config_rss {
1856 cmdline_fixed_string_t port;
1857 cmdline_fixed_string_t keyword;
1858 cmdline_fixed_string_t all;
1859 cmdline_fixed_string_t name;
1860 cmdline_fixed_string_t value;
1864 cmd_config_rss_parsed(void *parsed_result,
1865 __attribute__((unused)) struct cmdline *cl,
1866 __attribute__((unused)) void *data)
1868 struct cmd_config_rss *res = parsed_result;
1869 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1873 if (!strcmp(res->value, "all"))
1874 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1875 ETH_RSS_UDP | ETH_RSS_SCTP |
1877 else if (!strcmp(res->value, "ip"))
1878 rss_conf.rss_hf = ETH_RSS_IP;
1879 else if (!strcmp(res->value, "udp"))
1880 rss_conf.rss_hf = ETH_RSS_UDP;
1881 else if (!strcmp(res->value, "tcp"))
1882 rss_conf.rss_hf = ETH_RSS_TCP;
1883 else if (!strcmp(res->value, "sctp"))
1884 rss_conf.rss_hf = ETH_RSS_SCTP;
1885 else if (!strcmp(res->value, "ether"))
1886 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1887 else if (!strcmp(res->value, "port"))
1888 rss_conf.rss_hf = ETH_RSS_PORT;
1889 else if (!strcmp(res->value, "vxlan"))
1890 rss_conf.rss_hf = ETH_RSS_VXLAN;
1891 else if (!strcmp(res->value, "geneve"))
1892 rss_conf.rss_hf = ETH_RSS_GENEVE;
1893 else if (!strcmp(res->value, "nvgre"))
1894 rss_conf.rss_hf = ETH_RSS_NVGRE;
1895 else if (!strcmp(res->value, "none"))
1896 rss_conf.rss_hf = 0;
1897 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1898 atoi(res->value) < 64)
1899 rss_conf.rss_hf = 1ULL << atoi(res->value);
1901 printf("Unknown parameter\n");
1904 rss_conf.rss_key = NULL;
1905 for (i = 0; i < rte_eth_dev_count(); i++) {
1906 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1908 printf("Configuration of RSS hash at ethernet port %d "
1909 "failed with error (%d): %s.\n",
1910 i, -diag, strerror(-diag));
1914 cmdline_parse_token_string_t cmd_config_rss_port =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1916 cmdline_parse_token_string_t cmd_config_rss_keyword =
1917 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1918 cmdline_parse_token_string_t cmd_config_rss_all =
1919 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1920 cmdline_parse_token_string_t cmd_config_rss_name =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1922 cmdline_parse_token_string_t cmd_config_rss_value =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1925 cmdline_parse_inst_t cmd_config_rss = {
1926 .f = cmd_config_rss_parsed,
1928 .help_str = "port config all rss "
1929 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1931 (void *)&cmd_config_rss_port,
1932 (void *)&cmd_config_rss_keyword,
1933 (void *)&cmd_config_rss_all,
1934 (void *)&cmd_config_rss_name,
1935 (void *)&cmd_config_rss_value,
1940 /* *** configure rss hash key *** */
1941 struct cmd_config_rss_hash_key {
1942 cmdline_fixed_string_t port;
1943 cmdline_fixed_string_t config;
1945 cmdline_fixed_string_t rss_hash_key;
1946 cmdline_fixed_string_t rss_type;
1947 cmdline_fixed_string_t key;
1951 hexa_digit_to_value(char hexa_digit)
1953 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1954 return (uint8_t) (hexa_digit - '0');
1955 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1956 return (uint8_t) ((hexa_digit - 'a') + 10);
1957 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1958 return (uint8_t) ((hexa_digit - 'A') + 10);
1959 /* Invalid hexa digit */
1964 parse_and_check_key_hexa_digit(char *key, int idx)
1968 hexa_v = hexa_digit_to_value(key[idx]);
1970 printf("invalid key: character %c at position %d is not a "
1971 "valid hexa digit\n", key[idx], idx);
1976 cmd_config_rss_hash_key_parsed(void *parsed_result,
1977 __attribute__((unused)) struct cmdline *cl,
1978 __attribute__((unused)) void *data)
1980 struct cmd_config_rss_hash_key *res = parsed_result;
1981 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1985 struct rte_eth_dev_info dev_info;
1986 uint8_t hash_key_size;
1989 memset(&dev_info, 0, sizeof(dev_info));
1990 rte_eth_dev_info_get(res->port_id, &dev_info);
1991 if (dev_info.hash_key_size > 0 &&
1992 dev_info.hash_key_size <= sizeof(hash_key))
1993 hash_key_size = dev_info.hash_key_size;
1995 printf("dev_info did not provide a valid hash key size\n");
1998 /* Check the length of the RSS hash key */
1999 key_len = strlen(res->key);
2000 if (key_len != (hash_key_size * 2)) {
2001 printf("key length: %d invalid - key must be a string of %d"
2002 " hexa-decimal numbers\n",
2003 (int) key_len, hash_key_size * 2);
2006 /* Translate RSS hash key into binary representation */
2007 for (i = 0; i < hash_key_size; i++) {
2008 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2011 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2014 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2016 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2020 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2022 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2025 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2029 rss_hash_key, "rss-hash-key");
2030 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2031 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2032 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2033 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2034 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2035 "ipv6-tcp-ex#ipv6-udp-ex");
2036 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2039 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2040 .f = cmd_config_rss_hash_key_parsed,
2042 .help_str = "port config <port_id> rss-hash-key "
2043 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2044 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2045 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2046 "<string of hex digits (variable length, NIC dependent)>",
2048 (void *)&cmd_config_rss_hash_key_port,
2049 (void *)&cmd_config_rss_hash_key_config,
2050 (void *)&cmd_config_rss_hash_key_port_id,
2051 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2052 (void *)&cmd_config_rss_hash_key_rss_type,
2053 (void *)&cmd_config_rss_hash_key_value,
2058 /* *** configure port rxq/txq start/stop *** */
2059 struct cmd_config_rxtx_queue {
2060 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t rxtxq;
2064 cmdline_fixed_string_t opname;
2068 cmd_config_rxtx_queue_parsed(void *parsed_result,
2069 __attribute__((unused)) struct cmdline *cl,
2070 __attribute__((unused)) void *data)
2072 struct cmd_config_rxtx_queue *res = parsed_result;
2077 if (test_done == 0) {
2078 printf("Please stop forwarding first\n");
2082 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2085 if (port_is_started(res->portid) != 1) {
2086 printf("Please start port %u first\n", res->portid);
2090 if (!strcmp(res->rxtxq, "rxq"))
2092 else if (!strcmp(res->rxtxq, "txq"))
2095 printf("Unknown parameter\n");
2099 if (isrx && rx_queue_id_is_invalid(res->qid))
2101 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2104 if (!strcmp(res->opname, "start"))
2106 else if (!strcmp(res->opname, "stop"))
2109 printf("Unknown parameter\n");
2113 if (isstart && isrx)
2114 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2115 else if (!isstart && isrx)
2116 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2117 else if (isstart && !isrx)
2118 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2120 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2122 if (ret == -ENOTSUP)
2123 printf("Function not supported in PMD driver\n");
2126 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2128 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2129 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2130 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2132 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2133 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2134 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2138 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2139 .f = cmd_config_rxtx_queue_parsed,
2141 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2143 (void *)&cmd_config_speed_all_port,
2144 (void *)&cmd_config_rxtx_queue_portid,
2145 (void *)&cmd_config_rxtx_queue_rxtxq,
2146 (void *)&cmd_config_rxtx_queue_qid,
2147 (void *)&cmd_config_rxtx_queue_opname,
2152 /* *** Configure RSS RETA *** */
2153 struct cmd_config_rss_reta {
2154 cmdline_fixed_string_t port;
2155 cmdline_fixed_string_t keyword;
2157 cmdline_fixed_string_t name;
2158 cmdline_fixed_string_t list_name;
2159 cmdline_fixed_string_t list_of_items;
2163 parse_reta_config(const char *str,
2164 struct rte_eth_rss_reta_entry64 *reta_conf,
2165 uint16_t nb_entries)
2169 uint16_t hash_index, idx, shift;
2172 const char *p, *p0 = str;
2179 unsigned long int_fld[_NUM_FLD];
2180 char *str_fld[_NUM_FLD];
2182 while ((p = strchr(p0,'(')) != NULL) {
2184 if((p0 = strchr(p,')')) == NULL)
2188 if(size >= sizeof(s))
2191 snprintf(s, sizeof(s), "%.*s", size, p);
2192 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2194 for (i = 0; i < _NUM_FLD; i++) {
2196 int_fld[i] = strtoul(str_fld[i], &end, 0);
2197 if (errno != 0 || end == str_fld[i] ||
2202 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2203 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2205 if (hash_index >= nb_entries) {
2206 printf("Invalid RETA hash index=%d\n", hash_index);
2210 idx = hash_index / RTE_RETA_GROUP_SIZE;
2211 shift = hash_index % RTE_RETA_GROUP_SIZE;
2212 reta_conf[idx].mask |= (1ULL << shift);
2213 reta_conf[idx].reta[shift] = nb_queue;
2220 cmd_set_rss_reta_parsed(void *parsed_result,
2221 __attribute__((unused)) struct cmdline *cl,
2222 __attribute__((unused)) void *data)
2225 struct rte_eth_dev_info dev_info;
2226 struct rte_eth_rss_reta_entry64 reta_conf[8];
2227 struct cmd_config_rss_reta *res = parsed_result;
2229 memset(&dev_info, 0, sizeof(dev_info));
2230 rte_eth_dev_info_get(res->port_id, &dev_info);
2231 if (dev_info.reta_size == 0) {
2232 printf("Redirection table size is 0 which is "
2233 "invalid for RSS\n");
2236 printf("The reta size of port %d is %u\n",
2237 res->port_id, dev_info.reta_size);
2238 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2239 printf("Currently do not support more than %u entries of "
2240 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2244 memset(reta_conf, 0, sizeof(reta_conf));
2245 if (!strcmp(res->list_name, "reta")) {
2246 if (parse_reta_config(res->list_of_items, reta_conf,
2247 dev_info.reta_size)) {
2248 printf("Invalid RSS Redirection Table "
2249 "config entered\n");
2252 ret = rte_eth_dev_rss_reta_update(res->port_id,
2253 reta_conf, dev_info.reta_size);
2255 printf("Bad redirection table parameter, "
2256 "return code = %d \n", ret);
2260 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2261 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2262 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2263 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2264 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2265 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2266 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2268 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2270 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2271 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2273 cmdline_parse_inst_t cmd_config_rss_reta = {
2274 .f = cmd_set_rss_reta_parsed,
2276 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2278 (void *)&cmd_config_rss_reta_port,
2279 (void *)&cmd_config_rss_reta_keyword,
2280 (void *)&cmd_config_rss_reta_port_id,
2281 (void *)&cmd_config_rss_reta_name,
2282 (void *)&cmd_config_rss_reta_list_name,
2283 (void *)&cmd_config_rss_reta_list_of_items,
2288 /* *** SHOW PORT RETA INFO *** */
2289 struct cmd_showport_reta {
2290 cmdline_fixed_string_t show;
2291 cmdline_fixed_string_t port;
2293 cmdline_fixed_string_t rss;
2294 cmdline_fixed_string_t reta;
2296 cmdline_fixed_string_t list_of_items;
2300 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2301 uint16_t nb_entries,
2305 const char *p, *p0 = str;
2310 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2311 RTE_RETA_GROUP_SIZE;
2314 p = strchr(p0, '(');
2318 p0 = strchr(p, ')');
2322 if (size >= sizeof(s)) {
2323 printf("The string size exceeds the internal buffer size\n");
2326 snprintf(s, sizeof(s), "%.*s", size, p);
2327 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2328 if (ret <= 0 || ret != num) {
2329 printf("The bits of masks do not match the number of "
2330 "reta entries: %u\n", num);
2333 for (i = 0; i < ret; i++)
2334 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2340 cmd_showport_reta_parsed(void *parsed_result,
2341 __attribute__((unused)) struct cmdline *cl,
2342 __attribute__((unused)) void *data)
2344 struct cmd_showport_reta *res = parsed_result;
2345 struct rte_eth_rss_reta_entry64 reta_conf[8];
2346 struct rte_eth_dev_info dev_info;
2347 uint16_t max_reta_size;
2349 memset(&dev_info, 0, sizeof(dev_info));
2350 rte_eth_dev_info_get(res->port_id, &dev_info);
2351 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2352 if (res->size == 0 || res->size > max_reta_size) {
2353 printf("Invalid redirection table size: %u (1-%u)\n",
2354 res->size, max_reta_size);
2358 memset(reta_conf, 0, sizeof(reta_conf));
2359 if (showport_parse_reta_config(reta_conf, res->size,
2360 res->list_of_items) < 0) {
2361 printf("Invalid string: %s for reta masks\n",
2362 res->list_of_items);
2365 port_rss_reta_info(res->port_id, reta_conf, res->size);
2368 cmdline_parse_token_string_t cmd_showport_reta_show =
2369 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2370 cmdline_parse_token_string_t cmd_showport_reta_port =
2371 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2372 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2373 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2374 cmdline_parse_token_string_t cmd_showport_reta_rss =
2375 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2376 cmdline_parse_token_string_t cmd_showport_reta_reta =
2377 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2378 cmdline_parse_token_num_t cmd_showport_reta_size =
2379 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2380 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2381 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2382 list_of_items, NULL);
2384 cmdline_parse_inst_t cmd_showport_reta = {
2385 .f = cmd_showport_reta_parsed,
2387 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2389 (void *)&cmd_showport_reta_show,
2390 (void *)&cmd_showport_reta_port,
2391 (void *)&cmd_showport_reta_port_id,
2392 (void *)&cmd_showport_reta_rss,
2393 (void *)&cmd_showport_reta_reta,
2394 (void *)&cmd_showport_reta_size,
2395 (void *)&cmd_showport_reta_list_of_items,
2400 /* *** Show RSS hash configuration *** */
2401 struct cmd_showport_rss_hash {
2402 cmdline_fixed_string_t show;
2403 cmdline_fixed_string_t port;
2405 cmdline_fixed_string_t rss_hash;
2406 cmdline_fixed_string_t rss_type;
2407 cmdline_fixed_string_t key; /* optional argument */
2410 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2411 __attribute__((unused)) struct cmdline *cl,
2414 struct cmd_showport_rss_hash *res = parsed_result;
2416 port_rss_hash_conf_show(res->port_id, res->rss_type,
2417 show_rss_key != NULL);
2420 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2421 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2422 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2423 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2424 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2425 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2426 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2427 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2429 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2430 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2431 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2432 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2433 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2434 "ipv6-tcp-ex#ipv6-udp-ex");
2435 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2436 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2438 cmdline_parse_inst_t cmd_showport_rss_hash = {
2439 .f = cmd_showport_rss_hash_parsed,
2441 .help_str = "show port <port_id> rss-hash "
2442 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2443 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2444 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2446 (void *)&cmd_showport_rss_hash_show,
2447 (void *)&cmd_showport_rss_hash_port,
2448 (void *)&cmd_showport_rss_hash_port_id,
2449 (void *)&cmd_showport_rss_hash_rss_hash,
2450 (void *)&cmd_showport_rss_hash_rss_hash_info,
2455 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2456 .f = cmd_showport_rss_hash_parsed,
2458 .help_str = "show port <port_id> rss-hash "
2459 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2460 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2461 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2463 (void *)&cmd_showport_rss_hash_show,
2464 (void *)&cmd_showport_rss_hash_port,
2465 (void *)&cmd_showport_rss_hash_port_id,
2466 (void *)&cmd_showport_rss_hash_rss_hash,
2467 (void *)&cmd_showport_rss_hash_rss_hash_info,
2468 (void *)&cmd_showport_rss_hash_rss_key,
2473 /* *** Configure DCB *** */
2474 struct cmd_config_dcb {
2475 cmdline_fixed_string_t port;
2476 cmdline_fixed_string_t config;
2478 cmdline_fixed_string_t dcb;
2479 cmdline_fixed_string_t vt;
2480 cmdline_fixed_string_t vt_en;
2482 cmdline_fixed_string_t pfc;
2483 cmdline_fixed_string_t pfc_en;
2487 cmd_config_dcb_parsed(void *parsed_result,
2488 __attribute__((unused)) struct cmdline *cl,
2489 __attribute__((unused)) void *data)
2491 struct cmd_config_dcb *res = parsed_result;
2492 portid_t port_id = res->port_id;
2493 struct rte_port *port;
2497 port = &ports[port_id];
2498 /** Check if the port is not started **/
2499 if (port->port_status != RTE_PORT_STOPPED) {
2500 printf("Please stop port %d first\n", port_id);
2504 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2505 printf("The invalid number of traffic class,"
2506 " only 4 or 8 allowed.\n");
2510 if (nb_fwd_lcores < res->num_tcs) {
2511 printf("nb_cores shouldn't be less than number of TCs.\n");
2514 if (!strncmp(res->pfc_en, "on", 2))
2519 /* DCB in VT mode */
2520 if (!strncmp(res->vt_en, "on", 2))
2521 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2522 (enum rte_eth_nb_tcs)res->num_tcs,
2525 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2526 (enum rte_eth_nb_tcs)res->num_tcs,
2531 printf("Cannot initialize network ports.\n");
2535 cmd_reconfig_device_queue(port_id, 1, 1);
2538 cmdline_parse_token_string_t cmd_config_dcb_port =
2539 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2540 cmdline_parse_token_string_t cmd_config_dcb_config =
2541 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2542 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2543 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2544 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2546 cmdline_parse_token_string_t cmd_config_dcb_vt =
2547 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2548 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2549 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2550 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2551 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2552 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2554 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2555 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2557 cmdline_parse_inst_t cmd_config_dcb = {
2558 .f = cmd_config_dcb_parsed,
2560 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2562 (void *)&cmd_config_dcb_port,
2563 (void *)&cmd_config_dcb_config,
2564 (void *)&cmd_config_dcb_port_id,
2565 (void *)&cmd_config_dcb_dcb,
2566 (void *)&cmd_config_dcb_vt,
2567 (void *)&cmd_config_dcb_vt_en,
2568 (void *)&cmd_config_dcb_num_tcs,
2569 (void *)&cmd_config_dcb_pfc,
2570 (void *)&cmd_config_dcb_pfc_en,
2575 /* *** configure number of packets per burst *** */
2576 struct cmd_config_burst {
2577 cmdline_fixed_string_t port;
2578 cmdline_fixed_string_t keyword;
2579 cmdline_fixed_string_t all;
2580 cmdline_fixed_string_t name;
2585 cmd_config_burst_parsed(void *parsed_result,
2586 __attribute__((unused)) struct cmdline *cl,
2587 __attribute__((unused)) void *data)
2589 struct cmd_config_burst *res = parsed_result;
2591 if (!all_ports_stopped()) {
2592 printf("Please stop all ports first\n");
2596 if (!strcmp(res->name, "burst")) {
2597 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2598 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2601 nb_pkt_per_burst = res->value;
2603 printf("Unknown parameter\n");
2609 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2612 cmdline_parse_token_string_t cmd_config_burst_port =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2614 cmdline_parse_token_string_t cmd_config_burst_keyword =
2615 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2616 cmdline_parse_token_string_t cmd_config_burst_all =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2618 cmdline_parse_token_string_t cmd_config_burst_name =
2619 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2620 cmdline_parse_token_num_t cmd_config_burst_value =
2621 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2623 cmdline_parse_inst_t cmd_config_burst = {
2624 .f = cmd_config_burst_parsed,
2626 .help_str = "port config all burst <value>",
2628 (void *)&cmd_config_burst_port,
2629 (void *)&cmd_config_burst_keyword,
2630 (void *)&cmd_config_burst_all,
2631 (void *)&cmd_config_burst_name,
2632 (void *)&cmd_config_burst_value,
2637 /* *** configure rx/tx queues *** */
2638 struct cmd_config_thresh {
2639 cmdline_fixed_string_t port;
2640 cmdline_fixed_string_t keyword;
2641 cmdline_fixed_string_t all;
2642 cmdline_fixed_string_t name;
2647 cmd_config_thresh_parsed(void *parsed_result,
2648 __attribute__((unused)) struct cmdline *cl,
2649 __attribute__((unused)) void *data)
2651 struct cmd_config_thresh *res = parsed_result;
2653 if (!all_ports_stopped()) {
2654 printf("Please stop all ports first\n");
2658 if (!strcmp(res->name, "txpt"))
2659 tx_pthresh = res->value;
2660 else if(!strcmp(res->name, "txht"))
2661 tx_hthresh = res->value;
2662 else if(!strcmp(res->name, "txwt"))
2663 tx_wthresh = res->value;
2664 else if(!strcmp(res->name, "rxpt"))
2665 rx_pthresh = res->value;
2666 else if(!strcmp(res->name, "rxht"))
2667 rx_hthresh = res->value;
2668 else if(!strcmp(res->name, "rxwt"))
2669 rx_wthresh = res->value;
2671 printf("Unknown parameter\n");
2677 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2680 cmdline_parse_token_string_t cmd_config_thresh_port =
2681 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2682 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2683 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2684 cmdline_parse_token_string_t cmd_config_thresh_all =
2685 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2686 cmdline_parse_token_string_t cmd_config_thresh_name =
2687 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2688 "txpt#txht#txwt#rxpt#rxht#rxwt");
2689 cmdline_parse_token_num_t cmd_config_thresh_value =
2690 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2692 cmdline_parse_inst_t cmd_config_thresh = {
2693 .f = cmd_config_thresh_parsed,
2695 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2697 (void *)&cmd_config_thresh_port,
2698 (void *)&cmd_config_thresh_keyword,
2699 (void *)&cmd_config_thresh_all,
2700 (void *)&cmd_config_thresh_name,
2701 (void *)&cmd_config_thresh_value,
2706 /* *** configure free/rs threshold *** */
2707 struct cmd_config_threshold {
2708 cmdline_fixed_string_t port;
2709 cmdline_fixed_string_t keyword;
2710 cmdline_fixed_string_t all;
2711 cmdline_fixed_string_t name;
2716 cmd_config_threshold_parsed(void *parsed_result,
2717 __attribute__((unused)) struct cmdline *cl,
2718 __attribute__((unused)) void *data)
2720 struct cmd_config_threshold *res = parsed_result;
2722 if (!all_ports_stopped()) {
2723 printf("Please stop all ports first\n");
2727 if (!strcmp(res->name, "txfreet"))
2728 tx_free_thresh = res->value;
2729 else if (!strcmp(res->name, "txrst"))
2730 tx_rs_thresh = res->value;
2731 else if (!strcmp(res->name, "rxfreet"))
2732 rx_free_thresh = res->value;
2734 printf("Unknown parameter\n");
2740 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2743 cmdline_parse_token_string_t cmd_config_threshold_port =
2744 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2745 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2746 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2748 cmdline_parse_token_string_t cmd_config_threshold_all =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2750 cmdline_parse_token_string_t cmd_config_threshold_name =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2752 "txfreet#txrst#rxfreet");
2753 cmdline_parse_token_num_t cmd_config_threshold_value =
2754 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2756 cmdline_parse_inst_t cmd_config_threshold = {
2757 .f = cmd_config_threshold_parsed,
2759 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2761 (void *)&cmd_config_threshold_port,
2762 (void *)&cmd_config_threshold_keyword,
2763 (void *)&cmd_config_threshold_all,
2764 (void *)&cmd_config_threshold_name,
2765 (void *)&cmd_config_threshold_value,
2771 struct cmd_stop_result {
2772 cmdline_fixed_string_t stop;
2775 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2776 __attribute__((unused)) struct cmdline *cl,
2777 __attribute__((unused)) void *data)
2779 stop_packet_forwarding();
2782 cmdline_parse_token_string_t cmd_stop_stop =
2783 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2785 cmdline_parse_inst_t cmd_stop = {
2786 .f = cmd_stop_parsed,
2788 .help_str = "stop: Stop packet forwarding",
2790 (void *)&cmd_stop_stop,
2795 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2798 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2799 unsigned int *parsed_items, int check_unique_values)
2801 unsigned int nb_item;
2809 * First parse all items in the list and store their value.
2814 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2816 if ((c >= '0') && (c <= '9')) {
2817 value = (unsigned int) (value * 10 + (c - '0'));
2822 printf("character %c is not a decimal digit\n", c);
2826 printf("No valid value before comma\n");
2829 if (nb_item < max_items) {
2830 parsed_items[nb_item] = value;
2836 if (nb_item >= max_items) {
2837 printf("Number of %s = %u > %u (maximum items)\n",
2838 item_name, nb_item + 1, max_items);
2841 parsed_items[nb_item++] = value;
2842 if (! check_unique_values)
2846 * Then, check that all values in the list are differents.
2847 * No optimization here...
2849 for (i = 0; i < nb_item; i++) {
2850 for (j = i + 1; j < nb_item; j++) {
2851 if (parsed_items[j] == parsed_items[i]) {
2852 printf("duplicated %s %u at index %u and %u\n",
2853 item_name, parsed_items[i], i, j);
2861 struct cmd_set_list_result {
2862 cmdline_fixed_string_t cmd_keyword;
2863 cmdline_fixed_string_t list_name;
2864 cmdline_fixed_string_t list_of_items;
2867 static void cmd_set_list_parsed(void *parsed_result,
2868 __attribute__((unused)) struct cmdline *cl,
2869 __attribute__((unused)) void *data)
2871 struct cmd_set_list_result *res;
2873 unsigned int lcorelist[RTE_MAX_LCORE];
2874 unsigned int portlist[RTE_MAX_ETHPORTS];
2876 unsigned int nb_item;
2878 if (test_done == 0) {
2879 printf("Please stop forwarding first\n");
2883 res = parsed_result;
2884 if (!strcmp(res->list_name, "corelist")) {
2885 nb_item = parse_item_list(res->list_of_items, "core",
2887 parsed_items.lcorelist, 1);
2889 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2894 if (!strcmp(res->list_name, "portlist")) {
2895 nb_item = parse_item_list(res->list_of_items, "port",
2897 parsed_items.portlist, 1);
2899 set_fwd_ports_list(parsed_items.portlist, nb_item);
2905 cmdline_parse_token_string_t cmd_set_list_keyword =
2906 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2908 cmdline_parse_token_string_t cmd_set_list_name =
2909 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2910 "corelist#portlist");
2911 cmdline_parse_token_string_t cmd_set_list_of_items =
2912 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2915 cmdline_parse_inst_t cmd_set_fwd_list = {
2916 .f = cmd_set_list_parsed,
2918 .help_str = "set corelist|portlist <list0[,list1]*>",
2920 (void *)&cmd_set_list_keyword,
2921 (void *)&cmd_set_list_name,
2922 (void *)&cmd_set_list_of_items,
2927 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2929 struct cmd_setmask_result {
2930 cmdline_fixed_string_t set;
2931 cmdline_fixed_string_t mask;
2935 static void cmd_set_mask_parsed(void *parsed_result,
2936 __attribute__((unused)) struct cmdline *cl,
2937 __attribute__((unused)) void *data)
2939 struct cmd_setmask_result *res = parsed_result;
2941 if (test_done == 0) {
2942 printf("Please stop forwarding first\n");
2945 if (!strcmp(res->mask, "coremask")) {
2946 set_fwd_lcores_mask(res->hexavalue);
2948 } else if (!strcmp(res->mask, "portmask")) {
2949 set_fwd_ports_mask(res->hexavalue);
2954 cmdline_parse_token_string_t cmd_setmask_set =
2955 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2956 cmdline_parse_token_string_t cmd_setmask_mask =
2957 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2958 "coremask#portmask");
2959 cmdline_parse_token_num_t cmd_setmask_value =
2960 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2962 cmdline_parse_inst_t cmd_set_fwd_mask = {
2963 .f = cmd_set_mask_parsed,
2965 .help_str = "set coremask|portmask <hexadecimal value>",
2967 (void *)&cmd_setmask_set,
2968 (void *)&cmd_setmask_mask,
2969 (void *)&cmd_setmask_value,
2975 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2977 struct cmd_set_result {
2978 cmdline_fixed_string_t set;
2979 cmdline_fixed_string_t what;
2983 static void cmd_set_parsed(void *parsed_result,
2984 __attribute__((unused)) struct cmdline *cl,
2985 __attribute__((unused)) void *data)
2987 struct cmd_set_result *res = parsed_result;
2988 if (!strcmp(res->what, "nbport")) {
2989 set_fwd_ports_number(res->value);
2991 } else if (!strcmp(res->what, "nbcore")) {
2992 set_fwd_lcores_number(res->value);
2994 } else if (!strcmp(res->what, "burst"))
2995 set_nb_pkt_per_burst(res->value);
2996 else if (!strcmp(res->what, "verbose"))
2997 set_verbose_level(res->value);
3000 cmdline_parse_token_string_t cmd_set_set =
3001 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3002 cmdline_parse_token_string_t cmd_set_what =
3003 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3004 "nbport#nbcore#burst#verbose");
3005 cmdline_parse_token_num_t cmd_set_value =
3006 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3008 cmdline_parse_inst_t cmd_set_numbers = {
3009 .f = cmd_set_parsed,
3011 .help_str = "set nbport|nbcore|burst|verbose <value>",
3013 (void *)&cmd_set_set,
3014 (void *)&cmd_set_what,
3015 (void *)&cmd_set_value,
3020 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3022 struct cmd_set_txpkts_result {
3023 cmdline_fixed_string_t cmd_keyword;
3024 cmdline_fixed_string_t txpkts;
3025 cmdline_fixed_string_t seg_lengths;
3029 cmd_set_txpkts_parsed(void *parsed_result,
3030 __attribute__((unused)) struct cmdline *cl,
3031 __attribute__((unused)) void *data)
3033 struct cmd_set_txpkts_result *res;
3034 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3035 unsigned int nb_segs;
3037 res = parsed_result;
3038 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3039 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3041 set_tx_pkt_segments(seg_lengths, nb_segs);
3044 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3045 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3046 cmd_keyword, "set");
3047 cmdline_parse_token_string_t cmd_set_txpkts_name =
3048 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3050 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3051 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3054 cmdline_parse_inst_t cmd_set_txpkts = {
3055 .f = cmd_set_txpkts_parsed,
3057 .help_str = "set txpkts <len0[,len1]*>",
3059 (void *)&cmd_set_txpkts_keyword,
3060 (void *)&cmd_set_txpkts_name,
3061 (void *)&cmd_set_txpkts_lengths,
3066 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3068 struct cmd_set_txsplit_result {
3069 cmdline_fixed_string_t cmd_keyword;
3070 cmdline_fixed_string_t txsplit;
3071 cmdline_fixed_string_t mode;
3075 cmd_set_txsplit_parsed(void *parsed_result,
3076 __attribute__((unused)) struct cmdline *cl,
3077 __attribute__((unused)) void *data)
3079 struct cmd_set_txsplit_result *res;
3081 res = parsed_result;
3082 set_tx_pkt_split(res->mode);
3085 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3086 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3087 cmd_keyword, "set");
3088 cmdline_parse_token_string_t cmd_set_txsplit_name =
3089 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3090 txsplit, "txsplit");
3091 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3092 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3095 cmdline_parse_inst_t cmd_set_txsplit = {
3096 .f = cmd_set_txsplit_parsed,
3098 .help_str = "set txsplit on|off|rand",
3100 (void *)&cmd_set_txsplit_keyword,
3101 (void *)&cmd_set_txsplit_name,
3102 (void *)&cmd_set_txsplit_mode,
3107 /* *** CONFIG TX QUEUE FLAGS *** */
3109 struct cmd_config_txqflags_result {
3110 cmdline_fixed_string_t port;
3111 cmdline_fixed_string_t config;
3112 cmdline_fixed_string_t all;
3113 cmdline_fixed_string_t what;
3117 static void cmd_config_txqflags_parsed(void *parsed_result,
3118 __attribute__((unused)) struct cmdline *cl,
3119 __attribute__((unused)) void *data)
3121 struct cmd_config_txqflags_result *res = parsed_result;
3123 if (!all_ports_stopped()) {
3124 printf("Please stop all ports first\n");
3128 if (strcmp(res->what, "txqflags")) {
3129 printf("Unknown parameter\n");
3133 if (res->hexvalue >= 0) {
3134 txq_flags = res->hexvalue;
3136 printf("txqflags must be >= 0\n");
3142 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3145 cmdline_parse_token_string_t cmd_config_txqflags_port =
3146 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3148 cmdline_parse_token_string_t cmd_config_txqflags_config =
3149 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3151 cmdline_parse_token_string_t cmd_config_txqflags_all =
3152 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3154 cmdline_parse_token_string_t cmd_config_txqflags_what =
3155 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3157 cmdline_parse_token_num_t cmd_config_txqflags_value =
3158 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3161 cmdline_parse_inst_t cmd_config_txqflags = {
3162 .f = cmd_config_txqflags_parsed,
3164 .help_str = "port config all txqflags <value>",
3166 (void *)&cmd_config_txqflags_port,
3167 (void *)&cmd_config_txqflags_config,
3168 (void *)&cmd_config_txqflags_all,
3169 (void *)&cmd_config_txqflags_what,
3170 (void *)&cmd_config_txqflags_value,
3175 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3176 struct cmd_rx_vlan_filter_all_result {
3177 cmdline_fixed_string_t rx_vlan;
3178 cmdline_fixed_string_t what;
3179 cmdline_fixed_string_t all;
3184 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3185 __attribute__((unused)) struct cmdline *cl,
3186 __attribute__((unused)) void *data)
3188 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3190 if (!strcmp(res->what, "add"))
3191 rx_vlan_all_filter_set(res->port_id, 1);
3193 rx_vlan_all_filter_set(res->port_id, 0);
3196 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3197 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3198 rx_vlan, "rx_vlan");
3199 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3200 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3202 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3203 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3205 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3206 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3209 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3210 .f = cmd_rx_vlan_filter_all_parsed,
3212 .help_str = "rx_vlan add|rm all <port_id>: "
3213 "Add/Remove all identifiers to/from the set of VLAN "
3214 "identifiers filtered by a port",
3216 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3217 (void *)&cmd_rx_vlan_filter_all_what,
3218 (void *)&cmd_rx_vlan_filter_all_all,
3219 (void *)&cmd_rx_vlan_filter_all_portid,
3224 /* *** VLAN OFFLOAD SET ON A PORT *** */
3225 struct cmd_vlan_offload_result {
3226 cmdline_fixed_string_t vlan;
3227 cmdline_fixed_string_t set;
3228 cmdline_fixed_string_t vlan_type;
3229 cmdline_fixed_string_t what;
3230 cmdline_fixed_string_t on;
3231 cmdline_fixed_string_t port_id;
3235 cmd_vlan_offload_parsed(void *parsed_result,
3236 __attribute__((unused)) struct cmdline *cl,
3237 __attribute__((unused)) void *data)
3240 struct cmd_vlan_offload_result *res = parsed_result;
3243 portid_t port_id = 0;
3247 len = strnlen(str, STR_TOKEN_SIZE);
3249 /* Get port_id first */
3257 tmp = strtoul(str, NULL, 0);
3258 /* If port_id greater that what portid_t can represent, return */
3259 if(tmp >= RTE_MAX_ETHPORTS)
3261 port_id = (portid_t)tmp;
3263 if (!strcmp(res->on, "on"))
3268 if (!strcmp(res->what, "strip"))
3269 rx_vlan_strip_set(port_id, on);
3270 else if(!strcmp(res->what, "stripq")){
3271 uint16_t queue_id = 0;
3273 /* No queue_id, return */
3275 printf("must specify (port,queue_id)\n");
3278 tmp = strtoul(str + i + 1, NULL, 0);
3279 /* If queue_id greater that what 16-bits can represent, return */
3283 queue_id = (uint16_t)tmp;
3284 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3286 else if (!strcmp(res->what, "filter"))
3287 rx_vlan_filter_set(port_id, on);
3289 vlan_extend_set(port_id, on);
3294 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3295 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3297 cmdline_parse_token_string_t cmd_vlan_offload_set =
3298 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3300 cmdline_parse_token_string_t cmd_vlan_offload_what =
3301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3302 what, "strip#filter#qinq#stripq");
3303 cmdline_parse_token_string_t cmd_vlan_offload_on =
3304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3306 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3310 cmdline_parse_inst_t cmd_vlan_offload = {
3311 .f = cmd_vlan_offload_parsed,
3313 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3314 "<port_id[,queue_id]>: "
3315 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3317 (void *)&cmd_vlan_offload_vlan,
3318 (void *)&cmd_vlan_offload_set,
3319 (void *)&cmd_vlan_offload_what,
3320 (void *)&cmd_vlan_offload_on,
3321 (void *)&cmd_vlan_offload_portid,
3326 /* *** VLAN TPID SET ON A PORT *** */
3327 struct cmd_vlan_tpid_result {
3328 cmdline_fixed_string_t vlan;
3329 cmdline_fixed_string_t set;
3330 cmdline_fixed_string_t vlan_type;
3331 cmdline_fixed_string_t what;
3337 cmd_vlan_tpid_parsed(void *parsed_result,
3338 __attribute__((unused)) struct cmdline *cl,
3339 __attribute__((unused)) void *data)
3341 struct cmd_vlan_tpid_result *res = parsed_result;
3342 enum rte_vlan_type vlan_type;
3344 if (!strcmp(res->vlan_type, "inner"))
3345 vlan_type = ETH_VLAN_TYPE_INNER;
3346 else if (!strcmp(res->vlan_type, "outer"))
3347 vlan_type = ETH_VLAN_TYPE_OUTER;
3349 printf("Unknown vlan type\n");
3352 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3355 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3356 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3358 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3359 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3361 cmdline_parse_token_string_t cmd_vlan_type =
3362 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3363 vlan_type, "inner#outer");
3364 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3365 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3367 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3368 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3370 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3371 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3374 cmdline_parse_inst_t cmd_vlan_tpid = {
3375 .f = cmd_vlan_tpid_parsed,
3377 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3378 "Set the VLAN Ether type",
3380 (void *)&cmd_vlan_tpid_vlan,
3381 (void *)&cmd_vlan_tpid_set,
3382 (void *)&cmd_vlan_type,
3383 (void *)&cmd_vlan_tpid_what,
3384 (void *)&cmd_vlan_tpid_tpid,
3385 (void *)&cmd_vlan_tpid_portid,
3390 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3391 struct cmd_rx_vlan_filter_result {
3392 cmdline_fixed_string_t rx_vlan;
3393 cmdline_fixed_string_t what;
3399 cmd_rx_vlan_filter_parsed(void *parsed_result,
3400 __attribute__((unused)) struct cmdline *cl,
3401 __attribute__((unused)) void *data)
3403 struct cmd_rx_vlan_filter_result *res = parsed_result;
3405 if (!strcmp(res->what, "add"))
3406 rx_vft_set(res->port_id, res->vlan_id, 1);
3408 rx_vft_set(res->port_id, res->vlan_id, 0);
3411 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3412 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3413 rx_vlan, "rx_vlan");
3414 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3415 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3417 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3418 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3420 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3421 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3424 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3425 .f = cmd_rx_vlan_filter_parsed,
3427 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3428 "Add/Remove a VLAN identifier to/from the set of VLAN "
3429 "identifiers filtered by a port",
3431 (void *)&cmd_rx_vlan_filter_rx_vlan,
3432 (void *)&cmd_rx_vlan_filter_what,
3433 (void *)&cmd_rx_vlan_filter_vlanid,
3434 (void *)&cmd_rx_vlan_filter_portid,
3439 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3440 struct cmd_tx_vlan_set_result {
3441 cmdline_fixed_string_t tx_vlan;
3442 cmdline_fixed_string_t set;
3448 cmd_tx_vlan_set_parsed(void *parsed_result,
3449 __attribute__((unused)) struct cmdline *cl,
3450 __attribute__((unused)) void *data)
3452 struct cmd_tx_vlan_set_result *res = parsed_result;
3454 tx_vlan_set(res->port_id, res->vlan_id);
3457 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3458 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3459 tx_vlan, "tx_vlan");
3460 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3461 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3463 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3464 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3466 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3467 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3470 cmdline_parse_inst_t cmd_tx_vlan_set = {
3471 .f = cmd_tx_vlan_set_parsed,
3473 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3474 "Enable hardware insertion of a single VLAN header "
3475 "with a given TAG Identifier in packets sent on a port",
3477 (void *)&cmd_tx_vlan_set_tx_vlan,
3478 (void *)&cmd_tx_vlan_set_set,
3479 (void *)&cmd_tx_vlan_set_portid,
3480 (void *)&cmd_tx_vlan_set_vlanid,
3485 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3486 struct cmd_tx_vlan_set_qinq_result {
3487 cmdline_fixed_string_t tx_vlan;
3488 cmdline_fixed_string_t set;
3491 uint16_t vlan_id_outer;
3495 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3496 __attribute__((unused)) struct cmdline *cl,
3497 __attribute__((unused)) void *data)
3499 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3501 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3504 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3505 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3506 tx_vlan, "tx_vlan");
3507 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3508 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3510 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3511 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3513 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3514 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3516 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3517 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3518 vlan_id_outer, UINT16);
3520 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3521 .f = cmd_tx_vlan_set_qinq_parsed,
3523 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3524 "Enable hardware insertion of double VLAN header "
3525 "with given TAG Identifiers in packets sent on a port",
3527 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3528 (void *)&cmd_tx_vlan_set_qinq_set,
3529 (void *)&cmd_tx_vlan_set_qinq_portid,
3530 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3531 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3536 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3537 struct cmd_tx_vlan_set_pvid_result {
3538 cmdline_fixed_string_t tx_vlan;
3539 cmdline_fixed_string_t set;
3540 cmdline_fixed_string_t pvid;
3543 cmdline_fixed_string_t mode;
3547 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3548 __attribute__((unused)) struct cmdline *cl,
3549 __attribute__((unused)) void *data)
3551 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3553 if (strcmp(res->mode, "on") == 0)
3554 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3556 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3559 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3560 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3561 tx_vlan, "tx_vlan");
3562 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3563 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3565 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3566 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3568 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3569 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3571 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3572 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3574 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3575 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3578 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3579 .f = cmd_tx_vlan_set_pvid_parsed,
3581 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3583 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3584 (void *)&cmd_tx_vlan_set_pvid_set,
3585 (void *)&cmd_tx_vlan_set_pvid_pvid,
3586 (void *)&cmd_tx_vlan_set_pvid_port_id,
3587 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3588 (void *)&cmd_tx_vlan_set_pvid_mode,
3593 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3594 struct cmd_tx_vlan_reset_result {
3595 cmdline_fixed_string_t tx_vlan;
3596 cmdline_fixed_string_t reset;
3601 cmd_tx_vlan_reset_parsed(void *parsed_result,
3602 __attribute__((unused)) struct cmdline *cl,
3603 __attribute__((unused)) void *data)
3605 struct cmd_tx_vlan_reset_result *res = parsed_result;
3607 tx_vlan_reset(res->port_id);
3610 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3611 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3612 tx_vlan, "tx_vlan");
3613 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3614 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3616 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3617 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3620 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3621 .f = cmd_tx_vlan_reset_parsed,
3623 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3624 "VLAN header in packets sent on a port",
3626 (void *)&cmd_tx_vlan_reset_tx_vlan,
3627 (void *)&cmd_tx_vlan_reset_reset,
3628 (void *)&cmd_tx_vlan_reset_portid,
3634 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3635 struct cmd_csum_result {
3636 cmdline_fixed_string_t csum;
3637 cmdline_fixed_string_t mode;
3638 cmdline_fixed_string_t proto;
3639 cmdline_fixed_string_t hwsw;
3644 csum_show(int port_id)
3646 struct rte_eth_dev_info dev_info;
3649 ol_flags = ports[port_id].tx_ol_flags;
3650 printf("Parse tunnel is %s\n",
3651 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3652 printf("IP checksum offload is %s\n",
3653 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3654 printf("UDP checksum offload is %s\n",
3655 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3656 printf("TCP checksum offload is %s\n",
3657 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3658 printf("SCTP checksum offload is %s\n",
3659 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3660 printf("Outer-Ip checksum offload is %s\n",
3661 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3663 /* display warnings if configuration is not supported by the NIC */
3664 rte_eth_dev_info_get(port_id, &dev_info);
3665 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3666 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3667 printf("Warning: hardware IP checksum enabled but not "
3668 "supported by port %d\n", port_id);
3670 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3672 printf("Warning: hardware UDP checksum enabled but not "
3673 "supported by port %d\n", port_id);
3675 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3677 printf("Warning: hardware TCP checksum enabled but not "
3678 "supported by port %d\n", port_id);
3680 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3682 printf("Warning: hardware SCTP checksum enabled but not "
3683 "supported by port %d\n", port_id);
3685 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3687 printf("Warning: hardware outer IP checksum enabled but not "
3688 "supported by port %d\n", port_id);
3693 cmd_csum_parsed(void *parsed_result,
3694 __attribute__((unused)) struct cmdline *cl,
3695 __attribute__((unused)) void *data)
3697 struct cmd_csum_result *res = parsed_result;
3701 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3702 printf("invalid port %d\n", res->port_id);
3706 if (!strcmp(res->mode, "set")) {
3708 if (!strcmp(res->hwsw, "hw"))
3711 if (!strcmp(res->proto, "ip")) {
3712 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3713 } else if (!strcmp(res->proto, "udp")) {
3714 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3715 } else if (!strcmp(res->proto, "tcp")) {
3716 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3717 } else if (!strcmp(res->proto, "sctp")) {
3718 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3719 } else if (!strcmp(res->proto, "outer-ip")) {
3720 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3724 ports[res->port_id].tx_ol_flags |= mask;
3726 ports[res->port_id].tx_ol_flags &= (~mask);
3728 csum_show(res->port_id);
3731 cmdline_parse_token_string_t cmd_csum_csum =
3732 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3734 cmdline_parse_token_string_t cmd_csum_mode =
3735 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3737 cmdline_parse_token_string_t cmd_csum_proto =
3738 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3739 proto, "ip#tcp#udp#sctp#outer-ip");
3740 cmdline_parse_token_string_t cmd_csum_hwsw =
3741 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3743 cmdline_parse_token_num_t cmd_csum_portid =
3744 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3747 cmdline_parse_inst_t cmd_csum_set = {
3748 .f = cmd_csum_parsed,
3750 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3751 "Enable/Disable hardware calculation of L3/L4 checksum when "
3752 "using csum forward engine",
3754 (void *)&cmd_csum_csum,
3755 (void *)&cmd_csum_mode,
3756 (void *)&cmd_csum_proto,
3757 (void *)&cmd_csum_hwsw,
3758 (void *)&cmd_csum_portid,
3763 cmdline_parse_token_string_t cmd_csum_mode_show =
3764 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3767 cmdline_parse_inst_t cmd_csum_show = {
3768 .f = cmd_csum_parsed,
3770 .help_str = "csum show <port_id>: Show checksum offload configuration",
3772 (void *)&cmd_csum_csum,
3773 (void *)&cmd_csum_mode_show,
3774 (void *)&cmd_csum_portid,
3779 /* Enable/disable tunnel parsing */
3780 struct cmd_csum_tunnel_result {
3781 cmdline_fixed_string_t csum;
3782 cmdline_fixed_string_t parse;
3783 cmdline_fixed_string_t onoff;
3788 cmd_csum_tunnel_parsed(void *parsed_result,
3789 __attribute__((unused)) struct cmdline *cl,
3790 __attribute__((unused)) void *data)
3792 struct cmd_csum_tunnel_result *res = parsed_result;
3794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3797 if (!strcmp(res->onoff, "on"))
3798 ports[res->port_id].tx_ol_flags |=
3799 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3801 ports[res->port_id].tx_ol_flags &=
3802 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3804 csum_show(res->port_id);
3807 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3808 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3810 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3811 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3812 parse, "parse_tunnel");
3813 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3814 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3816 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3817 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3820 cmdline_parse_inst_t cmd_csum_tunnel = {
3821 .f = cmd_csum_tunnel_parsed,
3823 .help_str = "csum parse_tunnel on|off <port_id>: "
3824 "Enable/Disable parsing of tunnels for csum engine",
3826 (void *)&cmd_csum_tunnel_csum,
3827 (void *)&cmd_csum_tunnel_parse,
3828 (void *)&cmd_csum_tunnel_onoff,
3829 (void *)&cmd_csum_tunnel_portid,
3834 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3835 struct cmd_tso_set_result {
3836 cmdline_fixed_string_t tso;
3837 cmdline_fixed_string_t mode;
3843 cmd_tso_set_parsed(void *parsed_result,
3844 __attribute__((unused)) struct cmdline *cl,
3845 __attribute__((unused)) void *data)
3847 struct cmd_tso_set_result *res = parsed_result;
3848 struct rte_eth_dev_info dev_info;
3850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3853 if (!strcmp(res->mode, "set"))
3854 ports[res->port_id].tso_segsz = res->tso_segsz;
3856 if (ports[res->port_id].tso_segsz == 0)
3857 printf("TSO for non-tunneled packets is disabled\n");
3859 printf("TSO segment size for non-tunneled packets is %d\n",
3860 ports[res->port_id].tso_segsz);
3862 /* display warnings if configuration is not supported by the NIC */
3863 rte_eth_dev_info_get(res->port_id, &dev_info);
3864 if ((ports[res->port_id].tso_segsz != 0) &&
3865 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3866 printf("Warning: TSO enabled but not "
3867 "supported by port %d\n", res->port_id);
3871 cmdline_parse_token_string_t cmd_tso_set_tso =
3872 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3874 cmdline_parse_token_string_t cmd_tso_set_mode =
3875 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3877 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3878 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3880 cmdline_parse_token_num_t cmd_tso_set_portid =
3881 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3884 cmdline_parse_inst_t cmd_tso_set = {
3885 .f = cmd_tso_set_parsed,
3887 .help_str = "tso set <tso_segsz> <port_id>: "
3888 "Set TSO segment size of non-tunneled packets for csum engine "
3891 (void *)&cmd_tso_set_tso,
3892 (void *)&cmd_tso_set_mode,
3893 (void *)&cmd_tso_set_tso_segsz,
3894 (void *)&cmd_tso_set_portid,
3899 cmdline_parse_token_string_t cmd_tso_show_mode =
3900 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3904 cmdline_parse_inst_t cmd_tso_show = {
3905 .f = cmd_tso_set_parsed,
3907 .help_str = "tso show <port_id>: "
3908 "Show TSO segment size of non-tunneled packets for csum engine",
3910 (void *)&cmd_tso_set_tso,
3911 (void *)&cmd_tso_show_mode,
3912 (void *)&cmd_tso_set_portid,
3917 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3918 struct cmd_tunnel_tso_set_result {
3919 cmdline_fixed_string_t tso;
3920 cmdline_fixed_string_t mode;
3926 check_tunnel_tso_nic_support(portid_t port_id)
3928 struct rte_eth_dev_info dev_info;
3930 rte_eth_dev_info_get(port_id, &dev_info);
3931 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3932 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3933 "supported by port %d\n", port_id);
3934 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3935 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3936 "supported by port %d\n", port_id);
3937 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3938 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3939 "supported by port %d\n", port_id);
3940 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3941 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3942 "supported by port %d\n", port_id);
3946 cmd_tunnel_tso_set_parsed(void *parsed_result,
3947 __attribute__((unused)) struct cmdline *cl,
3948 __attribute__((unused)) void *data)
3950 struct cmd_tunnel_tso_set_result *res = parsed_result;
3952 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3955 if (!strcmp(res->mode, "set"))
3956 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3958 if (ports[res->port_id].tunnel_tso_segsz == 0)
3959 printf("TSO for tunneled packets is disabled\n");
3961 printf("TSO segment size for tunneled packets is %d\n",
3962 ports[res->port_id].tunnel_tso_segsz);
3964 /* Below conditions are needed to make it work:
3965 * (1) tunnel TSO is supported by the NIC;
3966 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3968 * (3) for tunneled pkts with outer L3 of IPv4,
3969 * "csum set outer-ip" must be set to hw, because after tso,
3970 * total_len of outer IP header is changed, and the checksum
3971 * of outer IP header calculated by sw should be wrong; that
3972 * is not necessary for IPv6 tunneled pkts because there's no
3973 * checksum in IP header anymore.
3975 check_tunnel_tso_nic_support(res->port_id);
3977 if (!(ports[res->port_id].tx_ol_flags &
3978 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3979 printf("Warning: csum parse_tunnel must be set "
3980 "so that tunneled packets are recognized\n");
3981 if (!(ports[res->port_id].tx_ol_flags &
3982 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3983 printf("Warning: csum set outer-ip must be set to hw "
3984 "if outer L3 is IPv4; not necessary for IPv6\n");
3988 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3989 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3991 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3992 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3994 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3995 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3997 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3998 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4001 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4002 .f = cmd_tunnel_tso_set_parsed,
4004 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4005 "Set TSO segment size of tunneled packets for csum engine "
4008 (void *)&cmd_tunnel_tso_set_tso,
4009 (void *)&cmd_tunnel_tso_set_mode,
4010 (void *)&cmd_tunnel_tso_set_tso_segsz,
4011 (void *)&cmd_tunnel_tso_set_portid,
4016 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4017 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4021 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4022 .f = cmd_tunnel_tso_set_parsed,
4024 .help_str = "tunnel_tso show <port_id> "
4025 "Show TSO segment size of tunneled packets for csum engine",
4027 (void *)&cmd_tunnel_tso_set_tso,
4028 (void *)&cmd_tunnel_tso_show_mode,
4029 (void *)&cmd_tunnel_tso_set_portid,
4034 /* *** SET GRO FOR A PORT *** */
4035 struct cmd_gro_enable_result {
4036 cmdline_fixed_string_t cmd_set;
4037 cmdline_fixed_string_t cmd_port;
4038 cmdline_fixed_string_t cmd_keyword;
4039 cmdline_fixed_string_t cmd_onoff;
4044 cmd_gro_enable_parsed(void *parsed_result,
4045 __attribute__((unused)) struct cmdline *cl,
4046 __attribute__((unused)) void *data)
4048 struct cmd_gro_enable_result *res;
4050 res = parsed_result;
4051 if (!strcmp(res->cmd_keyword, "gro"))
4052 setup_gro(res->cmd_onoff, res->cmd_pid);
4055 cmdline_parse_token_string_t cmd_gro_enable_set =
4056 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4058 cmdline_parse_token_string_t cmd_gro_enable_port =
4059 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4060 cmd_keyword, "port");
4061 cmdline_parse_token_num_t cmd_gro_enable_pid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4064 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4065 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4066 cmd_keyword, "gro");
4067 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4068 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4069 cmd_onoff, "on#off");
4071 cmdline_parse_inst_t cmd_gro_enable = {
4072 .f = cmd_gro_enable_parsed,
4074 .help_str = "set port <port_id> gro on|off",
4076 (void *)&cmd_gro_enable_set,
4077 (void *)&cmd_gro_enable_port,
4078 (void *)&cmd_gro_enable_pid,
4079 (void *)&cmd_gro_enable_keyword,
4080 (void *)&cmd_gro_enable_onoff,
4085 /* *** DISPLAY GRO CONFIGURATION *** */
4086 struct cmd_gro_show_result {
4087 cmdline_fixed_string_t cmd_show;
4088 cmdline_fixed_string_t cmd_port;
4089 cmdline_fixed_string_t cmd_keyword;
4094 cmd_gro_show_parsed(void *parsed_result,
4095 __attribute__((unused)) struct cmdline *cl,
4096 __attribute__((unused)) void *data)
4098 struct cmd_gro_show_result *res;
4100 res = parsed_result;
4101 if (!strcmp(res->cmd_keyword, "gro"))
4102 show_gro(res->cmd_pid);
4105 cmdline_parse_token_string_t cmd_gro_show_show =
4106 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4108 cmdline_parse_token_string_t cmd_gro_show_port =
4109 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4111 cmdline_parse_token_num_t cmd_gro_show_pid =
4112 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4114 cmdline_parse_token_string_t cmd_gro_show_keyword =
4115 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4116 cmd_keyword, "gro");
4118 cmdline_parse_inst_t cmd_gro_show = {
4119 .f = cmd_gro_show_parsed,
4121 .help_str = "show port <port_id> gro",
4123 (void *)&cmd_gro_show_show,
4124 (void *)&cmd_gro_show_port,
4125 (void *)&cmd_gro_show_pid,
4126 (void *)&cmd_gro_show_keyword,
4131 /* *** SET FLUSH CYCLES FOR GRO *** */
4132 struct cmd_gro_flush_result {
4133 cmdline_fixed_string_t cmd_set;
4134 cmdline_fixed_string_t cmd_keyword;
4135 cmdline_fixed_string_t cmd_flush;
4140 cmd_gro_flush_parsed(void *parsed_result,
4141 __attribute__((unused)) struct cmdline *cl,
4142 __attribute__((unused)) void *data)
4144 struct cmd_gro_flush_result *res;
4146 res = parsed_result;
4147 if ((!strcmp(res->cmd_keyword, "gro")) &&
4148 (!strcmp(res->cmd_flush, "flush")))
4149 setup_gro_flush_cycles(res->cmd_cycles);
4152 cmdline_parse_token_string_t cmd_gro_flush_set =
4153 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4155 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4156 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4157 cmd_keyword, "gro");
4158 cmdline_parse_token_string_t cmd_gro_flush_flush =
4159 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4160 cmd_flush, "flush");
4161 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4162 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4165 cmdline_parse_inst_t cmd_gro_flush = {
4166 .f = cmd_gro_flush_parsed,
4168 .help_str = "set gro flush <cycles>",
4170 (void *)&cmd_gro_flush_set,
4171 (void *)&cmd_gro_flush_keyword,
4172 (void *)&cmd_gro_flush_flush,
4173 (void *)&cmd_gro_flush_cycles,
4178 /* *** ENABLE/DISABLE GSO *** */
4179 struct cmd_gso_enable_result {
4180 cmdline_fixed_string_t cmd_set;
4181 cmdline_fixed_string_t cmd_port;
4182 cmdline_fixed_string_t cmd_keyword;
4183 cmdline_fixed_string_t cmd_mode;
4188 cmd_gso_enable_parsed(void *parsed_result,
4189 __attribute__((unused)) struct cmdline *cl,
4190 __attribute__((unused)) void *data)
4192 struct cmd_gso_enable_result *res;
4194 res = parsed_result;
4195 if (!strcmp(res->cmd_keyword, "gso"))
4196 setup_gso(res->cmd_mode, res->cmd_pid);
4199 cmdline_parse_token_string_t cmd_gso_enable_set =
4200 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4202 cmdline_parse_token_string_t cmd_gso_enable_port =
4203 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4205 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4206 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4207 cmd_keyword, "gso");
4208 cmdline_parse_token_string_t cmd_gso_enable_mode =
4209 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4210 cmd_mode, "on#off");
4211 cmdline_parse_token_num_t cmd_gso_enable_pid =
4212 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4215 cmdline_parse_inst_t cmd_gso_enable = {
4216 .f = cmd_gso_enable_parsed,
4218 .help_str = "set port <port_id> gso on|off",
4220 (void *)&cmd_gso_enable_set,
4221 (void *)&cmd_gso_enable_port,
4222 (void *)&cmd_gso_enable_pid,
4223 (void *)&cmd_gso_enable_keyword,
4224 (void *)&cmd_gso_enable_mode,
4229 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4230 struct cmd_gso_size_result {
4231 cmdline_fixed_string_t cmd_set;
4232 cmdline_fixed_string_t cmd_keyword;
4233 cmdline_fixed_string_t cmd_segsz;
4238 cmd_gso_size_parsed(void *parsed_result,
4239 __attribute__((unused)) struct cmdline *cl,
4240 __attribute__((unused)) void *data)
4242 struct cmd_gso_size_result *res = parsed_result;
4244 if (test_done == 0) {
4245 printf("Before setting GSO segsz, please first"
4246 " stop fowarding\n");
4250 if (!strcmp(res->cmd_keyword, "gso") &&
4251 !strcmp(res->cmd_segsz, "segsz")) {
4252 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4253 printf("gso_size should be larger than %zu."
4254 " Please input a legal value\n",
4255 RTE_GSO_SEG_SIZE_MIN);
4257 gso_max_segment_size = res->cmd_size;
4261 cmdline_parse_token_string_t cmd_gso_size_set =
4262 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4264 cmdline_parse_token_string_t cmd_gso_size_keyword =
4265 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4266 cmd_keyword, "gso");
4267 cmdline_parse_token_string_t cmd_gso_size_segsz =
4268 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4269 cmd_segsz, "segsz");
4270 cmdline_parse_token_num_t cmd_gso_size_size =
4271 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4274 cmdline_parse_inst_t cmd_gso_size = {
4275 .f = cmd_gso_size_parsed,
4277 .help_str = "set gso segsz <length>",
4279 (void *)&cmd_gso_size_set,
4280 (void *)&cmd_gso_size_keyword,
4281 (void *)&cmd_gso_size_segsz,
4282 (void *)&cmd_gso_size_size,
4287 /* *** SHOW GSO CONFIGURATION *** */
4288 struct cmd_gso_show_result {
4289 cmdline_fixed_string_t cmd_show;
4290 cmdline_fixed_string_t cmd_port;
4291 cmdline_fixed_string_t cmd_keyword;
4296 cmd_gso_show_parsed(void *parsed_result,
4297 __attribute__((unused)) struct cmdline *cl,
4298 __attribute__((unused)) void *data)
4300 struct cmd_gso_show_result *res = parsed_result;
4302 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4303 printf("invalid port id %u\n", res->cmd_pid);
4306 if (!strcmp(res->cmd_keyword, "gso")) {
4307 if (gso_ports[res->cmd_pid].enable) {
4308 printf("Max GSO'd packet size: %uB\n"
4309 "Supported GSO types: TCP/IPv4, "
4310 "VxLAN with inner TCP/IPv4 packet, "
4311 "GRE with inner TCP/IPv4 packet\n",
4312 gso_max_segment_size);
4314 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4318 cmdline_parse_token_string_t cmd_gso_show_show =
4319 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4321 cmdline_parse_token_string_t cmd_gso_show_port =
4322 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4324 cmdline_parse_token_string_t cmd_gso_show_keyword =
4325 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4326 cmd_keyword, "gso");
4327 cmdline_parse_token_num_t cmd_gso_show_pid =
4328 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4331 cmdline_parse_inst_t cmd_gso_show = {
4332 .f = cmd_gso_show_parsed,
4334 .help_str = "show port <port_id> gso",
4336 (void *)&cmd_gso_show_show,
4337 (void *)&cmd_gso_show_port,
4338 (void *)&cmd_gso_show_pid,
4339 (void *)&cmd_gso_show_keyword,
4344 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4345 struct cmd_set_flush_rx {
4346 cmdline_fixed_string_t set;
4347 cmdline_fixed_string_t flush_rx;
4348 cmdline_fixed_string_t mode;
4352 cmd_set_flush_rx_parsed(void *parsed_result,
4353 __attribute__((unused)) struct cmdline *cl,
4354 __attribute__((unused)) void *data)
4356 struct cmd_set_flush_rx *res = parsed_result;
4357 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4360 cmdline_parse_token_string_t cmd_setflushrx_set =
4361 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4363 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4364 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4365 flush_rx, "flush_rx");
4366 cmdline_parse_token_string_t cmd_setflushrx_mode =
4367 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4371 cmdline_parse_inst_t cmd_set_flush_rx = {
4372 .f = cmd_set_flush_rx_parsed,
4373 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4376 (void *)&cmd_setflushrx_set,
4377 (void *)&cmd_setflushrx_flush_rx,
4378 (void *)&cmd_setflushrx_mode,
4383 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4384 struct cmd_set_link_check {
4385 cmdline_fixed_string_t set;
4386 cmdline_fixed_string_t link_check;
4387 cmdline_fixed_string_t mode;
4391 cmd_set_link_check_parsed(void *parsed_result,
4392 __attribute__((unused)) struct cmdline *cl,
4393 __attribute__((unused)) void *data)
4395 struct cmd_set_link_check *res = parsed_result;
4396 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4399 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4402 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4403 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4404 link_check, "link_check");
4405 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4406 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4410 cmdline_parse_inst_t cmd_set_link_check = {
4411 .f = cmd_set_link_check_parsed,
4412 .help_str = "set link_check on|off: Enable/Disable link status check "
4413 "when starting/stopping a port",
4416 (void *)&cmd_setlinkcheck_set,
4417 (void *)&cmd_setlinkcheck_link_check,
4418 (void *)&cmd_setlinkcheck_mode,
4423 /* *** SET NIC BYPASS MODE *** */
4424 struct cmd_set_bypass_mode_result {
4425 cmdline_fixed_string_t set;
4426 cmdline_fixed_string_t bypass;
4427 cmdline_fixed_string_t mode;
4428 cmdline_fixed_string_t value;
4433 cmd_set_bypass_mode_parsed(void *parsed_result,
4434 __attribute__((unused)) struct cmdline *cl,
4435 __attribute__((unused)) void *data)
4437 struct cmd_set_bypass_mode_result *res = parsed_result;
4438 portid_t port_id = res->port_id;
4439 int32_t rc = -EINVAL;
4441 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4442 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4444 if (!strcmp(res->value, "bypass"))
4445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4446 else if (!strcmp(res->value, "isolate"))
4447 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4449 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4451 /* Set the bypass mode for the relevant port. */
4452 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4455 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4458 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4461 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4464 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4467 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4469 value, "normal#bypass#isolate");
4470 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4471 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4474 cmdline_parse_inst_t cmd_set_bypass_mode = {
4475 .f = cmd_set_bypass_mode_parsed,
4476 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4477 "Set the NIC bypass mode for port_id",
4480 (void *)&cmd_setbypass_mode_set,
4481 (void *)&cmd_setbypass_mode_bypass,
4482 (void *)&cmd_setbypass_mode_mode,
4483 (void *)&cmd_setbypass_mode_value,
4484 (void *)&cmd_setbypass_mode_port,
4489 /* *** SET NIC BYPASS EVENT *** */
4490 struct cmd_set_bypass_event_result {
4491 cmdline_fixed_string_t set;
4492 cmdline_fixed_string_t bypass;
4493 cmdline_fixed_string_t event;
4494 cmdline_fixed_string_t event_value;
4495 cmdline_fixed_string_t mode;
4496 cmdline_fixed_string_t mode_value;
4501 cmd_set_bypass_event_parsed(void *parsed_result,
4502 __attribute__((unused)) struct cmdline *cl,
4503 __attribute__((unused)) void *data)
4505 int32_t rc = -EINVAL;
4506 struct cmd_set_bypass_event_result *res = parsed_result;
4507 portid_t port_id = res->port_id;
4509 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4510 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4511 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4513 if (!strcmp(res->event_value, "timeout"))
4514 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4515 else if (!strcmp(res->event_value, "os_on"))
4516 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4517 else if (!strcmp(res->event_value, "os_off"))
4518 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4519 else if (!strcmp(res->event_value, "power_on"))
4520 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4521 else if (!strcmp(res->event_value, "power_off"))
4522 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4524 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4526 if (!strcmp(res->mode_value, "bypass"))
4527 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4528 else if (!strcmp(res->mode_value, "isolate"))
4529 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4531 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4533 /* Set the watchdog timeout. */
4534 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4537 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4538 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4542 printf("Failed to set timeout value %u "
4543 "for port %d, errto code: %d.\n",
4544 bypass_timeout, port_id, rc);
4548 /* Set the bypass event to transition to bypass mode. */
4549 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4554 printf("\t Failed to set bypass event for port = %d.\n",
4558 cmdline_parse_token_string_t cmd_setbypass_event_set =
4559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4561 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4564 cmdline_parse_token_string_t cmd_setbypass_event_event =
4565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4567 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4569 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4570 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4573 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4575 mode_value, "normal#bypass#isolate");
4576 cmdline_parse_token_num_t cmd_setbypass_event_port =
4577 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4580 cmdline_parse_inst_t cmd_set_bypass_event = {
4581 .f = cmd_set_bypass_event_parsed,
4582 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4583 "power_off mode normal|bypass|isolate <port_id>: "
4584 "Set the NIC bypass event mode for port_id",
4587 (void *)&cmd_setbypass_event_set,
4588 (void *)&cmd_setbypass_event_bypass,
4589 (void *)&cmd_setbypass_event_event,
4590 (void *)&cmd_setbypass_event_event_value,
4591 (void *)&cmd_setbypass_event_mode,
4592 (void *)&cmd_setbypass_event_mode_value,
4593 (void *)&cmd_setbypass_event_port,
4599 /* *** SET NIC BYPASS TIMEOUT *** */
4600 struct cmd_set_bypass_timeout_result {
4601 cmdline_fixed_string_t set;
4602 cmdline_fixed_string_t bypass;
4603 cmdline_fixed_string_t timeout;
4604 cmdline_fixed_string_t value;
4608 cmd_set_bypass_timeout_parsed(void *parsed_result,
4609 __attribute__((unused)) struct cmdline *cl,
4610 __attribute__((unused)) void *data)
4612 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4614 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4615 if (!strcmp(res->value, "1.5"))
4616 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4617 else if (!strcmp(res->value, "2"))
4618 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4619 else if (!strcmp(res->value, "3"))
4620 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4621 else if (!strcmp(res->value, "4"))
4622 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4623 else if (!strcmp(res->value, "8"))
4624 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4625 else if (!strcmp(res->value, "16"))
4626 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4627 else if (!strcmp(res->value, "32"))
4628 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4630 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4634 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4637 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4640 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4642 timeout, "timeout");
4643 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4645 value, "0#1.5#2#3#4#8#16#32");
4647 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4648 .f = cmd_set_bypass_timeout_parsed,
4649 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4650 "Set the NIC bypass watchdog timeout in seconds",
4653 (void *)&cmd_setbypass_timeout_set,
4654 (void *)&cmd_setbypass_timeout_bypass,
4655 (void *)&cmd_setbypass_timeout_timeout,
4656 (void *)&cmd_setbypass_timeout_value,
4661 /* *** SHOW NIC BYPASS MODE *** */
4662 struct cmd_show_bypass_config_result {
4663 cmdline_fixed_string_t show;
4664 cmdline_fixed_string_t bypass;
4665 cmdline_fixed_string_t config;
4670 cmd_show_bypass_config_parsed(void *parsed_result,
4671 __attribute__((unused)) struct cmdline *cl,
4672 __attribute__((unused)) void *data)
4674 struct cmd_show_bypass_config_result *res = parsed_result;
4675 portid_t port_id = res->port_id;
4677 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4678 uint32_t event_mode;
4679 uint32_t bypass_mode;
4680 uint32_t timeout = bypass_timeout;
4683 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4684 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4685 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4686 {"UNKNOWN", "normal", "bypass", "isolate"};
4687 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4694 int num_events = (sizeof events) / (sizeof events[0]);
4696 /* Display the bypass mode.*/
4697 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4698 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4702 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4703 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4705 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4708 /* Display the bypass timeout.*/
4709 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4710 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4712 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4714 /* Display the bypass events and associated modes. */
4715 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4717 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4718 printf("\tFailed to get bypass mode for event = %s\n",
4721 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4722 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4724 printf("\tbypass event: %-16s = %s\n", events[i],
4730 printf("\tFailed to get bypass configuration for port = %d\n",
4734 cmdline_parse_token_string_t cmd_showbypass_config_show =
4735 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4737 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4738 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4740 cmdline_parse_token_string_t cmd_showbypass_config_config =
4741 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4743 cmdline_parse_token_num_t cmd_showbypass_config_port =
4744 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4747 cmdline_parse_inst_t cmd_show_bypass_config = {
4748 .f = cmd_show_bypass_config_parsed,
4749 .help_str = "show bypass config <port_id>: "
4750 "Show the NIC bypass config for port_id",
4753 (void *)&cmd_showbypass_config_show,
4754 (void *)&cmd_showbypass_config_bypass,
4755 (void *)&cmd_showbypass_config_config,
4756 (void *)&cmd_showbypass_config_port,
4761 #ifdef RTE_LIBRTE_PMD_BOND
4762 /* *** SET BONDING MODE *** */
4763 struct cmd_set_bonding_mode_result {
4764 cmdline_fixed_string_t set;
4765 cmdline_fixed_string_t bonding;
4766 cmdline_fixed_string_t mode;
4771 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4772 __attribute__((unused)) struct cmdline *cl,
4773 __attribute__((unused)) void *data)
4775 struct cmd_set_bonding_mode_result *res = parsed_result;
4776 portid_t port_id = res->port_id;
4778 /* Set the bonding mode for the relevant port. */
4779 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4780 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4783 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4784 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4786 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4787 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4788 bonding, "bonding");
4789 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4792 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4793 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4795 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4796 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4799 cmdline_parse_inst_t cmd_set_bonding_mode = {
4800 .f = cmd_set_bonding_mode_parsed,
4801 .help_str = "set bonding mode <mode_value> <port_id>: "
4802 "Set the bonding mode for port_id",
4805 (void *) &cmd_setbonding_mode_set,
4806 (void *) &cmd_setbonding_mode_bonding,
4807 (void *) &cmd_setbonding_mode_mode,
4808 (void *) &cmd_setbonding_mode_value,
4809 (void *) &cmd_setbonding_mode_port,
4814 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4815 struct cmd_set_bonding_lacp_dedicated_queues_result {
4816 cmdline_fixed_string_t set;
4817 cmdline_fixed_string_t bonding;
4818 cmdline_fixed_string_t lacp;
4819 cmdline_fixed_string_t dedicated_queues;
4821 cmdline_fixed_string_t mode;
4824 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4825 __attribute__((unused)) struct cmdline *cl,
4826 __attribute__((unused)) void *data)
4828 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4829 portid_t port_id = res->port_id;
4830 struct rte_port *port;
4832 port = &ports[port_id];
4834 /** Check if the port is not started **/
4835 if (port->port_status != RTE_PORT_STOPPED) {
4836 printf("Please stop port %d first\n", port_id);
4840 if (!strcmp(res->mode, "enable")) {
4841 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4842 printf("Dedicate queues for LACP control packets"
4845 printf("Enabling dedicate queues for LACP control "
4846 "packets on port %d failed\n", port_id);
4847 } else if (!strcmp(res->mode, "disable")) {
4848 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4849 printf("Dedicated queues for LACP control packets "
4852 printf("Disabling dedicated queues for LACP control "
4853 "traffic on port %d failed\n", port_id);
4857 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4860 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4861 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4862 bonding, "bonding");
4863 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4864 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4866 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4867 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4868 dedicated_queues, "dedicated_queues");
4869 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4870 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4872 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4873 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4874 mode, "enable#disable");
4876 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4877 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4878 .help_str = "set bonding lacp dedicated_queues <port_id> "
4880 "Enable/disable dedicated queues for LACP control traffic for port_id",
4883 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4884 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4885 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4886 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4887 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4888 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4893 /* *** SET BALANCE XMIT POLICY *** */
4894 struct cmd_set_bonding_balance_xmit_policy_result {
4895 cmdline_fixed_string_t set;
4896 cmdline_fixed_string_t bonding;
4897 cmdline_fixed_string_t balance_xmit_policy;
4899 cmdline_fixed_string_t policy;
4902 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4903 __attribute__((unused)) struct cmdline *cl,
4904 __attribute__((unused)) void *data)
4906 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4907 portid_t port_id = res->port_id;
4910 if (!strcmp(res->policy, "l2")) {
4911 policy = BALANCE_XMIT_POLICY_LAYER2;
4912 } else if (!strcmp(res->policy, "l23")) {
4913 policy = BALANCE_XMIT_POLICY_LAYER23;
4914 } else if (!strcmp(res->policy, "l34")) {
4915 policy = BALANCE_XMIT_POLICY_LAYER34;
4917 printf("\t Invalid xmit policy selection");
4921 /* Set the bonding mode for the relevant port. */
4922 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4923 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4928 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4931 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4933 bonding, "bonding");
4934 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4935 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4936 balance_xmit_policy, "balance_xmit_policy");
4937 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4938 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4940 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4941 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4942 policy, "l2#l23#l34");
4944 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4945 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4946 .help_str = "set bonding balance_xmit_policy <port_id> "
4948 "Set the bonding balance_xmit_policy for port_id",
4951 (void *)&cmd_setbonding_balance_xmit_policy_set,
4952 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4953 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4954 (void *)&cmd_setbonding_balance_xmit_policy_port,
4955 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4960 /* *** SHOW NIC BONDING CONFIGURATION *** */
4961 struct cmd_show_bonding_config_result {
4962 cmdline_fixed_string_t show;
4963 cmdline_fixed_string_t bonding;
4964 cmdline_fixed_string_t config;
4968 static void cmd_show_bonding_config_parsed(void *parsed_result,
4969 __attribute__((unused)) struct cmdline *cl,
4970 __attribute__((unused)) void *data)
4972 struct cmd_show_bonding_config_result *res = parsed_result;
4973 int bonding_mode, agg_mode;
4974 portid_t slaves[RTE_MAX_ETHPORTS];
4975 int num_slaves, num_active_slaves;
4978 portid_t port_id = res->port_id;
4980 /* Display the bonding mode.*/
4981 bonding_mode = rte_eth_bond_mode_get(port_id);
4982 if (bonding_mode < 0) {
4983 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4986 printf("\tBonding mode: %d\n", bonding_mode);
4988 if (bonding_mode == BONDING_MODE_BALANCE) {
4989 int balance_xmit_policy;
4991 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4992 if (balance_xmit_policy < 0) {
4993 printf("\tFailed to get balance xmit policy for port = %d\n",
4997 printf("\tBalance Xmit Policy: ");
4999 switch (balance_xmit_policy) {
5000 case BALANCE_XMIT_POLICY_LAYER2:
5001 printf("BALANCE_XMIT_POLICY_LAYER2");
5003 case BALANCE_XMIT_POLICY_LAYER23:
5004 printf("BALANCE_XMIT_POLICY_LAYER23");
5006 case BALANCE_XMIT_POLICY_LAYER34:
5007 printf("BALANCE_XMIT_POLICY_LAYER34");
5014 if (bonding_mode == BONDING_MODE_8023AD) {
5015 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5016 printf("\tIEEE802.3AD Aggregator Mode: ");
5019 printf("bandwidth");
5031 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5033 if (num_slaves < 0) {
5034 printf("\tFailed to get slave list for port = %d\n", port_id);
5037 if (num_slaves > 0) {
5038 printf("\tSlaves (%d): [", num_slaves);
5039 for (i = 0; i < num_slaves - 1; i++)
5040 printf("%d ", slaves[i]);
5042 printf("%d]\n", slaves[num_slaves - 1]);
5044 printf("\tSlaves: []\n");
5048 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5051 if (num_active_slaves < 0) {
5052 printf("\tFailed to get active slave list for port = %d\n", port_id);
5055 if (num_active_slaves > 0) {
5056 printf("\tActive Slaves (%d): [", num_active_slaves);
5057 for (i = 0; i < num_active_slaves - 1; i++)
5058 printf("%d ", slaves[i]);
5060 printf("%d]\n", slaves[num_active_slaves - 1]);
5063 printf("\tActive Slaves: []\n");
5067 primary_id = rte_eth_bond_primary_get(port_id);
5068 if (primary_id < 0) {
5069 printf("\tFailed to get primary slave for port = %d\n", port_id);
5072 printf("\tPrimary: [%d]\n", primary_id);
5076 cmdline_parse_token_string_t cmd_showbonding_config_show =
5077 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5079 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5080 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5081 bonding, "bonding");
5082 cmdline_parse_token_string_t cmd_showbonding_config_config =
5083 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5085 cmdline_parse_token_num_t cmd_showbonding_config_port =
5086 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5089 cmdline_parse_inst_t cmd_show_bonding_config = {
5090 .f = cmd_show_bonding_config_parsed,
5091 .help_str = "show bonding config <port_id>: "
5092 "Show the bonding config for port_id",
5095 (void *)&cmd_showbonding_config_show,
5096 (void *)&cmd_showbonding_config_bonding,
5097 (void *)&cmd_showbonding_config_config,
5098 (void *)&cmd_showbonding_config_port,
5103 /* *** SET BONDING PRIMARY *** */
5104 struct cmd_set_bonding_primary_result {
5105 cmdline_fixed_string_t set;
5106 cmdline_fixed_string_t bonding;
5107 cmdline_fixed_string_t primary;
5112 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5113 __attribute__((unused)) struct cmdline *cl,
5114 __attribute__((unused)) void *data)
5116 struct cmd_set_bonding_primary_result *res = parsed_result;
5117 portid_t master_port_id = res->port_id;
5118 portid_t slave_port_id = res->slave_id;
5120 /* Set the primary slave for a bonded device. */
5121 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5122 printf("\t Failed to set primary slave for port = %d.\n",
5129 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5130 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5132 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5133 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5134 bonding, "bonding");
5135 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5136 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5137 primary, "primary");
5138 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5139 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5141 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5142 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5145 cmdline_parse_inst_t cmd_set_bonding_primary = {
5146 .f = cmd_set_bonding_primary_parsed,
5147 .help_str = "set bonding primary <slave_id> <port_id>: "
5148 "Set the primary slave for port_id",
5151 (void *)&cmd_setbonding_primary_set,
5152 (void *)&cmd_setbonding_primary_bonding,
5153 (void *)&cmd_setbonding_primary_primary,
5154 (void *)&cmd_setbonding_primary_slave,
5155 (void *)&cmd_setbonding_primary_port,
5160 /* *** ADD SLAVE *** */
5161 struct cmd_add_bonding_slave_result {
5162 cmdline_fixed_string_t add;
5163 cmdline_fixed_string_t bonding;
5164 cmdline_fixed_string_t slave;
5169 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5170 __attribute__((unused)) struct cmdline *cl,
5171 __attribute__((unused)) void *data)
5173 struct cmd_add_bonding_slave_result *res = parsed_result;
5174 portid_t master_port_id = res->port_id;
5175 portid_t slave_port_id = res->slave_id;
5177 /* add the slave for a bonded device. */
5178 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5179 printf("\t Failed to add slave %d to master port = %d.\n",
5180 slave_port_id, master_port_id);
5184 set_port_slave_flag(slave_port_id);
5187 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5188 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5190 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5191 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5192 bonding, "bonding");
5193 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5194 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5196 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5197 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5199 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5200 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5203 cmdline_parse_inst_t cmd_add_bonding_slave = {
5204 .f = cmd_add_bonding_slave_parsed,
5205 .help_str = "add bonding slave <slave_id> <port_id>: "
5206 "Add a slave device to a bonded device",
5209 (void *)&cmd_addbonding_slave_add,
5210 (void *)&cmd_addbonding_slave_bonding,
5211 (void *)&cmd_addbonding_slave_slave,
5212 (void *)&cmd_addbonding_slave_slaveid,
5213 (void *)&cmd_addbonding_slave_port,
5218 /* *** REMOVE SLAVE *** */
5219 struct cmd_remove_bonding_slave_result {
5220 cmdline_fixed_string_t remove;
5221 cmdline_fixed_string_t bonding;
5222 cmdline_fixed_string_t slave;
5227 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5228 __attribute__((unused)) struct cmdline *cl,
5229 __attribute__((unused)) void *data)
5231 struct cmd_remove_bonding_slave_result *res = parsed_result;
5232 portid_t master_port_id = res->port_id;
5233 portid_t slave_port_id = res->slave_id;
5235 /* remove the slave from a bonded device. */
5236 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5237 printf("\t Failed to remove slave %d from master port = %d.\n",
5238 slave_port_id, master_port_id);
5242 clear_port_slave_flag(slave_port_id);
5245 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5246 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5248 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5249 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5250 bonding, "bonding");
5251 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5252 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5254 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5255 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5257 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5258 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5261 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5262 .f = cmd_remove_bonding_slave_parsed,
5263 .help_str = "remove bonding slave <slave_id> <port_id>: "
5264 "Remove a slave device from a bonded device",
5267 (void *)&cmd_removebonding_slave_remove,
5268 (void *)&cmd_removebonding_slave_bonding,
5269 (void *)&cmd_removebonding_slave_slave,
5270 (void *)&cmd_removebonding_slave_slaveid,
5271 (void *)&cmd_removebonding_slave_port,
5276 /* *** CREATE BONDED DEVICE *** */
5277 struct cmd_create_bonded_device_result {
5278 cmdline_fixed_string_t create;
5279 cmdline_fixed_string_t bonded;
5280 cmdline_fixed_string_t device;
5285 static int bond_dev_num = 0;
5287 static void cmd_create_bonded_device_parsed(void *parsed_result,
5288 __attribute__((unused)) struct cmdline *cl,
5289 __attribute__((unused)) void *data)
5291 struct cmd_create_bonded_device_result *res = parsed_result;
5292 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5295 if (test_done == 0) {
5296 printf("Please stop forwarding first\n");
5300 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5303 /* Create a new bonded device. */
5304 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5306 printf("\t Failed to create bonded device.\n");
5309 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5312 /* Update number of ports */
5313 nb_ports = rte_eth_dev_count();
5314 reconfig(port_id, res->socket);
5315 rte_eth_promiscuous_enable(port_id);
5320 cmdline_parse_token_string_t cmd_createbonded_device_create =
5321 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5323 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5324 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5326 cmdline_parse_token_string_t cmd_createbonded_device_device =
5327 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5329 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5330 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5332 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5333 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5336 cmdline_parse_inst_t cmd_create_bonded_device = {
5337 .f = cmd_create_bonded_device_parsed,
5338 .help_str = "create bonded device <mode> <socket>: "
5339 "Create a new bonded device with specific bonding mode and socket",
5342 (void *)&cmd_createbonded_device_create,
5343 (void *)&cmd_createbonded_device_bonded,
5344 (void *)&cmd_createbonded_device_device,
5345 (void *)&cmd_createbonded_device_mode,
5346 (void *)&cmd_createbonded_device_socket,
5351 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5352 struct cmd_set_bond_mac_addr_result {
5353 cmdline_fixed_string_t set;
5354 cmdline_fixed_string_t bonding;
5355 cmdline_fixed_string_t mac_addr;
5357 struct ether_addr address;
5360 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5361 __attribute__((unused)) struct cmdline *cl,
5362 __attribute__((unused)) void *data)
5364 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5367 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5370 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5372 /* check the return value and print it if is < 0 */
5374 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5377 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5379 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5382 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5385 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5386 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5388 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5391 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5392 .f = cmd_set_bond_mac_addr_parsed,
5394 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5396 (void *)&cmd_set_bond_mac_addr_set,
5397 (void *)&cmd_set_bond_mac_addr_bonding,
5398 (void *)&cmd_set_bond_mac_addr_mac,
5399 (void *)&cmd_set_bond_mac_addr_portnum,
5400 (void *)&cmd_set_bond_mac_addr_addr,
5406 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5407 struct cmd_set_bond_mon_period_result {
5408 cmdline_fixed_string_t set;
5409 cmdline_fixed_string_t bonding;
5410 cmdline_fixed_string_t mon_period;
5415 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5416 __attribute__((unused)) struct cmdline *cl,
5417 __attribute__((unused)) void *data)
5419 struct cmd_set_bond_mon_period_result *res = parsed_result;
5422 if (res->port_num >= nb_ports) {
5423 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5427 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5429 /* check the return value and print it if is < 0 */
5431 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5434 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5435 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5437 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5439 bonding, "bonding");
5440 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5441 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5442 mon_period, "mon_period");
5443 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5444 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5446 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5447 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5450 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5451 .f = cmd_set_bond_mon_period_parsed,
5453 .help_str = "set bonding mon_period <port_id> <period_ms>",
5455 (void *)&cmd_set_bond_mon_period_set,
5456 (void *)&cmd_set_bond_mon_period_bonding,
5457 (void *)&cmd_set_bond_mon_period_mon_period,
5458 (void *)&cmd_set_bond_mon_period_portnum,
5459 (void *)&cmd_set_bond_mon_period_period_ms,
5466 struct cmd_set_bonding_agg_mode_policy_result {
5467 cmdline_fixed_string_t set;
5468 cmdline_fixed_string_t bonding;
5469 cmdline_fixed_string_t agg_mode;
5471 cmdline_fixed_string_t policy;
5476 cmd_set_bonding_agg_mode(void *parsed_result,
5477 __attribute__((unused)) struct cmdline *cl,
5478 __attribute__((unused)) void *data)
5480 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5481 uint8_t policy = AGG_BANDWIDTH;
5483 if (res->port_num >= nb_ports) {
5484 printf("Port id %d must be less than %d\n",
5485 res->port_num, nb_ports);
5489 if (!strcmp(res->policy, "bandwidth"))
5490 policy = AGG_BANDWIDTH;
5491 else if (!strcmp(res->policy, "stable"))
5492 policy = AGG_STABLE;
5493 else if (!strcmp(res->policy, "count"))
5496 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5500 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5501 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5503 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5504 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5505 bonding, "bonding");
5507 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5509 agg_mode, "agg_mode");
5511 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5512 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5515 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5516 TOKEN_STRING_INITIALIZER(
5517 struct cmd_set_bonding_balance_xmit_policy_result,
5518 policy, "stable#bandwidth#count");
5520 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5521 .f = cmd_set_bonding_agg_mode,
5523 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5525 (void *)&cmd_set_bonding_agg_mode_set,
5526 (void *)&cmd_set_bonding_agg_mode_bonding,
5527 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5528 (void *)&cmd_set_bonding_agg_mode_portnum,
5529 (void *)&cmd_set_bonding_agg_mode_policy_string,
5535 #endif /* RTE_LIBRTE_PMD_BOND */
5537 /* *** SET FORWARDING MODE *** */
5538 struct cmd_set_fwd_mode_result {
5539 cmdline_fixed_string_t set;
5540 cmdline_fixed_string_t fwd;
5541 cmdline_fixed_string_t mode;
5544 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5545 __attribute__((unused)) struct cmdline *cl,
5546 __attribute__((unused)) void *data)
5548 struct cmd_set_fwd_mode_result *res = parsed_result;
5551 set_pkt_forwarding_mode(res->mode);
5554 cmdline_parse_token_string_t cmd_setfwd_set =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5556 cmdline_parse_token_string_t cmd_setfwd_fwd =
5557 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5558 cmdline_parse_token_string_t cmd_setfwd_mode =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5560 "" /* defined at init */);
5562 cmdline_parse_inst_t cmd_set_fwd_mode = {
5563 .f = cmd_set_fwd_mode_parsed,
5565 .help_str = NULL, /* defined at init */
5567 (void *)&cmd_setfwd_set,
5568 (void *)&cmd_setfwd_fwd,
5569 (void *)&cmd_setfwd_mode,
5574 static void cmd_set_fwd_mode_init(void)
5577 static char token[128];
5578 static char help[256];
5579 cmdline_parse_token_string_t *token_struct;
5581 modes = list_pkt_forwarding_modes();
5582 snprintf(help, sizeof(help), "set fwd %s: "
5583 "Set packet forwarding mode", modes);
5584 cmd_set_fwd_mode.help_str = help;
5586 /* string token separator is # */
5587 for (c = token; *modes != '\0'; modes++)
5592 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5593 token_struct->string_data.str = token;
5596 /* *** SET RETRY FORWARDING MODE *** */
5597 struct cmd_set_fwd_retry_mode_result {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t fwd;
5600 cmdline_fixed_string_t mode;
5601 cmdline_fixed_string_t retry;
5604 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5605 __attribute__((unused)) struct cmdline *cl,
5606 __attribute__((unused)) void *data)
5608 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5611 set_pkt_forwarding_mode(res->mode);
5614 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5617 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5620 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5621 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5623 "" /* defined at init */);
5624 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5628 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5629 .f = cmd_set_fwd_retry_mode_parsed,
5631 .help_str = NULL, /* defined at init */
5633 (void *)&cmd_setfwd_retry_set,
5634 (void *)&cmd_setfwd_retry_fwd,
5635 (void *)&cmd_setfwd_retry_mode,
5636 (void *)&cmd_setfwd_retry_retry,
5641 static void cmd_set_fwd_retry_mode_init(void)
5644 static char token[128];
5645 static char help[256];
5646 cmdline_parse_token_string_t *token_struct;
5648 modes = list_pkt_forwarding_retry_modes();
5649 snprintf(help, sizeof(help), "set fwd %s retry: "
5650 "Set packet forwarding mode with retry", modes);
5651 cmd_set_fwd_retry_mode.help_str = help;
5653 /* string token separator is # */
5654 for (c = token; *modes != '\0'; modes++)
5659 token_struct = (cmdline_parse_token_string_t *)
5660 cmd_set_fwd_retry_mode.tokens[2];
5661 token_struct->string_data.str = token;
5664 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5665 struct cmd_set_burst_tx_retry_result {
5666 cmdline_fixed_string_t set;
5667 cmdline_fixed_string_t burst;
5668 cmdline_fixed_string_t tx;
5669 cmdline_fixed_string_t delay;
5671 cmdline_fixed_string_t retry;
5675 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5676 __attribute__((unused)) struct cmdline *cl,
5677 __attribute__((unused)) void *data)
5679 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5681 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5682 && !strcmp(res->tx, "tx")) {
5683 if (!strcmp(res->delay, "delay"))
5684 burst_tx_delay_time = res->time;
5685 if (!strcmp(res->retry, "retry"))
5686 burst_tx_retry_num = res->retry_num;
5691 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5693 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5696 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5698 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5700 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5701 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5702 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5704 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5705 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5707 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5708 .f = cmd_set_burst_tx_retry_parsed,
5709 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5711 (void *)&cmd_set_burst_tx_retry_set,
5712 (void *)&cmd_set_burst_tx_retry_burst,
5713 (void *)&cmd_set_burst_tx_retry_tx,
5714 (void *)&cmd_set_burst_tx_retry_delay,
5715 (void *)&cmd_set_burst_tx_retry_time,
5716 (void *)&cmd_set_burst_tx_retry_retry,
5717 (void *)&cmd_set_burst_tx_retry_retry_num,
5722 /* *** SET PROMISC MODE *** */
5723 struct cmd_set_promisc_mode_result {
5724 cmdline_fixed_string_t set;
5725 cmdline_fixed_string_t promisc;
5726 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5727 uint16_t port_num; /* valid if "allports" argument == 0 */
5728 cmdline_fixed_string_t mode;
5731 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5732 __attribute__((unused)) struct cmdline *cl,
5735 struct cmd_set_promisc_mode_result *res = parsed_result;
5739 if (!strcmp(res->mode, "on"))
5746 RTE_ETH_FOREACH_DEV(i) {
5748 rte_eth_promiscuous_enable(i);
5750 rte_eth_promiscuous_disable(i);
5755 rte_eth_promiscuous_enable(res->port_num);
5757 rte_eth_promiscuous_disable(res->port_num);
5761 cmdline_parse_token_string_t cmd_setpromisc_set =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5763 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5766 cmdline_parse_token_string_t cmd_setpromisc_portall =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5769 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5772 cmdline_parse_token_string_t cmd_setpromisc_mode =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5776 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5777 .f = cmd_set_promisc_mode_parsed,
5779 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5781 (void *)&cmd_setpromisc_set,
5782 (void *)&cmd_setpromisc_promisc,
5783 (void *)&cmd_setpromisc_portall,
5784 (void *)&cmd_setpromisc_mode,
5789 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5790 .f = cmd_set_promisc_mode_parsed,
5792 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5794 (void *)&cmd_setpromisc_set,
5795 (void *)&cmd_setpromisc_promisc,
5796 (void *)&cmd_setpromisc_portnum,
5797 (void *)&cmd_setpromisc_mode,
5802 /* *** SET ALLMULTI MODE *** */
5803 struct cmd_set_allmulti_mode_result {
5804 cmdline_fixed_string_t set;
5805 cmdline_fixed_string_t allmulti;
5806 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5807 uint16_t port_num; /* valid if "allports" argument == 0 */
5808 cmdline_fixed_string_t mode;
5811 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5812 __attribute__((unused)) struct cmdline *cl,
5815 struct cmd_set_allmulti_mode_result *res = parsed_result;
5819 if (!strcmp(res->mode, "on"))
5826 RTE_ETH_FOREACH_DEV(i) {
5828 rte_eth_allmulticast_enable(i);
5830 rte_eth_allmulticast_disable(i);
5835 rte_eth_allmulticast_enable(res->port_num);
5837 rte_eth_allmulticast_disable(res->port_num);
5841 cmdline_parse_token_string_t cmd_setallmulti_set =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5843 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5846 cmdline_parse_token_string_t cmd_setallmulti_portall =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5849 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5850 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5852 cmdline_parse_token_string_t cmd_setallmulti_mode =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5856 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5857 .f = cmd_set_allmulti_mode_parsed,
5859 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5861 (void *)&cmd_setallmulti_set,
5862 (void *)&cmd_setallmulti_allmulti,
5863 (void *)&cmd_setallmulti_portall,
5864 (void *)&cmd_setallmulti_mode,
5869 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5870 .f = cmd_set_allmulti_mode_parsed,
5872 .help_str = "set allmulti <port_id> on|off: "
5873 "Set allmulti mode on port_id",
5875 (void *)&cmd_setallmulti_set,
5876 (void *)&cmd_setallmulti_allmulti,
5877 (void *)&cmd_setallmulti_portnum,
5878 (void *)&cmd_setallmulti_mode,
5883 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5884 struct cmd_link_flow_ctrl_set_result {
5885 cmdline_fixed_string_t set;
5886 cmdline_fixed_string_t flow_ctrl;
5887 cmdline_fixed_string_t rx;
5888 cmdline_fixed_string_t rx_lfc_mode;
5889 cmdline_fixed_string_t tx;
5890 cmdline_fixed_string_t tx_lfc_mode;
5891 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5892 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5893 cmdline_fixed_string_t autoneg_str;
5894 cmdline_fixed_string_t autoneg;
5895 cmdline_fixed_string_t hw_str;
5896 uint32_t high_water;
5897 cmdline_fixed_string_t lw_str;
5899 cmdline_fixed_string_t pt_str;
5900 uint16_t pause_time;
5901 cmdline_fixed_string_t xon_str;
5906 cmdline_parse_token_string_t cmd_lfc_set_set =
5907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5909 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5911 flow_ctrl, "flow_ctrl");
5912 cmdline_parse_token_string_t cmd_lfc_set_rx =
5913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5915 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5917 rx_lfc_mode, "on#off");
5918 cmdline_parse_token_string_t cmd_lfc_set_tx =
5919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5921 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5923 tx_lfc_mode, "on#off");
5924 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5925 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5926 hw_str, "high_water");
5927 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5928 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5929 high_water, UINT32);
5930 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5932 lw_str, "low_water");
5933 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5934 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5936 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5938 pt_str, "pause_time");
5939 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5940 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5941 pause_time, UINT16);
5942 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5944 xon_str, "send_xon");
5945 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5946 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5948 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5950 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5951 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5953 mac_ctrl_frame_fwd_mode, "on#off");
5954 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5956 autoneg_str, "autoneg");
5957 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5960 cmdline_parse_token_num_t cmd_lfc_set_portid =
5961 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5964 /* forward declaration */
5966 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5969 cmdline_parse_inst_t cmd_link_flow_control_set = {
5970 .f = cmd_link_flow_ctrl_set_parsed,
5972 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5973 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5974 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5976 (void *)&cmd_lfc_set_set,
5977 (void *)&cmd_lfc_set_flow_ctrl,
5978 (void *)&cmd_lfc_set_rx,
5979 (void *)&cmd_lfc_set_rx_mode,
5980 (void *)&cmd_lfc_set_tx,
5981 (void *)&cmd_lfc_set_tx_mode,
5982 (void *)&cmd_lfc_set_high_water,
5983 (void *)&cmd_lfc_set_low_water,
5984 (void *)&cmd_lfc_set_pause_time,
5985 (void *)&cmd_lfc_set_send_xon,
5986 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5987 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5988 (void *)&cmd_lfc_set_autoneg_str,
5989 (void *)&cmd_lfc_set_autoneg,
5990 (void *)&cmd_lfc_set_portid,
5995 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5996 .f = cmd_link_flow_ctrl_set_parsed,
5997 .data = (void *)&cmd_link_flow_control_set_rx,
5998 .help_str = "set flow_ctrl rx on|off <port_id>: "
5999 "Change rx flow control parameter",
6001 (void *)&cmd_lfc_set_set,
6002 (void *)&cmd_lfc_set_flow_ctrl,
6003 (void *)&cmd_lfc_set_rx,
6004 (void *)&cmd_lfc_set_rx_mode,
6005 (void *)&cmd_lfc_set_portid,
6010 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6011 .f = cmd_link_flow_ctrl_set_parsed,
6012 .data = (void *)&cmd_link_flow_control_set_tx,
6013 .help_str = "set flow_ctrl tx on|off <port_id>: "
6014 "Change tx flow control parameter",
6016 (void *)&cmd_lfc_set_set,
6017 (void *)&cmd_lfc_set_flow_ctrl,
6018 (void *)&cmd_lfc_set_tx,
6019 (void *)&cmd_lfc_set_tx_mode,
6020 (void *)&cmd_lfc_set_portid,
6025 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6026 .f = cmd_link_flow_ctrl_set_parsed,
6027 .data = (void *)&cmd_link_flow_control_set_hw,
6028 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6029 "Change high water flow control parameter",
6031 (void *)&cmd_lfc_set_set,
6032 (void *)&cmd_lfc_set_flow_ctrl,
6033 (void *)&cmd_lfc_set_high_water_str,
6034 (void *)&cmd_lfc_set_high_water,
6035 (void *)&cmd_lfc_set_portid,
6040 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6041 .f = cmd_link_flow_ctrl_set_parsed,
6042 .data = (void *)&cmd_link_flow_control_set_lw,
6043 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6044 "Change low water flow control parameter",
6046 (void *)&cmd_lfc_set_set,
6047 (void *)&cmd_lfc_set_flow_ctrl,
6048 (void *)&cmd_lfc_set_low_water_str,
6049 (void *)&cmd_lfc_set_low_water,
6050 (void *)&cmd_lfc_set_portid,
6055 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6056 .f = cmd_link_flow_ctrl_set_parsed,
6057 .data = (void *)&cmd_link_flow_control_set_pt,
6058 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6059 "Change pause time flow control parameter",
6061 (void *)&cmd_lfc_set_set,
6062 (void *)&cmd_lfc_set_flow_ctrl,
6063 (void *)&cmd_lfc_set_pause_time_str,
6064 (void *)&cmd_lfc_set_pause_time,
6065 (void *)&cmd_lfc_set_portid,
6070 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6071 .f = cmd_link_flow_ctrl_set_parsed,
6072 .data = (void *)&cmd_link_flow_control_set_xon,
6073 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6074 "Change send_xon flow control parameter",
6076 (void *)&cmd_lfc_set_set,
6077 (void *)&cmd_lfc_set_flow_ctrl,
6078 (void *)&cmd_lfc_set_send_xon_str,
6079 (void *)&cmd_lfc_set_send_xon,
6080 (void *)&cmd_lfc_set_portid,
6085 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6086 .f = cmd_link_flow_ctrl_set_parsed,
6087 .data = (void *)&cmd_link_flow_control_set_macfwd,
6088 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6089 "Change mac ctrl fwd flow control parameter",
6091 (void *)&cmd_lfc_set_set,
6092 (void *)&cmd_lfc_set_flow_ctrl,
6093 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6094 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6095 (void *)&cmd_lfc_set_portid,
6100 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6101 .f = cmd_link_flow_ctrl_set_parsed,
6102 .data = (void *)&cmd_link_flow_control_set_autoneg,
6103 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6104 "Change autoneg flow control parameter",
6106 (void *)&cmd_lfc_set_set,
6107 (void *)&cmd_lfc_set_flow_ctrl,
6108 (void *)&cmd_lfc_set_autoneg_str,
6109 (void *)&cmd_lfc_set_autoneg,
6110 (void *)&cmd_lfc_set_portid,
6116 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6117 __attribute__((unused)) struct cmdline *cl,
6120 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6121 cmdline_parse_inst_t *cmd = data;
6122 struct rte_eth_fc_conf fc_conf;
6128 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6129 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6130 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6131 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6133 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6134 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6137 /* Partial command line, retrieve current configuration */
6139 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6141 printf("cannot get current flow ctrl parameters, return"
6142 "code = %d\n", ret);
6146 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6147 (fc_conf.mode == RTE_FC_FULL))
6149 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6150 (fc_conf.mode == RTE_FC_FULL))
6154 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6155 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6157 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6158 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6160 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6162 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6163 fc_conf.high_water = res->high_water;
6165 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6166 fc_conf.low_water = res->low_water;
6168 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6169 fc_conf.pause_time = res->pause_time;
6171 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6172 fc_conf.send_xon = res->send_xon;
6174 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6175 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6176 fc_conf.mac_ctrl_frame_fwd = 1;
6178 fc_conf.mac_ctrl_frame_fwd = 0;
6181 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6182 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6184 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6186 printf("bad flow contrl parameter, return code = %d \n", ret);
6189 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6190 struct cmd_priority_flow_ctrl_set_result {
6191 cmdline_fixed_string_t set;
6192 cmdline_fixed_string_t pfc_ctrl;
6193 cmdline_fixed_string_t rx;
6194 cmdline_fixed_string_t rx_pfc_mode;
6195 cmdline_fixed_string_t tx;
6196 cmdline_fixed_string_t tx_pfc_mode;
6197 uint32_t high_water;
6199 uint16_t pause_time;
6205 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6206 __attribute__((unused)) struct cmdline *cl,
6207 __attribute__((unused)) void *data)
6209 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6210 struct rte_eth_pfc_conf pfc_conf;
6211 int rx_fc_enable, tx_fc_enable;
6215 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6216 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6217 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6218 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6220 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6221 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6224 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6225 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6226 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6227 pfc_conf.fc.high_water = res->high_water;
6228 pfc_conf.fc.low_water = res->low_water;
6229 pfc_conf.fc.pause_time = res->pause_time;
6230 pfc_conf.priority = res->priority;
6232 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6234 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6237 cmdline_parse_token_string_t cmd_pfc_set_set =
6238 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6240 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6241 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6242 pfc_ctrl, "pfc_ctrl");
6243 cmdline_parse_token_string_t cmd_pfc_set_rx =
6244 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6246 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6247 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6248 rx_pfc_mode, "on#off");
6249 cmdline_parse_token_string_t cmd_pfc_set_tx =
6250 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6252 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6253 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6254 tx_pfc_mode, "on#off");
6255 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6256 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6257 high_water, UINT32);
6258 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6259 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6261 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6262 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6263 pause_time, UINT16);
6264 cmdline_parse_token_num_t cmd_pfc_set_priority =
6265 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6267 cmdline_parse_token_num_t cmd_pfc_set_portid =
6268 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6271 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6272 .f = cmd_priority_flow_ctrl_set_parsed,
6274 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6275 "<pause_time> <priority> <port_id>: "
6276 "Configure the Ethernet priority flow control",
6278 (void *)&cmd_pfc_set_set,
6279 (void *)&cmd_pfc_set_flow_ctrl,
6280 (void *)&cmd_pfc_set_rx,
6281 (void *)&cmd_pfc_set_rx_mode,
6282 (void *)&cmd_pfc_set_tx,
6283 (void *)&cmd_pfc_set_tx_mode,
6284 (void *)&cmd_pfc_set_high_water,
6285 (void *)&cmd_pfc_set_low_water,
6286 (void *)&cmd_pfc_set_pause_time,
6287 (void *)&cmd_pfc_set_priority,
6288 (void *)&cmd_pfc_set_portid,
6293 /* *** RESET CONFIGURATION *** */
6294 struct cmd_reset_result {
6295 cmdline_fixed_string_t reset;
6296 cmdline_fixed_string_t def;
6299 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6301 __attribute__((unused)) void *data)
6303 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6304 set_def_fwd_config();
6307 cmdline_parse_token_string_t cmd_reset_set =
6308 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6309 cmdline_parse_token_string_t cmd_reset_def =
6310 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6313 cmdline_parse_inst_t cmd_reset = {
6314 .f = cmd_reset_parsed,
6316 .help_str = "set default: Reset default forwarding configuration",
6318 (void *)&cmd_reset_set,
6319 (void *)&cmd_reset_def,
6324 /* *** START FORWARDING *** */
6325 struct cmd_start_result {
6326 cmdline_fixed_string_t start;
6329 cmdline_parse_token_string_t cmd_start_start =
6330 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6332 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6333 __attribute__((unused)) struct cmdline *cl,
6334 __attribute__((unused)) void *data)
6336 start_packet_forwarding(0);
6339 cmdline_parse_inst_t cmd_start = {
6340 .f = cmd_start_parsed,
6342 .help_str = "start: Start packet forwarding",
6344 (void *)&cmd_start_start,
6349 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6350 struct cmd_start_tx_first_result {
6351 cmdline_fixed_string_t start;
6352 cmdline_fixed_string_t tx_first;
6356 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6357 __attribute__((unused)) struct cmdline *cl,
6358 __attribute__((unused)) void *data)
6360 start_packet_forwarding(1);
6363 cmdline_parse_token_string_t cmd_start_tx_first_start =
6364 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6366 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6367 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6368 tx_first, "tx_first");
6370 cmdline_parse_inst_t cmd_start_tx_first = {
6371 .f = cmd_start_tx_first_parsed,
6373 .help_str = "start tx_first: Start packet forwarding, "
6374 "after sending 1 burst of packets",
6376 (void *)&cmd_start_tx_first_start,
6377 (void *)&cmd_start_tx_first_tx_first,
6382 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6383 struct cmd_start_tx_first_n_result {
6384 cmdline_fixed_string_t start;
6385 cmdline_fixed_string_t tx_first;
6390 cmd_start_tx_first_n_parsed(void *parsed_result,
6391 __attribute__((unused)) struct cmdline *cl,
6392 __attribute__((unused)) void *data)
6394 struct cmd_start_tx_first_n_result *res = parsed_result;
6396 start_packet_forwarding(res->tx_num);
6399 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6400 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6402 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6403 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6404 tx_first, "tx_first");
6405 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6406 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6409 cmdline_parse_inst_t cmd_start_tx_first_n = {
6410 .f = cmd_start_tx_first_n_parsed,
6412 .help_str = "start tx_first <num>: "
6413 "packet forwarding, after sending <num> bursts of packets",
6415 (void *)&cmd_start_tx_first_n_start,
6416 (void *)&cmd_start_tx_first_n_tx_first,
6417 (void *)&cmd_start_tx_first_n_tx_num,
6422 /* *** SET LINK UP *** */
6423 struct cmd_set_link_up_result {
6424 cmdline_fixed_string_t set;
6425 cmdline_fixed_string_t link_up;
6426 cmdline_fixed_string_t port;
6430 cmdline_parse_token_string_t cmd_set_link_up_set =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6432 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6435 cmdline_parse_token_string_t cmd_set_link_up_port =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6437 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6438 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6440 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6441 __attribute__((unused)) struct cmdline *cl,
6442 __attribute__((unused)) void *data)
6444 struct cmd_set_link_up_result *res = parsed_result;
6445 dev_set_link_up(res->port_id);
6448 cmdline_parse_inst_t cmd_set_link_up = {
6449 .f = cmd_set_link_up_parsed,
6451 .help_str = "set link-up port <port id>",
6453 (void *)&cmd_set_link_up_set,
6454 (void *)&cmd_set_link_up_link_up,
6455 (void *)&cmd_set_link_up_port,
6456 (void *)&cmd_set_link_up_port_id,
6461 /* *** SET LINK DOWN *** */
6462 struct cmd_set_link_down_result {
6463 cmdline_fixed_string_t set;
6464 cmdline_fixed_string_t link_down;
6465 cmdline_fixed_string_t port;
6469 cmdline_parse_token_string_t cmd_set_link_down_set =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6471 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6474 cmdline_parse_token_string_t cmd_set_link_down_port =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6476 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6477 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6479 static void cmd_set_link_down_parsed(
6480 __attribute__((unused)) void *parsed_result,
6481 __attribute__((unused)) struct cmdline *cl,
6482 __attribute__((unused)) void *data)
6484 struct cmd_set_link_down_result *res = parsed_result;
6485 dev_set_link_down(res->port_id);
6488 cmdline_parse_inst_t cmd_set_link_down = {
6489 .f = cmd_set_link_down_parsed,
6491 .help_str = "set link-down port <port id>",
6493 (void *)&cmd_set_link_down_set,
6494 (void *)&cmd_set_link_down_link_down,
6495 (void *)&cmd_set_link_down_port,
6496 (void *)&cmd_set_link_down_port_id,
6501 /* *** SHOW CFG *** */
6502 struct cmd_showcfg_result {
6503 cmdline_fixed_string_t show;
6504 cmdline_fixed_string_t cfg;
6505 cmdline_fixed_string_t what;
6508 static void cmd_showcfg_parsed(void *parsed_result,
6509 __attribute__((unused)) struct cmdline *cl,
6510 __attribute__((unused)) void *data)
6512 struct cmd_showcfg_result *res = parsed_result;
6513 if (!strcmp(res->what, "rxtx"))
6514 rxtx_config_display();
6515 else if (!strcmp(res->what, "cores"))
6516 fwd_lcores_config_display();
6517 else if (!strcmp(res->what, "fwd"))
6518 pkt_fwd_config_display(&cur_fwd_config);
6519 else if (!strcmp(res->what, "txpkts"))
6520 show_tx_pkt_segments();
6523 cmdline_parse_token_string_t cmd_showcfg_show =
6524 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6525 cmdline_parse_token_string_t cmd_showcfg_port =
6526 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6527 cmdline_parse_token_string_t cmd_showcfg_what =
6528 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6529 "rxtx#cores#fwd#txpkts");
6531 cmdline_parse_inst_t cmd_showcfg = {
6532 .f = cmd_showcfg_parsed,
6534 .help_str = "show config rxtx|cores|fwd|txpkts",
6536 (void *)&cmd_showcfg_show,
6537 (void *)&cmd_showcfg_port,
6538 (void *)&cmd_showcfg_what,
6543 /* *** SHOW ALL PORT INFO *** */
6544 struct cmd_showportall_result {
6545 cmdline_fixed_string_t show;
6546 cmdline_fixed_string_t port;
6547 cmdline_fixed_string_t what;
6548 cmdline_fixed_string_t all;
6551 static void cmd_showportall_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6557 struct cmd_showportall_result *res = parsed_result;
6558 if (!strcmp(res->show, "clear")) {
6559 if (!strcmp(res->what, "stats"))
6560 RTE_ETH_FOREACH_DEV(i)
6562 else if (!strcmp(res->what, "xstats"))
6563 RTE_ETH_FOREACH_DEV(i)
6564 nic_xstats_clear(i);
6565 } else if (!strcmp(res->what, "info"))
6566 RTE_ETH_FOREACH_DEV(i)
6567 port_infos_display(i);
6568 else if (!strcmp(res->what, "stats"))
6569 RTE_ETH_FOREACH_DEV(i)
6570 nic_stats_display(i);
6571 else if (!strcmp(res->what, "xstats"))
6572 RTE_ETH_FOREACH_DEV(i)
6573 nic_xstats_display(i);
6574 else if (!strcmp(res->what, "fdir"))
6575 RTE_ETH_FOREACH_DEV(i)
6577 else if (!strcmp(res->what, "stat_qmap"))
6578 RTE_ETH_FOREACH_DEV(i)
6579 nic_stats_mapping_display(i);
6580 else if (!strcmp(res->what, "dcb_tc"))
6581 RTE_ETH_FOREACH_DEV(i)
6582 port_dcb_info_display(i);
6583 else if (!strcmp(res->what, "cap"))
6584 RTE_ETH_FOREACH_DEV(i)
6585 port_offload_cap_display(i);
6588 cmdline_parse_token_string_t cmd_showportall_show =
6589 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6591 cmdline_parse_token_string_t cmd_showportall_port =
6592 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6593 cmdline_parse_token_string_t cmd_showportall_what =
6594 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6595 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6596 cmdline_parse_token_string_t cmd_showportall_all =
6597 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6598 cmdline_parse_inst_t cmd_showportall = {
6599 .f = cmd_showportall_parsed,
6601 .help_str = "show|clear port "
6602 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6604 (void *)&cmd_showportall_show,
6605 (void *)&cmd_showportall_port,
6606 (void *)&cmd_showportall_what,
6607 (void *)&cmd_showportall_all,
6612 /* *** SHOW PORT INFO *** */
6613 struct cmd_showport_result {
6614 cmdline_fixed_string_t show;
6615 cmdline_fixed_string_t port;
6616 cmdline_fixed_string_t what;
6620 static void cmd_showport_parsed(void *parsed_result,
6621 __attribute__((unused)) struct cmdline *cl,
6622 __attribute__((unused)) void *data)
6624 struct cmd_showport_result *res = parsed_result;
6625 if (!strcmp(res->show, "clear")) {
6626 if (!strcmp(res->what, "stats"))
6627 nic_stats_clear(res->portnum);
6628 else if (!strcmp(res->what, "xstats"))
6629 nic_xstats_clear(res->portnum);
6630 } else if (!strcmp(res->what, "info"))
6631 port_infos_display(res->portnum);
6632 else if (!strcmp(res->what, "stats"))
6633 nic_stats_display(res->portnum);
6634 else if (!strcmp(res->what, "xstats"))
6635 nic_xstats_display(res->portnum);
6636 else if (!strcmp(res->what, "fdir"))
6637 fdir_get_infos(res->portnum);
6638 else if (!strcmp(res->what, "stat_qmap"))
6639 nic_stats_mapping_display(res->portnum);
6640 else if (!strcmp(res->what, "dcb_tc"))
6641 port_dcb_info_display(res->portnum);
6642 else if (!strcmp(res->what, "cap"))
6643 port_offload_cap_display(res->portnum);
6646 cmdline_parse_token_string_t cmd_showport_show =
6647 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6649 cmdline_parse_token_string_t cmd_showport_port =
6650 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6651 cmdline_parse_token_string_t cmd_showport_what =
6652 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6653 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6654 cmdline_parse_token_num_t cmd_showport_portnum =
6655 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6657 cmdline_parse_inst_t cmd_showport = {
6658 .f = cmd_showport_parsed,
6660 .help_str = "show|clear port "
6661 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6664 (void *)&cmd_showport_show,
6665 (void *)&cmd_showport_port,
6666 (void *)&cmd_showport_what,
6667 (void *)&cmd_showport_portnum,
6672 /* *** SHOW QUEUE INFO *** */
6673 struct cmd_showqueue_result {
6674 cmdline_fixed_string_t show;
6675 cmdline_fixed_string_t type;
6676 cmdline_fixed_string_t what;
6682 cmd_showqueue_parsed(void *parsed_result,
6683 __attribute__((unused)) struct cmdline *cl,
6684 __attribute__((unused)) void *data)
6686 struct cmd_showqueue_result *res = parsed_result;
6688 if (!strcmp(res->type, "rxq"))
6689 rx_queue_infos_display(res->portnum, res->queuenum);
6690 else if (!strcmp(res->type, "txq"))
6691 tx_queue_infos_display(res->portnum, res->queuenum);
6694 cmdline_parse_token_string_t cmd_showqueue_show =
6695 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6696 cmdline_parse_token_string_t cmd_showqueue_type =
6697 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6698 cmdline_parse_token_string_t cmd_showqueue_what =
6699 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6700 cmdline_parse_token_num_t cmd_showqueue_portnum =
6701 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6702 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6703 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6705 cmdline_parse_inst_t cmd_showqueue = {
6706 .f = cmd_showqueue_parsed,
6708 .help_str = "show rxq|txq info <port_id> <queue_id>",
6710 (void *)&cmd_showqueue_show,
6711 (void *)&cmd_showqueue_type,
6712 (void *)&cmd_showqueue_what,
6713 (void *)&cmd_showqueue_portnum,
6714 (void *)&cmd_showqueue_queuenum,
6719 /* *** READ PORT REGISTER *** */
6720 struct cmd_read_reg_result {
6721 cmdline_fixed_string_t read;
6722 cmdline_fixed_string_t reg;
6728 cmd_read_reg_parsed(void *parsed_result,
6729 __attribute__((unused)) struct cmdline *cl,
6730 __attribute__((unused)) void *data)
6732 struct cmd_read_reg_result *res = parsed_result;
6733 port_reg_display(res->port_id, res->reg_off);
6736 cmdline_parse_token_string_t cmd_read_reg_read =
6737 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6738 cmdline_parse_token_string_t cmd_read_reg_reg =
6739 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6740 cmdline_parse_token_num_t cmd_read_reg_port_id =
6741 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6742 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6743 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6745 cmdline_parse_inst_t cmd_read_reg = {
6746 .f = cmd_read_reg_parsed,
6748 .help_str = "read reg <port_id> <reg_off>",
6750 (void *)&cmd_read_reg_read,
6751 (void *)&cmd_read_reg_reg,
6752 (void *)&cmd_read_reg_port_id,
6753 (void *)&cmd_read_reg_reg_off,
6758 /* *** READ PORT REGISTER BIT FIELD *** */
6759 struct cmd_read_reg_bit_field_result {
6760 cmdline_fixed_string_t read;
6761 cmdline_fixed_string_t regfield;
6769 cmd_read_reg_bit_field_parsed(void *parsed_result,
6770 __attribute__((unused)) struct cmdline *cl,
6771 __attribute__((unused)) void *data)
6773 struct cmd_read_reg_bit_field_result *res = parsed_result;
6774 port_reg_bit_field_display(res->port_id, res->reg_off,
6775 res->bit1_pos, res->bit2_pos);
6778 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6779 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6781 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6782 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6783 regfield, "regfield");
6784 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6785 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6787 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6788 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6790 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6791 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6793 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6794 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6797 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6798 .f = cmd_read_reg_bit_field_parsed,
6800 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6801 "Read register bit field between bit_x and bit_y included",
6803 (void *)&cmd_read_reg_bit_field_read,
6804 (void *)&cmd_read_reg_bit_field_regfield,
6805 (void *)&cmd_read_reg_bit_field_port_id,
6806 (void *)&cmd_read_reg_bit_field_reg_off,
6807 (void *)&cmd_read_reg_bit_field_bit1_pos,
6808 (void *)&cmd_read_reg_bit_field_bit2_pos,
6813 /* *** READ PORT REGISTER BIT *** */
6814 struct cmd_read_reg_bit_result {
6815 cmdline_fixed_string_t read;
6816 cmdline_fixed_string_t regbit;
6823 cmd_read_reg_bit_parsed(void *parsed_result,
6824 __attribute__((unused)) struct cmdline *cl,
6825 __attribute__((unused)) void *data)
6827 struct cmd_read_reg_bit_result *res = parsed_result;
6828 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6831 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6832 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6833 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6834 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6836 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6837 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6838 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6839 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6840 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6841 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6843 cmdline_parse_inst_t cmd_read_reg_bit = {
6844 .f = cmd_read_reg_bit_parsed,
6846 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6848 (void *)&cmd_read_reg_bit_read,
6849 (void *)&cmd_read_reg_bit_regbit,
6850 (void *)&cmd_read_reg_bit_port_id,
6851 (void *)&cmd_read_reg_bit_reg_off,
6852 (void *)&cmd_read_reg_bit_bit_pos,
6857 /* *** WRITE PORT REGISTER *** */
6858 struct cmd_write_reg_result {
6859 cmdline_fixed_string_t write;
6860 cmdline_fixed_string_t reg;
6867 cmd_write_reg_parsed(void *parsed_result,
6868 __attribute__((unused)) struct cmdline *cl,
6869 __attribute__((unused)) void *data)
6871 struct cmd_write_reg_result *res = parsed_result;
6872 port_reg_set(res->port_id, res->reg_off, res->value);
6875 cmdline_parse_token_string_t cmd_write_reg_write =
6876 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6877 cmdline_parse_token_string_t cmd_write_reg_reg =
6878 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6879 cmdline_parse_token_num_t cmd_write_reg_port_id =
6880 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6881 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6882 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6883 cmdline_parse_token_num_t cmd_write_reg_value =
6884 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6886 cmdline_parse_inst_t cmd_write_reg = {
6887 .f = cmd_write_reg_parsed,
6889 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6891 (void *)&cmd_write_reg_write,
6892 (void *)&cmd_write_reg_reg,
6893 (void *)&cmd_write_reg_port_id,
6894 (void *)&cmd_write_reg_reg_off,
6895 (void *)&cmd_write_reg_value,
6900 /* *** WRITE PORT REGISTER BIT FIELD *** */
6901 struct cmd_write_reg_bit_field_result {
6902 cmdline_fixed_string_t write;
6903 cmdline_fixed_string_t regfield;
6912 cmd_write_reg_bit_field_parsed(void *parsed_result,
6913 __attribute__((unused)) struct cmdline *cl,
6914 __attribute__((unused)) void *data)
6916 struct cmd_write_reg_bit_field_result *res = parsed_result;
6917 port_reg_bit_field_set(res->port_id, res->reg_off,
6918 res->bit1_pos, res->bit2_pos, res->value);
6921 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6922 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6924 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6925 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6926 regfield, "regfield");
6927 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6928 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6930 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6931 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6933 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6934 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6936 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6937 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6939 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6940 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6943 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6944 .f = cmd_write_reg_bit_field_parsed,
6946 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6948 "Set register bit field between bit_x and bit_y included",
6950 (void *)&cmd_write_reg_bit_field_write,
6951 (void *)&cmd_write_reg_bit_field_regfield,
6952 (void *)&cmd_write_reg_bit_field_port_id,
6953 (void *)&cmd_write_reg_bit_field_reg_off,
6954 (void *)&cmd_write_reg_bit_field_bit1_pos,
6955 (void *)&cmd_write_reg_bit_field_bit2_pos,
6956 (void *)&cmd_write_reg_bit_field_value,
6961 /* *** WRITE PORT REGISTER BIT *** */
6962 struct cmd_write_reg_bit_result {
6963 cmdline_fixed_string_t write;
6964 cmdline_fixed_string_t regbit;
6972 cmd_write_reg_bit_parsed(void *parsed_result,
6973 __attribute__((unused)) struct cmdline *cl,
6974 __attribute__((unused)) void *data)
6976 struct cmd_write_reg_bit_result *res = parsed_result;
6977 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6980 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6983 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6984 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6986 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6988 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6989 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6990 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6991 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6992 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6995 cmdline_parse_inst_t cmd_write_reg_bit = {
6996 .f = cmd_write_reg_bit_parsed,
6998 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7001 (void *)&cmd_write_reg_bit_write,
7002 (void *)&cmd_write_reg_bit_regbit,
7003 (void *)&cmd_write_reg_bit_port_id,
7004 (void *)&cmd_write_reg_bit_reg_off,
7005 (void *)&cmd_write_reg_bit_bit_pos,
7006 (void *)&cmd_write_reg_bit_value,
7011 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7012 struct cmd_read_rxd_txd_result {
7013 cmdline_fixed_string_t read;
7014 cmdline_fixed_string_t rxd_txd;
7021 cmd_read_rxd_txd_parsed(void *parsed_result,
7022 __attribute__((unused)) struct cmdline *cl,
7023 __attribute__((unused)) void *data)
7025 struct cmd_read_rxd_txd_result *res = parsed_result;
7027 if (!strcmp(res->rxd_txd, "rxd"))
7028 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7029 else if (!strcmp(res->rxd_txd, "txd"))
7030 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7033 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7034 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7035 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7036 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7038 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7039 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7040 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7041 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7042 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7043 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7045 cmdline_parse_inst_t cmd_read_rxd_txd = {
7046 .f = cmd_read_rxd_txd_parsed,
7048 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7050 (void *)&cmd_read_rxd_txd_read,
7051 (void *)&cmd_read_rxd_txd_rxd_txd,
7052 (void *)&cmd_read_rxd_txd_port_id,
7053 (void *)&cmd_read_rxd_txd_queue_id,
7054 (void *)&cmd_read_rxd_txd_desc_id,
7060 struct cmd_quit_result {
7061 cmdline_fixed_string_t quit;
7064 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7066 __attribute__((unused)) void *data)
7072 cmdline_parse_token_string_t cmd_quit_quit =
7073 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7075 cmdline_parse_inst_t cmd_quit = {
7076 .f = cmd_quit_parsed,
7078 .help_str = "quit: Exit application",
7080 (void *)&cmd_quit_quit,
7085 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7086 struct cmd_mac_addr_result {
7087 cmdline_fixed_string_t mac_addr_cmd;
7088 cmdline_fixed_string_t what;
7090 struct ether_addr address;
7093 static void cmd_mac_addr_parsed(void *parsed_result,
7094 __attribute__((unused)) struct cmdline *cl,
7095 __attribute__((unused)) void *data)
7097 struct cmd_mac_addr_result *res = parsed_result;
7100 if (strcmp(res->what, "add") == 0)
7101 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7102 else if (strcmp(res->what, "set") == 0)
7103 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7106 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7108 /* check the return value and print it if is < 0 */
7110 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7114 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7115 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7117 cmdline_parse_token_string_t cmd_mac_addr_what =
7118 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7120 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7121 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7123 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7124 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7126 cmdline_parse_inst_t cmd_mac_addr = {
7127 .f = cmd_mac_addr_parsed,
7129 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7130 "Add/Remove/Set MAC address on port_id",
7132 (void *)&cmd_mac_addr_cmd,
7133 (void *)&cmd_mac_addr_what,
7134 (void *)&cmd_mac_addr_portnum,
7135 (void *)&cmd_mac_addr_addr,
7141 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7142 struct cmd_set_qmap_result {
7143 cmdline_fixed_string_t set;
7144 cmdline_fixed_string_t qmap;
7145 cmdline_fixed_string_t what;
7152 cmd_set_qmap_parsed(void *parsed_result,
7153 __attribute__((unused)) struct cmdline *cl,
7154 __attribute__((unused)) void *data)
7156 struct cmd_set_qmap_result *res = parsed_result;
7157 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7159 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7162 cmdline_parse_token_string_t cmd_setqmap_set =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7165 cmdline_parse_token_string_t cmd_setqmap_qmap =
7166 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7168 cmdline_parse_token_string_t cmd_setqmap_what =
7169 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7171 cmdline_parse_token_num_t cmd_setqmap_portid =
7172 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7174 cmdline_parse_token_num_t cmd_setqmap_queueid =
7175 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7177 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7178 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7181 cmdline_parse_inst_t cmd_set_qmap = {
7182 .f = cmd_set_qmap_parsed,
7184 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7185 "Set statistics mapping value on tx|rx queue_id of port_id",
7187 (void *)&cmd_setqmap_set,
7188 (void *)&cmd_setqmap_qmap,
7189 (void *)&cmd_setqmap_what,
7190 (void *)&cmd_setqmap_portid,
7191 (void *)&cmd_setqmap_queueid,
7192 (void *)&cmd_setqmap_mapvalue,
7197 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7198 struct cmd_set_xstats_hide_zero_result {
7199 cmdline_fixed_string_t keyword;
7200 cmdline_fixed_string_t name;
7201 cmdline_fixed_string_t on_off;
7205 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7206 __attribute__((unused)) struct cmdline *cl,
7207 __attribute__((unused)) void *data)
7209 struct cmd_set_xstats_hide_zero_result *res;
7210 uint16_t on_off = 0;
7212 res = parsed_result;
7213 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7214 set_xstats_hide_zero(on_off);
7217 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7218 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7220 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7221 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7222 name, "xstats-hide-zero");
7223 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7224 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7227 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7228 .f = cmd_set_xstats_hide_zero_parsed,
7230 .help_str = "set xstats-hide-zero on|off",
7232 (void *)&cmd_set_xstats_hide_zero_keyword,
7233 (void *)&cmd_set_xstats_hide_zero_name,
7234 (void *)&cmd_set_xstats_hide_zero_on_off,
7239 /* *** CONFIGURE UNICAST HASH TABLE *** */
7240 struct cmd_set_uc_hash_table {
7241 cmdline_fixed_string_t set;
7242 cmdline_fixed_string_t port;
7244 cmdline_fixed_string_t what;
7245 struct ether_addr address;
7246 cmdline_fixed_string_t mode;
7250 cmd_set_uc_hash_parsed(void *parsed_result,
7251 __attribute__((unused)) struct cmdline *cl,
7252 __attribute__((unused)) void *data)
7255 struct cmd_set_uc_hash_table *res = parsed_result;
7257 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7259 if (strcmp(res->what, "uta") == 0)
7260 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7261 &res->address,(uint8_t)is_on);
7263 printf("bad unicast hash table parameter, return code = %d \n", ret);
7267 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7268 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7270 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7271 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7273 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7274 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7276 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7277 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7279 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7280 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7282 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7283 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7286 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7287 .f = cmd_set_uc_hash_parsed,
7289 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7291 (void *)&cmd_set_uc_hash_set,
7292 (void *)&cmd_set_uc_hash_port,
7293 (void *)&cmd_set_uc_hash_portid,
7294 (void *)&cmd_set_uc_hash_what,
7295 (void *)&cmd_set_uc_hash_mac,
7296 (void *)&cmd_set_uc_hash_mode,
7301 struct cmd_set_uc_all_hash_table {
7302 cmdline_fixed_string_t set;
7303 cmdline_fixed_string_t port;
7305 cmdline_fixed_string_t what;
7306 cmdline_fixed_string_t value;
7307 cmdline_fixed_string_t mode;
7311 cmd_set_uc_all_hash_parsed(void *parsed_result,
7312 __attribute__((unused)) struct cmdline *cl,
7313 __attribute__((unused)) void *data)
7316 struct cmd_set_uc_all_hash_table *res = parsed_result;
7318 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7320 if ((strcmp(res->what, "uta") == 0) &&
7321 (strcmp(res->value, "all") == 0))
7322 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7324 printf("bad unicast hash table parameter,"
7325 "return code = %d \n", ret);
7328 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7331 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7334 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7335 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7337 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7338 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7340 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7343 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7344 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7347 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7348 .f = cmd_set_uc_all_hash_parsed,
7350 .help_str = "set port <port_id> uta all on|off",
7352 (void *)&cmd_set_uc_all_hash_set,
7353 (void *)&cmd_set_uc_all_hash_port,
7354 (void *)&cmd_set_uc_all_hash_portid,
7355 (void *)&cmd_set_uc_all_hash_what,
7356 (void *)&cmd_set_uc_all_hash_value,
7357 (void *)&cmd_set_uc_all_hash_mode,
7362 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7363 struct cmd_set_vf_macvlan_filter {
7364 cmdline_fixed_string_t set;
7365 cmdline_fixed_string_t port;
7367 cmdline_fixed_string_t vf;
7369 struct ether_addr address;
7370 cmdline_fixed_string_t filter_type;
7371 cmdline_fixed_string_t mode;
7375 cmd_set_vf_macvlan_parsed(void *parsed_result,
7376 __attribute__((unused)) struct cmdline *cl,
7377 __attribute__((unused)) void *data)
7380 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7381 struct rte_eth_mac_filter filter;
7383 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7385 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7387 /* set VF MAC filter */
7391 filter.dst_id = res->vf_id;
7393 if (!strcmp(res->filter_type, "exact-mac"))
7394 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7395 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7396 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7397 else if (!strcmp(res->filter_type, "hashmac"))
7398 filter.filter_type = RTE_MAC_HASH_MATCH;
7399 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7400 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7402 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7405 ret = rte_eth_dev_filter_ctrl(res->port_id,
7406 RTE_ETH_FILTER_MACVLAN,
7410 ret = rte_eth_dev_filter_ctrl(res->port_id,
7411 RTE_ETH_FILTER_MACVLAN,
7412 RTE_ETH_FILTER_DELETE,
7416 printf("bad set MAC hash parameter, return code = %d\n", ret);
7420 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7423 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7424 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7426 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7427 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7429 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7432 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7433 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7435 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7438 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7440 filter_type, "exact-mac#exact-mac-vlan"
7441 "#hashmac#hashmac-vlan");
7442 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7443 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7446 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7447 .f = cmd_set_vf_macvlan_parsed,
7449 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7450 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7451 "Exact match rule: exact match of MAC or MAC and VLAN; "
7452 "hash match rule: hash match of MAC and exact match of VLAN",
7454 (void *)&cmd_set_vf_macvlan_set,
7455 (void *)&cmd_set_vf_macvlan_port,
7456 (void *)&cmd_set_vf_macvlan_portid,
7457 (void *)&cmd_set_vf_macvlan_vf,
7458 (void *)&cmd_set_vf_macvlan_vf_id,
7459 (void *)&cmd_set_vf_macvlan_mac,
7460 (void *)&cmd_set_vf_macvlan_filter_type,
7461 (void *)&cmd_set_vf_macvlan_mode,
7466 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7467 struct cmd_set_vf_traffic {
7468 cmdline_fixed_string_t set;
7469 cmdline_fixed_string_t port;
7471 cmdline_fixed_string_t vf;
7473 cmdline_fixed_string_t what;
7474 cmdline_fixed_string_t mode;
7478 cmd_set_vf_traffic_parsed(void *parsed_result,
7479 __attribute__((unused)) struct cmdline *cl,
7480 __attribute__((unused)) void *data)
7482 struct cmd_set_vf_traffic *res = parsed_result;
7483 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7484 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7486 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7489 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7492 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7495 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7496 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7498 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7501 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7502 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7504 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7507 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7511 cmdline_parse_inst_t cmd_set_vf_traffic = {
7512 .f = cmd_set_vf_traffic_parsed,
7514 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7516 (void *)&cmd_setvf_traffic_set,
7517 (void *)&cmd_setvf_traffic_port,
7518 (void *)&cmd_setvf_traffic_portid,
7519 (void *)&cmd_setvf_traffic_vf,
7520 (void *)&cmd_setvf_traffic_vfid,
7521 (void *)&cmd_setvf_traffic_what,
7522 (void *)&cmd_setvf_traffic_mode,
7527 /* *** CONFIGURE VF RECEIVE MODE *** */
7528 struct cmd_set_vf_rxmode {
7529 cmdline_fixed_string_t set;
7530 cmdline_fixed_string_t port;
7532 cmdline_fixed_string_t vf;
7534 cmdline_fixed_string_t what;
7535 cmdline_fixed_string_t mode;
7536 cmdline_fixed_string_t on;
7540 cmd_set_vf_rxmode_parsed(void *parsed_result,
7541 __attribute__((unused)) struct cmdline *cl,
7542 __attribute__((unused)) void *data)
7545 uint16_t rx_mode = 0;
7546 struct cmd_set_vf_rxmode *res = parsed_result;
7548 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7549 if (!strcmp(res->what,"rxmode")) {
7550 if (!strcmp(res->mode, "AUPE"))
7551 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7552 else if (!strcmp(res->mode, "ROPE"))
7553 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7554 else if (!strcmp(res->mode, "BAM"))
7555 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7556 else if (!strncmp(res->mode, "MPE",3))
7557 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7560 RTE_SET_USED(is_on);
7562 #ifdef RTE_LIBRTE_IXGBE_PMD
7563 if (ret == -ENOTSUP)
7564 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7565 rx_mode, (uint8_t)is_on);
7567 #ifdef RTE_LIBRTE_BNXT_PMD
7568 if (ret == -ENOTSUP)
7569 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7570 rx_mode, (uint8_t)is_on);
7573 printf("bad VF receive mode parameter, return code = %d \n",
7577 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7580 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7581 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7583 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7584 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7586 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7589 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7590 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7592 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7595 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7597 mode, "AUPE#ROPE#BAM#MPE");
7598 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7599 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7602 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7603 .f = cmd_set_vf_rxmode_parsed,
7605 .help_str = "set port <port_id> vf <vf_id> rxmode "
7606 "AUPE|ROPE|BAM|MPE on|off",
7608 (void *)&cmd_set_vf_rxmode_set,
7609 (void *)&cmd_set_vf_rxmode_port,
7610 (void *)&cmd_set_vf_rxmode_portid,
7611 (void *)&cmd_set_vf_rxmode_vf,
7612 (void *)&cmd_set_vf_rxmode_vfid,
7613 (void *)&cmd_set_vf_rxmode_what,
7614 (void *)&cmd_set_vf_rxmode_mode,
7615 (void *)&cmd_set_vf_rxmode_on,
7620 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7621 struct cmd_vf_mac_addr_result {
7622 cmdline_fixed_string_t mac_addr_cmd;
7623 cmdline_fixed_string_t what;
7624 cmdline_fixed_string_t port;
7626 cmdline_fixed_string_t vf;
7628 struct ether_addr address;
7631 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7632 __attribute__((unused)) struct cmdline *cl,
7633 __attribute__((unused)) void *data)
7635 struct cmd_vf_mac_addr_result *res = parsed_result;
7638 if (strcmp(res->what, "add") != 0)
7641 #ifdef RTE_LIBRTE_I40E_PMD
7642 if (ret == -ENOTSUP)
7643 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7646 #ifdef RTE_LIBRTE_BNXT_PMD
7647 if (ret == -ENOTSUP)
7648 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7653 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7657 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7658 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7659 mac_addr_cmd,"mac_addr");
7660 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7661 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7663 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7664 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7666 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7667 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7669 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7670 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7672 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7673 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7675 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7679 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7680 .f = cmd_vf_mac_addr_parsed,
7682 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7683 "Add MAC address filtering for a VF on port_id",
7685 (void *)&cmd_vf_mac_addr_cmd,
7686 (void *)&cmd_vf_mac_addr_what,
7687 (void *)&cmd_vf_mac_addr_port,
7688 (void *)&cmd_vf_mac_addr_portnum,
7689 (void *)&cmd_vf_mac_addr_vf,
7690 (void *)&cmd_vf_mac_addr_vfnum,
7691 (void *)&cmd_vf_mac_addr_addr,
7696 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7697 struct cmd_vf_rx_vlan_filter {
7698 cmdline_fixed_string_t rx_vlan;
7699 cmdline_fixed_string_t what;
7701 cmdline_fixed_string_t port;
7703 cmdline_fixed_string_t vf;
7708 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7709 __attribute__((unused)) struct cmdline *cl,
7710 __attribute__((unused)) void *data)
7712 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7715 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7717 #ifdef RTE_LIBRTE_IXGBE_PMD
7718 if (ret == -ENOTSUP)
7719 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7720 res->vlan_id, res->vf_mask, is_add);
7722 #ifdef RTE_LIBRTE_I40E_PMD
7723 if (ret == -ENOTSUP)
7724 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7725 res->vlan_id, res->vf_mask, is_add);
7727 #ifdef RTE_LIBRTE_BNXT_PMD
7728 if (ret == -ENOTSUP)
7729 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7730 res->vlan_id, res->vf_mask, is_add);
7737 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7738 res->vlan_id, res->vf_mask);
7741 printf("invalid port_id %d\n", res->port_id);
7744 printf("function not implemented or supported\n");
7747 printf("programming error: (%s)\n", strerror(-ret));
7751 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7752 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7753 rx_vlan, "rx_vlan");
7754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7755 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7757 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7758 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7760 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7761 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7763 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7764 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7766 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7767 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7769 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7770 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7773 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7774 .f = cmd_vf_rx_vlan_filter_parsed,
7776 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7777 "(vf_mask = hexadecimal VF mask)",
7779 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7780 (void *)&cmd_vf_rx_vlan_filter_what,
7781 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7782 (void *)&cmd_vf_rx_vlan_filter_port,
7783 (void *)&cmd_vf_rx_vlan_filter_portid,
7784 (void *)&cmd_vf_rx_vlan_filter_vf,
7785 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7790 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7791 struct cmd_queue_rate_limit_result {
7792 cmdline_fixed_string_t set;
7793 cmdline_fixed_string_t port;
7795 cmdline_fixed_string_t queue;
7797 cmdline_fixed_string_t rate;
7801 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7802 __attribute__((unused)) struct cmdline *cl,
7803 __attribute__((unused)) void *data)
7805 struct cmd_queue_rate_limit_result *res = parsed_result;
7808 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7809 && (strcmp(res->queue, "queue") == 0)
7810 && (strcmp(res->rate, "rate") == 0))
7811 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7814 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7818 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7819 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7821 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7822 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7824 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7825 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7827 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7828 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7830 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7831 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7833 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7834 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7836 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7837 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7840 cmdline_parse_inst_t cmd_queue_rate_limit = {
7841 .f = cmd_queue_rate_limit_parsed,
7843 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7844 "Set rate limit for a queue on port_id",
7846 (void *)&cmd_queue_rate_limit_set,
7847 (void *)&cmd_queue_rate_limit_port,
7848 (void *)&cmd_queue_rate_limit_portnum,
7849 (void *)&cmd_queue_rate_limit_queue,
7850 (void *)&cmd_queue_rate_limit_queuenum,
7851 (void *)&cmd_queue_rate_limit_rate,
7852 (void *)&cmd_queue_rate_limit_ratenum,
7857 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7858 struct cmd_vf_rate_limit_result {
7859 cmdline_fixed_string_t set;
7860 cmdline_fixed_string_t port;
7862 cmdline_fixed_string_t vf;
7864 cmdline_fixed_string_t rate;
7866 cmdline_fixed_string_t q_msk;
7870 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7871 __attribute__((unused)) struct cmdline *cl,
7872 __attribute__((unused)) void *data)
7874 struct cmd_vf_rate_limit_result *res = parsed_result;
7877 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7878 && (strcmp(res->vf, "vf") == 0)
7879 && (strcmp(res->rate, "rate") == 0)
7880 && (strcmp(res->q_msk, "queue_mask") == 0))
7881 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7882 res->rate_num, res->q_msk_val);
7884 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7888 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7889 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7891 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7892 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7894 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7895 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7897 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7900 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7901 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7903 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7904 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7906 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7907 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7909 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7910 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7911 q_msk, "queue_mask");
7912 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7913 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7916 cmdline_parse_inst_t cmd_vf_rate_limit = {
7917 .f = cmd_vf_rate_limit_parsed,
7919 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7920 "queue_mask <queue_mask_value>: "
7921 "Set rate limit for queues of VF on port_id",
7923 (void *)&cmd_vf_rate_limit_set,
7924 (void *)&cmd_vf_rate_limit_port,
7925 (void *)&cmd_vf_rate_limit_portnum,
7926 (void *)&cmd_vf_rate_limit_vf,
7927 (void *)&cmd_vf_rate_limit_vfnum,
7928 (void *)&cmd_vf_rate_limit_rate,
7929 (void *)&cmd_vf_rate_limit_ratenum,
7930 (void *)&cmd_vf_rate_limit_q_msk,
7931 (void *)&cmd_vf_rate_limit_q_msk_val,
7936 /* *** ADD TUNNEL FILTER OF A PORT *** */
7937 struct cmd_tunnel_filter_result {
7938 cmdline_fixed_string_t cmd;
7939 cmdline_fixed_string_t what;
7941 struct ether_addr outer_mac;
7942 struct ether_addr inner_mac;
7943 cmdline_ipaddr_t ip_value;
7944 uint16_t inner_vlan;
7945 cmdline_fixed_string_t tunnel_type;
7946 cmdline_fixed_string_t filter_type;
7952 cmd_tunnel_filter_parsed(void *parsed_result,
7953 __attribute__((unused)) struct cmdline *cl,
7954 __attribute__((unused)) void *data)
7956 struct cmd_tunnel_filter_result *res = parsed_result;
7957 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7960 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7962 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7963 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7964 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7966 if (res->ip_value.family == AF_INET) {
7967 tunnel_filter_conf.ip_addr.ipv4_addr =
7968 res->ip_value.addr.ipv4.s_addr;
7969 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7971 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7972 &(res->ip_value.addr.ipv6),
7973 sizeof(struct in6_addr));
7974 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7977 if (!strcmp(res->filter_type, "imac-ivlan"))
7978 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7979 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7980 tunnel_filter_conf.filter_type =
7981 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7982 else if (!strcmp(res->filter_type, "imac-tenid"))
7983 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7984 else if (!strcmp(res->filter_type, "imac"))
7985 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7986 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7987 tunnel_filter_conf.filter_type =
7988 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7989 else if (!strcmp(res->filter_type, "oip"))
7990 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7991 else if (!strcmp(res->filter_type, "iip"))
7992 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7994 printf("The filter type is not supported");
7998 if (!strcmp(res->tunnel_type, "vxlan"))
7999 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8000 else if (!strcmp(res->tunnel_type, "nvgre"))
8001 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8002 else if (!strcmp(res->tunnel_type, "ipingre"))
8003 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8005 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8009 tunnel_filter_conf.tenant_id = res->tenant_id;
8010 tunnel_filter_conf.queue_id = res->queue_num;
8011 if (!strcmp(res->what, "add"))
8012 ret = rte_eth_dev_filter_ctrl(res->port_id,
8013 RTE_ETH_FILTER_TUNNEL,
8015 &tunnel_filter_conf);
8017 ret = rte_eth_dev_filter_ctrl(res->port_id,
8018 RTE_ETH_FILTER_TUNNEL,
8019 RTE_ETH_FILTER_DELETE,
8020 &tunnel_filter_conf);
8022 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8026 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8027 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8028 cmd, "tunnel_filter");
8029 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8030 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8032 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8033 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8035 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8036 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8038 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8039 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8041 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8042 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8043 inner_vlan, UINT16);
8044 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8045 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8047 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8049 tunnel_type, "vxlan#nvgre#ipingre");
8051 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8052 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8053 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8054 "imac#omac-imac-tenid");
8055 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8056 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8058 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8059 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8062 cmdline_parse_inst_t cmd_tunnel_filter = {
8063 .f = cmd_tunnel_filter_parsed,
8065 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8066 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8067 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8068 "<queue_id>: Add/Rm tunnel filter of a port",
8070 (void *)&cmd_tunnel_filter_cmd,
8071 (void *)&cmd_tunnel_filter_what,
8072 (void *)&cmd_tunnel_filter_port_id,
8073 (void *)&cmd_tunnel_filter_outer_mac,
8074 (void *)&cmd_tunnel_filter_inner_mac,
8075 (void *)&cmd_tunnel_filter_ip_value,
8076 (void *)&cmd_tunnel_filter_innner_vlan,
8077 (void *)&cmd_tunnel_filter_tunnel_type,
8078 (void *)&cmd_tunnel_filter_filter_type,
8079 (void *)&cmd_tunnel_filter_tenant_id,
8080 (void *)&cmd_tunnel_filter_queue_num,
8085 /* *** CONFIGURE TUNNEL UDP PORT *** */
8086 struct cmd_tunnel_udp_config {
8087 cmdline_fixed_string_t cmd;
8088 cmdline_fixed_string_t what;
8094 cmd_tunnel_udp_config_parsed(void *parsed_result,
8095 __attribute__((unused)) struct cmdline *cl,
8096 __attribute__((unused)) void *data)
8098 struct cmd_tunnel_udp_config *res = parsed_result;
8099 struct rte_eth_udp_tunnel tunnel_udp;
8102 tunnel_udp.udp_port = res->udp_port;
8104 if (!strcmp(res->cmd, "rx_vxlan_port"))
8105 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8107 if (!strcmp(res->what, "add"))
8108 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8111 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8115 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8118 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8120 cmd, "rx_vxlan_port");
8121 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8124 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8127 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8128 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8131 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8132 .f = cmd_tunnel_udp_config_parsed,
8134 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8135 "Add/Remove a tunneling UDP port filter",
8137 (void *)&cmd_tunnel_udp_config_cmd,
8138 (void *)&cmd_tunnel_udp_config_what,
8139 (void *)&cmd_tunnel_udp_config_udp_port,
8140 (void *)&cmd_tunnel_udp_config_port_id,
8145 /* *** GLOBAL CONFIG *** */
8146 struct cmd_global_config_result {
8147 cmdline_fixed_string_t cmd;
8149 cmdline_fixed_string_t cfg_type;
8154 cmd_global_config_parsed(void *parsed_result,
8155 __attribute__((unused)) struct cmdline *cl,
8156 __attribute__((unused)) void *data)
8158 struct cmd_global_config_result *res = parsed_result;
8159 struct rte_eth_global_cfg conf;
8162 memset(&conf, 0, sizeof(conf));
8163 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8164 conf.cfg.gre_key_len = res->len;
8165 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8166 RTE_ETH_FILTER_SET, &conf);
8168 printf("Global config error\n");
8171 cmdline_parse_token_string_t cmd_global_config_cmd =
8172 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8174 cmdline_parse_token_num_t cmd_global_config_port_id =
8175 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8177 cmdline_parse_token_string_t cmd_global_config_type =
8178 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8179 cfg_type, "gre-key-len");
8180 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8181 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8184 cmdline_parse_inst_t cmd_global_config = {
8185 .f = cmd_global_config_parsed,
8186 .data = (void *)NULL,
8187 .help_str = "global_config <port_id> gre-key-len <key_len>",
8189 (void *)&cmd_global_config_cmd,
8190 (void *)&cmd_global_config_port_id,
8191 (void *)&cmd_global_config_type,
8192 (void *)&cmd_global_config_gre_key_len,
8197 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8198 struct cmd_set_mirror_mask_result {
8199 cmdline_fixed_string_t set;
8200 cmdline_fixed_string_t port;
8202 cmdline_fixed_string_t mirror;
8204 cmdline_fixed_string_t what;
8205 cmdline_fixed_string_t value;
8206 cmdline_fixed_string_t dstpool;
8208 cmdline_fixed_string_t on;
8211 cmdline_parse_token_string_t cmd_mirror_mask_set =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8214 cmdline_parse_token_string_t cmd_mirror_mask_port =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8217 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8218 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8220 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8222 mirror, "mirror-rule");
8223 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8224 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8226 cmdline_parse_token_string_t cmd_mirror_mask_what =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8228 what, "pool-mirror-up#pool-mirror-down"
8230 cmdline_parse_token_string_t cmd_mirror_mask_value =
8231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8233 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8234 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8235 dstpool, "dst-pool");
8236 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8237 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8239 cmdline_parse_token_string_t cmd_mirror_mask_on =
8240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8244 cmd_set_mirror_mask_parsed(void *parsed_result,
8245 __attribute__((unused)) struct cmdline *cl,
8246 __attribute__((unused)) void *data)
8249 struct cmd_set_mirror_mask_result *res = parsed_result;
8250 struct rte_eth_mirror_conf mr_conf;
8252 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8254 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8256 mr_conf.dst_pool = res->dstpool_id;
8258 if (!strcmp(res->what, "pool-mirror-up")) {
8259 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8260 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8261 } else if (!strcmp(res->what, "pool-mirror-down")) {
8262 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8263 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8264 } else if (!strcmp(res->what, "vlan-mirror")) {
8265 mr_conf.rule_type = ETH_MIRROR_VLAN;
8266 nb_item = parse_item_list(res->value, "vlan",
8267 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8271 for (i = 0; i < nb_item; i++) {
8272 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8273 printf("Invalid vlan_id: must be < 4096\n");
8277 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8278 mr_conf.vlan.vlan_mask |= 1ULL << i;
8282 if (!strcmp(res->on, "on"))
8283 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8286 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8289 printf("mirror rule add error: (%s)\n", strerror(-ret));
8292 cmdline_parse_inst_t cmd_set_mirror_mask = {
8293 .f = cmd_set_mirror_mask_parsed,
8295 .help_str = "set port <port_id> mirror-rule <rule_id> "
8296 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8297 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8299 (void *)&cmd_mirror_mask_set,
8300 (void *)&cmd_mirror_mask_port,
8301 (void *)&cmd_mirror_mask_portid,
8302 (void *)&cmd_mirror_mask_mirror,
8303 (void *)&cmd_mirror_mask_ruleid,
8304 (void *)&cmd_mirror_mask_what,
8305 (void *)&cmd_mirror_mask_value,
8306 (void *)&cmd_mirror_mask_dstpool,
8307 (void *)&cmd_mirror_mask_poolid,
8308 (void *)&cmd_mirror_mask_on,
8313 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8314 struct cmd_set_mirror_link_result {
8315 cmdline_fixed_string_t set;
8316 cmdline_fixed_string_t port;
8318 cmdline_fixed_string_t mirror;
8320 cmdline_fixed_string_t what;
8321 cmdline_fixed_string_t dstpool;
8323 cmdline_fixed_string_t on;
8326 cmdline_parse_token_string_t cmd_mirror_link_set =
8327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8329 cmdline_parse_token_string_t cmd_mirror_link_port =
8330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8332 cmdline_parse_token_num_t cmd_mirror_link_portid =
8333 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8335 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8337 mirror, "mirror-rule");
8338 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8339 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8341 cmdline_parse_token_string_t cmd_mirror_link_what =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8343 what, "uplink-mirror#downlink-mirror");
8344 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8346 dstpool, "dst-pool");
8347 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8348 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8350 cmdline_parse_token_string_t cmd_mirror_link_on =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8355 cmd_set_mirror_link_parsed(void *parsed_result,
8356 __attribute__((unused)) struct cmdline *cl,
8357 __attribute__((unused)) void *data)
8360 struct cmd_set_mirror_link_result *res = parsed_result;
8361 struct rte_eth_mirror_conf mr_conf;
8363 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8364 if (!strcmp(res->what, "uplink-mirror"))
8365 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8367 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8369 mr_conf.dst_pool = res->dstpool_id;
8371 if (!strcmp(res->on, "on"))
8372 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8375 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8378 /* check the return value and print it if is < 0 */
8380 printf("mirror rule add error: (%s)\n", strerror(-ret));
8384 cmdline_parse_inst_t cmd_set_mirror_link = {
8385 .f = cmd_set_mirror_link_parsed,
8387 .help_str = "set port <port_id> mirror-rule <rule_id> "
8388 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8390 (void *)&cmd_mirror_link_set,
8391 (void *)&cmd_mirror_link_port,
8392 (void *)&cmd_mirror_link_portid,
8393 (void *)&cmd_mirror_link_mirror,
8394 (void *)&cmd_mirror_link_ruleid,
8395 (void *)&cmd_mirror_link_what,
8396 (void *)&cmd_mirror_link_dstpool,
8397 (void *)&cmd_mirror_link_poolid,
8398 (void *)&cmd_mirror_link_on,
8403 /* *** RESET VM MIRROR RULE *** */
8404 struct cmd_rm_mirror_rule_result {
8405 cmdline_fixed_string_t reset;
8406 cmdline_fixed_string_t port;
8408 cmdline_fixed_string_t mirror;
8412 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8413 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8415 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8416 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8418 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8419 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8421 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8422 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8423 mirror, "mirror-rule");
8424 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8425 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8429 cmd_reset_mirror_rule_parsed(void *parsed_result,
8430 __attribute__((unused)) struct cmdline *cl,
8431 __attribute__((unused)) void *data)
8434 struct cmd_set_mirror_link_result *res = parsed_result;
8436 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8438 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8441 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8442 .f = cmd_reset_mirror_rule_parsed,
8444 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8446 (void *)&cmd_rm_mirror_rule_reset,
8447 (void *)&cmd_rm_mirror_rule_port,
8448 (void *)&cmd_rm_mirror_rule_portid,
8449 (void *)&cmd_rm_mirror_rule_mirror,
8450 (void *)&cmd_rm_mirror_rule_ruleid,
8455 /* ******************************************************************************** */
8457 struct cmd_dump_result {
8458 cmdline_fixed_string_t dump;
8462 dump_struct_sizes(void)
8464 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8465 DUMP_SIZE(struct rte_mbuf);
8466 DUMP_SIZE(struct rte_mempool);
8467 DUMP_SIZE(struct rte_ring);
8471 static void cmd_dump_parsed(void *parsed_result,
8472 __attribute__((unused)) struct cmdline *cl,
8473 __attribute__((unused)) void *data)
8475 struct cmd_dump_result *res = parsed_result;
8477 if (!strcmp(res->dump, "dump_physmem"))
8478 rte_dump_physmem_layout(stdout);
8479 else if (!strcmp(res->dump, "dump_memzone"))
8480 rte_memzone_dump(stdout);
8481 else if (!strcmp(res->dump, "dump_struct_sizes"))
8482 dump_struct_sizes();
8483 else if (!strcmp(res->dump, "dump_ring"))
8484 rte_ring_list_dump(stdout);
8485 else if (!strcmp(res->dump, "dump_mempool"))
8486 rte_mempool_list_dump(stdout);
8487 else if (!strcmp(res->dump, "dump_devargs"))
8488 rte_eal_devargs_dump(stdout);
8489 else if (!strcmp(res->dump, "dump_log_types"))
8490 rte_log_dump(stdout);
8493 cmdline_parse_token_string_t cmd_dump_dump =
8494 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8497 "dump_struct_sizes#"
8503 cmdline_parse_inst_t cmd_dump = {
8504 .f = cmd_dump_parsed, /* function to call */
8505 .data = NULL, /* 2nd arg of func */
8506 .help_str = "Dump status",
8507 .tokens = { /* token list, NULL terminated */
8508 (void *)&cmd_dump_dump,
8513 /* ******************************************************************************** */
8515 struct cmd_dump_one_result {
8516 cmdline_fixed_string_t dump;
8517 cmdline_fixed_string_t name;
8520 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8521 __attribute__((unused)) void *data)
8523 struct cmd_dump_one_result *res = parsed_result;
8525 if (!strcmp(res->dump, "dump_ring")) {
8527 r = rte_ring_lookup(res->name);
8529 cmdline_printf(cl, "Cannot find ring\n");
8532 rte_ring_dump(stdout, r);
8533 } else if (!strcmp(res->dump, "dump_mempool")) {
8534 struct rte_mempool *mp;
8535 mp = rte_mempool_lookup(res->name);
8537 cmdline_printf(cl, "Cannot find mempool\n");
8540 rte_mempool_dump(stdout, mp);
8544 cmdline_parse_token_string_t cmd_dump_one_dump =
8545 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8546 "dump_ring#dump_mempool");
8548 cmdline_parse_token_string_t cmd_dump_one_name =
8549 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8551 cmdline_parse_inst_t cmd_dump_one = {
8552 .f = cmd_dump_one_parsed, /* function to call */
8553 .data = NULL, /* 2nd arg of func */
8554 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8555 .tokens = { /* token list, NULL terminated */
8556 (void *)&cmd_dump_one_dump,
8557 (void *)&cmd_dump_one_name,
8562 /* *** Add/Del syn filter *** */
8563 struct cmd_syn_filter_result {
8564 cmdline_fixed_string_t filter;
8566 cmdline_fixed_string_t ops;
8567 cmdline_fixed_string_t priority;
8568 cmdline_fixed_string_t high;
8569 cmdline_fixed_string_t queue;
8574 cmd_syn_filter_parsed(void *parsed_result,
8575 __attribute__((unused)) struct cmdline *cl,
8576 __attribute__((unused)) void *data)
8578 struct cmd_syn_filter_result *res = parsed_result;
8579 struct rte_eth_syn_filter syn_filter;
8582 ret = rte_eth_dev_filter_supported(res->port_id,
8583 RTE_ETH_FILTER_SYN);
8585 printf("syn filter is not supported on port %u.\n",
8590 memset(&syn_filter, 0, sizeof(syn_filter));
8592 if (!strcmp(res->ops, "add")) {
8593 if (!strcmp(res->high, "high"))
8594 syn_filter.hig_pri = 1;
8596 syn_filter.hig_pri = 0;
8598 syn_filter.queue = res->queue_id;
8599 ret = rte_eth_dev_filter_ctrl(res->port_id,
8604 ret = rte_eth_dev_filter_ctrl(res->port_id,
8606 RTE_ETH_FILTER_DELETE,
8610 printf("syn filter programming error: (%s)\n",
8614 cmdline_parse_token_string_t cmd_syn_filter_filter =
8615 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8616 filter, "syn_filter");
8617 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8618 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8620 cmdline_parse_token_string_t cmd_syn_filter_ops =
8621 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8623 cmdline_parse_token_string_t cmd_syn_filter_priority =
8624 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8625 priority, "priority");
8626 cmdline_parse_token_string_t cmd_syn_filter_high =
8627 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8629 cmdline_parse_token_string_t cmd_syn_filter_queue =
8630 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8632 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8633 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8636 cmdline_parse_inst_t cmd_syn_filter = {
8637 .f = cmd_syn_filter_parsed,
8639 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8640 "<queue_id>: Add/Delete syn filter",
8642 (void *)&cmd_syn_filter_filter,
8643 (void *)&cmd_syn_filter_port_id,
8644 (void *)&cmd_syn_filter_ops,
8645 (void *)&cmd_syn_filter_priority,
8646 (void *)&cmd_syn_filter_high,
8647 (void *)&cmd_syn_filter_queue,
8648 (void *)&cmd_syn_filter_queue_id,
8653 /* *** queue region set *** */
8654 struct cmd_queue_region_result {
8655 cmdline_fixed_string_t set;
8656 cmdline_fixed_string_t port;
8658 cmdline_fixed_string_t cmd;
8659 cmdline_fixed_string_t region;
8661 cmdline_fixed_string_t queue_start_index;
8663 cmdline_fixed_string_t queue_num;
8664 uint8_t queue_num_value;
8668 cmd_queue_region_parsed(void *parsed_result,
8669 __attribute__((unused)) struct cmdline *cl,
8670 __attribute__((unused)) void *data)
8672 struct cmd_queue_region_result *res = parsed_result;
8674 #ifdef RTE_LIBRTE_I40E_PMD
8675 struct rte_pmd_i40e_queue_region_conf region_conf;
8676 enum rte_pmd_i40e_queue_region_op op_type;
8679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8682 #ifdef RTE_LIBRTE_I40E_PMD
8683 memset(®ion_conf, 0, sizeof(region_conf));
8684 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8685 region_conf.region_id = res->region_id;
8686 region_conf.queue_num = res->queue_num_value;
8687 region_conf.queue_start_index = res->queue_id;
8689 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8690 op_type, ®ion_conf);
8697 printf("function not implemented or supported\n");
8700 printf("queue region config error: (%s)\n", strerror(-ret));
8704 cmdline_parse_token_string_t cmd_queue_region_set =
8705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8707 cmdline_parse_token_string_t cmd_queue_region_port =
8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8709 cmdline_parse_token_num_t cmd_queue_region_port_id =
8710 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8712 cmdline_parse_token_string_t cmd_queue_region_cmd =
8713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8714 cmd, "queue-region");
8715 cmdline_parse_token_string_t cmd_queue_region_id =
8716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8717 region, "region_id");
8718 cmdline_parse_token_num_t cmd_queue_region_index =
8719 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8721 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8722 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8723 queue_start_index, "queue_start_index");
8724 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8725 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8727 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8729 queue_num, "queue_num");
8730 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8732 queue_num_value, UINT8);
8734 cmdline_parse_inst_t cmd_queue_region = {
8735 .f = cmd_queue_region_parsed,
8737 .help_str = "set port <port_id> queue-region region_id <value> "
8738 "queue_start_index <value> queue_num <value>: Set a queue region",
8740 (void *)&cmd_queue_region_set,
8741 (void *)&cmd_queue_region_port,
8742 (void *)&cmd_queue_region_port_id,
8743 (void *)&cmd_queue_region_cmd,
8744 (void *)&cmd_queue_region_id,
8745 (void *)&cmd_queue_region_index,
8746 (void *)&cmd_queue_region_queue_start_index,
8747 (void *)&cmd_queue_region_queue_id,
8748 (void *)&cmd_queue_region_queue_num,
8749 (void *)&cmd_queue_region_queue_num_value,
8754 /* *** queue region and flowtype set *** */
8755 struct cmd_region_flowtype_result {
8756 cmdline_fixed_string_t set;
8757 cmdline_fixed_string_t port;
8759 cmdline_fixed_string_t cmd;
8760 cmdline_fixed_string_t region;
8762 cmdline_fixed_string_t flowtype;
8763 uint8_t flowtype_id;
8767 cmd_region_flowtype_parsed(void *parsed_result,
8768 __attribute__((unused)) struct cmdline *cl,
8769 __attribute__((unused)) void *data)
8771 struct cmd_region_flowtype_result *res = parsed_result;
8773 #ifdef RTE_LIBRTE_I40E_PMD
8774 struct rte_pmd_i40e_queue_region_conf region_conf;
8775 enum rte_pmd_i40e_queue_region_op op_type;
8778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8781 #ifdef RTE_LIBRTE_I40E_PMD
8782 memset(®ion_conf, 0, sizeof(region_conf));
8784 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8785 region_conf.region_id = res->region_id;
8786 region_conf.hw_flowtype = res->flowtype_id;
8788 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8789 op_type, ®ion_conf);
8796 printf("function not implemented or supported\n");
8799 printf("region flowtype config error: (%s)\n", strerror(-ret));
8803 cmdline_parse_token_string_t cmd_region_flowtype_set =
8804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8806 cmdline_parse_token_string_t cmd_region_flowtype_port =
8807 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8809 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8810 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8812 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8814 cmd, "queue-region");
8815 cmdline_parse_token_string_t cmd_region_flowtype_index =
8816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8817 region, "region_id");
8818 cmdline_parse_token_num_t cmd_region_flowtype_id =
8819 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8821 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8822 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8823 flowtype, "flowtype");
8824 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8825 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8826 flowtype_id, UINT8);
8827 cmdline_parse_inst_t cmd_region_flowtype = {
8828 .f = cmd_region_flowtype_parsed,
8830 .help_str = "set port <port_id> queue-region region_id <value> "
8831 "flowtype <value>: Set a flowtype region index",
8833 (void *)&cmd_region_flowtype_set,
8834 (void *)&cmd_region_flowtype_port,
8835 (void *)&cmd_region_flowtype_port_index,
8836 (void *)&cmd_region_flowtype_cmd,
8837 (void *)&cmd_region_flowtype_index,
8838 (void *)&cmd_region_flowtype_id,
8839 (void *)&cmd_region_flowtype_flow_index,
8840 (void *)&cmd_region_flowtype_flow_id,
8845 /* *** User Priority (UP) to queue region (region_id) set *** */
8846 struct cmd_user_priority_region_result {
8847 cmdline_fixed_string_t set;
8848 cmdline_fixed_string_t port;
8850 cmdline_fixed_string_t cmd;
8851 cmdline_fixed_string_t user_priority;
8852 uint8_t user_priority_id;
8853 cmdline_fixed_string_t region;
8858 cmd_user_priority_region_parsed(void *parsed_result,
8859 __attribute__((unused)) struct cmdline *cl,
8860 __attribute__((unused)) void *data)
8862 struct cmd_user_priority_region_result *res = parsed_result;
8864 #ifdef RTE_LIBRTE_I40E_PMD
8865 struct rte_pmd_i40e_queue_region_conf region_conf;
8866 enum rte_pmd_i40e_queue_region_op op_type;
8869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8872 #ifdef RTE_LIBRTE_I40E_PMD
8873 memset(®ion_conf, 0, sizeof(region_conf));
8874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8875 region_conf.user_priority = res->user_priority_id;
8876 region_conf.region_id = res->region_id;
8878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8879 op_type, ®ion_conf);
8886 printf("function not implemented or supported\n");
8889 printf("user_priority region config error: (%s)\n",
8894 cmdline_parse_token_string_t cmd_user_priority_region_set =
8895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8897 cmdline_parse_token_string_t cmd_user_priority_region_port =
8898 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8900 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8901 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8903 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8905 cmd, "queue-region");
8906 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8908 user_priority, "UP");
8909 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8910 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8911 user_priority_id, UINT8);
8912 cmdline_parse_token_string_t cmd_user_priority_region_region =
8913 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8914 region, "region_id");
8915 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8916 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8919 cmdline_parse_inst_t cmd_user_priority_region = {
8920 .f = cmd_user_priority_region_parsed,
8922 .help_str = "set port <port_id> queue-region UP <value> "
8923 "region_id <value>: Set the mapping of User Priority (UP) "
8924 "to queue region (region_id) ",
8926 (void *)&cmd_user_priority_region_set,
8927 (void *)&cmd_user_priority_region_port,
8928 (void *)&cmd_user_priority_region_port_index,
8929 (void *)&cmd_user_priority_region_cmd,
8930 (void *)&cmd_user_priority_region_UP,
8931 (void *)&cmd_user_priority_region_UP_id,
8932 (void *)&cmd_user_priority_region_region,
8933 (void *)&cmd_user_priority_region_region_id,
8938 /* *** flush all queue region related configuration *** */
8939 struct cmd_flush_queue_region_result {
8940 cmdline_fixed_string_t set;
8941 cmdline_fixed_string_t port;
8943 cmdline_fixed_string_t cmd;
8944 cmdline_fixed_string_t flush;
8945 cmdline_fixed_string_t what;
8949 cmd_flush_queue_region_parsed(void *parsed_result,
8950 __attribute__((unused)) struct cmdline *cl,
8951 __attribute__((unused)) void *data)
8953 struct cmd_flush_queue_region_result *res = parsed_result;
8955 #ifdef RTE_LIBRTE_I40E_PMD
8956 struct rte_pmd_i40e_queue_region_conf region_conf;
8957 enum rte_pmd_i40e_queue_region_op op_type;
8960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8963 #ifdef RTE_LIBRTE_I40E_PMD
8964 memset(®ion_conf, 0, sizeof(region_conf));
8966 if (strcmp(res->what, "on") == 0)
8967 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8969 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8971 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8972 op_type, ®ion_conf);
8979 printf("function not implemented or supported\n");
8982 printf("queue region config flush error: (%s)\n",
8987 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8990 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8993 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8994 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8996 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8997 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8998 cmd, "queue-region");
8999 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9002 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9006 cmdline_parse_inst_t cmd_flush_queue_region = {
9007 .f = cmd_flush_queue_region_parsed,
9009 .help_str = "set port <port_id> queue-region flush on|off"
9010 ": flush all queue region related configuration",
9012 (void *)&cmd_flush_queue_region_set,
9013 (void *)&cmd_flush_queue_region_port,
9014 (void *)&cmd_flush_queue_region_port_index,
9015 (void *)&cmd_flush_queue_region_cmd,
9016 (void *)&cmd_flush_queue_region_flush,
9017 (void *)&cmd_flush_queue_region_what,
9022 /* *** get all queue region related configuration info *** */
9023 struct cmd_show_queue_region_info {
9024 cmdline_fixed_string_t show;
9025 cmdline_fixed_string_t port;
9027 cmdline_fixed_string_t cmd;
9031 cmd_show_queue_region_info_parsed(void *parsed_result,
9032 __attribute__((unused)) struct cmdline *cl,
9033 __attribute__((unused)) void *data)
9035 struct cmd_show_queue_region_info *res = parsed_result;
9037 #ifdef RTE_LIBRTE_I40E_PMD
9038 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9039 enum rte_pmd_i40e_queue_region_op op_type;
9042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9045 #ifdef RTE_LIBRTE_I40E_PMD
9046 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9048 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9050 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9051 op_type, &rte_pmd_regions);
9053 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9060 printf("function not implemented or supported\n");
9063 printf("queue region config info show error: (%s)\n",
9068 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9071 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9072 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9074 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9075 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9077 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9078 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9079 cmd, "queue-region");
9081 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9082 .f = cmd_show_queue_region_info_parsed,
9084 .help_str = "show port <port_id> queue-region"
9085 ": show all queue region related configuration info",
9087 (void *)&cmd_show_queue_region_info_get,
9088 (void *)&cmd_show_queue_region_info_port,
9089 (void *)&cmd_show_queue_region_info_port_index,
9090 (void *)&cmd_show_queue_region_info_cmd,
9095 /* *** ADD/REMOVE A 2tuple FILTER *** */
9096 struct cmd_2tuple_filter_result {
9097 cmdline_fixed_string_t filter;
9099 cmdline_fixed_string_t ops;
9100 cmdline_fixed_string_t dst_port;
9101 uint16_t dst_port_value;
9102 cmdline_fixed_string_t protocol;
9103 uint8_t protocol_value;
9104 cmdline_fixed_string_t mask;
9106 cmdline_fixed_string_t tcp_flags;
9107 uint8_t tcp_flags_value;
9108 cmdline_fixed_string_t priority;
9109 uint8_t priority_value;
9110 cmdline_fixed_string_t queue;
9115 cmd_2tuple_filter_parsed(void *parsed_result,
9116 __attribute__((unused)) struct cmdline *cl,
9117 __attribute__((unused)) void *data)
9119 struct rte_eth_ntuple_filter filter;
9120 struct cmd_2tuple_filter_result *res = parsed_result;
9123 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9125 printf("ntuple filter is not supported on port %u.\n",
9130 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9132 filter.flags = RTE_2TUPLE_FLAGS;
9133 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9134 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9135 filter.proto = res->protocol_value;
9136 filter.priority = res->priority_value;
9137 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9138 printf("nonzero tcp_flags is only meaningful"
9139 " when protocol is TCP.\n");
9142 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9143 printf("invalid TCP flags.\n");
9147 if (res->tcp_flags_value != 0) {
9148 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9149 filter.tcp_flags = res->tcp_flags_value;
9152 /* need convert to big endian. */
9153 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9154 filter.queue = res->queue_id;
9156 if (!strcmp(res->ops, "add"))
9157 ret = rte_eth_dev_filter_ctrl(res->port_id,
9158 RTE_ETH_FILTER_NTUPLE,
9162 ret = rte_eth_dev_filter_ctrl(res->port_id,
9163 RTE_ETH_FILTER_NTUPLE,
9164 RTE_ETH_FILTER_DELETE,
9167 printf("2tuple filter programming error: (%s)\n",
9172 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9174 filter, "2tuple_filter");
9175 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9178 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9181 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9182 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9183 dst_port, "dst_port");
9184 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9185 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9186 dst_port_value, UINT16);
9187 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9188 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9189 protocol, "protocol");
9190 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9191 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9192 protocol_value, UINT8);
9193 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9194 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9196 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9197 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9199 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9200 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9201 tcp_flags, "tcp_flags");
9202 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9203 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9204 tcp_flags_value, UINT8);
9205 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9206 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9207 priority, "priority");
9208 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9209 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9210 priority_value, UINT8);
9211 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9212 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9214 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9215 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9218 cmdline_parse_inst_t cmd_2tuple_filter = {
9219 .f = cmd_2tuple_filter_parsed,
9221 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9222 "<value> mask <value> tcp_flags <value> priority <value> queue "
9223 "<queue_id>: Add a 2tuple filter",
9225 (void *)&cmd_2tuple_filter_filter,
9226 (void *)&cmd_2tuple_filter_port_id,
9227 (void *)&cmd_2tuple_filter_ops,
9228 (void *)&cmd_2tuple_filter_dst_port,
9229 (void *)&cmd_2tuple_filter_dst_port_value,
9230 (void *)&cmd_2tuple_filter_protocol,
9231 (void *)&cmd_2tuple_filter_protocol_value,
9232 (void *)&cmd_2tuple_filter_mask,
9233 (void *)&cmd_2tuple_filter_mask_value,
9234 (void *)&cmd_2tuple_filter_tcp_flags,
9235 (void *)&cmd_2tuple_filter_tcp_flags_value,
9236 (void *)&cmd_2tuple_filter_priority,
9237 (void *)&cmd_2tuple_filter_priority_value,
9238 (void *)&cmd_2tuple_filter_queue,
9239 (void *)&cmd_2tuple_filter_queue_id,
9244 /* *** ADD/REMOVE A 5tuple FILTER *** */
9245 struct cmd_5tuple_filter_result {
9246 cmdline_fixed_string_t filter;
9248 cmdline_fixed_string_t ops;
9249 cmdline_fixed_string_t dst_ip;
9250 cmdline_ipaddr_t dst_ip_value;
9251 cmdline_fixed_string_t src_ip;
9252 cmdline_ipaddr_t src_ip_value;
9253 cmdline_fixed_string_t dst_port;
9254 uint16_t dst_port_value;
9255 cmdline_fixed_string_t src_port;
9256 uint16_t src_port_value;
9257 cmdline_fixed_string_t protocol;
9258 uint8_t protocol_value;
9259 cmdline_fixed_string_t mask;
9261 cmdline_fixed_string_t tcp_flags;
9262 uint8_t tcp_flags_value;
9263 cmdline_fixed_string_t priority;
9264 uint8_t priority_value;
9265 cmdline_fixed_string_t queue;
9270 cmd_5tuple_filter_parsed(void *parsed_result,
9271 __attribute__((unused)) struct cmdline *cl,
9272 __attribute__((unused)) void *data)
9274 struct rte_eth_ntuple_filter filter;
9275 struct cmd_5tuple_filter_result *res = parsed_result;
9278 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9280 printf("ntuple filter is not supported on port %u.\n",
9285 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9287 filter.flags = RTE_5TUPLE_FLAGS;
9288 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9289 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9290 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9291 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9292 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9293 filter.proto = res->protocol_value;
9294 filter.priority = res->priority_value;
9295 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9296 printf("nonzero tcp_flags is only meaningful"
9297 " when protocol is TCP.\n");
9300 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9301 printf("invalid TCP flags.\n");
9305 if (res->tcp_flags_value != 0) {
9306 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9307 filter.tcp_flags = res->tcp_flags_value;
9310 if (res->dst_ip_value.family == AF_INET)
9311 /* no need to convert, already big endian. */
9312 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9314 if (filter.dst_ip_mask == 0) {
9315 printf("can not support ipv6 involved compare.\n");
9321 if (res->src_ip_value.family == AF_INET)
9322 /* no need to convert, already big endian. */
9323 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9325 if (filter.src_ip_mask == 0) {
9326 printf("can not support ipv6 involved compare.\n");
9331 /* need convert to big endian. */
9332 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9333 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9334 filter.queue = res->queue_id;
9336 if (!strcmp(res->ops, "add"))
9337 ret = rte_eth_dev_filter_ctrl(res->port_id,
9338 RTE_ETH_FILTER_NTUPLE,
9342 ret = rte_eth_dev_filter_ctrl(res->port_id,
9343 RTE_ETH_FILTER_NTUPLE,
9344 RTE_ETH_FILTER_DELETE,
9347 printf("5tuple filter programming error: (%s)\n",
9351 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9353 filter, "5tuple_filter");
9354 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9355 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9357 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9360 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9361 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9363 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9364 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9366 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9367 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9369 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9370 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9372 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9373 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9374 dst_port, "dst_port");
9375 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9376 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9377 dst_port_value, UINT16);
9378 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9380 src_port, "src_port");
9381 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9383 src_port_value, UINT16);
9384 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9386 protocol, "protocol");
9387 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9388 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9389 protocol_value, UINT8);
9390 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9391 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9393 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9394 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9396 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9397 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9398 tcp_flags, "tcp_flags");
9399 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9400 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9401 tcp_flags_value, UINT8);
9402 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9403 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9404 priority, "priority");
9405 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9406 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9407 priority_value, UINT8);
9408 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9409 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9411 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9412 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9415 cmdline_parse_inst_t cmd_5tuple_filter = {
9416 .f = cmd_5tuple_filter_parsed,
9418 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9419 "src_ip <value> dst_port <value> src_port <value> "
9420 "protocol <value> mask <value> tcp_flags <value> "
9421 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9423 (void *)&cmd_5tuple_filter_filter,
9424 (void *)&cmd_5tuple_filter_port_id,
9425 (void *)&cmd_5tuple_filter_ops,
9426 (void *)&cmd_5tuple_filter_dst_ip,
9427 (void *)&cmd_5tuple_filter_dst_ip_value,
9428 (void *)&cmd_5tuple_filter_src_ip,
9429 (void *)&cmd_5tuple_filter_src_ip_value,
9430 (void *)&cmd_5tuple_filter_dst_port,
9431 (void *)&cmd_5tuple_filter_dst_port_value,
9432 (void *)&cmd_5tuple_filter_src_port,
9433 (void *)&cmd_5tuple_filter_src_port_value,
9434 (void *)&cmd_5tuple_filter_protocol,
9435 (void *)&cmd_5tuple_filter_protocol_value,
9436 (void *)&cmd_5tuple_filter_mask,
9437 (void *)&cmd_5tuple_filter_mask_value,
9438 (void *)&cmd_5tuple_filter_tcp_flags,
9439 (void *)&cmd_5tuple_filter_tcp_flags_value,
9440 (void *)&cmd_5tuple_filter_priority,
9441 (void *)&cmd_5tuple_filter_priority_value,
9442 (void *)&cmd_5tuple_filter_queue,
9443 (void *)&cmd_5tuple_filter_queue_id,
9448 /* *** ADD/REMOVE A flex FILTER *** */
9449 struct cmd_flex_filter_result {
9450 cmdline_fixed_string_t filter;
9451 cmdline_fixed_string_t ops;
9453 cmdline_fixed_string_t len;
9455 cmdline_fixed_string_t bytes;
9456 cmdline_fixed_string_t bytes_value;
9457 cmdline_fixed_string_t mask;
9458 cmdline_fixed_string_t mask_value;
9459 cmdline_fixed_string_t priority;
9460 uint8_t priority_value;
9461 cmdline_fixed_string_t queue;
9465 static int xdigit2val(unsigned char c)
9470 else if (isupper(c))
9478 cmd_flex_filter_parsed(void *parsed_result,
9479 __attribute__((unused)) struct cmdline *cl,
9480 __attribute__((unused)) void *data)
9483 struct rte_eth_flex_filter filter;
9484 struct cmd_flex_filter_result *res = parsed_result;
9485 char *bytes_ptr, *mask_ptr;
9486 uint16_t len, i, j = 0;
9491 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9492 printf("the len exceed the max length 128\n");
9495 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9496 filter.len = res->len_value;
9497 filter.priority = res->priority_value;
9498 filter.queue = res->queue_id;
9499 bytes_ptr = res->bytes_value;
9500 mask_ptr = res->mask_value;
9502 /* translate bytes string to array. */
9503 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9504 (bytes_ptr[1] == 'X')))
9506 len = strnlen(bytes_ptr, res->len_value * 2);
9507 if (len == 0 || (len % 8 != 0)) {
9508 printf("please check len and bytes input\n");
9511 for (i = 0; i < len; i++) {
9513 if (isxdigit(c) == 0) {
9514 /* invalid characters. */
9515 printf("invalid input\n");
9518 val = xdigit2val(c);
9521 filter.bytes[j] = byte;
9522 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9529 /* translate mask string to uint8_t array. */
9530 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9531 (mask_ptr[1] == 'X')))
9533 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9535 printf("invalid input\n");
9540 for (i = 0; i < len; i++) {
9542 if (isxdigit(c) == 0) {
9543 /* invalid characters. */
9544 printf("invalid input\n");
9547 val = xdigit2val(c);
9550 filter.mask[j] = byte;
9551 printf("mask[%d]:%02x ", j, filter.mask[j]);
9559 if (!strcmp(res->ops, "add"))
9560 ret = rte_eth_dev_filter_ctrl(res->port_id,
9561 RTE_ETH_FILTER_FLEXIBLE,
9565 ret = rte_eth_dev_filter_ctrl(res->port_id,
9566 RTE_ETH_FILTER_FLEXIBLE,
9567 RTE_ETH_FILTER_DELETE,
9571 printf("flex filter setting error: (%s)\n", strerror(-ret));
9574 cmdline_parse_token_string_t cmd_flex_filter_filter =
9575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9576 filter, "flex_filter");
9577 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9578 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9580 cmdline_parse_token_string_t cmd_flex_filter_ops =
9581 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9583 cmdline_parse_token_string_t cmd_flex_filter_len =
9584 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9586 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9587 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9589 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9590 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9592 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9593 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9595 cmdline_parse_token_string_t cmd_flex_filter_mask =
9596 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9598 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9599 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9601 cmdline_parse_token_string_t cmd_flex_filter_priority =
9602 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9603 priority, "priority");
9604 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9605 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9606 priority_value, UINT8);
9607 cmdline_parse_token_string_t cmd_flex_filter_queue =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9610 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9611 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9613 cmdline_parse_inst_t cmd_flex_filter = {
9614 .f = cmd_flex_filter_parsed,
9616 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9617 "<value> mask <value> priority <value> queue <queue_id>: "
9618 "Add/Del a flex filter",
9620 (void *)&cmd_flex_filter_filter,
9621 (void *)&cmd_flex_filter_port_id,
9622 (void *)&cmd_flex_filter_ops,
9623 (void *)&cmd_flex_filter_len,
9624 (void *)&cmd_flex_filter_len_value,
9625 (void *)&cmd_flex_filter_bytes,
9626 (void *)&cmd_flex_filter_bytes_value,
9627 (void *)&cmd_flex_filter_mask,
9628 (void *)&cmd_flex_filter_mask_value,
9629 (void *)&cmd_flex_filter_priority,
9630 (void *)&cmd_flex_filter_priority_value,
9631 (void *)&cmd_flex_filter_queue,
9632 (void *)&cmd_flex_filter_queue_id,
9637 /* *** Filters Control *** */
9639 /* *** deal with ethertype filter *** */
9640 struct cmd_ethertype_filter_result {
9641 cmdline_fixed_string_t filter;
9643 cmdline_fixed_string_t ops;
9644 cmdline_fixed_string_t mac;
9645 struct ether_addr mac_addr;
9646 cmdline_fixed_string_t ethertype;
9647 uint16_t ethertype_value;
9648 cmdline_fixed_string_t drop;
9649 cmdline_fixed_string_t queue;
9653 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9655 filter, "ethertype_filter");
9656 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9659 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9660 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9662 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9663 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9664 mac, "mac_addr#mac_ignr");
9665 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9668 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9669 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9670 ethertype, "ethertype");
9671 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9672 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9673 ethertype_value, UINT16);
9674 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9675 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9677 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9678 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9680 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9681 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9685 cmd_ethertype_filter_parsed(void *parsed_result,
9686 __attribute__((unused)) struct cmdline *cl,
9687 __attribute__((unused)) void *data)
9689 struct cmd_ethertype_filter_result *res = parsed_result;
9690 struct rte_eth_ethertype_filter filter;
9693 ret = rte_eth_dev_filter_supported(res->port_id,
9694 RTE_ETH_FILTER_ETHERTYPE);
9696 printf("ethertype filter is not supported on port %u.\n",
9701 memset(&filter, 0, sizeof(filter));
9702 if (!strcmp(res->mac, "mac_addr")) {
9703 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9704 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9705 sizeof(struct ether_addr));
9707 if (!strcmp(res->drop, "drop"))
9708 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9709 filter.ether_type = res->ethertype_value;
9710 filter.queue = res->queue_id;
9712 if (!strcmp(res->ops, "add"))
9713 ret = rte_eth_dev_filter_ctrl(res->port_id,
9714 RTE_ETH_FILTER_ETHERTYPE,
9718 ret = rte_eth_dev_filter_ctrl(res->port_id,
9719 RTE_ETH_FILTER_ETHERTYPE,
9720 RTE_ETH_FILTER_DELETE,
9723 printf("ethertype filter programming error: (%s)\n",
9727 cmdline_parse_inst_t cmd_ethertype_filter = {
9728 .f = cmd_ethertype_filter_parsed,
9730 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9731 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9732 "Add or delete an ethertype filter entry",
9734 (void *)&cmd_ethertype_filter_filter,
9735 (void *)&cmd_ethertype_filter_port_id,
9736 (void *)&cmd_ethertype_filter_ops,
9737 (void *)&cmd_ethertype_filter_mac,
9738 (void *)&cmd_ethertype_filter_mac_addr,
9739 (void *)&cmd_ethertype_filter_ethertype,
9740 (void *)&cmd_ethertype_filter_ethertype_value,
9741 (void *)&cmd_ethertype_filter_drop,
9742 (void *)&cmd_ethertype_filter_queue,
9743 (void *)&cmd_ethertype_filter_queue_id,
9748 /* *** deal with flow director filter *** */
9749 struct cmd_flow_director_result {
9750 cmdline_fixed_string_t flow_director_filter;
9752 cmdline_fixed_string_t mode;
9753 cmdline_fixed_string_t mode_value;
9754 cmdline_fixed_string_t ops;
9755 cmdline_fixed_string_t flow;
9756 cmdline_fixed_string_t flow_type;
9757 cmdline_fixed_string_t ether;
9758 uint16_t ether_type;
9759 cmdline_fixed_string_t src;
9760 cmdline_ipaddr_t ip_src;
9762 cmdline_fixed_string_t dst;
9763 cmdline_ipaddr_t ip_dst;
9765 cmdline_fixed_string_t verify_tag;
9766 uint32_t verify_tag_value;
9767 cmdline_ipaddr_t tos;
9769 cmdline_ipaddr_t proto;
9770 uint8_t proto_value;
9771 cmdline_ipaddr_t ttl;
9773 cmdline_fixed_string_t vlan;
9774 uint16_t vlan_value;
9775 cmdline_fixed_string_t flexbytes;
9776 cmdline_fixed_string_t flexbytes_value;
9777 cmdline_fixed_string_t pf_vf;
9778 cmdline_fixed_string_t drop;
9779 cmdline_fixed_string_t queue;
9781 cmdline_fixed_string_t fd_id;
9782 uint32_t fd_id_value;
9783 cmdline_fixed_string_t mac;
9784 struct ether_addr mac_addr;
9785 cmdline_fixed_string_t tunnel;
9786 cmdline_fixed_string_t tunnel_type;
9787 cmdline_fixed_string_t tunnel_id;
9788 uint32_t tunnel_id_value;
9792 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9795 const char *p, *p0 = q_arg;
9797 unsigned long int_fld;
9798 char *str_fld[max_num];
9803 p = strchr(p0, '(');
9807 p0 = strchr(p, ')');
9812 if (size >= sizeof(s))
9815 snprintf(s, sizeof(s), "%.*s", size, p);
9816 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9817 if (ret < 0 || ret > max_num)
9819 for (i = 0; i < ret; i++) {
9821 int_fld = strtoul(str_fld[i], &end, 0);
9822 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9824 flexbytes[i] = (uint8_t)int_fld;
9830 str2flowtype(char *string)
9833 static const struct {
9836 } flowtype_str[] = {
9837 {"raw", RTE_ETH_FLOW_RAW},
9838 {"ipv4", RTE_ETH_FLOW_IPV4},
9839 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9840 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9841 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9842 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9843 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9844 {"ipv6", RTE_ETH_FLOW_IPV6},
9845 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9846 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9847 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9848 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9849 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9850 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9853 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9854 if (!strcmp(flowtype_str[i].str, string))
9855 return flowtype_str[i].type;
9858 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9859 return (uint16_t)atoi(string);
9861 return RTE_ETH_FLOW_UNKNOWN;
9864 static enum rte_eth_fdir_tunnel_type
9865 str2fdir_tunneltype(char *string)
9869 static const struct {
9871 enum rte_eth_fdir_tunnel_type type;
9872 } tunneltype_str[] = {
9873 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9874 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9877 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9878 if (!strcmp(tunneltype_str[i].str, string))
9879 return tunneltype_str[i].type;
9881 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9884 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9886 if ((ip_addr).family == AF_INET) \
9887 (ip) = (ip_addr).addr.ipv4.s_addr; \
9889 printf("invalid parameter.\n"); \
9894 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9896 if ((ip_addr).family == AF_INET6) \
9898 &((ip_addr).addr.ipv6), \
9899 sizeof(struct in6_addr)); \
9901 printf("invalid parameter.\n"); \
9907 cmd_flow_director_filter_parsed(void *parsed_result,
9908 __attribute__((unused)) struct cmdline *cl,
9909 __attribute__((unused)) void *data)
9911 struct cmd_flow_director_result *res = parsed_result;
9912 struct rte_eth_fdir_filter entry;
9913 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9915 unsigned long vf_id;
9918 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9920 printf("flow director is not supported on port %u.\n",
9924 memset(flexbytes, 0, sizeof(flexbytes));
9925 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9927 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9928 if (strcmp(res->mode_value, "MAC-VLAN")) {
9929 printf("Please set mode to MAC-VLAN.\n");
9932 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9933 if (strcmp(res->mode_value, "Tunnel")) {
9934 printf("Please set mode to Tunnel.\n");
9938 if (strcmp(res->mode_value, "IP")) {
9939 printf("Please set mode to IP.\n");
9942 entry.input.flow_type = str2flowtype(res->flow_type);
9945 ret = parse_flexbytes(res->flexbytes_value,
9947 RTE_ETH_FDIR_MAX_FLEXLEN);
9949 printf("error: Cannot parse flexbytes input.\n");
9953 switch (entry.input.flow_type) {
9954 case RTE_ETH_FLOW_FRAG_IPV4:
9955 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9956 entry.input.flow.ip4_flow.proto = res->proto_value;
9958 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9959 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9960 IPV4_ADDR_TO_UINT(res->ip_dst,
9961 entry.input.flow.ip4_flow.dst_ip);
9962 IPV4_ADDR_TO_UINT(res->ip_src,
9963 entry.input.flow.ip4_flow.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.udp4_flow.dst_port =
9968 rte_cpu_to_be_16(res->port_dst);
9969 entry.input.flow.udp4_flow.src_port =
9970 rte_cpu_to_be_16(res->port_src);
9972 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9973 IPV4_ADDR_TO_UINT(res->ip_dst,
9974 entry.input.flow.sctp4_flow.ip.dst_ip);
9975 IPV4_ADDR_TO_UINT(res->ip_src,
9976 entry.input.flow.sctp4_flow.ip.src_ip);
9977 entry.input.flow.ip4_flow.tos = res->tos_value;
9978 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9979 /* need convert to big endian. */
9980 entry.input.flow.sctp4_flow.dst_port =
9981 rte_cpu_to_be_16(res->port_dst);
9982 entry.input.flow.sctp4_flow.src_port =
9983 rte_cpu_to_be_16(res->port_src);
9984 entry.input.flow.sctp4_flow.verify_tag =
9985 rte_cpu_to_be_32(res->verify_tag_value);
9987 case RTE_ETH_FLOW_FRAG_IPV6:
9988 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9989 entry.input.flow.ipv6_flow.proto = res->proto_value;
9991 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9992 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9993 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9994 entry.input.flow.ipv6_flow.dst_ip);
9995 IPV6_ADDR_TO_ARRAY(res->ip_src,
9996 entry.input.flow.ipv6_flow.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.udp6_flow.dst_port =
10001 rte_cpu_to_be_16(res->port_dst);
10002 entry.input.flow.udp6_flow.src_port =
10003 rte_cpu_to_be_16(res->port_src);
10005 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10006 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10007 entry.input.flow.sctp6_flow.ip.dst_ip);
10008 IPV6_ADDR_TO_ARRAY(res->ip_src,
10009 entry.input.flow.sctp6_flow.ip.src_ip);
10010 entry.input.flow.ipv6_flow.tc = res->tos_value;
10011 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10012 /* need convert to big endian. */
10013 entry.input.flow.sctp6_flow.dst_port =
10014 rte_cpu_to_be_16(res->port_dst);
10015 entry.input.flow.sctp6_flow.src_port =
10016 rte_cpu_to_be_16(res->port_src);
10017 entry.input.flow.sctp6_flow.verify_tag =
10018 rte_cpu_to_be_32(res->verify_tag_value);
10020 case RTE_ETH_FLOW_L2_PAYLOAD:
10021 entry.input.flow.l2_flow.ether_type =
10022 rte_cpu_to_be_16(res->ether_type);
10028 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10029 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10031 sizeof(struct ether_addr));
10033 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10034 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10036 sizeof(struct ether_addr));
10037 entry.input.flow.tunnel_flow.tunnel_type =
10038 str2fdir_tunneltype(res->tunnel_type);
10039 entry.input.flow.tunnel_flow.tunnel_id =
10040 rte_cpu_to_be_32(res->tunnel_id_value);
10043 rte_memcpy(entry.input.flow_ext.flexbytes,
10045 RTE_ETH_FDIR_MAX_FLEXLEN);
10047 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10049 entry.action.flex_off = 0; /*use 0 by default */
10050 if (!strcmp(res->drop, "drop"))
10051 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10053 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10055 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10056 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10057 if (!strcmp(res->pf_vf, "pf"))
10058 entry.input.flow_ext.is_vf = 0;
10059 else if (!strncmp(res->pf_vf, "vf", 2)) {
10060 struct rte_eth_dev_info dev_info;
10062 memset(&dev_info, 0, sizeof(dev_info));
10063 rte_eth_dev_info_get(res->port_id, &dev_info);
10065 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10066 if (errno != 0 || *end != '\0' ||
10067 vf_id >= dev_info.max_vfs) {
10068 printf("invalid parameter %s.\n", res->pf_vf);
10071 entry.input.flow_ext.is_vf = 1;
10072 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10074 printf("invalid parameter %s.\n", res->pf_vf);
10079 /* set to report FD ID by default */
10080 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10081 entry.action.rx_queue = res->queue_id;
10082 entry.soft_id = res->fd_id_value;
10083 if (!strcmp(res->ops, "add"))
10084 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10085 RTE_ETH_FILTER_ADD, &entry);
10086 else if (!strcmp(res->ops, "del"))
10087 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10088 RTE_ETH_FILTER_DELETE, &entry);
10090 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10091 RTE_ETH_FILTER_UPDATE, &entry);
10093 printf("flow director programming error: (%s)\n",
10097 cmdline_parse_token_string_t cmd_flow_director_filter =
10098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10099 flow_director_filter, "flow_director_filter");
10100 cmdline_parse_token_num_t cmd_flow_director_port_id =
10101 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10103 cmdline_parse_token_string_t cmd_flow_director_ops =
10104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10105 ops, "add#del#update");
10106 cmdline_parse_token_string_t cmd_flow_director_flow =
10107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10109 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10110 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10111 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10112 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10113 cmdline_parse_token_string_t cmd_flow_director_ether =
10114 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10116 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10117 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10118 ether_type, UINT16);
10119 cmdline_parse_token_string_t cmd_flow_director_src =
10120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10122 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10123 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10125 cmdline_parse_token_num_t cmd_flow_director_port_src =
10126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10128 cmdline_parse_token_string_t cmd_flow_director_dst =
10129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10131 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10132 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10134 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10135 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10137 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10139 verify_tag, "verify_tag");
10140 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10142 verify_tag_value, UINT32);
10143 cmdline_parse_token_string_t cmd_flow_director_tos =
10144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10146 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10147 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10149 cmdline_parse_token_string_t cmd_flow_director_proto =
10150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10152 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10153 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10154 proto_value, UINT8);
10155 cmdline_parse_token_string_t cmd_flow_director_ttl =
10156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10158 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10159 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10161 cmdline_parse_token_string_t cmd_flow_director_vlan =
10162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10164 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10165 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10166 vlan_value, UINT16);
10167 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10169 flexbytes, "flexbytes");
10170 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10172 flexbytes_value, NULL);
10173 cmdline_parse_token_string_t cmd_flow_director_drop =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10176 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10179 cmdline_parse_token_string_t cmd_flow_director_queue =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10182 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10183 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10185 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10188 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10189 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10190 fd_id_value, UINT32);
10192 cmdline_parse_token_string_t cmd_flow_director_mode =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10195 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10198 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10200 mode_value, "MAC-VLAN");
10201 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10203 mode_value, "Tunnel");
10204 cmdline_parse_token_string_t cmd_flow_director_mac =
10205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10207 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10208 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10210 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10213 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10215 tunnel_type, "NVGRE#VxLAN");
10216 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10218 tunnel_id, "tunnel-id");
10219 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10220 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10221 tunnel_id_value, UINT32);
10223 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10224 .f = cmd_flow_director_filter_parsed,
10226 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10227 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10228 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10229 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10230 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10231 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10232 "fd_id <fd_id_value>: "
10233 "Add or delete an ip flow director entry on NIC",
10235 (void *)&cmd_flow_director_filter,
10236 (void *)&cmd_flow_director_port_id,
10237 (void *)&cmd_flow_director_mode,
10238 (void *)&cmd_flow_director_mode_ip,
10239 (void *)&cmd_flow_director_ops,
10240 (void *)&cmd_flow_director_flow,
10241 (void *)&cmd_flow_director_flow_type,
10242 (void *)&cmd_flow_director_src,
10243 (void *)&cmd_flow_director_ip_src,
10244 (void *)&cmd_flow_director_dst,
10245 (void *)&cmd_flow_director_ip_dst,
10246 (void *)&cmd_flow_director_tos,
10247 (void *)&cmd_flow_director_tos_value,
10248 (void *)&cmd_flow_director_proto,
10249 (void *)&cmd_flow_director_proto_value,
10250 (void *)&cmd_flow_director_ttl,
10251 (void *)&cmd_flow_director_ttl_value,
10252 (void *)&cmd_flow_director_vlan,
10253 (void *)&cmd_flow_director_vlan_value,
10254 (void *)&cmd_flow_director_flexbytes,
10255 (void *)&cmd_flow_director_flexbytes_value,
10256 (void *)&cmd_flow_director_drop,
10257 (void *)&cmd_flow_director_pf_vf,
10258 (void *)&cmd_flow_director_queue,
10259 (void *)&cmd_flow_director_queue_id,
10260 (void *)&cmd_flow_director_fd_id,
10261 (void *)&cmd_flow_director_fd_id_value,
10266 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10267 .f = cmd_flow_director_filter_parsed,
10269 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10270 "director entry on NIC",
10272 (void *)&cmd_flow_director_filter,
10273 (void *)&cmd_flow_director_port_id,
10274 (void *)&cmd_flow_director_mode,
10275 (void *)&cmd_flow_director_mode_ip,
10276 (void *)&cmd_flow_director_ops,
10277 (void *)&cmd_flow_director_flow,
10278 (void *)&cmd_flow_director_flow_type,
10279 (void *)&cmd_flow_director_src,
10280 (void *)&cmd_flow_director_ip_src,
10281 (void *)&cmd_flow_director_port_src,
10282 (void *)&cmd_flow_director_dst,
10283 (void *)&cmd_flow_director_ip_dst,
10284 (void *)&cmd_flow_director_port_dst,
10285 (void *)&cmd_flow_director_tos,
10286 (void *)&cmd_flow_director_tos_value,
10287 (void *)&cmd_flow_director_ttl,
10288 (void *)&cmd_flow_director_ttl_value,
10289 (void *)&cmd_flow_director_vlan,
10290 (void *)&cmd_flow_director_vlan_value,
10291 (void *)&cmd_flow_director_flexbytes,
10292 (void *)&cmd_flow_director_flexbytes_value,
10293 (void *)&cmd_flow_director_drop,
10294 (void *)&cmd_flow_director_pf_vf,
10295 (void *)&cmd_flow_director_queue,
10296 (void *)&cmd_flow_director_queue_id,
10297 (void *)&cmd_flow_director_fd_id,
10298 (void *)&cmd_flow_director_fd_id_value,
10303 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10304 .f = cmd_flow_director_filter_parsed,
10306 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10307 "director entry on NIC",
10309 (void *)&cmd_flow_director_filter,
10310 (void *)&cmd_flow_director_port_id,
10311 (void *)&cmd_flow_director_mode,
10312 (void *)&cmd_flow_director_mode_ip,
10313 (void *)&cmd_flow_director_ops,
10314 (void *)&cmd_flow_director_flow,
10315 (void *)&cmd_flow_director_flow_type,
10316 (void *)&cmd_flow_director_src,
10317 (void *)&cmd_flow_director_ip_src,
10318 (void *)&cmd_flow_director_port_dst,
10319 (void *)&cmd_flow_director_dst,
10320 (void *)&cmd_flow_director_ip_dst,
10321 (void *)&cmd_flow_director_port_dst,
10322 (void *)&cmd_flow_director_verify_tag,
10323 (void *)&cmd_flow_director_verify_tag_value,
10324 (void *)&cmd_flow_director_tos,
10325 (void *)&cmd_flow_director_tos_value,
10326 (void *)&cmd_flow_director_ttl,
10327 (void *)&cmd_flow_director_ttl_value,
10328 (void *)&cmd_flow_director_vlan,
10329 (void *)&cmd_flow_director_vlan_value,
10330 (void *)&cmd_flow_director_flexbytes,
10331 (void *)&cmd_flow_director_flexbytes_value,
10332 (void *)&cmd_flow_director_drop,
10333 (void *)&cmd_flow_director_pf_vf,
10334 (void *)&cmd_flow_director_queue,
10335 (void *)&cmd_flow_director_queue_id,
10336 (void *)&cmd_flow_director_fd_id,
10337 (void *)&cmd_flow_director_fd_id_value,
10342 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10343 .f = cmd_flow_director_filter_parsed,
10345 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10346 "director entry on NIC",
10348 (void *)&cmd_flow_director_filter,
10349 (void *)&cmd_flow_director_port_id,
10350 (void *)&cmd_flow_director_mode,
10351 (void *)&cmd_flow_director_mode_ip,
10352 (void *)&cmd_flow_director_ops,
10353 (void *)&cmd_flow_director_flow,
10354 (void *)&cmd_flow_director_flow_type,
10355 (void *)&cmd_flow_director_ether,
10356 (void *)&cmd_flow_director_ether_type,
10357 (void *)&cmd_flow_director_flexbytes,
10358 (void *)&cmd_flow_director_flexbytes_value,
10359 (void *)&cmd_flow_director_drop,
10360 (void *)&cmd_flow_director_pf_vf,
10361 (void *)&cmd_flow_director_queue,
10362 (void *)&cmd_flow_director_queue_id,
10363 (void *)&cmd_flow_director_fd_id,
10364 (void *)&cmd_flow_director_fd_id_value,
10369 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10370 .f = cmd_flow_director_filter_parsed,
10372 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10373 "director entry on NIC",
10375 (void *)&cmd_flow_director_filter,
10376 (void *)&cmd_flow_director_port_id,
10377 (void *)&cmd_flow_director_mode,
10378 (void *)&cmd_flow_director_mode_mac_vlan,
10379 (void *)&cmd_flow_director_ops,
10380 (void *)&cmd_flow_director_mac,
10381 (void *)&cmd_flow_director_mac_addr,
10382 (void *)&cmd_flow_director_vlan,
10383 (void *)&cmd_flow_director_vlan_value,
10384 (void *)&cmd_flow_director_flexbytes,
10385 (void *)&cmd_flow_director_flexbytes_value,
10386 (void *)&cmd_flow_director_drop,
10387 (void *)&cmd_flow_director_queue,
10388 (void *)&cmd_flow_director_queue_id,
10389 (void *)&cmd_flow_director_fd_id,
10390 (void *)&cmd_flow_director_fd_id_value,
10395 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10396 .f = cmd_flow_director_filter_parsed,
10398 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10399 "director entry on NIC",
10401 (void *)&cmd_flow_director_filter,
10402 (void *)&cmd_flow_director_port_id,
10403 (void *)&cmd_flow_director_mode,
10404 (void *)&cmd_flow_director_mode_tunnel,
10405 (void *)&cmd_flow_director_ops,
10406 (void *)&cmd_flow_director_mac,
10407 (void *)&cmd_flow_director_mac_addr,
10408 (void *)&cmd_flow_director_vlan,
10409 (void *)&cmd_flow_director_vlan_value,
10410 (void *)&cmd_flow_director_tunnel,
10411 (void *)&cmd_flow_director_tunnel_type,
10412 (void *)&cmd_flow_director_tunnel_id,
10413 (void *)&cmd_flow_director_tunnel_id_value,
10414 (void *)&cmd_flow_director_flexbytes,
10415 (void *)&cmd_flow_director_flexbytes_value,
10416 (void *)&cmd_flow_director_drop,
10417 (void *)&cmd_flow_director_queue,
10418 (void *)&cmd_flow_director_queue_id,
10419 (void *)&cmd_flow_director_fd_id,
10420 (void *)&cmd_flow_director_fd_id_value,
10425 struct cmd_flush_flow_director_result {
10426 cmdline_fixed_string_t flush_flow_director;
10430 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10432 flush_flow_director, "flush_flow_director");
10433 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10434 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10438 cmd_flush_flow_director_parsed(void *parsed_result,
10439 __attribute__((unused)) struct cmdline *cl,
10440 __attribute__((unused)) void *data)
10442 struct cmd_flow_director_result *res = parsed_result;
10445 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10447 printf("flow director is not supported on port %u.\n",
10452 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10453 RTE_ETH_FILTER_FLUSH, NULL);
10455 printf("flow director table flushing error: (%s)\n",
10459 cmdline_parse_inst_t cmd_flush_flow_director = {
10460 .f = cmd_flush_flow_director_parsed,
10462 .help_str = "flush_flow_director <port_id>: "
10463 "Flush all flow director entries of a device on NIC",
10465 (void *)&cmd_flush_flow_director_flush,
10466 (void *)&cmd_flush_flow_director_port_id,
10471 /* *** deal with flow director mask *** */
10472 struct cmd_flow_director_mask_result {
10473 cmdline_fixed_string_t flow_director_mask;
10475 cmdline_fixed_string_t mode;
10476 cmdline_fixed_string_t mode_value;
10477 cmdline_fixed_string_t vlan;
10478 uint16_t vlan_mask;
10479 cmdline_fixed_string_t src_mask;
10480 cmdline_ipaddr_t ipv4_src;
10481 cmdline_ipaddr_t ipv6_src;
10483 cmdline_fixed_string_t dst_mask;
10484 cmdline_ipaddr_t ipv4_dst;
10485 cmdline_ipaddr_t ipv6_dst;
10487 cmdline_fixed_string_t mac;
10488 uint8_t mac_addr_byte_mask;
10489 cmdline_fixed_string_t tunnel_id;
10490 uint32_t tunnel_id_mask;
10491 cmdline_fixed_string_t tunnel_type;
10492 uint8_t tunnel_type_mask;
10496 cmd_flow_director_mask_parsed(void *parsed_result,
10497 __attribute__((unused)) struct cmdline *cl,
10498 __attribute__((unused)) void *data)
10500 struct cmd_flow_director_mask_result *res = parsed_result;
10501 struct rte_eth_fdir_masks *mask;
10502 struct rte_port *port;
10504 if (res->port_id > nb_ports) {
10505 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10509 port = &ports[res->port_id];
10510 /** Check if the port is not started **/
10511 if (port->port_status != RTE_PORT_STOPPED) {
10512 printf("Please stop port %d first\n", res->port_id);
10516 mask = &port->dev_conf.fdir_conf.mask;
10518 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10519 if (strcmp(res->mode_value, "MAC-VLAN")) {
10520 printf("Please set mode to MAC-VLAN.\n");
10524 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10525 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10526 if (strcmp(res->mode_value, "Tunnel")) {
10527 printf("Please set mode to Tunnel.\n");
10531 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10532 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10533 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10534 mask->tunnel_type_mask = res->tunnel_type_mask;
10536 if (strcmp(res->mode_value, "IP")) {
10537 printf("Please set mode to IP.\n");
10541 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10542 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10543 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10544 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10545 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10546 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10547 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10550 cmd_reconfig_device_queue(res->port_id, 1, 1);
10553 cmdline_parse_token_string_t cmd_flow_director_mask =
10554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10555 flow_director_mask, "flow_director_mask");
10556 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10557 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10559 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10562 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10563 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10564 vlan_mask, UINT16);
10565 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10567 src_mask, "src_mask");
10568 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10569 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10571 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10572 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10574 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10575 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10577 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10578 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10579 dst_mask, "dst_mask");
10580 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10581 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10583 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10584 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10586 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10587 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10590 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10593 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10596 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10598 mode_value, "MAC-VLAN");
10599 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10601 mode_value, "Tunnel");
10602 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10605 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10606 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10607 mac_addr_byte_mask, UINT8);
10608 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10610 tunnel_type, "tunnel-type");
10611 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10613 tunnel_type_mask, UINT8);
10614 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10616 tunnel_id, "tunnel-id");
10617 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10619 tunnel_id_mask, UINT32);
10621 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10622 .f = cmd_flow_director_mask_parsed,
10624 .help_str = "flow_director_mask ... : "
10625 "Set IP mode flow director's mask on NIC",
10627 (void *)&cmd_flow_director_mask,
10628 (void *)&cmd_flow_director_mask_port_id,
10629 (void *)&cmd_flow_director_mask_mode,
10630 (void *)&cmd_flow_director_mask_mode_ip,
10631 (void *)&cmd_flow_director_mask_vlan,
10632 (void *)&cmd_flow_director_mask_vlan_value,
10633 (void *)&cmd_flow_director_mask_src,
10634 (void *)&cmd_flow_director_mask_ipv4_src,
10635 (void *)&cmd_flow_director_mask_ipv6_src,
10636 (void *)&cmd_flow_director_mask_port_src,
10637 (void *)&cmd_flow_director_mask_dst,
10638 (void *)&cmd_flow_director_mask_ipv4_dst,
10639 (void *)&cmd_flow_director_mask_ipv6_dst,
10640 (void *)&cmd_flow_director_mask_port_dst,
10645 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10646 .f = cmd_flow_director_mask_parsed,
10648 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10649 "flow director's mask on NIC",
10651 (void *)&cmd_flow_director_mask,
10652 (void *)&cmd_flow_director_mask_port_id,
10653 (void *)&cmd_flow_director_mask_mode,
10654 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10655 (void *)&cmd_flow_director_mask_vlan,
10656 (void *)&cmd_flow_director_mask_vlan_value,
10661 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10662 .f = cmd_flow_director_mask_parsed,
10664 .help_str = "flow_director_mask ... : Set tunnel mode "
10665 "flow director's mask on NIC",
10667 (void *)&cmd_flow_director_mask,
10668 (void *)&cmd_flow_director_mask_port_id,
10669 (void *)&cmd_flow_director_mask_mode,
10670 (void *)&cmd_flow_director_mask_mode_tunnel,
10671 (void *)&cmd_flow_director_mask_vlan,
10672 (void *)&cmd_flow_director_mask_vlan_value,
10673 (void *)&cmd_flow_director_mask_mac,
10674 (void *)&cmd_flow_director_mask_mac_value,
10675 (void *)&cmd_flow_director_mask_tunnel_type,
10676 (void *)&cmd_flow_director_mask_tunnel_type_value,
10677 (void *)&cmd_flow_director_mask_tunnel_id,
10678 (void *)&cmd_flow_director_mask_tunnel_id_value,
10683 /* *** deal with flow director mask on flexible payload *** */
10684 struct cmd_flow_director_flex_mask_result {
10685 cmdline_fixed_string_t flow_director_flexmask;
10687 cmdline_fixed_string_t flow;
10688 cmdline_fixed_string_t flow_type;
10689 cmdline_fixed_string_t mask;
10693 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10694 __attribute__((unused)) struct cmdline *cl,
10695 __attribute__((unused)) void *data)
10697 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10698 struct rte_eth_fdir_info fdir_info;
10699 struct rte_eth_fdir_flex_mask flex_mask;
10700 struct rte_port *port;
10701 uint32_t flow_type_mask;
10705 if (res->port_id > nb_ports) {
10706 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10710 port = &ports[res->port_id];
10711 /** Check if the port is not started **/
10712 if (port->port_status != RTE_PORT_STOPPED) {
10713 printf("Please stop port %d first\n", res->port_id);
10717 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10718 ret = parse_flexbytes(res->mask,
10720 RTE_ETH_FDIR_MAX_FLEXLEN);
10722 printf("error: Cannot parse mask input.\n");
10726 memset(&fdir_info, 0, sizeof(fdir_info));
10727 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10728 RTE_ETH_FILTER_INFO, &fdir_info);
10730 printf("Cannot get FDir filter info\n");
10734 if (!strcmp(res->flow_type, "none")) {
10735 /* means don't specify the flow type */
10736 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10737 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10738 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10739 0, sizeof(struct rte_eth_fdir_flex_mask));
10740 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10741 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10743 sizeof(struct rte_eth_fdir_flex_mask));
10744 cmd_reconfig_device_queue(res->port_id, 1, 1);
10747 flow_type_mask = fdir_info.flow_types_mask[0];
10748 if (!strcmp(res->flow_type, "all")) {
10749 if (!flow_type_mask) {
10750 printf("No flow type supported\n");
10753 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10754 if (flow_type_mask & (1 << i)) {
10755 flex_mask.flow_type = i;
10756 fdir_set_flex_mask(res->port_id, &flex_mask);
10759 cmd_reconfig_device_queue(res->port_id, 1, 1);
10762 flex_mask.flow_type = str2flowtype(res->flow_type);
10763 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10764 printf("Flow type %s not supported on port %d\n",
10765 res->flow_type, res->port_id);
10768 fdir_set_flex_mask(res->port_id, &flex_mask);
10769 cmd_reconfig_device_queue(res->port_id, 1, 1);
10772 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10774 flow_director_flexmask,
10775 "flow_director_flex_mask");
10776 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10777 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10779 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10782 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10783 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10784 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10785 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10786 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10790 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10791 .f = cmd_flow_director_flex_mask_parsed,
10793 .help_str = "flow_director_flex_mask ... : "
10794 "Set flow director's flex mask on NIC",
10796 (void *)&cmd_flow_director_flexmask,
10797 (void *)&cmd_flow_director_flexmask_port_id,
10798 (void *)&cmd_flow_director_flexmask_flow,
10799 (void *)&cmd_flow_director_flexmask_flow_type,
10800 (void *)&cmd_flow_director_flexmask_mask,
10805 /* *** deal with flow director flexible payload configuration *** */
10806 struct cmd_flow_director_flexpayload_result {
10807 cmdline_fixed_string_t flow_director_flexpayload;
10809 cmdline_fixed_string_t payload_layer;
10810 cmdline_fixed_string_t payload_cfg;
10814 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10817 const char *p, *p0 = q_arg;
10819 unsigned long int_fld;
10820 char *str_fld[max_num];
10825 p = strchr(p0, '(');
10829 p0 = strchr(p, ')');
10834 if (size >= sizeof(s))
10837 snprintf(s, sizeof(s), "%.*s", size, p);
10838 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10839 if (ret < 0 || ret > max_num)
10841 for (i = 0; i < ret; i++) {
10843 int_fld = strtoul(str_fld[i], &end, 0);
10844 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10846 offsets[i] = (uint16_t)int_fld;
10852 cmd_flow_director_flxpld_parsed(void *parsed_result,
10853 __attribute__((unused)) struct cmdline *cl,
10854 __attribute__((unused)) void *data)
10856 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10857 struct rte_eth_flex_payload_cfg flex_cfg;
10858 struct rte_port *port;
10861 if (res->port_id > nb_ports) {
10862 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10866 port = &ports[res->port_id];
10867 /** Check if the port is not started **/
10868 if (port->port_status != RTE_PORT_STOPPED) {
10869 printf("Please stop port %d first\n", res->port_id);
10873 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10875 if (!strcmp(res->payload_layer, "raw"))
10876 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10877 else if (!strcmp(res->payload_layer, "l2"))
10878 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10879 else if (!strcmp(res->payload_layer, "l3"))
10880 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10881 else if (!strcmp(res->payload_layer, "l4"))
10882 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10884 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10885 RTE_ETH_FDIR_MAX_FLEXLEN);
10887 printf("error: Cannot parse flex payload input.\n");
10891 fdir_set_flex_payload(res->port_id, &flex_cfg);
10892 cmd_reconfig_device_queue(res->port_id, 1, 1);
10895 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10896 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10897 flow_director_flexpayload,
10898 "flow_director_flex_payload");
10899 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10900 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10902 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10903 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10904 payload_layer, "raw#l2#l3#l4");
10905 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10907 payload_cfg, NULL);
10909 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10910 .f = cmd_flow_director_flxpld_parsed,
10912 .help_str = "flow_director_flexpayload ... : "
10913 "Set flow director's flex payload on NIC",
10915 (void *)&cmd_flow_director_flexpayload,
10916 (void *)&cmd_flow_director_flexpayload_port_id,
10917 (void *)&cmd_flow_director_flexpayload_payload_layer,
10918 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10923 /* Generic flow interface command. */
10924 extern cmdline_parse_inst_t cmd_flow;
10926 /* *** Classification Filters Control *** */
10927 /* *** Get symmetric hash enable per port *** */
10928 struct cmd_get_sym_hash_ena_per_port_result {
10929 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10934 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10935 __rte_unused struct cmdline *cl,
10936 __rte_unused void *data)
10938 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10939 struct rte_eth_hash_filter_info info;
10942 if (rte_eth_dev_filter_supported(res->port_id,
10943 RTE_ETH_FILTER_HASH) < 0) {
10944 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10949 memset(&info, 0, sizeof(info));
10950 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10951 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10952 RTE_ETH_FILTER_GET, &info);
10955 printf("Cannot get symmetric hash enable per port "
10956 "on port %u\n", res->port_id);
10960 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10961 "enabled" : "disabled", res->port_id);
10964 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10965 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10966 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10967 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10968 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10971 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10972 .f = cmd_get_sym_hash_per_port_parsed,
10974 .help_str = "get_sym_hash_ena_per_port <port_id>",
10976 (void *)&cmd_get_sym_hash_ena_per_port_all,
10977 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10982 /* *** Set symmetric hash enable per port *** */
10983 struct cmd_set_sym_hash_ena_per_port_result {
10984 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10985 cmdline_fixed_string_t enable;
10990 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10991 __rte_unused struct cmdline *cl,
10992 __rte_unused void *data)
10994 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10995 struct rte_eth_hash_filter_info info;
10998 if (rte_eth_dev_filter_supported(res->port_id,
10999 RTE_ETH_FILTER_HASH) < 0) {
11000 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11005 memset(&info, 0, sizeof(info));
11006 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11007 if (!strcmp(res->enable, "enable"))
11008 info.info.enable = 1;
11009 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11010 RTE_ETH_FILTER_SET, &info);
11012 printf("Cannot set symmetric hash enable per port on "
11013 "port %u\n", res->port_id);
11016 printf("Symmetric hash has been set to %s on port %u\n",
11017 res->enable, res->port_id);
11020 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11021 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11022 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11023 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11024 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11026 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11027 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11028 enable, "enable#disable");
11030 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11031 .f = cmd_set_sym_hash_per_port_parsed,
11033 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11035 (void *)&cmd_set_sym_hash_ena_per_port_all,
11036 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11037 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11042 /* Get global config of hash function */
11043 struct cmd_get_hash_global_config_result {
11044 cmdline_fixed_string_t get_hash_global_config;
11049 flowtype_to_str(uint16_t ftype)
11055 } ftype_table[] = {
11056 {"ipv4", RTE_ETH_FLOW_IPV4},
11057 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11058 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11059 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11060 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11061 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11062 {"ipv6", RTE_ETH_FLOW_IPV6},
11063 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11064 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11065 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11066 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11067 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11068 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11069 {"port", RTE_ETH_FLOW_PORT},
11070 {"vxlan", RTE_ETH_FLOW_VXLAN},
11071 {"geneve", RTE_ETH_FLOW_GENEVE},
11072 {"nvgre", RTE_ETH_FLOW_NVGRE},
11075 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11076 if (ftype_table[i].ftype == ftype)
11077 return ftype_table[i].str;
11084 cmd_get_hash_global_config_parsed(void *parsed_result,
11085 __rte_unused struct cmdline *cl,
11086 __rte_unused void *data)
11088 struct cmd_get_hash_global_config_result *res = parsed_result;
11089 struct rte_eth_hash_filter_info info;
11090 uint32_t idx, offset;
11095 if (rte_eth_dev_filter_supported(res->port_id,
11096 RTE_ETH_FILTER_HASH) < 0) {
11097 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11102 memset(&info, 0, sizeof(info));
11103 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11104 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11105 RTE_ETH_FILTER_GET, &info);
11107 printf("Cannot get hash global configurations by port %d\n",
11112 switch (info.info.global_conf.hash_func) {
11113 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11114 printf("Hash function is Toeplitz\n");
11116 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11117 printf("Hash function is Simple XOR\n");
11120 printf("Unknown hash function\n");
11124 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11125 idx = i / UINT32_BIT;
11126 offset = i % UINT32_BIT;
11127 if (!(info.info.global_conf.valid_bit_mask[idx] &
11130 str = flowtype_to_str(i);
11133 printf("Symmetric hash is %s globally for flow type %s "
11135 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11136 (1UL << offset)) ? "enabled" : "disabled"), str,
11141 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11142 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11143 get_hash_global_config, "get_hash_global_config");
11144 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11145 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11148 cmdline_parse_inst_t cmd_get_hash_global_config = {
11149 .f = cmd_get_hash_global_config_parsed,
11151 .help_str = "get_hash_global_config <port_id>",
11153 (void *)&cmd_get_hash_global_config_all,
11154 (void *)&cmd_get_hash_global_config_port_id,
11159 /* Set global config of hash function */
11160 struct cmd_set_hash_global_config_result {
11161 cmdline_fixed_string_t set_hash_global_config;
11163 cmdline_fixed_string_t hash_func;
11164 cmdline_fixed_string_t flow_type;
11165 cmdline_fixed_string_t enable;
11169 cmd_set_hash_global_config_parsed(void *parsed_result,
11170 __rte_unused struct cmdline *cl,
11171 __rte_unused void *data)
11173 struct cmd_set_hash_global_config_result *res = parsed_result;
11174 struct rte_eth_hash_filter_info info;
11175 uint32_t ftype, idx, offset;
11178 if (rte_eth_dev_filter_supported(res->port_id,
11179 RTE_ETH_FILTER_HASH) < 0) {
11180 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11184 memset(&info, 0, sizeof(info));
11185 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11186 if (!strcmp(res->hash_func, "toeplitz"))
11187 info.info.global_conf.hash_func =
11188 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11189 else if (!strcmp(res->hash_func, "simple_xor"))
11190 info.info.global_conf.hash_func =
11191 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11192 else if (!strcmp(res->hash_func, "default"))
11193 info.info.global_conf.hash_func =
11194 RTE_ETH_HASH_FUNCTION_DEFAULT;
11196 ftype = str2flowtype(res->flow_type);
11197 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11198 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11199 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11200 if (!strcmp(res->enable, "enable"))
11201 info.info.global_conf.sym_hash_enable_mask[idx] |=
11203 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11204 RTE_ETH_FILTER_SET, &info);
11206 printf("Cannot set global hash configurations by port %d\n",
11209 printf("Global hash configurations have been set "
11210 "succcessfully by port %d\n", res->port_id);
11213 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11214 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11215 set_hash_global_config, "set_hash_global_config");
11216 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11217 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11219 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11220 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11221 hash_func, "toeplitz#simple_xor#default");
11222 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11223 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11225 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11226 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11227 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11228 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11229 enable, "enable#disable");
11231 cmdline_parse_inst_t cmd_set_hash_global_config = {
11232 .f = cmd_set_hash_global_config_parsed,
11234 .help_str = "set_hash_global_config <port_id> "
11235 "toeplitz|simple_xor|default "
11236 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11237 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11238 "l2_payload enable|disable",
11240 (void *)&cmd_set_hash_global_config_all,
11241 (void *)&cmd_set_hash_global_config_port_id,
11242 (void *)&cmd_set_hash_global_config_hash_func,
11243 (void *)&cmd_set_hash_global_config_flow_type,
11244 (void *)&cmd_set_hash_global_config_enable,
11249 /* Set hash input set */
11250 struct cmd_set_hash_input_set_result {
11251 cmdline_fixed_string_t set_hash_input_set;
11253 cmdline_fixed_string_t flow_type;
11254 cmdline_fixed_string_t inset_field;
11255 cmdline_fixed_string_t select;
11258 static enum rte_eth_input_set_field
11259 str2inset(char *string)
11263 static const struct {
11265 enum rte_eth_input_set_field inset;
11266 } inset_table[] = {
11267 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11268 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11269 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11270 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11271 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11272 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11273 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11274 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11275 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11276 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11277 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11278 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11279 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11280 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11281 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11282 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11283 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11284 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11285 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11286 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11287 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11288 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11289 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11290 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11291 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11292 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11293 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11294 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11295 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11296 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11297 {"none", RTE_ETH_INPUT_SET_NONE},
11300 for (i = 0; i < RTE_DIM(inset_table); i++) {
11301 if (!strcmp(string, inset_table[i].str))
11302 return inset_table[i].inset;
11305 return RTE_ETH_INPUT_SET_UNKNOWN;
11309 cmd_set_hash_input_set_parsed(void *parsed_result,
11310 __rte_unused struct cmdline *cl,
11311 __rte_unused void *data)
11313 struct cmd_set_hash_input_set_result *res = parsed_result;
11314 struct rte_eth_hash_filter_info info;
11316 memset(&info, 0, sizeof(info));
11317 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11318 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11319 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11320 info.info.input_set_conf.inset_size = 1;
11321 if (!strcmp(res->select, "select"))
11322 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11323 else if (!strcmp(res->select, "add"))
11324 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11325 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11326 RTE_ETH_FILTER_SET, &info);
11329 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11330 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11331 set_hash_input_set, "set_hash_input_set");
11332 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11333 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11335 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11336 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11338 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11339 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11341 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11342 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11343 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11344 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11345 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11347 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11348 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11349 select, "select#add");
11351 cmdline_parse_inst_t cmd_set_hash_input_set = {
11352 .f = cmd_set_hash_input_set_parsed,
11354 .help_str = "set_hash_input_set <port_id> "
11355 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11356 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11357 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11358 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11359 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11360 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11361 "fld-7th|fld-8th|none select|add",
11363 (void *)&cmd_set_hash_input_set_cmd,
11364 (void *)&cmd_set_hash_input_set_port_id,
11365 (void *)&cmd_set_hash_input_set_flow_type,
11366 (void *)&cmd_set_hash_input_set_field,
11367 (void *)&cmd_set_hash_input_set_select,
11372 /* Set flow director input set */
11373 struct cmd_set_fdir_input_set_result {
11374 cmdline_fixed_string_t set_fdir_input_set;
11376 cmdline_fixed_string_t flow_type;
11377 cmdline_fixed_string_t inset_field;
11378 cmdline_fixed_string_t select;
11382 cmd_set_fdir_input_set_parsed(void *parsed_result,
11383 __rte_unused struct cmdline *cl,
11384 __rte_unused void *data)
11386 struct cmd_set_fdir_input_set_result *res = parsed_result;
11387 struct rte_eth_fdir_filter_info info;
11389 memset(&info, 0, sizeof(info));
11390 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11391 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11392 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11393 info.info.input_set_conf.inset_size = 1;
11394 if (!strcmp(res->select, "select"))
11395 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11396 else if (!strcmp(res->select, "add"))
11397 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11398 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11399 RTE_ETH_FILTER_SET, &info);
11402 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11403 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11404 set_fdir_input_set, "set_fdir_input_set");
11405 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11406 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11408 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11409 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11411 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11412 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11413 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11414 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11416 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11417 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11418 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11419 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11420 "sctp-veri-tag#none");
11421 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11422 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11423 select, "select#add");
11425 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11426 .f = cmd_set_fdir_input_set_parsed,
11428 .help_str = "set_fdir_input_set <port_id> "
11429 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11430 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11431 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11432 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11433 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11434 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11435 "sctp-veri-tag|none select|add",
11437 (void *)&cmd_set_fdir_input_set_cmd,
11438 (void *)&cmd_set_fdir_input_set_port_id,
11439 (void *)&cmd_set_fdir_input_set_flow_type,
11440 (void *)&cmd_set_fdir_input_set_field,
11441 (void *)&cmd_set_fdir_input_set_select,
11446 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11447 struct cmd_mcast_addr_result {
11448 cmdline_fixed_string_t mcast_addr_cmd;
11449 cmdline_fixed_string_t what;
11451 struct ether_addr mc_addr;
11454 static void cmd_mcast_addr_parsed(void *parsed_result,
11455 __attribute__((unused)) struct cmdline *cl,
11456 __attribute__((unused)) void *data)
11458 struct cmd_mcast_addr_result *res = parsed_result;
11460 if (!is_multicast_ether_addr(&res->mc_addr)) {
11461 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11462 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11463 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11464 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11467 if (strcmp(res->what, "add") == 0)
11468 mcast_addr_add(res->port_num, &res->mc_addr);
11470 mcast_addr_remove(res->port_num, &res->mc_addr);
11473 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11474 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11475 mcast_addr_cmd, "mcast_addr");
11476 cmdline_parse_token_string_t cmd_mcast_addr_what =
11477 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11479 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11480 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11481 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11484 cmdline_parse_inst_t cmd_mcast_addr = {
11485 .f = cmd_mcast_addr_parsed,
11487 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11488 "Add/Remove multicast MAC address on port_id",
11490 (void *)&cmd_mcast_addr_cmd,
11491 (void *)&cmd_mcast_addr_what,
11492 (void *)&cmd_mcast_addr_portnum,
11493 (void *)&cmd_mcast_addr_addr,
11498 /* l2 tunnel config
11499 * only support E-tag now.
11502 /* Ether type config */
11503 struct cmd_config_l2_tunnel_eth_type_result {
11504 cmdline_fixed_string_t port;
11505 cmdline_fixed_string_t config;
11506 cmdline_fixed_string_t all;
11508 cmdline_fixed_string_t l2_tunnel;
11509 cmdline_fixed_string_t l2_tunnel_type;
11510 cmdline_fixed_string_t eth_type;
11511 uint16_t eth_type_val;
11514 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_config_l2_tunnel_eth_type_result,
11518 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_config_l2_tunnel_eth_type_result,
11522 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_config_l2_tunnel_eth_type_result,
11526 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11527 TOKEN_NUM_INITIALIZER
11528 (struct cmd_config_l2_tunnel_eth_type_result,
11530 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11531 TOKEN_STRING_INITIALIZER
11532 (struct cmd_config_l2_tunnel_eth_type_result,
11533 l2_tunnel, "l2-tunnel");
11534 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_config_l2_tunnel_eth_type_result,
11537 l2_tunnel_type, "E-tag");
11538 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_config_l2_tunnel_eth_type_result,
11541 eth_type, "ether-type");
11542 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11543 TOKEN_NUM_INITIALIZER
11544 (struct cmd_config_l2_tunnel_eth_type_result,
11545 eth_type_val, UINT16);
11547 static enum rte_eth_tunnel_type
11548 str2fdir_l2_tunnel_type(char *string)
11552 static const struct {
11554 enum rte_eth_tunnel_type type;
11555 } l2_tunnel_type_str[] = {
11556 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11559 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11560 if (!strcmp(l2_tunnel_type_str[i].str, string))
11561 return l2_tunnel_type_str[i].type;
11563 return RTE_TUNNEL_TYPE_NONE;
11566 /* ether type config for all ports */
11568 cmd_config_l2_tunnel_eth_type_all_parsed
11569 (void *parsed_result,
11570 __attribute__((unused)) struct cmdline *cl,
11571 __attribute__((unused)) void *data)
11573 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11574 struct rte_eth_l2_tunnel_conf entry;
11577 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11578 entry.ether_type = res->eth_type_val;
11580 RTE_ETH_FOREACH_DEV(pid) {
11581 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11585 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11586 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11588 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11590 (void *)&cmd_config_l2_tunnel_eth_type_port,
11591 (void *)&cmd_config_l2_tunnel_eth_type_config,
11592 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11593 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11594 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11595 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11596 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11601 /* ether type config for a specific port */
11603 cmd_config_l2_tunnel_eth_type_specific_parsed(
11604 void *parsed_result,
11605 __attribute__((unused)) struct cmdline *cl,
11606 __attribute__((unused)) void *data)
11608 struct cmd_config_l2_tunnel_eth_type_result *res =
11610 struct rte_eth_l2_tunnel_conf entry;
11612 if (port_id_is_invalid(res->id, ENABLED_WARN))
11615 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11616 entry.ether_type = res->eth_type_val;
11618 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11621 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11622 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11624 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11626 (void *)&cmd_config_l2_tunnel_eth_type_port,
11627 (void *)&cmd_config_l2_tunnel_eth_type_config,
11628 (void *)&cmd_config_l2_tunnel_eth_type_id,
11629 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11630 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11631 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11632 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11637 /* Enable/disable l2 tunnel */
11638 struct cmd_config_l2_tunnel_en_dis_result {
11639 cmdline_fixed_string_t port;
11640 cmdline_fixed_string_t config;
11641 cmdline_fixed_string_t all;
11643 cmdline_fixed_string_t l2_tunnel;
11644 cmdline_fixed_string_t l2_tunnel_type;
11645 cmdline_fixed_string_t en_dis;
11648 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11649 TOKEN_STRING_INITIALIZER
11650 (struct cmd_config_l2_tunnel_en_dis_result,
11652 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11653 TOKEN_STRING_INITIALIZER
11654 (struct cmd_config_l2_tunnel_en_dis_result,
11656 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11657 TOKEN_STRING_INITIALIZER
11658 (struct cmd_config_l2_tunnel_en_dis_result,
11660 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11661 TOKEN_NUM_INITIALIZER
11662 (struct cmd_config_l2_tunnel_en_dis_result,
11664 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_config_l2_tunnel_en_dis_result,
11667 l2_tunnel, "l2-tunnel");
11668 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_config_l2_tunnel_en_dis_result,
11671 l2_tunnel_type, "E-tag");
11672 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11673 TOKEN_STRING_INITIALIZER
11674 (struct cmd_config_l2_tunnel_en_dis_result,
11675 en_dis, "enable#disable");
11677 /* enable/disable l2 tunnel for all ports */
11679 cmd_config_l2_tunnel_en_dis_all_parsed(
11680 void *parsed_result,
11681 __attribute__((unused)) struct cmdline *cl,
11682 __attribute__((unused)) void *data)
11684 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11685 struct rte_eth_l2_tunnel_conf entry;
11689 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11691 if (!strcmp("enable", res->en_dis))
11696 RTE_ETH_FOREACH_DEV(pid) {
11697 rte_eth_dev_l2_tunnel_offload_set(pid,
11699 ETH_L2_TUNNEL_ENABLE_MASK,
11704 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11705 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11707 .help_str = "port config all l2-tunnel E-tag enable|disable",
11709 (void *)&cmd_config_l2_tunnel_en_dis_port,
11710 (void *)&cmd_config_l2_tunnel_en_dis_config,
11711 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11712 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11713 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11714 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11719 /* enable/disable l2 tunnel for a port */
11721 cmd_config_l2_tunnel_en_dis_specific_parsed(
11722 void *parsed_result,
11723 __attribute__((unused)) struct cmdline *cl,
11724 __attribute__((unused)) void *data)
11726 struct cmd_config_l2_tunnel_en_dis_result *res =
11728 struct rte_eth_l2_tunnel_conf entry;
11730 if (port_id_is_invalid(res->id, ENABLED_WARN))
11733 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11735 if (!strcmp("enable", res->en_dis))
11736 rte_eth_dev_l2_tunnel_offload_set(res->id,
11738 ETH_L2_TUNNEL_ENABLE_MASK,
11741 rte_eth_dev_l2_tunnel_offload_set(res->id,
11743 ETH_L2_TUNNEL_ENABLE_MASK,
11747 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11748 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11750 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11752 (void *)&cmd_config_l2_tunnel_en_dis_port,
11753 (void *)&cmd_config_l2_tunnel_en_dis_config,
11754 (void *)&cmd_config_l2_tunnel_en_dis_id,
11755 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11756 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11757 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11762 /* E-tag configuration */
11764 /* Common result structure for all E-tag configuration */
11765 struct cmd_config_e_tag_result {
11766 cmdline_fixed_string_t e_tag;
11767 cmdline_fixed_string_t set;
11768 cmdline_fixed_string_t insertion;
11769 cmdline_fixed_string_t stripping;
11770 cmdline_fixed_string_t forwarding;
11771 cmdline_fixed_string_t filter;
11772 cmdline_fixed_string_t add;
11773 cmdline_fixed_string_t del;
11774 cmdline_fixed_string_t on;
11775 cmdline_fixed_string_t off;
11776 cmdline_fixed_string_t on_off;
11777 cmdline_fixed_string_t port_tag_id;
11778 uint32_t port_tag_id_val;
11779 cmdline_fixed_string_t e_tag_id;
11780 uint16_t e_tag_id_val;
11781 cmdline_fixed_string_t dst_pool;
11782 uint8_t dst_pool_val;
11783 cmdline_fixed_string_t port;
11785 cmdline_fixed_string_t vf;
11789 /* Common CLI fields for all E-tag configuration */
11790 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11791 TOKEN_STRING_INITIALIZER
11792 (struct cmd_config_e_tag_result,
11794 cmdline_parse_token_string_t cmd_config_e_tag_set =
11795 TOKEN_STRING_INITIALIZER
11796 (struct cmd_config_e_tag_result,
11798 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11799 TOKEN_STRING_INITIALIZER
11800 (struct cmd_config_e_tag_result,
11801 insertion, "insertion");
11802 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11803 TOKEN_STRING_INITIALIZER
11804 (struct cmd_config_e_tag_result,
11805 stripping, "stripping");
11806 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_config_e_tag_result,
11809 forwarding, "forwarding");
11810 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_config_e_tag_result,
11814 cmdline_parse_token_string_t cmd_config_e_tag_add =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_config_e_tag_result,
11818 cmdline_parse_token_string_t cmd_config_e_tag_del =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_config_e_tag_result,
11822 cmdline_parse_token_string_t cmd_config_e_tag_on =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_config_e_tag_result,
11826 cmdline_parse_token_string_t cmd_config_e_tag_off =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_config_e_tag_result,
11830 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11831 TOKEN_STRING_INITIALIZER
11832 (struct cmd_config_e_tag_result,
11834 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11835 TOKEN_STRING_INITIALIZER
11836 (struct cmd_config_e_tag_result,
11837 port_tag_id, "port-tag-id");
11838 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11839 TOKEN_NUM_INITIALIZER
11840 (struct cmd_config_e_tag_result,
11841 port_tag_id_val, UINT32);
11842 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11843 TOKEN_STRING_INITIALIZER
11844 (struct cmd_config_e_tag_result,
11845 e_tag_id, "e-tag-id");
11846 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11847 TOKEN_NUM_INITIALIZER
11848 (struct cmd_config_e_tag_result,
11849 e_tag_id_val, UINT16);
11850 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_config_e_tag_result,
11853 dst_pool, "dst-pool");
11854 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11855 TOKEN_NUM_INITIALIZER
11856 (struct cmd_config_e_tag_result,
11857 dst_pool_val, UINT8);
11858 cmdline_parse_token_string_t cmd_config_e_tag_port =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_config_e_tag_result,
11862 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11863 TOKEN_NUM_INITIALIZER
11864 (struct cmd_config_e_tag_result,
11866 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_config_e_tag_result,
11870 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11871 TOKEN_NUM_INITIALIZER
11872 (struct cmd_config_e_tag_result,
11875 /* E-tag insertion configuration */
11877 cmd_config_e_tag_insertion_en_parsed(
11878 void *parsed_result,
11879 __attribute__((unused)) struct cmdline *cl,
11880 __attribute__((unused)) void *data)
11882 struct cmd_config_e_tag_result *res =
11884 struct rte_eth_l2_tunnel_conf entry;
11886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11889 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11890 entry.tunnel_id = res->port_tag_id_val;
11891 entry.vf_id = res->vf_id;
11892 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11894 ETH_L2_TUNNEL_INSERTION_MASK,
11899 cmd_config_e_tag_insertion_dis_parsed(
11900 void *parsed_result,
11901 __attribute__((unused)) struct cmdline *cl,
11902 __attribute__((unused)) void *data)
11904 struct cmd_config_e_tag_result *res =
11906 struct rte_eth_l2_tunnel_conf entry;
11908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11911 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11912 entry.vf_id = res->vf_id;
11914 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11916 ETH_L2_TUNNEL_INSERTION_MASK,
11920 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11921 .f = cmd_config_e_tag_insertion_en_parsed,
11923 .help_str = "E-tag ... : E-tag insertion enable",
11925 (void *)&cmd_config_e_tag_e_tag,
11926 (void *)&cmd_config_e_tag_set,
11927 (void *)&cmd_config_e_tag_insertion,
11928 (void *)&cmd_config_e_tag_on,
11929 (void *)&cmd_config_e_tag_port_tag_id,
11930 (void *)&cmd_config_e_tag_port_tag_id_val,
11931 (void *)&cmd_config_e_tag_port,
11932 (void *)&cmd_config_e_tag_port_id,
11933 (void *)&cmd_config_e_tag_vf,
11934 (void *)&cmd_config_e_tag_vf_id,
11939 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11940 .f = cmd_config_e_tag_insertion_dis_parsed,
11942 .help_str = "E-tag ... : E-tag insertion disable",
11944 (void *)&cmd_config_e_tag_e_tag,
11945 (void *)&cmd_config_e_tag_set,
11946 (void *)&cmd_config_e_tag_insertion,
11947 (void *)&cmd_config_e_tag_off,
11948 (void *)&cmd_config_e_tag_port,
11949 (void *)&cmd_config_e_tag_port_id,
11950 (void *)&cmd_config_e_tag_vf,
11951 (void *)&cmd_config_e_tag_vf_id,
11956 /* E-tag stripping configuration */
11958 cmd_config_e_tag_stripping_parsed(
11959 void *parsed_result,
11960 __attribute__((unused)) struct cmdline *cl,
11961 __attribute__((unused)) void *data)
11963 struct cmd_config_e_tag_result *res =
11965 struct rte_eth_l2_tunnel_conf entry;
11967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11970 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11972 if (!strcmp(res->on_off, "on"))
11973 rte_eth_dev_l2_tunnel_offload_set
11976 ETH_L2_TUNNEL_STRIPPING_MASK,
11979 rte_eth_dev_l2_tunnel_offload_set
11982 ETH_L2_TUNNEL_STRIPPING_MASK,
11986 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11987 .f = cmd_config_e_tag_stripping_parsed,
11989 .help_str = "E-tag ... : E-tag stripping enable/disable",
11991 (void *)&cmd_config_e_tag_e_tag,
11992 (void *)&cmd_config_e_tag_set,
11993 (void *)&cmd_config_e_tag_stripping,
11994 (void *)&cmd_config_e_tag_on_off,
11995 (void *)&cmd_config_e_tag_port,
11996 (void *)&cmd_config_e_tag_port_id,
12001 /* E-tag forwarding configuration */
12003 cmd_config_e_tag_forwarding_parsed(
12004 void *parsed_result,
12005 __attribute__((unused)) struct cmdline *cl,
12006 __attribute__((unused)) void *data)
12008 struct cmd_config_e_tag_result *res = parsed_result;
12009 struct rte_eth_l2_tunnel_conf entry;
12011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12014 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12016 if (!strcmp(res->on_off, "on"))
12017 rte_eth_dev_l2_tunnel_offload_set
12020 ETH_L2_TUNNEL_FORWARDING_MASK,
12023 rte_eth_dev_l2_tunnel_offload_set
12026 ETH_L2_TUNNEL_FORWARDING_MASK,
12030 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12031 .f = cmd_config_e_tag_forwarding_parsed,
12033 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12035 (void *)&cmd_config_e_tag_e_tag,
12036 (void *)&cmd_config_e_tag_set,
12037 (void *)&cmd_config_e_tag_forwarding,
12038 (void *)&cmd_config_e_tag_on_off,
12039 (void *)&cmd_config_e_tag_port,
12040 (void *)&cmd_config_e_tag_port_id,
12045 /* E-tag filter configuration */
12047 cmd_config_e_tag_filter_add_parsed(
12048 void *parsed_result,
12049 __attribute__((unused)) struct cmdline *cl,
12050 __attribute__((unused)) void *data)
12052 struct cmd_config_e_tag_result *res = parsed_result;
12053 struct rte_eth_l2_tunnel_conf entry;
12056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12059 if (res->e_tag_id_val > 0x3fff) {
12060 printf("e-tag-id must be equal or less than 0x3fff.\n");
12064 ret = rte_eth_dev_filter_supported(res->port_id,
12065 RTE_ETH_FILTER_L2_TUNNEL);
12067 printf("E-tag filter is not supported on port %u.\n",
12072 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12073 entry.tunnel_id = res->e_tag_id_val;
12074 entry.pool = res->dst_pool_val;
12076 ret = rte_eth_dev_filter_ctrl(res->port_id,
12077 RTE_ETH_FILTER_L2_TUNNEL,
12078 RTE_ETH_FILTER_ADD,
12081 printf("E-tag filter programming error: (%s)\n",
12085 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12086 .f = cmd_config_e_tag_filter_add_parsed,
12088 .help_str = "E-tag ... : E-tag filter add",
12090 (void *)&cmd_config_e_tag_e_tag,
12091 (void *)&cmd_config_e_tag_set,
12092 (void *)&cmd_config_e_tag_filter,
12093 (void *)&cmd_config_e_tag_add,
12094 (void *)&cmd_config_e_tag_e_tag_id,
12095 (void *)&cmd_config_e_tag_e_tag_id_val,
12096 (void *)&cmd_config_e_tag_dst_pool,
12097 (void *)&cmd_config_e_tag_dst_pool_val,
12098 (void *)&cmd_config_e_tag_port,
12099 (void *)&cmd_config_e_tag_port_id,
12105 cmd_config_e_tag_filter_del_parsed(
12106 void *parsed_result,
12107 __attribute__((unused)) struct cmdline *cl,
12108 __attribute__((unused)) void *data)
12110 struct cmd_config_e_tag_result *res = parsed_result;
12111 struct rte_eth_l2_tunnel_conf entry;
12114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12117 if (res->e_tag_id_val > 0x3fff) {
12118 printf("e-tag-id must be less than 0x3fff.\n");
12122 ret = rte_eth_dev_filter_supported(res->port_id,
12123 RTE_ETH_FILTER_L2_TUNNEL);
12125 printf("E-tag filter is not supported on port %u.\n",
12130 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12131 entry.tunnel_id = res->e_tag_id_val;
12133 ret = rte_eth_dev_filter_ctrl(res->port_id,
12134 RTE_ETH_FILTER_L2_TUNNEL,
12135 RTE_ETH_FILTER_DELETE,
12138 printf("E-tag filter programming error: (%s)\n",
12142 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12143 .f = cmd_config_e_tag_filter_del_parsed,
12145 .help_str = "E-tag ... : E-tag filter delete",
12147 (void *)&cmd_config_e_tag_e_tag,
12148 (void *)&cmd_config_e_tag_set,
12149 (void *)&cmd_config_e_tag_filter,
12150 (void *)&cmd_config_e_tag_del,
12151 (void *)&cmd_config_e_tag_e_tag_id,
12152 (void *)&cmd_config_e_tag_e_tag_id_val,
12153 (void *)&cmd_config_e_tag_port,
12154 (void *)&cmd_config_e_tag_port_id,
12159 /* vf vlan anti spoof configuration */
12161 /* Common result structure for vf vlan anti spoof */
12162 struct cmd_vf_vlan_anti_spoof_result {
12163 cmdline_fixed_string_t set;
12164 cmdline_fixed_string_t vf;
12165 cmdline_fixed_string_t vlan;
12166 cmdline_fixed_string_t antispoof;
12169 cmdline_fixed_string_t on_off;
12172 /* Common CLI fields for vf vlan anti spoof enable disable */
12173 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_vf_vlan_anti_spoof_result,
12177 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_vf_vlan_anti_spoof_result,
12181 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12182 TOKEN_STRING_INITIALIZER
12183 (struct cmd_vf_vlan_anti_spoof_result,
12185 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12186 TOKEN_STRING_INITIALIZER
12187 (struct cmd_vf_vlan_anti_spoof_result,
12188 antispoof, "antispoof");
12189 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12190 TOKEN_NUM_INITIALIZER
12191 (struct cmd_vf_vlan_anti_spoof_result,
12193 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12194 TOKEN_NUM_INITIALIZER
12195 (struct cmd_vf_vlan_anti_spoof_result,
12197 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_vf_vlan_anti_spoof_result,
12203 cmd_set_vf_vlan_anti_spoof_parsed(
12204 void *parsed_result,
12205 __attribute__((unused)) struct cmdline *cl,
12206 __attribute__((unused)) void *data)
12208 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12209 int ret = -ENOTSUP;
12211 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12216 #ifdef RTE_LIBRTE_IXGBE_PMD
12217 if (ret == -ENOTSUP)
12218 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12219 res->vf_id, is_on);
12221 #ifdef RTE_LIBRTE_I40E_PMD
12222 if (ret == -ENOTSUP)
12223 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12224 res->vf_id, is_on);
12226 #ifdef RTE_LIBRTE_BNXT_PMD
12227 if (ret == -ENOTSUP)
12228 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12229 res->vf_id, is_on);
12236 printf("invalid vf_id %d\n", res->vf_id);
12239 printf("invalid port_id %d\n", res->port_id);
12242 printf("function not implemented\n");
12245 printf("programming error: (%s)\n", strerror(-ret));
12249 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12250 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12252 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12254 (void *)&cmd_vf_vlan_anti_spoof_set,
12255 (void *)&cmd_vf_vlan_anti_spoof_vf,
12256 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12257 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12258 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12259 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12260 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12265 /* vf mac anti spoof configuration */
12267 /* Common result structure for vf mac anti spoof */
12268 struct cmd_vf_mac_anti_spoof_result {
12269 cmdline_fixed_string_t set;
12270 cmdline_fixed_string_t vf;
12271 cmdline_fixed_string_t mac;
12272 cmdline_fixed_string_t antispoof;
12275 cmdline_fixed_string_t on_off;
12278 /* Common CLI fields for vf mac anti spoof enable disable */
12279 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_vf_mac_anti_spoof_result,
12283 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_mac_anti_spoof_result,
12287 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_mac_anti_spoof_result,
12291 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_mac_anti_spoof_result,
12294 antispoof, "antispoof");
12295 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_vf_mac_anti_spoof_result,
12299 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_vf_mac_anti_spoof_result,
12303 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_mac_anti_spoof_result,
12309 cmd_set_vf_mac_anti_spoof_parsed(
12310 void *parsed_result,
12311 __attribute__((unused)) struct cmdline *cl,
12312 __attribute__((unused)) void *data)
12314 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12315 int ret = -ENOTSUP;
12317 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12322 #ifdef RTE_LIBRTE_IXGBE_PMD
12323 if (ret == -ENOTSUP)
12324 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12325 res->vf_id, is_on);
12327 #ifdef RTE_LIBRTE_I40E_PMD
12328 if (ret == -ENOTSUP)
12329 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12330 res->vf_id, is_on);
12332 #ifdef RTE_LIBRTE_BNXT_PMD
12333 if (ret == -ENOTSUP)
12334 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12335 res->vf_id, is_on);
12342 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12345 printf("invalid port_id %d\n", res->port_id);
12348 printf("function not implemented\n");
12351 printf("programming error: (%s)\n", strerror(-ret));
12355 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12356 .f = cmd_set_vf_mac_anti_spoof_parsed,
12358 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12360 (void *)&cmd_vf_mac_anti_spoof_set,
12361 (void *)&cmd_vf_mac_anti_spoof_vf,
12362 (void *)&cmd_vf_mac_anti_spoof_mac,
12363 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12364 (void *)&cmd_vf_mac_anti_spoof_port_id,
12365 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12366 (void *)&cmd_vf_mac_anti_spoof_on_off,
12371 /* vf vlan strip queue configuration */
12373 /* Common result structure for vf mac anti spoof */
12374 struct cmd_vf_vlan_stripq_result {
12375 cmdline_fixed_string_t set;
12376 cmdline_fixed_string_t vf;
12377 cmdline_fixed_string_t vlan;
12378 cmdline_fixed_string_t stripq;
12381 cmdline_fixed_string_t on_off;
12384 /* Common CLI fields for vf vlan strip enable disable */
12385 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_vf_vlan_stripq_result,
12389 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12390 TOKEN_STRING_INITIALIZER
12391 (struct cmd_vf_vlan_stripq_result,
12393 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_vf_vlan_stripq_result,
12397 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12398 TOKEN_STRING_INITIALIZER
12399 (struct cmd_vf_vlan_stripq_result,
12401 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12402 TOKEN_NUM_INITIALIZER
12403 (struct cmd_vf_vlan_stripq_result,
12405 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12406 TOKEN_NUM_INITIALIZER
12407 (struct cmd_vf_vlan_stripq_result,
12409 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12410 TOKEN_STRING_INITIALIZER
12411 (struct cmd_vf_vlan_stripq_result,
12415 cmd_set_vf_vlan_stripq_parsed(
12416 void *parsed_result,
12417 __attribute__((unused)) struct cmdline *cl,
12418 __attribute__((unused)) void *data)
12420 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12421 int ret = -ENOTSUP;
12423 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12428 #ifdef RTE_LIBRTE_IXGBE_PMD
12429 if (ret == -ENOTSUP)
12430 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12431 res->vf_id, is_on);
12433 #ifdef RTE_LIBRTE_I40E_PMD
12434 if (ret == -ENOTSUP)
12435 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12436 res->vf_id, is_on);
12438 #ifdef RTE_LIBRTE_BNXT_PMD
12439 if (ret == -ENOTSUP)
12440 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12441 res->vf_id, is_on);
12448 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12451 printf("invalid port_id %d\n", res->port_id);
12454 printf("function not implemented\n");
12457 printf("programming error: (%s)\n", strerror(-ret));
12461 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12462 .f = cmd_set_vf_vlan_stripq_parsed,
12464 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12466 (void *)&cmd_vf_vlan_stripq_set,
12467 (void *)&cmd_vf_vlan_stripq_vf,
12468 (void *)&cmd_vf_vlan_stripq_vlan,
12469 (void *)&cmd_vf_vlan_stripq_stripq,
12470 (void *)&cmd_vf_vlan_stripq_port_id,
12471 (void *)&cmd_vf_vlan_stripq_vf_id,
12472 (void *)&cmd_vf_vlan_stripq_on_off,
12477 /* vf vlan insert configuration */
12479 /* Common result structure for vf vlan insert */
12480 struct cmd_vf_vlan_insert_result {
12481 cmdline_fixed_string_t set;
12482 cmdline_fixed_string_t vf;
12483 cmdline_fixed_string_t vlan;
12484 cmdline_fixed_string_t insert;
12490 /* Common CLI fields for vf vlan insert enable disable */
12491 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12492 TOKEN_STRING_INITIALIZER
12493 (struct cmd_vf_vlan_insert_result,
12495 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12496 TOKEN_STRING_INITIALIZER
12497 (struct cmd_vf_vlan_insert_result,
12499 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_vf_vlan_insert_result,
12503 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_vf_vlan_insert_result,
12507 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12508 TOKEN_NUM_INITIALIZER
12509 (struct cmd_vf_vlan_insert_result,
12511 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12512 TOKEN_NUM_INITIALIZER
12513 (struct cmd_vf_vlan_insert_result,
12515 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12516 TOKEN_NUM_INITIALIZER
12517 (struct cmd_vf_vlan_insert_result,
12521 cmd_set_vf_vlan_insert_parsed(
12522 void *parsed_result,
12523 __attribute__((unused)) struct cmdline *cl,
12524 __attribute__((unused)) void *data)
12526 struct cmd_vf_vlan_insert_result *res = parsed_result;
12527 int ret = -ENOTSUP;
12529 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12532 #ifdef RTE_LIBRTE_IXGBE_PMD
12533 if (ret == -ENOTSUP)
12534 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12537 #ifdef RTE_LIBRTE_I40E_PMD
12538 if (ret == -ENOTSUP)
12539 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12542 #ifdef RTE_LIBRTE_BNXT_PMD
12543 if (ret == -ENOTSUP)
12544 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12552 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12555 printf("invalid port_id %d\n", res->port_id);
12558 printf("function not implemented\n");
12561 printf("programming error: (%s)\n", strerror(-ret));
12565 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12566 .f = cmd_set_vf_vlan_insert_parsed,
12568 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12570 (void *)&cmd_vf_vlan_insert_set,
12571 (void *)&cmd_vf_vlan_insert_vf,
12572 (void *)&cmd_vf_vlan_insert_vlan,
12573 (void *)&cmd_vf_vlan_insert_insert,
12574 (void *)&cmd_vf_vlan_insert_port_id,
12575 (void *)&cmd_vf_vlan_insert_vf_id,
12576 (void *)&cmd_vf_vlan_insert_vlan_id,
12581 /* tx loopback configuration */
12583 /* Common result structure for tx loopback */
12584 struct cmd_tx_loopback_result {
12585 cmdline_fixed_string_t set;
12586 cmdline_fixed_string_t tx;
12587 cmdline_fixed_string_t loopback;
12589 cmdline_fixed_string_t on_off;
12592 /* Common CLI fields for tx loopback enable disable */
12593 cmdline_parse_token_string_t cmd_tx_loopback_set =
12594 TOKEN_STRING_INITIALIZER
12595 (struct cmd_tx_loopback_result,
12597 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12598 TOKEN_STRING_INITIALIZER
12599 (struct cmd_tx_loopback_result,
12601 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12602 TOKEN_STRING_INITIALIZER
12603 (struct cmd_tx_loopback_result,
12604 loopback, "loopback");
12605 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12606 TOKEN_NUM_INITIALIZER
12607 (struct cmd_tx_loopback_result,
12609 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12610 TOKEN_STRING_INITIALIZER
12611 (struct cmd_tx_loopback_result,
12615 cmd_set_tx_loopback_parsed(
12616 void *parsed_result,
12617 __attribute__((unused)) struct cmdline *cl,
12618 __attribute__((unused)) void *data)
12620 struct cmd_tx_loopback_result *res = parsed_result;
12621 int ret = -ENOTSUP;
12623 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12628 #ifdef RTE_LIBRTE_IXGBE_PMD
12629 if (ret == -ENOTSUP)
12630 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12632 #ifdef RTE_LIBRTE_I40E_PMD
12633 if (ret == -ENOTSUP)
12634 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12636 #ifdef RTE_LIBRTE_BNXT_PMD
12637 if (ret == -ENOTSUP)
12638 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12645 printf("invalid is_on %d\n", is_on);
12648 printf("invalid port_id %d\n", res->port_id);
12651 printf("function not implemented\n");
12654 printf("programming error: (%s)\n", strerror(-ret));
12658 cmdline_parse_inst_t cmd_set_tx_loopback = {
12659 .f = cmd_set_tx_loopback_parsed,
12661 .help_str = "set tx loopback <port_id> on|off",
12663 (void *)&cmd_tx_loopback_set,
12664 (void *)&cmd_tx_loopback_tx,
12665 (void *)&cmd_tx_loopback_loopback,
12666 (void *)&cmd_tx_loopback_port_id,
12667 (void *)&cmd_tx_loopback_on_off,
12672 /* all queues drop enable configuration */
12674 /* Common result structure for all queues drop enable */
12675 struct cmd_all_queues_drop_en_result {
12676 cmdline_fixed_string_t set;
12677 cmdline_fixed_string_t all;
12678 cmdline_fixed_string_t queues;
12679 cmdline_fixed_string_t drop;
12681 cmdline_fixed_string_t on_off;
12684 /* Common CLI fields for tx loopback enable disable */
12685 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_all_queues_drop_en_result,
12689 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_all_queues_drop_en_result,
12693 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_all_queues_drop_en_result,
12697 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_all_queues_drop_en_result,
12701 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12702 TOKEN_NUM_INITIALIZER
12703 (struct cmd_all_queues_drop_en_result,
12705 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12706 TOKEN_STRING_INITIALIZER
12707 (struct cmd_all_queues_drop_en_result,
12711 cmd_set_all_queues_drop_en_parsed(
12712 void *parsed_result,
12713 __attribute__((unused)) struct cmdline *cl,
12714 __attribute__((unused)) void *data)
12716 struct cmd_all_queues_drop_en_result *res = parsed_result;
12717 int ret = -ENOTSUP;
12718 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12723 #ifdef RTE_LIBRTE_IXGBE_PMD
12724 if (ret == -ENOTSUP)
12725 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12727 #ifdef RTE_LIBRTE_BNXT_PMD
12728 if (ret == -ENOTSUP)
12729 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12735 printf("invalid is_on %d\n", is_on);
12738 printf("invalid port_id %d\n", res->port_id);
12741 printf("function not implemented\n");
12744 printf("programming error: (%s)\n", strerror(-ret));
12748 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12749 .f = cmd_set_all_queues_drop_en_parsed,
12751 .help_str = "set all queues drop <port_id> on|off",
12753 (void *)&cmd_all_queues_drop_en_set,
12754 (void *)&cmd_all_queues_drop_en_all,
12755 (void *)&cmd_all_queues_drop_en_queues,
12756 (void *)&cmd_all_queues_drop_en_drop,
12757 (void *)&cmd_all_queues_drop_en_port_id,
12758 (void *)&cmd_all_queues_drop_en_on_off,
12763 /* vf split drop enable configuration */
12765 /* Common result structure for vf split drop enable */
12766 struct cmd_vf_split_drop_en_result {
12767 cmdline_fixed_string_t set;
12768 cmdline_fixed_string_t vf;
12769 cmdline_fixed_string_t split;
12770 cmdline_fixed_string_t drop;
12773 cmdline_fixed_string_t on_off;
12776 /* Common CLI fields for vf split drop enable disable */
12777 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12778 TOKEN_STRING_INITIALIZER
12779 (struct cmd_vf_split_drop_en_result,
12781 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12782 TOKEN_STRING_INITIALIZER
12783 (struct cmd_vf_split_drop_en_result,
12785 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12786 TOKEN_STRING_INITIALIZER
12787 (struct cmd_vf_split_drop_en_result,
12789 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12790 TOKEN_STRING_INITIALIZER
12791 (struct cmd_vf_split_drop_en_result,
12793 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12794 TOKEN_NUM_INITIALIZER
12795 (struct cmd_vf_split_drop_en_result,
12797 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12798 TOKEN_NUM_INITIALIZER
12799 (struct cmd_vf_split_drop_en_result,
12801 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12802 TOKEN_STRING_INITIALIZER
12803 (struct cmd_vf_split_drop_en_result,
12807 cmd_set_vf_split_drop_en_parsed(
12808 void *parsed_result,
12809 __attribute__((unused)) struct cmdline *cl,
12810 __attribute__((unused)) void *data)
12812 struct cmd_vf_split_drop_en_result *res = parsed_result;
12813 int ret = -ENOTSUP;
12814 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12816 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12819 #ifdef RTE_LIBRTE_IXGBE_PMD
12820 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12827 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12830 printf("invalid port_id %d\n", res->port_id);
12833 printf("not supported on port %d\n", res->port_id);
12836 printf("programming error: (%s)\n", strerror(-ret));
12840 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12841 .f = cmd_set_vf_split_drop_en_parsed,
12843 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12845 (void *)&cmd_vf_split_drop_en_set,
12846 (void *)&cmd_vf_split_drop_en_vf,
12847 (void *)&cmd_vf_split_drop_en_split,
12848 (void *)&cmd_vf_split_drop_en_drop,
12849 (void *)&cmd_vf_split_drop_en_port_id,
12850 (void *)&cmd_vf_split_drop_en_vf_id,
12851 (void *)&cmd_vf_split_drop_en_on_off,
12856 /* vf mac address configuration */
12858 /* Common result structure for vf mac address */
12859 struct cmd_set_vf_mac_addr_result {
12860 cmdline_fixed_string_t set;
12861 cmdline_fixed_string_t vf;
12862 cmdline_fixed_string_t mac;
12863 cmdline_fixed_string_t addr;
12866 struct ether_addr mac_addr;
12870 /* Common CLI fields for vf split drop enable disable */
12871 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_set_vf_mac_addr_result,
12875 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12876 TOKEN_STRING_INITIALIZER
12877 (struct cmd_set_vf_mac_addr_result,
12879 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12880 TOKEN_STRING_INITIALIZER
12881 (struct cmd_set_vf_mac_addr_result,
12883 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12884 TOKEN_STRING_INITIALIZER
12885 (struct cmd_set_vf_mac_addr_result,
12887 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12888 TOKEN_NUM_INITIALIZER
12889 (struct cmd_set_vf_mac_addr_result,
12891 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12892 TOKEN_NUM_INITIALIZER
12893 (struct cmd_set_vf_mac_addr_result,
12895 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12896 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12900 cmd_set_vf_mac_addr_parsed(
12901 void *parsed_result,
12902 __attribute__((unused)) struct cmdline *cl,
12903 __attribute__((unused)) void *data)
12905 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12906 int ret = -ENOTSUP;
12908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12911 #ifdef RTE_LIBRTE_IXGBE_PMD
12912 if (ret == -ENOTSUP)
12913 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12916 #ifdef RTE_LIBRTE_I40E_PMD
12917 if (ret == -ENOTSUP)
12918 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12921 #ifdef RTE_LIBRTE_BNXT_PMD
12922 if (ret == -ENOTSUP)
12923 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12931 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12934 printf("invalid port_id %d\n", res->port_id);
12937 printf("function not implemented\n");
12940 printf("programming error: (%s)\n", strerror(-ret));
12944 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12945 .f = cmd_set_vf_mac_addr_parsed,
12947 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12949 (void *)&cmd_set_vf_mac_addr_set,
12950 (void *)&cmd_set_vf_mac_addr_vf,
12951 (void *)&cmd_set_vf_mac_addr_mac,
12952 (void *)&cmd_set_vf_mac_addr_addr,
12953 (void *)&cmd_set_vf_mac_addr_port_id,
12954 (void *)&cmd_set_vf_mac_addr_vf_id,
12955 (void *)&cmd_set_vf_mac_addr_mac_addr,
12960 /* MACsec configuration */
12962 /* Common result structure for MACsec offload enable */
12963 struct cmd_macsec_offload_on_result {
12964 cmdline_fixed_string_t set;
12965 cmdline_fixed_string_t macsec;
12966 cmdline_fixed_string_t offload;
12968 cmdline_fixed_string_t on;
12969 cmdline_fixed_string_t encrypt;
12970 cmdline_fixed_string_t en_on_off;
12971 cmdline_fixed_string_t replay_protect;
12972 cmdline_fixed_string_t rp_on_off;
12975 /* Common CLI fields for MACsec offload disable */
12976 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_macsec_offload_on_result,
12980 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_macsec_offload_on_result,
12984 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_macsec_offload_on_result,
12987 offload, "offload");
12988 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12989 TOKEN_NUM_INITIALIZER
12990 (struct cmd_macsec_offload_on_result,
12992 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_macsec_offload_on_result,
12996 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12997 TOKEN_STRING_INITIALIZER
12998 (struct cmd_macsec_offload_on_result,
12999 encrypt, "encrypt");
13000 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13001 TOKEN_STRING_INITIALIZER
13002 (struct cmd_macsec_offload_on_result,
13003 en_on_off, "on#off");
13004 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13005 TOKEN_STRING_INITIALIZER
13006 (struct cmd_macsec_offload_on_result,
13007 replay_protect, "replay-protect");
13008 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13009 TOKEN_STRING_INITIALIZER
13010 (struct cmd_macsec_offload_on_result,
13011 rp_on_off, "on#off");
13014 cmd_set_macsec_offload_on_parsed(
13015 void *parsed_result,
13016 __attribute__((unused)) struct cmdline *cl,
13017 __attribute__((unused)) void *data)
13019 struct cmd_macsec_offload_on_result *res = parsed_result;
13020 int ret = -ENOTSUP;
13021 portid_t port_id = res->port_id;
13022 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13023 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13025 if (port_id_is_invalid(port_id, ENABLED_WARN))
13028 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
13029 #ifdef RTE_LIBRTE_IXGBE_PMD
13030 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13039 printf("invalid port_id %d\n", port_id);
13042 printf("not supported on port %d\n", port_id);
13045 printf("programming error: (%s)\n", strerror(-ret));
13049 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13050 .f = cmd_set_macsec_offload_on_parsed,
13052 .help_str = "set macsec offload <port_id> on "
13053 "encrypt on|off replay-protect on|off",
13055 (void *)&cmd_macsec_offload_on_set,
13056 (void *)&cmd_macsec_offload_on_macsec,
13057 (void *)&cmd_macsec_offload_on_offload,
13058 (void *)&cmd_macsec_offload_on_port_id,
13059 (void *)&cmd_macsec_offload_on_on,
13060 (void *)&cmd_macsec_offload_on_encrypt,
13061 (void *)&cmd_macsec_offload_on_en_on_off,
13062 (void *)&cmd_macsec_offload_on_replay_protect,
13063 (void *)&cmd_macsec_offload_on_rp_on_off,
13068 /* Common result structure for MACsec offload disable */
13069 struct cmd_macsec_offload_off_result {
13070 cmdline_fixed_string_t set;
13071 cmdline_fixed_string_t macsec;
13072 cmdline_fixed_string_t offload;
13074 cmdline_fixed_string_t off;
13077 /* Common CLI fields for MACsec offload disable */
13078 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_macsec_offload_off_result,
13082 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_macsec_offload_off_result,
13086 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13087 TOKEN_STRING_INITIALIZER
13088 (struct cmd_macsec_offload_off_result,
13089 offload, "offload");
13090 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13091 TOKEN_NUM_INITIALIZER
13092 (struct cmd_macsec_offload_off_result,
13094 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_macsec_offload_off_result,
13100 cmd_set_macsec_offload_off_parsed(
13101 void *parsed_result,
13102 __attribute__((unused)) struct cmdline *cl,
13103 __attribute__((unused)) void *data)
13105 struct cmd_macsec_offload_off_result *res = parsed_result;
13106 int ret = -ENOTSUP;
13107 portid_t port_id = res->port_id;
13109 if (port_id_is_invalid(port_id, ENABLED_WARN))
13112 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13113 #ifdef RTE_LIBRTE_IXGBE_PMD
13114 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13121 printf("invalid port_id %d\n", port_id);
13124 printf("not supported on port %d\n", port_id);
13127 printf("programming error: (%s)\n", strerror(-ret));
13131 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13132 .f = cmd_set_macsec_offload_off_parsed,
13134 .help_str = "set macsec offload <port_id> off",
13136 (void *)&cmd_macsec_offload_off_set,
13137 (void *)&cmd_macsec_offload_off_macsec,
13138 (void *)&cmd_macsec_offload_off_offload,
13139 (void *)&cmd_macsec_offload_off_port_id,
13140 (void *)&cmd_macsec_offload_off_off,
13145 /* Common result structure for MACsec secure connection configure */
13146 struct cmd_macsec_sc_result {
13147 cmdline_fixed_string_t set;
13148 cmdline_fixed_string_t macsec;
13149 cmdline_fixed_string_t sc;
13150 cmdline_fixed_string_t tx_rx;
13152 struct ether_addr mac;
13156 /* Common CLI fields for MACsec secure connection configure */
13157 cmdline_parse_token_string_t cmd_macsec_sc_set =
13158 TOKEN_STRING_INITIALIZER
13159 (struct cmd_macsec_sc_result,
13161 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13162 TOKEN_STRING_INITIALIZER
13163 (struct cmd_macsec_sc_result,
13165 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_macsec_sc_result,
13169 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_macsec_sc_result,
13173 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13174 TOKEN_NUM_INITIALIZER
13175 (struct cmd_macsec_sc_result,
13177 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13178 TOKEN_ETHERADDR_INITIALIZER
13179 (struct cmd_macsec_sc_result,
13181 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13182 TOKEN_NUM_INITIALIZER
13183 (struct cmd_macsec_sc_result,
13187 cmd_set_macsec_sc_parsed(
13188 void *parsed_result,
13189 __attribute__((unused)) struct cmdline *cl,
13190 __attribute__((unused)) void *data)
13192 struct cmd_macsec_sc_result *res = parsed_result;
13193 int ret = -ENOTSUP;
13194 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13196 #ifdef RTE_LIBRTE_IXGBE_PMD
13198 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13199 res->mac.addr_bytes) :
13200 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13201 res->mac.addr_bytes, res->pi);
13203 RTE_SET_USED(is_tx);
13209 printf("invalid port_id %d\n", res->port_id);
13212 printf("not supported on port %d\n", res->port_id);
13215 printf("programming error: (%s)\n", strerror(-ret));
13219 cmdline_parse_inst_t cmd_set_macsec_sc = {
13220 .f = cmd_set_macsec_sc_parsed,
13222 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13224 (void *)&cmd_macsec_sc_set,
13225 (void *)&cmd_macsec_sc_macsec,
13226 (void *)&cmd_macsec_sc_sc,
13227 (void *)&cmd_macsec_sc_tx_rx,
13228 (void *)&cmd_macsec_sc_port_id,
13229 (void *)&cmd_macsec_sc_mac,
13230 (void *)&cmd_macsec_sc_pi,
13235 /* Common result structure for MACsec secure connection configure */
13236 struct cmd_macsec_sa_result {
13237 cmdline_fixed_string_t set;
13238 cmdline_fixed_string_t macsec;
13239 cmdline_fixed_string_t sa;
13240 cmdline_fixed_string_t tx_rx;
13245 cmdline_fixed_string_t key;
13248 /* Common CLI fields for MACsec secure connection configure */
13249 cmdline_parse_token_string_t cmd_macsec_sa_set =
13250 TOKEN_STRING_INITIALIZER
13251 (struct cmd_macsec_sa_result,
13253 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13254 TOKEN_STRING_INITIALIZER
13255 (struct cmd_macsec_sa_result,
13257 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13258 TOKEN_STRING_INITIALIZER
13259 (struct cmd_macsec_sa_result,
13261 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13262 TOKEN_STRING_INITIALIZER
13263 (struct cmd_macsec_sa_result,
13265 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13266 TOKEN_NUM_INITIALIZER
13267 (struct cmd_macsec_sa_result,
13269 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13270 TOKEN_NUM_INITIALIZER
13271 (struct cmd_macsec_sa_result,
13273 cmdline_parse_token_num_t cmd_macsec_sa_an =
13274 TOKEN_NUM_INITIALIZER
13275 (struct cmd_macsec_sa_result,
13277 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13278 TOKEN_NUM_INITIALIZER
13279 (struct cmd_macsec_sa_result,
13281 cmdline_parse_token_string_t cmd_macsec_sa_key =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_macsec_sa_result,
13287 cmd_set_macsec_sa_parsed(
13288 void *parsed_result,
13289 __attribute__((unused)) struct cmdline *cl,
13290 __attribute__((unused)) void *data)
13292 struct cmd_macsec_sa_result *res = parsed_result;
13293 int ret = -ENOTSUP;
13294 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13295 uint8_t key[16] = { 0 };
13301 key_len = strlen(res->key) / 2;
13305 for (i = 0; i < key_len; i++) {
13306 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13309 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13312 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13315 #ifdef RTE_LIBRTE_IXGBE_PMD
13317 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13318 res->idx, res->an, res->pn, key) :
13319 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13320 res->idx, res->an, res->pn, key);
13322 RTE_SET_USED(is_tx);
13329 printf("invalid idx %d or an %d\n", res->idx, res->an);
13332 printf("invalid port_id %d\n", res->port_id);
13335 printf("not supported on port %d\n", res->port_id);
13338 printf("programming error: (%s)\n", strerror(-ret));
13342 cmdline_parse_inst_t cmd_set_macsec_sa = {
13343 .f = cmd_set_macsec_sa_parsed,
13345 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13347 (void *)&cmd_macsec_sa_set,
13348 (void *)&cmd_macsec_sa_macsec,
13349 (void *)&cmd_macsec_sa_sa,
13350 (void *)&cmd_macsec_sa_tx_rx,
13351 (void *)&cmd_macsec_sa_port_id,
13352 (void *)&cmd_macsec_sa_idx,
13353 (void *)&cmd_macsec_sa_an,
13354 (void *)&cmd_macsec_sa_pn,
13355 (void *)&cmd_macsec_sa_key,
13360 /* VF unicast promiscuous mode configuration */
13362 /* Common result structure for VF unicast promiscuous mode */
13363 struct cmd_vf_promisc_result {
13364 cmdline_fixed_string_t set;
13365 cmdline_fixed_string_t vf;
13366 cmdline_fixed_string_t promisc;
13369 cmdline_fixed_string_t on_off;
13372 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13373 cmdline_parse_token_string_t cmd_vf_promisc_set =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_vf_promisc_result,
13377 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_vf_promisc_result,
13381 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_vf_promisc_result,
13384 promisc, "promisc");
13385 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13386 TOKEN_NUM_INITIALIZER
13387 (struct cmd_vf_promisc_result,
13389 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13390 TOKEN_NUM_INITIALIZER
13391 (struct cmd_vf_promisc_result,
13393 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_vf_promisc_result,
13399 cmd_set_vf_promisc_parsed(
13400 void *parsed_result,
13401 __attribute__((unused)) struct cmdline *cl,
13402 __attribute__((unused)) void *data)
13404 struct cmd_vf_promisc_result *res = parsed_result;
13405 int ret = -ENOTSUP;
13407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13412 #ifdef RTE_LIBRTE_I40E_PMD
13413 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13414 res->vf_id, is_on);
13421 printf("invalid vf_id %d\n", res->vf_id);
13424 printf("invalid port_id %d\n", res->port_id);
13427 printf("function not implemented\n");
13430 printf("programming error: (%s)\n", strerror(-ret));
13434 cmdline_parse_inst_t cmd_set_vf_promisc = {
13435 .f = cmd_set_vf_promisc_parsed,
13437 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13438 "Set unicast promiscuous mode for a VF from the PF",
13440 (void *)&cmd_vf_promisc_set,
13441 (void *)&cmd_vf_promisc_vf,
13442 (void *)&cmd_vf_promisc_promisc,
13443 (void *)&cmd_vf_promisc_port_id,
13444 (void *)&cmd_vf_promisc_vf_id,
13445 (void *)&cmd_vf_promisc_on_off,
13450 /* VF multicast promiscuous mode configuration */
13452 /* Common result structure for VF multicast promiscuous mode */
13453 struct cmd_vf_allmulti_result {
13454 cmdline_fixed_string_t set;
13455 cmdline_fixed_string_t vf;
13456 cmdline_fixed_string_t allmulti;
13459 cmdline_fixed_string_t on_off;
13462 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13463 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13464 TOKEN_STRING_INITIALIZER
13465 (struct cmd_vf_allmulti_result,
13467 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_vf_allmulti_result,
13471 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13472 TOKEN_STRING_INITIALIZER
13473 (struct cmd_vf_allmulti_result,
13474 allmulti, "allmulti");
13475 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13476 TOKEN_NUM_INITIALIZER
13477 (struct cmd_vf_allmulti_result,
13479 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13480 TOKEN_NUM_INITIALIZER
13481 (struct cmd_vf_allmulti_result,
13483 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13484 TOKEN_STRING_INITIALIZER
13485 (struct cmd_vf_allmulti_result,
13489 cmd_set_vf_allmulti_parsed(
13490 void *parsed_result,
13491 __attribute__((unused)) struct cmdline *cl,
13492 __attribute__((unused)) void *data)
13494 struct cmd_vf_allmulti_result *res = parsed_result;
13495 int ret = -ENOTSUP;
13497 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13499 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13502 #ifdef RTE_LIBRTE_I40E_PMD
13503 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13504 res->vf_id, is_on);
13511 printf("invalid vf_id %d\n", res->vf_id);
13514 printf("invalid port_id %d\n", res->port_id);
13517 printf("function not implemented\n");
13520 printf("programming error: (%s)\n", strerror(-ret));
13524 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13525 .f = cmd_set_vf_allmulti_parsed,
13527 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13528 "Set multicast promiscuous mode for a VF from the PF",
13530 (void *)&cmd_vf_allmulti_set,
13531 (void *)&cmd_vf_allmulti_vf,
13532 (void *)&cmd_vf_allmulti_allmulti,
13533 (void *)&cmd_vf_allmulti_port_id,
13534 (void *)&cmd_vf_allmulti_vf_id,
13535 (void *)&cmd_vf_allmulti_on_off,
13540 /* vf broadcast mode configuration */
13542 /* Common result structure for vf broadcast */
13543 struct cmd_set_vf_broadcast_result {
13544 cmdline_fixed_string_t set;
13545 cmdline_fixed_string_t vf;
13546 cmdline_fixed_string_t broadcast;
13549 cmdline_fixed_string_t on_off;
13552 /* Common CLI fields for vf broadcast enable disable */
13553 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_set_vf_broadcast_result,
13557 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_set_vf_broadcast_result,
13561 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_set_vf_broadcast_result,
13564 broadcast, "broadcast");
13565 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13566 TOKEN_NUM_INITIALIZER
13567 (struct cmd_set_vf_broadcast_result,
13569 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13570 TOKEN_NUM_INITIALIZER
13571 (struct cmd_set_vf_broadcast_result,
13573 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13574 TOKEN_STRING_INITIALIZER
13575 (struct cmd_set_vf_broadcast_result,
13579 cmd_set_vf_broadcast_parsed(
13580 void *parsed_result,
13581 __attribute__((unused)) struct cmdline *cl,
13582 __attribute__((unused)) void *data)
13584 struct cmd_set_vf_broadcast_result *res = parsed_result;
13585 int ret = -ENOTSUP;
13587 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13589 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13592 #ifdef RTE_LIBRTE_I40E_PMD
13593 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13594 res->vf_id, is_on);
13601 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13604 printf("invalid port_id %d\n", res->port_id);
13607 printf("function not implemented\n");
13610 printf("programming error: (%s)\n", strerror(-ret));
13614 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13615 .f = cmd_set_vf_broadcast_parsed,
13617 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13619 (void *)&cmd_set_vf_broadcast_set,
13620 (void *)&cmd_set_vf_broadcast_vf,
13621 (void *)&cmd_set_vf_broadcast_broadcast,
13622 (void *)&cmd_set_vf_broadcast_port_id,
13623 (void *)&cmd_set_vf_broadcast_vf_id,
13624 (void *)&cmd_set_vf_broadcast_on_off,
13629 /* vf vlan tag configuration */
13631 /* Common result structure for vf vlan tag */
13632 struct cmd_set_vf_vlan_tag_result {
13633 cmdline_fixed_string_t set;
13634 cmdline_fixed_string_t vf;
13635 cmdline_fixed_string_t vlan;
13636 cmdline_fixed_string_t tag;
13639 cmdline_fixed_string_t on_off;
13642 /* Common CLI fields for vf vlan tag enable disable */
13643 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_set_vf_vlan_tag_result,
13647 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_set_vf_vlan_tag_result,
13651 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_set_vf_vlan_tag_result,
13655 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_set_vf_vlan_tag_result,
13659 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_set_vf_vlan_tag_result,
13663 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13664 TOKEN_NUM_INITIALIZER
13665 (struct cmd_set_vf_vlan_tag_result,
13667 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_set_vf_vlan_tag_result,
13673 cmd_set_vf_vlan_tag_parsed(
13674 void *parsed_result,
13675 __attribute__((unused)) struct cmdline *cl,
13676 __attribute__((unused)) void *data)
13678 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13679 int ret = -ENOTSUP;
13681 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13683 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13686 #ifdef RTE_LIBRTE_I40E_PMD
13687 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13688 res->vf_id, is_on);
13695 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13698 printf("invalid port_id %d\n", res->port_id);
13701 printf("function not implemented\n");
13704 printf("programming error: (%s)\n", strerror(-ret));
13708 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13709 .f = cmd_set_vf_vlan_tag_parsed,
13711 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13713 (void *)&cmd_set_vf_vlan_tag_set,
13714 (void *)&cmd_set_vf_vlan_tag_vf,
13715 (void *)&cmd_set_vf_vlan_tag_vlan,
13716 (void *)&cmd_set_vf_vlan_tag_tag,
13717 (void *)&cmd_set_vf_vlan_tag_port_id,
13718 (void *)&cmd_set_vf_vlan_tag_vf_id,
13719 (void *)&cmd_set_vf_vlan_tag_on_off,
13724 /* Common definition of VF and TC TX bandwidth configuration */
13725 struct cmd_vf_tc_bw_result {
13726 cmdline_fixed_string_t set;
13727 cmdline_fixed_string_t vf;
13728 cmdline_fixed_string_t tc;
13729 cmdline_fixed_string_t tx;
13730 cmdline_fixed_string_t min_bw;
13731 cmdline_fixed_string_t max_bw;
13732 cmdline_fixed_string_t strict_link_prio;
13737 cmdline_fixed_string_t bw_list;
13741 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13742 TOKEN_STRING_INITIALIZER
13743 (struct cmd_vf_tc_bw_result,
13745 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13746 TOKEN_STRING_INITIALIZER
13747 (struct cmd_vf_tc_bw_result,
13749 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13750 TOKEN_STRING_INITIALIZER
13751 (struct cmd_vf_tc_bw_result,
13753 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13754 TOKEN_STRING_INITIALIZER
13755 (struct cmd_vf_tc_bw_result,
13757 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13758 TOKEN_STRING_INITIALIZER
13759 (struct cmd_vf_tc_bw_result,
13760 strict_link_prio, "strict-link-priority");
13761 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13762 TOKEN_STRING_INITIALIZER
13763 (struct cmd_vf_tc_bw_result,
13764 min_bw, "min-bandwidth");
13765 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_vf_tc_bw_result,
13768 max_bw, "max-bandwidth");
13769 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13770 TOKEN_NUM_INITIALIZER
13771 (struct cmd_vf_tc_bw_result,
13773 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13774 TOKEN_NUM_INITIALIZER
13775 (struct cmd_vf_tc_bw_result,
13777 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13778 TOKEN_NUM_INITIALIZER
13779 (struct cmd_vf_tc_bw_result,
13781 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13782 TOKEN_NUM_INITIALIZER
13783 (struct cmd_vf_tc_bw_result,
13785 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13786 TOKEN_STRING_INITIALIZER
13787 (struct cmd_vf_tc_bw_result,
13789 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13790 TOKEN_NUM_INITIALIZER
13791 (struct cmd_vf_tc_bw_result,
13794 /* VF max bandwidth setting */
13796 cmd_vf_max_bw_parsed(
13797 void *parsed_result,
13798 __attribute__((unused)) struct cmdline *cl,
13799 __attribute__((unused)) void *data)
13801 struct cmd_vf_tc_bw_result *res = parsed_result;
13802 int ret = -ENOTSUP;
13804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13807 #ifdef RTE_LIBRTE_I40E_PMD
13808 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13809 res->vf_id, res->bw);
13816 printf("invalid vf_id %d or bandwidth %d\n",
13817 res->vf_id, res->bw);
13820 printf("invalid port_id %d\n", res->port_id);
13823 printf("function not implemented\n");
13826 printf("programming error: (%s)\n", strerror(-ret));
13830 cmdline_parse_inst_t cmd_vf_max_bw = {
13831 .f = cmd_vf_max_bw_parsed,
13833 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13835 (void *)&cmd_vf_tc_bw_set,
13836 (void *)&cmd_vf_tc_bw_vf,
13837 (void *)&cmd_vf_tc_bw_tx,
13838 (void *)&cmd_vf_tc_bw_max_bw,
13839 (void *)&cmd_vf_tc_bw_port_id,
13840 (void *)&cmd_vf_tc_bw_vf_id,
13841 (void *)&cmd_vf_tc_bw_bw,
13847 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13852 const char *p, *p0 = str;
13859 p = strchr(p0, '(');
13861 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13865 p0 = strchr(p, ')');
13867 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13871 if (size >= sizeof(s)) {
13872 printf("The string size exceeds the internal buffer size\n");
13875 snprintf(s, sizeof(s), "%.*s", size, p);
13876 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13878 printf("Failed to get the bandwidth list. ");
13882 for (i = 0; i < ret; i++)
13883 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13888 /* TC min bandwidth setting */
13890 cmd_vf_tc_min_bw_parsed(
13891 void *parsed_result,
13892 __attribute__((unused)) struct cmdline *cl,
13893 __attribute__((unused)) void *data)
13895 struct cmd_vf_tc_bw_result *res = parsed_result;
13898 int ret = -ENOTSUP;
13900 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13903 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13907 #ifdef RTE_LIBRTE_I40E_PMD
13908 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13916 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13919 printf("invalid port_id %d\n", res->port_id);
13922 printf("function not implemented\n");
13925 printf("programming error: (%s)\n", strerror(-ret));
13929 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13930 .f = cmd_vf_tc_min_bw_parsed,
13932 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13933 " <bw1, bw2, ...>",
13935 (void *)&cmd_vf_tc_bw_set,
13936 (void *)&cmd_vf_tc_bw_vf,
13937 (void *)&cmd_vf_tc_bw_tc,
13938 (void *)&cmd_vf_tc_bw_tx,
13939 (void *)&cmd_vf_tc_bw_min_bw,
13940 (void *)&cmd_vf_tc_bw_port_id,
13941 (void *)&cmd_vf_tc_bw_vf_id,
13942 (void *)&cmd_vf_tc_bw_bw_list,
13948 cmd_tc_min_bw_parsed(
13949 void *parsed_result,
13950 __attribute__((unused)) struct cmdline *cl,
13951 __attribute__((unused)) void *data)
13953 struct cmd_vf_tc_bw_result *res = parsed_result;
13954 struct rte_port *port;
13957 int ret = -ENOTSUP;
13959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13962 port = &ports[res->port_id];
13963 /** Check if the port is not started **/
13964 if (port->port_status != RTE_PORT_STOPPED) {
13965 printf("Please stop port %d first\n", res->port_id);
13969 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13973 #ifdef RTE_LIBRTE_IXGBE_PMD
13974 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13981 printf("invalid bandwidth\n");
13984 printf("invalid port_id %d\n", res->port_id);
13987 printf("function not implemented\n");
13990 printf("programming error: (%s)\n", strerror(-ret));
13994 cmdline_parse_inst_t cmd_tc_min_bw = {
13995 .f = cmd_tc_min_bw_parsed,
13997 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13999 (void *)&cmd_vf_tc_bw_set,
14000 (void *)&cmd_vf_tc_bw_tc,
14001 (void *)&cmd_vf_tc_bw_tx,
14002 (void *)&cmd_vf_tc_bw_min_bw,
14003 (void *)&cmd_vf_tc_bw_port_id,
14004 (void *)&cmd_vf_tc_bw_bw_list,
14009 /* TC max bandwidth setting */
14011 cmd_vf_tc_max_bw_parsed(
14012 void *parsed_result,
14013 __attribute__((unused)) struct cmdline *cl,
14014 __attribute__((unused)) void *data)
14016 struct cmd_vf_tc_bw_result *res = parsed_result;
14017 int ret = -ENOTSUP;
14019 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14022 #ifdef RTE_LIBRTE_I40E_PMD
14023 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14024 res->tc_no, res->bw);
14031 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14032 res->vf_id, res->tc_no, res->bw);
14035 printf("invalid port_id %d\n", res->port_id);
14038 printf("function not implemented\n");
14041 printf("programming error: (%s)\n", strerror(-ret));
14045 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14046 .f = cmd_vf_tc_max_bw_parsed,
14048 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14051 (void *)&cmd_vf_tc_bw_set,
14052 (void *)&cmd_vf_tc_bw_vf,
14053 (void *)&cmd_vf_tc_bw_tc,
14054 (void *)&cmd_vf_tc_bw_tx,
14055 (void *)&cmd_vf_tc_bw_max_bw,
14056 (void *)&cmd_vf_tc_bw_port_id,
14057 (void *)&cmd_vf_tc_bw_vf_id,
14058 (void *)&cmd_vf_tc_bw_tc_no,
14059 (void *)&cmd_vf_tc_bw_bw,
14065 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14067 /* *** Set Port default Traffic Management Hierarchy *** */
14068 struct cmd_set_port_tm_hierarchy_default_result {
14069 cmdline_fixed_string_t set;
14070 cmdline_fixed_string_t port;
14071 cmdline_fixed_string_t tm;
14072 cmdline_fixed_string_t hierarchy;
14073 cmdline_fixed_string_t def;
14077 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14078 TOKEN_STRING_INITIALIZER(
14079 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14080 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14081 TOKEN_STRING_INITIALIZER(
14082 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14083 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14084 TOKEN_STRING_INITIALIZER(
14085 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14086 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14087 TOKEN_STRING_INITIALIZER(
14088 struct cmd_set_port_tm_hierarchy_default_result,
14089 hierarchy, "hierarchy");
14090 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14091 TOKEN_STRING_INITIALIZER(
14092 struct cmd_set_port_tm_hierarchy_default_result,
14094 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14095 TOKEN_NUM_INITIALIZER(
14096 struct cmd_set_port_tm_hierarchy_default_result,
14099 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14100 __attribute__((unused)) struct cmdline *cl,
14101 __attribute__((unused)) void *data)
14103 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14104 struct rte_port *p;
14105 portid_t port_id = res->port_id;
14107 if (port_id_is_invalid(port_id, ENABLED_WARN))
14110 p = &ports[port_id];
14113 if (p->softport.tm_flag == 0) {
14114 printf(" tm not enabled on port %u (error)\n", port_id);
14118 /* Forward mode: tm */
14119 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14120 printf(" tm mode not enabled(error)\n");
14124 /* Set the default tm hierarchy */
14125 p->softport.tm.default_hierarchy_enable = 1;
14128 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14129 .f = cmd_set_port_tm_hierarchy_default_parsed,
14131 .help_str = "set port tm hierarchy default <port_id>",
14133 (void *)&cmd_set_port_tm_hierarchy_default_set,
14134 (void *)&cmd_set_port_tm_hierarchy_default_port,
14135 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14136 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14137 (void *)&cmd_set_port_tm_hierarchy_default_default,
14138 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14144 /* Strict link priority scheduling mode setting */
14146 cmd_strict_link_prio_parsed(
14147 void *parsed_result,
14148 __attribute__((unused)) struct cmdline *cl,
14149 __attribute__((unused)) void *data)
14151 struct cmd_vf_tc_bw_result *res = parsed_result;
14152 int ret = -ENOTSUP;
14154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14157 #ifdef RTE_LIBRTE_I40E_PMD
14158 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14165 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14168 printf("invalid port_id %d\n", res->port_id);
14171 printf("function not implemented\n");
14174 printf("programming error: (%s)\n", strerror(-ret));
14178 cmdline_parse_inst_t cmd_strict_link_prio = {
14179 .f = cmd_strict_link_prio_parsed,
14181 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14183 (void *)&cmd_vf_tc_bw_set,
14184 (void *)&cmd_vf_tc_bw_tx,
14185 (void *)&cmd_vf_tc_bw_strict_link_prio,
14186 (void *)&cmd_vf_tc_bw_port_id,
14187 (void *)&cmd_vf_tc_bw_tc_map,
14192 /* Load dynamic device personalization*/
14193 struct cmd_ddp_add_result {
14194 cmdline_fixed_string_t ddp;
14195 cmdline_fixed_string_t add;
14200 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14201 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14202 cmdline_parse_token_string_t cmd_ddp_add_add =
14203 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14204 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14205 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14206 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14207 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14210 cmd_ddp_add_parsed(
14211 void *parsed_result,
14212 __attribute__((unused)) struct cmdline *cl,
14213 __attribute__((unused)) void *data)
14215 struct cmd_ddp_add_result *res = parsed_result;
14221 int ret = -ENOTSUP;
14223 if (res->port_id > nb_ports) {
14224 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14228 if (!all_ports_stopped()) {
14229 printf("Please stop all ports first\n");
14233 filepath = strdup(res->filepath);
14234 if (filepath == NULL) {
14235 printf("Failed to allocate memory\n");
14238 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14240 buff = open_ddp_package_file(file_fld[0], &size);
14242 free((void *)filepath);
14246 #ifdef RTE_LIBRTE_I40E_PMD
14247 if (ret == -ENOTSUP)
14248 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14250 RTE_PMD_I40E_PKG_OP_WR_ADD);
14253 if (ret == -EEXIST)
14254 printf("Profile has already existed.\n");
14256 printf("Failed to load profile.\n");
14257 else if (file_num == 2)
14258 save_ddp_package_file(file_fld[1], buff, size);
14260 close_ddp_package_file(buff);
14261 free((void *)filepath);
14264 cmdline_parse_inst_t cmd_ddp_add = {
14265 .f = cmd_ddp_add_parsed,
14267 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14269 (void *)&cmd_ddp_add_ddp,
14270 (void *)&cmd_ddp_add_add,
14271 (void *)&cmd_ddp_add_port_id,
14272 (void *)&cmd_ddp_add_filepath,
14277 /* Delete dynamic device personalization*/
14278 struct cmd_ddp_del_result {
14279 cmdline_fixed_string_t ddp;
14280 cmdline_fixed_string_t del;
14285 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14286 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14287 cmdline_parse_token_string_t cmd_ddp_del_del =
14288 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14289 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14290 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14291 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14292 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14295 cmd_ddp_del_parsed(
14296 void *parsed_result,
14297 __attribute__((unused)) struct cmdline *cl,
14298 __attribute__((unused)) void *data)
14300 struct cmd_ddp_del_result *res = parsed_result;
14303 int ret = -ENOTSUP;
14305 if (res->port_id > nb_ports) {
14306 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14310 if (!all_ports_stopped()) {
14311 printf("Please stop all ports first\n");
14315 buff = open_ddp_package_file(res->filepath, &size);
14319 #ifdef RTE_LIBRTE_I40E_PMD
14320 if (ret == -ENOTSUP)
14321 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14323 RTE_PMD_I40E_PKG_OP_WR_DEL);
14326 if (ret == -EACCES)
14327 printf("Profile does not exist.\n");
14329 printf("Failed to delete profile.\n");
14331 close_ddp_package_file(buff);
14334 cmdline_parse_inst_t cmd_ddp_del = {
14335 .f = cmd_ddp_del_parsed,
14337 .help_str = "ddp del <port_id> <profile_path>",
14339 (void *)&cmd_ddp_del_ddp,
14340 (void *)&cmd_ddp_del_del,
14341 (void *)&cmd_ddp_del_port_id,
14342 (void *)&cmd_ddp_del_filepath,
14347 /* Get dynamic device personalization profile info */
14348 struct cmd_ddp_info_result {
14349 cmdline_fixed_string_t ddp;
14350 cmdline_fixed_string_t get;
14351 cmdline_fixed_string_t info;
14355 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14357 cmdline_parse_token_string_t cmd_ddp_info_get =
14358 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14359 cmdline_parse_token_string_t cmd_ddp_info_info =
14360 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14361 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14362 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14365 cmd_ddp_info_parsed(
14366 void *parsed_result,
14367 __attribute__((unused)) struct cmdline *cl,
14368 __attribute__((unused)) void *data)
14370 struct cmd_ddp_info_result *res = parsed_result;
14373 int ret = -ENOTSUP;
14374 #ifdef RTE_LIBRTE_I40E_PMD
14377 uint32_t buff_size = 0;
14378 struct rte_pmd_i40e_profile_info info;
14379 uint32_t dev_num = 0;
14380 struct rte_pmd_i40e_ddp_device_id *devs;
14381 uint32_t proto_num = 0;
14382 struct rte_pmd_i40e_proto_info *proto = NULL;
14383 uint32_t pctype_num = 0;
14384 struct rte_pmd_i40e_ptype_info *pctype;
14385 uint32_t ptype_num = 0;
14386 struct rte_pmd_i40e_ptype_info *ptype;
14391 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14395 #ifdef RTE_LIBRTE_I40E_PMD
14396 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14397 (uint8_t *)&info, sizeof(info),
14398 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14400 printf("Global Track id: 0x%x\n", info.track_id);
14401 printf("Global Version: %d.%d.%d.%d\n",
14402 info.version.major,
14403 info.version.minor,
14404 info.version.update,
14405 info.version.draft);
14406 printf("Global Package name: %s\n\n", info.name);
14409 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14410 (uint8_t *)&info, sizeof(info),
14411 RTE_PMD_I40E_PKG_INFO_HEADER);
14413 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14414 printf("i40e Profile Version: %d.%d.%d.%d\n",
14415 info.version.major,
14416 info.version.minor,
14417 info.version.update,
14418 info.version.draft);
14419 printf("i40e Profile name: %s\n\n", info.name);
14422 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14423 (uint8_t *)&buff_size, sizeof(buff_size),
14424 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14425 if (!ret && buff_size) {
14426 buff = (uint8_t *)malloc(buff_size);
14428 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14430 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14432 printf("Package Notes:\n%s\n\n", buff);
14437 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14438 (uint8_t *)&dev_num, sizeof(dev_num),
14439 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14440 if (!ret && dev_num) {
14441 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14442 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14444 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14445 (uint8_t *)devs, buff_size,
14446 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14448 printf("List of supported devices:\n");
14449 for (i = 0; i < dev_num; i++) {
14450 printf(" %04X:%04X %04X:%04X\n",
14451 devs[i].vendor_dev_id >> 16,
14452 devs[i].vendor_dev_id & 0xFFFF,
14453 devs[i].sub_vendor_dev_id >> 16,
14454 devs[i].sub_vendor_dev_id & 0xFFFF);
14462 /* get information about protocols and packet types */
14463 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14464 (uint8_t *)&proto_num, sizeof(proto_num),
14465 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14466 if (ret || !proto_num)
14467 goto no_print_return;
14469 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14470 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14472 goto no_print_return;
14474 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14476 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14478 printf("List of used protocols:\n");
14479 for (i = 0; i < proto_num; i++)
14480 printf(" %2u: %s\n", proto[i].proto_id,
14484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14485 (uint8_t *)&pctype_num, sizeof(pctype_num),
14486 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14487 if (ret || !pctype_num)
14488 goto no_print_pctypes;
14490 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14491 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14493 goto no_print_pctypes;
14495 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14497 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14500 goto no_print_pctypes;
14503 printf("List of defined packet classification types:\n");
14504 for (i = 0; i < pctype_num; i++) {
14505 printf(" %2u:", pctype[i].ptype_id);
14506 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14507 proto_id = pctype[i].protocols[j];
14508 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14509 for (n = 0; n < proto_num; n++) {
14510 if (proto[n].proto_id == proto_id) {
14511 printf(" %s", proto[n].name);
14524 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14526 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14527 if (ret || !ptype_num)
14528 goto no_print_return;
14530 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14531 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14533 goto no_print_return;
14535 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14537 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14540 goto no_print_return;
14542 printf("List of defined packet types:\n");
14543 for (i = 0; i < ptype_num; i++) {
14544 printf(" %2u:", ptype[i].ptype_id);
14545 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14546 proto_id = ptype[i].protocols[j];
14547 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14548 for (n = 0; n < proto_num; n++) {
14549 if (proto[n].proto_id == proto_id) {
14550 printf(" %s", proto[n].name);
14566 if (ret == -ENOTSUP)
14567 printf("Function not supported in PMD driver\n");
14568 close_ddp_package_file(pkg);
14571 cmdline_parse_inst_t cmd_ddp_get_info = {
14572 .f = cmd_ddp_info_parsed,
14574 .help_str = "ddp get info <profile_path>",
14576 (void *)&cmd_ddp_info_ddp,
14577 (void *)&cmd_ddp_info_get,
14578 (void *)&cmd_ddp_info_info,
14579 (void *)&cmd_ddp_info_filepath,
14584 /* Get dynamic device personalization profile info list*/
14585 #define PROFILE_INFO_SIZE 48
14586 #define MAX_PROFILE_NUM 16
14588 struct cmd_ddp_get_list_result {
14589 cmdline_fixed_string_t ddp;
14590 cmdline_fixed_string_t get;
14591 cmdline_fixed_string_t list;
14595 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14596 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14597 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14598 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14599 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14600 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14601 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14602 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14605 cmd_ddp_get_list_parsed(
14606 void *parsed_result,
14607 __attribute__((unused)) struct cmdline *cl,
14608 __attribute__((unused)) void *data)
14610 struct cmd_ddp_get_list_result *res = parsed_result;
14611 #ifdef RTE_LIBRTE_I40E_PMD
14612 struct rte_pmd_i40e_profile_list *p_list;
14613 struct rte_pmd_i40e_profile_info *p_info;
14618 int ret = -ENOTSUP;
14620 if (res->port_id > nb_ports) {
14621 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14625 #ifdef RTE_LIBRTE_I40E_PMD
14626 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14627 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14629 printf("%s: Failed to malloc buffer\n", __func__);
14631 if (ret == -ENOTSUP)
14632 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14633 (uint8_t *)p_list, size);
14636 p_num = p_list->p_count;
14637 printf("Profile number is: %d\n\n", p_num);
14639 for (i = 0; i < p_num; i++) {
14640 p_info = &p_list->p_info[i];
14641 printf("Profile %d:\n", i);
14642 printf("Track id: 0x%x\n", p_info->track_id);
14643 printf("Version: %d.%d.%d.%d\n",
14644 p_info->version.major,
14645 p_info->version.minor,
14646 p_info->version.update,
14647 p_info->version.draft);
14648 printf("Profile name: %s\n\n", p_info->name);
14656 printf("Failed to get ddp list\n");
14659 cmdline_parse_inst_t cmd_ddp_get_list = {
14660 .f = cmd_ddp_get_list_parsed,
14662 .help_str = "ddp get list <port_id>",
14664 (void *)&cmd_ddp_get_list_ddp,
14665 (void *)&cmd_ddp_get_list_get,
14666 (void *)&cmd_ddp_get_list_list,
14667 (void *)&cmd_ddp_get_list_port_id,
14672 /* show vf stats */
14674 /* Common result structure for show vf stats */
14675 struct cmd_show_vf_stats_result {
14676 cmdline_fixed_string_t show;
14677 cmdline_fixed_string_t vf;
14678 cmdline_fixed_string_t stats;
14683 /* Common CLI fields show vf stats*/
14684 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_show_vf_stats_result,
14688 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14689 TOKEN_STRING_INITIALIZER
14690 (struct cmd_show_vf_stats_result,
14692 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14693 TOKEN_STRING_INITIALIZER
14694 (struct cmd_show_vf_stats_result,
14696 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14697 TOKEN_NUM_INITIALIZER
14698 (struct cmd_show_vf_stats_result,
14700 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14701 TOKEN_NUM_INITIALIZER
14702 (struct cmd_show_vf_stats_result,
14706 cmd_show_vf_stats_parsed(
14707 void *parsed_result,
14708 __attribute__((unused)) struct cmdline *cl,
14709 __attribute__((unused)) void *data)
14711 struct cmd_show_vf_stats_result *res = parsed_result;
14712 struct rte_eth_stats stats;
14713 int ret = -ENOTSUP;
14714 static const char *nic_stats_border = "########################";
14716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14719 memset(&stats, 0, sizeof(stats));
14721 #ifdef RTE_LIBRTE_I40E_PMD
14722 if (ret == -ENOTSUP)
14723 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14727 #ifdef RTE_LIBRTE_BNXT_PMD
14728 if (ret == -ENOTSUP)
14729 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14738 printf("invalid vf_id %d\n", res->vf_id);
14741 printf("invalid port_id %d\n", res->port_id);
14744 printf("function not implemented\n");
14747 printf("programming error: (%s)\n", strerror(-ret));
14750 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14751 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14753 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14755 stats.ipackets, stats.imissed, stats.ibytes);
14756 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14757 printf(" RX-nombuf: %-10"PRIu64"\n",
14759 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14761 stats.opackets, stats.oerrors, stats.obytes);
14763 printf(" %s############################%s\n",
14764 nic_stats_border, nic_stats_border);
14767 cmdline_parse_inst_t cmd_show_vf_stats = {
14768 .f = cmd_show_vf_stats_parsed,
14770 .help_str = "show vf stats <port_id> <vf_id>",
14772 (void *)&cmd_show_vf_stats_show,
14773 (void *)&cmd_show_vf_stats_vf,
14774 (void *)&cmd_show_vf_stats_stats,
14775 (void *)&cmd_show_vf_stats_port_id,
14776 (void *)&cmd_show_vf_stats_vf_id,
14781 /* clear vf stats */
14783 /* Common result structure for clear vf stats */
14784 struct cmd_clear_vf_stats_result {
14785 cmdline_fixed_string_t clear;
14786 cmdline_fixed_string_t vf;
14787 cmdline_fixed_string_t stats;
14792 /* Common CLI fields clear vf stats*/
14793 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14794 TOKEN_STRING_INITIALIZER
14795 (struct cmd_clear_vf_stats_result,
14797 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14798 TOKEN_STRING_INITIALIZER
14799 (struct cmd_clear_vf_stats_result,
14801 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14802 TOKEN_STRING_INITIALIZER
14803 (struct cmd_clear_vf_stats_result,
14805 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14806 TOKEN_NUM_INITIALIZER
14807 (struct cmd_clear_vf_stats_result,
14809 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14810 TOKEN_NUM_INITIALIZER
14811 (struct cmd_clear_vf_stats_result,
14815 cmd_clear_vf_stats_parsed(
14816 void *parsed_result,
14817 __attribute__((unused)) struct cmdline *cl,
14818 __attribute__((unused)) void *data)
14820 struct cmd_clear_vf_stats_result *res = parsed_result;
14821 int ret = -ENOTSUP;
14823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14826 #ifdef RTE_LIBRTE_I40E_PMD
14827 if (ret == -ENOTSUP)
14828 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14831 #ifdef RTE_LIBRTE_BNXT_PMD
14832 if (ret == -ENOTSUP)
14833 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14841 printf("invalid vf_id %d\n", res->vf_id);
14844 printf("invalid port_id %d\n", res->port_id);
14847 printf("function not implemented\n");
14850 printf("programming error: (%s)\n", strerror(-ret));
14854 cmdline_parse_inst_t cmd_clear_vf_stats = {
14855 .f = cmd_clear_vf_stats_parsed,
14857 .help_str = "clear vf stats <port_id> <vf_id>",
14859 (void *)&cmd_clear_vf_stats_clear,
14860 (void *)&cmd_clear_vf_stats_vf,
14861 (void *)&cmd_clear_vf_stats_stats,
14862 (void *)&cmd_clear_vf_stats_port_id,
14863 (void *)&cmd_clear_vf_stats_vf_id,
14868 /* port config pctype mapping reset */
14870 /* Common result structure for port config pctype mapping reset */
14871 struct cmd_pctype_mapping_reset_result {
14872 cmdline_fixed_string_t port;
14873 cmdline_fixed_string_t config;
14875 cmdline_fixed_string_t pctype;
14876 cmdline_fixed_string_t mapping;
14877 cmdline_fixed_string_t reset;
14880 /* Common CLI fields for port config pctype mapping reset*/
14881 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14882 TOKEN_STRING_INITIALIZER
14883 (struct cmd_pctype_mapping_reset_result,
14885 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14886 TOKEN_STRING_INITIALIZER
14887 (struct cmd_pctype_mapping_reset_result,
14889 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14890 TOKEN_NUM_INITIALIZER
14891 (struct cmd_pctype_mapping_reset_result,
14893 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14894 TOKEN_STRING_INITIALIZER
14895 (struct cmd_pctype_mapping_reset_result,
14897 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14898 TOKEN_STRING_INITIALIZER
14899 (struct cmd_pctype_mapping_reset_result,
14900 mapping, "mapping");
14901 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14902 TOKEN_STRING_INITIALIZER
14903 (struct cmd_pctype_mapping_reset_result,
14907 cmd_pctype_mapping_reset_parsed(
14908 void *parsed_result,
14909 __attribute__((unused)) struct cmdline *cl,
14910 __attribute__((unused)) void *data)
14912 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14913 int ret = -ENOTSUP;
14915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14918 #ifdef RTE_LIBRTE_I40E_PMD
14919 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14926 printf("invalid port_id %d\n", res->port_id);
14929 printf("function not implemented\n");
14932 printf("programming error: (%s)\n", strerror(-ret));
14936 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14937 .f = cmd_pctype_mapping_reset_parsed,
14939 .help_str = "port config <port_id> pctype mapping reset",
14941 (void *)&cmd_pctype_mapping_reset_port,
14942 (void *)&cmd_pctype_mapping_reset_config,
14943 (void *)&cmd_pctype_mapping_reset_port_id,
14944 (void *)&cmd_pctype_mapping_reset_pctype,
14945 (void *)&cmd_pctype_mapping_reset_mapping,
14946 (void *)&cmd_pctype_mapping_reset_reset,
14951 /* show port pctype mapping */
14953 /* Common result structure for show port pctype mapping */
14954 struct cmd_pctype_mapping_get_result {
14955 cmdline_fixed_string_t show;
14956 cmdline_fixed_string_t port;
14958 cmdline_fixed_string_t pctype;
14959 cmdline_fixed_string_t mapping;
14962 /* Common CLI fields for pctype mapping get */
14963 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_pctype_mapping_get_result,
14967 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14968 TOKEN_STRING_INITIALIZER
14969 (struct cmd_pctype_mapping_get_result,
14971 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14972 TOKEN_NUM_INITIALIZER
14973 (struct cmd_pctype_mapping_get_result,
14975 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14976 TOKEN_STRING_INITIALIZER
14977 (struct cmd_pctype_mapping_get_result,
14979 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14980 TOKEN_STRING_INITIALIZER
14981 (struct cmd_pctype_mapping_get_result,
14982 mapping, "mapping");
14985 cmd_pctype_mapping_get_parsed(
14986 void *parsed_result,
14987 __attribute__((unused)) struct cmdline *cl,
14988 __attribute__((unused)) void *data)
14990 struct cmd_pctype_mapping_get_result *res = parsed_result;
14991 int ret = -ENOTSUP;
14992 #ifdef RTE_LIBRTE_I40E_PMD
14993 struct rte_pmd_i40e_flow_type_mapping
14994 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14995 int i, j, first_pctype;
14998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15001 #ifdef RTE_LIBRTE_I40E_PMD
15002 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15009 printf("invalid port_id %d\n", res->port_id);
15012 printf("function not implemented\n");
15015 printf("programming error: (%s)\n", strerror(-ret));
15019 #ifdef RTE_LIBRTE_I40E_PMD
15020 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15021 if (mapping[i].pctype != 0ULL) {
15024 printf("pctype: ");
15025 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15026 if (mapping[i].pctype & (1ULL << j)) {
15027 printf(first_pctype ?
15028 "%02d" : ",%02d", j);
15032 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15038 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15039 .f = cmd_pctype_mapping_get_parsed,
15041 .help_str = "show port <port_id> pctype mapping",
15043 (void *)&cmd_pctype_mapping_get_show,
15044 (void *)&cmd_pctype_mapping_get_port,
15045 (void *)&cmd_pctype_mapping_get_port_id,
15046 (void *)&cmd_pctype_mapping_get_pctype,
15047 (void *)&cmd_pctype_mapping_get_mapping,
15052 /* port config pctype mapping update */
15054 /* Common result structure for port config pctype mapping update */
15055 struct cmd_pctype_mapping_update_result {
15056 cmdline_fixed_string_t port;
15057 cmdline_fixed_string_t config;
15059 cmdline_fixed_string_t pctype;
15060 cmdline_fixed_string_t mapping;
15061 cmdline_fixed_string_t update;
15062 cmdline_fixed_string_t pctype_list;
15063 uint16_t flow_type;
15066 /* Common CLI fields for pctype mapping update*/
15067 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15068 TOKEN_STRING_INITIALIZER
15069 (struct cmd_pctype_mapping_update_result,
15071 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15072 TOKEN_STRING_INITIALIZER
15073 (struct cmd_pctype_mapping_update_result,
15075 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15076 TOKEN_NUM_INITIALIZER
15077 (struct cmd_pctype_mapping_update_result,
15079 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15080 TOKEN_STRING_INITIALIZER
15081 (struct cmd_pctype_mapping_update_result,
15083 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15084 TOKEN_STRING_INITIALIZER
15085 (struct cmd_pctype_mapping_update_result,
15086 mapping, "mapping");
15087 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15088 TOKEN_STRING_INITIALIZER
15089 (struct cmd_pctype_mapping_update_result,
15091 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15092 TOKEN_STRING_INITIALIZER
15093 (struct cmd_pctype_mapping_update_result,
15094 pctype_list, NULL);
15095 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15096 TOKEN_NUM_INITIALIZER
15097 (struct cmd_pctype_mapping_update_result,
15098 flow_type, UINT16);
15101 cmd_pctype_mapping_update_parsed(
15102 void *parsed_result,
15103 __attribute__((unused)) struct cmdline *cl,
15104 __attribute__((unused)) void *data)
15106 struct cmd_pctype_mapping_update_result *res = parsed_result;
15107 int ret = -ENOTSUP;
15108 #ifdef RTE_LIBRTE_I40E_PMD
15109 struct rte_pmd_i40e_flow_type_mapping mapping;
15111 unsigned int nb_item;
15112 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15118 #ifdef RTE_LIBRTE_I40E_PMD
15119 nb_item = parse_item_list(res->pctype_list, "pctypes",
15120 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15121 mapping.flow_type = res->flow_type;
15122 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15123 mapping.pctype |= (1ULL << pctype_list[i]);
15124 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15134 printf("invalid pctype or flow type\n");
15137 printf("invalid port_id %d\n", res->port_id);
15140 printf("function not implemented\n");
15143 printf("programming error: (%s)\n", strerror(-ret));
15147 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15148 .f = cmd_pctype_mapping_update_parsed,
15150 .help_str = "port config <port_id> pctype mapping update"
15151 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15153 (void *)&cmd_pctype_mapping_update_port,
15154 (void *)&cmd_pctype_mapping_update_config,
15155 (void *)&cmd_pctype_mapping_update_port_id,
15156 (void *)&cmd_pctype_mapping_update_pctype,
15157 (void *)&cmd_pctype_mapping_update_mapping,
15158 (void *)&cmd_pctype_mapping_update_update,
15159 (void *)&cmd_pctype_mapping_update_pc_type,
15160 (void *)&cmd_pctype_mapping_update_flow_type,
15165 /* ptype mapping get */
15167 /* Common result structure for ptype mapping get */
15168 struct cmd_ptype_mapping_get_result {
15169 cmdline_fixed_string_t ptype;
15170 cmdline_fixed_string_t mapping;
15171 cmdline_fixed_string_t get;
15173 uint8_t valid_only;
15176 /* Common CLI fields for ptype mapping get */
15177 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15178 TOKEN_STRING_INITIALIZER
15179 (struct cmd_ptype_mapping_get_result,
15181 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15182 TOKEN_STRING_INITIALIZER
15183 (struct cmd_ptype_mapping_get_result,
15184 mapping, "mapping");
15185 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_ptype_mapping_get_result,
15189 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15190 TOKEN_NUM_INITIALIZER
15191 (struct cmd_ptype_mapping_get_result,
15193 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15194 TOKEN_NUM_INITIALIZER
15195 (struct cmd_ptype_mapping_get_result,
15196 valid_only, UINT8);
15199 cmd_ptype_mapping_get_parsed(
15200 void *parsed_result,
15201 __attribute__((unused)) struct cmdline *cl,
15202 __attribute__((unused)) void *data)
15204 struct cmd_ptype_mapping_get_result *res = parsed_result;
15205 int ret = -ENOTSUP;
15206 #ifdef RTE_LIBRTE_I40E_PMD
15207 int max_ptype_num = 256;
15208 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15216 #ifdef RTE_LIBRTE_I40E_PMD
15217 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15228 printf("invalid port_id %d\n", res->port_id);
15231 printf("function not implemented\n");
15234 printf("programming error: (%s)\n", strerror(-ret));
15237 #ifdef RTE_LIBRTE_I40E_PMD
15239 for (i = 0; i < count; i++)
15240 printf("%3d\t0x%08x\n",
15241 mapping[i].hw_ptype, mapping[i].sw_ptype);
15246 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15247 .f = cmd_ptype_mapping_get_parsed,
15249 .help_str = "ptype mapping get <port_id> <valid_only>",
15251 (void *)&cmd_ptype_mapping_get_ptype,
15252 (void *)&cmd_ptype_mapping_get_mapping,
15253 (void *)&cmd_ptype_mapping_get_get,
15254 (void *)&cmd_ptype_mapping_get_port_id,
15255 (void *)&cmd_ptype_mapping_get_valid_only,
15260 /* ptype mapping replace */
15262 /* Common result structure for ptype mapping replace */
15263 struct cmd_ptype_mapping_replace_result {
15264 cmdline_fixed_string_t ptype;
15265 cmdline_fixed_string_t mapping;
15266 cmdline_fixed_string_t replace;
15273 /* Common CLI fields for ptype mapping replace */
15274 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15275 TOKEN_STRING_INITIALIZER
15276 (struct cmd_ptype_mapping_replace_result,
15278 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15279 TOKEN_STRING_INITIALIZER
15280 (struct cmd_ptype_mapping_replace_result,
15281 mapping, "mapping");
15282 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15283 TOKEN_STRING_INITIALIZER
15284 (struct cmd_ptype_mapping_replace_result,
15285 replace, "replace");
15286 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15287 TOKEN_NUM_INITIALIZER
15288 (struct cmd_ptype_mapping_replace_result,
15290 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15291 TOKEN_NUM_INITIALIZER
15292 (struct cmd_ptype_mapping_replace_result,
15294 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15295 TOKEN_NUM_INITIALIZER
15296 (struct cmd_ptype_mapping_replace_result,
15298 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15299 TOKEN_NUM_INITIALIZER
15300 (struct cmd_ptype_mapping_replace_result,
15304 cmd_ptype_mapping_replace_parsed(
15305 void *parsed_result,
15306 __attribute__((unused)) struct cmdline *cl,
15307 __attribute__((unused)) void *data)
15309 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15310 int ret = -ENOTSUP;
15312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15315 #ifdef RTE_LIBRTE_I40E_PMD
15316 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15326 printf("invalid ptype 0x%8x or 0x%8x\n",
15327 res->target, res->pkt_type);
15330 printf("invalid port_id %d\n", res->port_id);
15333 printf("function not implemented\n");
15336 printf("programming error: (%s)\n", strerror(-ret));
15340 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15341 .f = cmd_ptype_mapping_replace_parsed,
15344 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15346 (void *)&cmd_ptype_mapping_replace_ptype,
15347 (void *)&cmd_ptype_mapping_replace_mapping,
15348 (void *)&cmd_ptype_mapping_replace_replace,
15349 (void *)&cmd_ptype_mapping_replace_port_id,
15350 (void *)&cmd_ptype_mapping_replace_target,
15351 (void *)&cmd_ptype_mapping_replace_mask,
15352 (void *)&cmd_ptype_mapping_replace_pkt_type,
15357 /* ptype mapping reset */
15359 /* Common result structure for ptype mapping reset */
15360 struct cmd_ptype_mapping_reset_result {
15361 cmdline_fixed_string_t ptype;
15362 cmdline_fixed_string_t mapping;
15363 cmdline_fixed_string_t reset;
15367 /* Common CLI fields for ptype mapping reset*/
15368 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15369 TOKEN_STRING_INITIALIZER
15370 (struct cmd_ptype_mapping_reset_result,
15372 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15373 TOKEN_STRING_INITIALIZER
15374 (struct cmd_ptype_mapping_reset_result,
15375 mapping, "mapping");
15376 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15377 TOKEN_STRING_INITIALIZER
15378 (struct cmd_ptype_mapping_reset_result,
15380 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15381 TOKEN_NUM_INITIALIZER
15382 (struct cmd_ptype_mapping_reset_result,
15386 cmd_ptype_mapping_reset_parsed(
15387 void *parsed_result,
15388 __attribute__((unused)) struct cmdline *cl,
15389 __attribute__((unused)) void *data)
15391 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15392 int ret = -ENOTSUP;
15394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15397 #ifdef RTE_LIBRTE_I40E_PMD
15398 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15405 printf("invalid port_id %d\n", res->port_id);
15408 printf("function not implemented\n");
15411 printf("programming error: (%s)\n", strerror(-ret));
15415 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15416 .f = cmd_ptype_mapping_reset_parsed,
15418 .help_str = "ptype mapping reset <port_id>",
15420 (void *)&cmd_ptype_mapping_reset_ptype,
15421 (void *)&cmd_ptype_mapping_reset_mapping,
15422 (void *)&cmd_ptype_mapping_reset_reset,
15423 (void *)&cmd_ptype_mapping_reset_port_id,
15428 /* ptype mapping update */
15430 /* Common result structure for ptype mapping update */
15431 struct cmd_ptype_mapping_update_result {
15432 cmdline_fixed_string_t ptype;
15433 cmdline_fixed_string_t mapping;
15434 cmdline_fixed_string_t reset;
15440 /* Common CLI fields for ptype mapping update*/
15441 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15442 TOKEN_STRING_INITIALIZER
15443 (struct cmd_ptype_mapping_update_result,
15445 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15446 TOKEN_STRING_INITIALIZER
15447 (struct cmd_ptype_mapping_update_result,
15448 mapping, "mapping");
15449 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15450 TOKEN_STRING_INITIALIZER
15451 (struct cmd_ptype_mapping_update_result,
15453 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15454 TOKEN_NUM_INITIALIZER
15455 (struct cmd_ptype_mapping_update_result,
15457 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15458 TOKEN_NUM_INITIALIZER
15459 (struct cmd_ptype_mapping_update_result,
15461 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15462 TOKEN_NUM_INITIALIZER
15463 (struct cmd_ptype_mapping_update_result,
15467 cmd_ptype_mapping_update_parsed(
15468 void *parsed_result,
15469 __attribute__((unused)) struct cmdline *cl,
15470 __attribute__((unused)) void *data)
15472 struct cmd_ptype_mapping_update_result *res = parsed_result;
15473 int ret = -ENOTSUP;
15474 #ifdef RTE_LIBRTE_I40E_PMD
15475 struct rte_pmd_i40e_ptype_mapping mapping;
15477 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15480 #ifdef RTE_LIBRTE_I40E_PMD
15481 mapping.hw_ptype = res->hw_ptype;
15482 mapping.sw_ptype = res->sw_ptype;
15483 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15493 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15496 printf("invalid port_id %d\n", res->port_id);
15499 printf("function not implemented\n");
15502 printf("programming error: (%s)\n", strerror(-ret));
15506 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15507 .f = cmd_ptype_mapping_update_parsed,
15509 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15511 (void *)&cmd_ptype_mapping_update_ptype,
15512 (void *)&cmd_ptype_mapping_update_mapping,
15513 (void *)&cmd_ptype_mapping_update_update,
15514 (void *)&cmd_ptype_mapping_update_port_id,
15515 (void *)&cmd_ptype_mapping_update_hw_ptype,
15516 (void *)&cmd_ptype_mapping_update_sw_ptype,
15521 /* Common result structure for file commands */
15522 struct cmd_cmdfile_result {
15523 cmdline_fixed_string_t load;
15524 cmdline_fixed_string_t filename;
15527 /* Common CLI fields for file commands */
15528 cmdline_parse_token_string_t cmd_load_cmdfile =
15529 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15530 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15531 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15534 cmd_load_from_file_parsed(
15535 void *parsed_result,
15536 __attribute__((unused)) struct cmdline *cl,
15537 __attribute__((unused)) void *data)
15539 struct cmd_cmdfile_result *res = parsed_result;
15541 cmdline_read_from_file(res->filename);
15544 cmdline_parse_inst_t cmd_load_from_file = {
15545 .f = cmd_load_from_file_parsed,
15547 .help_str = "load <filename>",
15549 (void *)&cmd_load_cmdfile,
15550 (void *)&cmd_load_cmdfile_filename,
15555 /* ******************************************************************************** */
15557 /* list of instructions */
15558 cmdline_parse_ctx_t main_ctx[] = {
15559 (cmdline_parse_inst_t *)&cmd_help_brief,
15560 (cmdline_parse_inst_t *)&cmd_help_long,
15561 (cmdline_parse_inst_t *)&cmd_quit,
15562 (cmdline_parse_inst_t *)&cmd_load_from_file,
15563 (cmdline_parse_inst_t *)&cmd_showport,
15564 (cmdline_parse_inst_t *)&cmd_showqueue,
15565 (cmdline_parse_inst_t *)&cmd_showportall,
15566 (cmdline_parse_inst_t *)&cmd_showcfg,
15567 (cmdline_parse_inst_t *)&cmd_start,
15568 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15569 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15570 (cmdline_parse_inst_t *)&cmd_set_link_up,
15571 (cmdline_parse_inst_t *)&cmd_set_link_down,
15572 (cmdline_parse_inst_t *)&cmd_reset,
15573 (cmdline_parse_inst_t *)&cmd_set_numbers,
15574 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15575 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15576 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15577 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15578 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15579 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15580 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15581 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15582 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15583 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15584 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15585 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15586 (cmdline_parse_inst_t *)&cmd_set_link_check,
15587 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15588 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15589 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15590 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15591 #ifdef RTE_LIBRTE_PMD_BOND
15592 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15593 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15594 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15595 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15596 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15597 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15598 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15599 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15600 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15601 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15602 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15604 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15605 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15606 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15607 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15608 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15609 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15610 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15611 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15612 (cmdline_parse_inst_t *)&cmd_csum_set,
15613 (cmdline_parse_inst_t *)&cmd_csum_show,
15614 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15615 (cmdline_parse_inst_t *)&cmd_tso_set,
15616 (cmdline_parse_inst_t *)&cmd_tso_show,
15617 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15618 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15619 (cmdline_parse_inst_t *)&cmd_gro_enable,
15620 (cmdline_parse_inst_t *)&cmd_gro_flush,
15621 (cmdline_parse_inst_t *)&cmd_gro_show,
15622 (cmdline_parse_inst_t *)&cmd_gso_enable,
15623 (cmdline_parse_inst_t *)&cmd_gso_size,
15624 (cmdline_parse_inst_t *)&cmd_gso_show,
15625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15626 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15634 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15635 (cmdline_parse_inst_t *)&cmd_config_dcb,
15636 (cmdline_parse_inst_t *)&cmd_read_reg,
15637 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15638 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15639 (cmdline_parse_inst_t *)&cmd_write_reg,
15640 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15641 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15642 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15643 (cmdline_parse_inst_t *)&cmd_stop,
15644 (cmdline_parse_inst_t *)&cmd_mac_addr,
15645 (cmdline_parse_inst_t *)&cmd_set_qmap,
15646 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15647 (cmdline_parse_inst_t *)&cmd_operate_port,
15648 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15649 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15650 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15651 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15652 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15653 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15654 (cmdline_parse_inst_t *)&cmd_config_mtu,
15655 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15656 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15657 (cmdline_parse_inst_t *)&cmd_config_rss,
15658 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15659 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15660 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15661 (cmdline_parse_inst_t *)&cmd_showport_reta,
15662 (cmdline_parse_inst_t *)&cmd_config_burst,
15663 (cmdline_parse_inst_t *)&cmd_config_thresh,
15664 (cmdline_parse_inst_t *)&cmd_config_threshold,
15665 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15666 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15667 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15668 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15669 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15670 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15671 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15672 (cmdline_parse_inst_t *)&cmd_global_config,
15673 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15674 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15675 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15676 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15677 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15678 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15679 (cmdline_parse_inst_t *)&cmd_dump,
15680 (cmdline_parse_inst_t *)&cmd_dump_one,
15681 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15682 (cmdline_parse_inst_t *)&cmd_syn_filter,
15683 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15684 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15685 (cmdline_parse_inst_t *)&cmd_flex_filter,
15686 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15687 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15688 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15689 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15690 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15691 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15692 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15693 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15694 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15695 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15696 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15697 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15698 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15699 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15700 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15701 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15702 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15703 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15704 (cmdline_parse_inst_t *)&cmd_flow,
15705 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15706 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15707 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15708 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15709 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15710 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15711 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15712 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15713 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15714 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15715 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15716 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15717 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15718 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15719 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15720 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15721 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15722 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15723 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15724 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15725 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15726 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15727 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15728 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15729 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15730 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15731 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15732 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15733 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15734 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15735 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15736 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15737 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15738 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15739 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15740 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15741 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15742 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15743 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15744 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15745 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15746 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15747 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15748 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15749 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15750 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15751 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15752 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15753 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15754 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15755 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15757 (cmdline_parse_inst_t *)&cmd_ddp_add,
15758 (cmdline_parse_inst_t *)&cmd_ddp_del,
15759 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15760 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15761 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15762 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15763 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15764 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15765 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15768 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15769 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15770 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15771 (cmdline_parse_inst_t *)&cmd_queue_region,
15772 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15773 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15774 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15775 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15776 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15777 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15778 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15779 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15780 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15781 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15782 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15783 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15784 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15785 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15786 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15787 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15788 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15789 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15790 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15791 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15792 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15796 /* read cmdline commands from file */
15798 cmdline_read_from_file(const char *filename)
15800 struct cmdline *cl;
15802 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15804 printf("Failed to create file based cmdline context: %s\n",
15809 cmdline_interact(cl);
15814 printf("Read CLI commands from %s\n", filename);
15817 /* prompt function, called from main on MASTER lcore */
15821 /* initialize non-constant commands */
15822 cmd_set_fwd_mode_init();
15823 cmd_set_fwd_retry_mode_init();
15825 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15826 if (testpmd_cl == NULL)
15828 cmdline_interact(testpmd_cl);
15829 cmdline_stdin_exit(testpmd_cl);
15835 if (testpmd_cl != NULL)
15836 cmdline_quit(testpmd_cl);
15840 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15842 if (id == (portid_t)RTE_PORT_ALL) {
15845 RTE_ETH_FOREACH_DEV(pid) {
15846 /* check if need_reconfig has been set to 1 */
15847 if (ports[pid].need_reconfig == 0)
15848 ports[pid].need_reconfig = dev;
15849 /* check if need_reconfig_queues has been set to 1 */
15850 if (ports[pid].need_reconfig_queues == 0)
15851 ports[pid].need_reconfig_queues = queue;
15853 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15854 /* check if need_reconfig has been set to 1 */
15855 if (ports[id].need_reconfig == 0)
15856 ports[id].need_reconfig = dev;
15857 /* check if need_reconfig_queues has been set to 1 */
15858 if (ports[id].need_reconfig_queues == 0)
15859 ports[id].need_reconfig_queues = queue;